:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #17201c;
  --muted: #637067;
  --line: #dce3df;
  --green: #167a5b;
  --blue: #285c8f;
  --red: #a33a35;
  --amber: #9a6a13;
  --shadow: 0 16px 40px rgba(23, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 28px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0 18px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 760;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  font-size: 13px;
}

.status-strip span {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 10px;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(380px, 1fr) minmax(380px, 1fr);
  gap: 16px;
  margin-top: 18px;
  align-items: start;
}

.control-panel,
.input-panel,
.result-panel,
.tagset-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 14px;
}

.panel-section + .panel-section,
.panel-grid,
.primary-button {
  margin-top: 16px;
}

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

.segmented {
  display: grid;
  gap: 8px;
}

.segmented label,
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfc;
  cursor: pointer;
}

.segmented input,
.check-row input {
  accent-color: var(--green);
}

.segmented label:has(input:checked),
.check-row:has(input:checked) {
  border-color: rgba(22, 122, 91, 0.55);
  background: #edf7f3;
}

.task-list[data-disabled="true"] {
  opacity: 0.55;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

input[type="number"] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fbfcfc;
}

.primary-button,
.ghost-button {
  height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 730;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  background: var(--green);
  color: white;
}

.primary-button[disabled] {
  opacity: 0.65;
  cursor: wait;
}

.ghost-button {
  padding: 0 14px;
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

.input-panel,
.result-panel {
  min-height: 640px;
}

.text-head,
.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 58px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.text-head .label,
.text-head label {
  margin-bottom: 0;
}

textarea {
  display: block;
  width: 100%;
  min-height: 580px;
  resize: vertical;
  border: 0;
  outline: none;
  padding: 16px;
  font: 16px/1.6 Consolas, "Segoe UI", monospace;
  color: var(--ink);
  background: #fbfcfc;
  border-radius: 0 0 8px 8px;
}

.result-head h2 {
  font-size: 18px;
}

.runtime {
  min-width: 92px;
  text-align: right;
  color: var(--muted);
  font-size: 13px;
}

.results {
  padding: 14px;
}

.empty-state {
  color: var(--muted);
}

.prediction-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
  background: #fbfcfc;
}

.source-text {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  line-height: 1.5;
}

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

.task-result {
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.task-result:nth-child(2n) {
  border-right: 0;
}

.task-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.task-value {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  font-size: 15px;
  font-weight: 760;
}

.score {
  color: var(--blue);
  font-size: 12px;
  font-weight: 760;
}

.score-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.score-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 7px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
}

.error-box {
  border: 1px solid rgba(163, 58, 53, 0.4);
  background: #fff4f2;
  color: var(--red);
  border-radius: 8px;
  padding: 12px;
}

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

.tagset-head {
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.tagset-head h2 {
  font-size: 18px;
}

.tagset-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.tagset-sections {
  display: grid;
  grid-template-columns: minmax(420px, 1.2fr) minmax(320px, 0.8fr);
  gap: 14px;
  padding: 14px;
}

.tagset-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.tag-table {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  border-spacing: 0;
  border-collapse: separate;
  overflow: hidden;
  background: #fbfcfc;
  table-layout: fixed;
}

.tag-table th,
.tag-table td {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.tag-table thead th {
  border-top: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.tag-table tbody th {
  color: var(--green);
  font-weight: 760;
}

.tag-table th:first-child {
  width: 80px;
}

.tag-table:not(.tag-table-compact) th:nth-child(2),
.tag-table:not(.tag-table-compact) td:nth-child(2) {
  width: 34%;
}

.tag-table-compact th:first-child {
  width: 112px;
}

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

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

  .tagset-sections {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 10px;
  }

  .topbar,
  .workspace {
    display: block;
  }

  .status-strip {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .control-panel,
  .input-panel,
  .result-panel,
  .tagset-panel {
    margin-top: 12px;
  }

  .input-panel,
  .result-panel {
    min-height: 0;
  }

  textarea {
    min-height: 320px;
  }

  .task-grid {
    grid-template-columns: 1fr;
  }

  .task-result {
    border-right: 0;
  }

  .tagset-sections {
    padding: 10px;
  }
}
