:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

.shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 720;
}

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

p {
  color: var(--muted);
  margin-top: 4px;
}

.grid {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.model-grid {
  grid-template-columns: minmax(260px, 420px);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(640px, 1.35fr) minmax(360px, 0.8fr);
  gap: 12px;
  align-items: start;
}

.side-column {
  display: grid;
  gap: 12px;
}

.metadata-grid {
  grid-template-columns: 1fr 1fr max-content max-content;
  align-items: end;
}

.panel,
label {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
  height: 60px;
  min-width: 170px;
}

.checkbox-row span {
  color: var(--text);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

input,
select {
  height: 34px;
  padding: 0 10px;
}

input[type="file"] {
  width: auto;
  max-width: 280px;
  border: 0;
  padding: 0;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

textarea {
  min-height: 260px;
  resize: vertical;
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
}

textarea.large {
  min-height: 320px;
}

.asr-panel textarea {
  min-height: 520px;
}

.panel {
  overflow: hidden;
  margin-bottom: 12px;
}

details.panel {
  background: var(--panel);
}

details.panel summary {
  cursor: pointer;
  min-height: 48px;
  padding: 14px 12px;
  color: var(--muted);
  font-weight: 700;
}

details.panel[open] summary {
  border-bottom: 1px solid var(--line);
}

.panel-head {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.button-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 0;
}

.setting-item {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.setting-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 5px;
}

.setting-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.prompt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
}

.prompt-grid label {
  min-width: 0;
}

.prompt-textarea {
  min-height: 360px;
  border: 1px solid var(--line) !important;
  border-radius: 6px !important;
  font-size: 12px;
  line-height: 1.45;
}

.record-form {
  padding: 12px;
}

.record-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.record-section h3 {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  font-size: 14px;
}

.record-fields {
  display: grid;
  gap: 0;
}

.record-fields.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.record-field {
  display: grid;
  grid-template-columns: minmax(120px, 0.28fr) minmax(220px, 1fr) minmax(220px, 0.95fr);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.record-field:last-child {
  border-bottom: 0;
}

.record-fields.compact .record-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--line);
}

.record-fields.compact .record-field:nth-child(3n) {
  border-right: 0;
}

.record-field label {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.record-field input,
.record-field textarea {
  min-height: 36px;
  border-color: #cfd6e2;
}

.record-field textarea {
  min-height: 96px;
}

.record-field.has-suggestion input,
.record-field.has-suggestion textarea {
  border-color: var(--accent);
}

.field-suggestions {
  min-height: 36px;
  border: 1px solid #b7dfd8;
  border-radius: 7px;
  background: #f0fdfa;
  padding: 8px;
}

.field-suggestions.empty {
  border-style: dashed;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.suggestion-card + .suggestion-card {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #b7dfd8;
}

.suggestion-card p {
  color: var(--text);
  margin: 0;
  line-height: 1.45;
}

.suggestion-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.evidence-list {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.evidence-heading {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.evidence-item {
  border: 1px solid #d9dee7;
  border-radius: 7px;
  background: #fff;
  padding: 7px 8px;
}

.evidence-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.evidence-text {
  color: var(--text) !important;
  margin: 0 !important;
  line-height: 1.45;
}

.uncertain-panel {
  padding: 0 12px 12px;
}

.uncertain-panel h2 {
  margin: 4px 0 8px;
}

.uncertain-list {
  border: 1px solid #f0c36d;
  border-radius: 8px;
  background: #fffbeb;
  padding: 10px;
}

.uncertain-list.empty {
  border-style: dashed;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}

.uncertain-card + .uncertain-card {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f0c36d;
}

.uncertain-title {
  display: inline-flex;
  margin-bottom: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 800;
}

.uncertain-card p {
  color: var(--text);
  margin: 0;
  line-height: 1.45;
}

.uncertain-reason {
  margin-top: 6px !important;
  color: #92400e !important;
}

.panel textarea,
.panel pre {
  border: 0;
  border-radius: 0;
}

button {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button.primary {
  min-width: 108px;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

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

button.secondary {
  background: #fff;
  color: var(--text);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.status {
  margin: 0;
  padding: 10px 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: pre-wrap;
}

.status.error {
  color: var(--danger);
}

.metrics {
  display: none;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.metrics.visible {
  display: flex;
}

.metric {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  font-weight: 650;
}

.output {
  min-height: 320px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  background: #fff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .model-grid,
  .workspace-grid,
  .metadata-grid,
  .settings-grid,
  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .record-field,
  .record-fields.compact {
    grid-template-columns: 1fr;
  }

  .record-fields.compact .record-field {
    border-right: 0;
  }

  .setting-item {
    border-right: 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
