:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --line: #d9e0e4;
  --text: #172026;
  --muted: #5f6f7a;
  --accent: #18746b;
  --accent-dark: #105b54;
  --sidebar: #1f2a30;
  --sidebar-text: #edf4f2;
  --sidebar-muted: #9fb0ad;
  --warn: #a04418;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px;
  color: var(--sidebar-text);
  background: var(--sidebar);
  border-right: 1px solid #172026;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  font-size: 16px;
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: #10201d;
  background: #77c9ba;
}

.tool-list {
  display: grid;
  gap: 6px;
}

.tool-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  color: var(--sidebar-text);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.tool-item:hover,
.tool-item.active {
  background: #293840;
  border-color: #3b4c53;
}

.tool-item strong {
  font-size: 14px;
}

.tool-item span {
  color: var(--sidebar-muted);
  font-size: 12px;
  line-height: 1.4;
}

.workspace {
  min-width: 0;
  padding: 32px;
}

.tool-panel {
  max-width: 860px;
}

.tool-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.tool-header p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.upload-form {
  display: grid;
  gap: 18px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.file-picker {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 116px;
  padding: 22px;
  background: #f8faf9;
  border: 1px dashed #a9b7bc;
  border-radius: 8px;
  cursor: pointer;
}

.file-picker:hover {
  border-color: var(--accent);
}

.file-picker.dragging {
  background: #edf8f5;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.file-icon {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--accent-dark);
  background: #d9f0eb;
  border-radius: 8px;
  font-size: 24px;
  font-weight: 700;
}

.file-picker strong {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.file-picker small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

#fileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.output-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.output-options[hidden] {
  display: none;
}

.output-options legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.output-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.output-choice:has(input:checked) {
  background: #edf8f5;
  border-color: var(--accent);
}

.output-choice input {
  margin: 3px 0 0;
  accent-color: var(--accent);
}

.output-choice strong,
.output-choice small {
  display: block;
}

.output-choice small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 42px;
}

button[type="submit"] {
  min-width: 112px;
  height: 42px;
  padding: 0 18px;
  color: #ffffff;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

button[type="submit"]:hover {
  background: var(--accent-dark);
}

button[type="submit"]:disabled {
  background: #9aacb0;
  cursor: wait;
}

#statusText {
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

#statusText.error {
  color: var(--warn);
}

.result-panel {
  margin-top: 20px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0 0;
}

.stat {
  padding: 12px;
  background: #f7f9fa;
  border: 1px solid #e1e7ea;
  border-radius: 8px;
}

.stat dt {
  color: var(--muted);
  font-size: 12px;
}

.stat dd {
  margin: 6px 0 0;
  font-size: 22px;
  font-weight: 700;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    gap: 12px;
    padding: 14px;
  }

  .tool-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .tool-item {
    min-width: 190px;
  }

  .workspace {
    padding: 20px 14px;
  }

  .tool-header {
    margin-bottom: 18px;
  }

  h1 {
    font-size: 24px;
  }

  .upload-form,
  .result-panel {
    padding: 16px;
  }

  .file-picker {
    min-height: 104px;
    padding: 16px;
  }

  .output-options {
    grid-template-columns: 1fr;
  }
}
