:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --line: #d8dee5;
  --text: #17202a;
  --muted: #637083;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --ok: #067647;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: 0;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
}

h2 {
  font-size: 15px;
  font-weight: 700;
}

.topbar p {
  margin-top: 3px;
  color: var(--muted);
}

.server-state {
  min-width: 150px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.server-state.ok {
  border-color: rgba(6, 118, 71, 0.35);
  color: var(--ok);
  background: #ecfdf3;
}

.server-state.warn {
  border-color: rgba(180, 35, 24, 0.25);
  color: var(--danger);
  background: #fff1f0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1fr) minmax(300px, 0.9fr);
  gap: 16px;
  padding: 18px;
}

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.hint,
.job-id {
  color: var(--muted);
  font-size: 12px;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 190px;
  padding: 18px;
  border: 2px dashed #b9c4d0;
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone strong {
  color: var(--text);
  font-size: 16px;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: #ecfdf3;
}

.dropzone input {
  display: none;
}

.drop-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 30px;
  line-height: 1;
}

.file-list {
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.file-item,
.empty {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.file-item strong {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label span,
legend {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

input:focus,
select:focus,
button:focus,
a:focus {
  outline: 2px solid rgba(15, 118, 110, 0.25);
  outline-offset: 2px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 16px 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented legend {
  padding: 0 0 7px;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 38px;
  margin: 0;
  border-right: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  text-transform: none;
  font-size: 14px;
}

.segmented label:last-child span {
  border-right: 0;
}

.segmented input:checked + span {
  background: #dff7f2;
  color: var(--accent-strong);
}

.mode-selector {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 0 16px;
}

#formatSettings {
  margin-top: 14px;
}

.advanced {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.advanced summary {
  padding: 11px 0;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 700;
}

.advanced-grid {
  padding-bottom: 14px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding-top: 20px;
}

.checkline input {
  width: 18px;
  min-height: 18px;
}

.checkline span {
  margin: 0;
  color: var(--text);
  text-transform: none;
  font-size: 14px;
}

.primary,
.download,
.ghost,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 6px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
}

.primary {
  width: 100%;
  margin-top: 16px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.primary:hover {
  background: var(--accent-strong);
}

.primary:disabled,
.download.disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.text-button {
  min-height: 30px;
  padding: 4px 8px;
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress div {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.status-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 16px;
}

.status-line strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.metrics div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

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

.metrics dd {
  margin: 3px 0 0;
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ambiguity-panel {
  margin: 0 0 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.ambiguity-panel h3 {
  margin: 0;
  font-size: 15px;
}

.ambiguity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.ambiguity-row p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.ambiguity-row select {
  width: 100%;
}

.download {
  background: var(--text);
  color: #ffffff;
}

.ghost {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.log {
  margin-top: 16px;
  max-height: 180px;
  overflow: auto;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .status-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar,
  .workspace {
    padding: 14px;
  }

  .topbar,
  .workspace,
  .grid.two {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .server-state {
    width: 100%;
  }

  .ambiguity-row {
    grid-template-columns: 1fr;
  }
}
