:root {
  --bg: #0c0c0e;
  --surface: #141416;
  --raised: #1c1c1f;
  --inset: #101012;
  --border: #2a2a2e;
  --text: #eeeef2;
  --soft: #d8d8df;
  --muted: #a6a6b2;
  --accent: #c8a96e;
  --accent-strong: #dcc491;
  --good: #8bd39c;
  --mono: "JetBrains Mono", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f3f1ec;
  --surface: #fdfcfa;
  --raised: #f0ede6;
  --inset: #faf8f4;
  --border: #d9d4c9;
  --text: #16150f;
  --soft: #2e2c27;
  --muted: #56524b;
  --accent: #75591f;
  --accent-strong: #5c4517;
  --good: #1a5f33;
  color-scheme: light;
}

@media (prefers-reduced-motion: no-preference) {
  body, button, textarea, pre {
    transition: background-color .25s ease, color .25s ease, border-color .25s ease;
  }
}

* { box-sizing: border-box; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 10;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  background: var(--raised);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--soft);
  font-family: var(--sans);
}

button, textarea {
  font: inherit;
}

button {
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  padding: 10px 13px;
  cursor: pointer;
}

button:hover, button.active {
  border-color: var(--accent);
  color: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: .65;
}

/* Busy = working, not broken: spinner ring instead of a dead hourglass. */
button.busy {
  cursor: progress;
}

button.busy::after {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-left: 8px;
  vertical-align: -1px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

@media (prefers-reduced-motion: no-preference) {
  button.busy::after {
    animation: dia-spin .7s linear infinite;
  }
}

@keyframes dia-spin {
  to { transform: rotate(360deg); }
}

.shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  border: 1px solid var(--border);
  background: var(--surface);
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  padding: 22px;
}

/* Superscript-corner affordance: small, subtle, hugging the "A" in DIA. */
.app-tip {
  position: relative;
  display: inline-block;
  margin-left: 3px;
  vertical-align: top;
}

.info-tip {
  width: 15px;
  height: 15px;
  padding: 0;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  opacity: .7;
}

.info-tip:hover,
.info-tip:focus-visible,
.app-tip.open .info-tip {
  opacity: 1;
}

.tip-bubble {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  white-space: nowrap;
  border: 1px solid var(--accent);
  background: var(--raised);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .06em;
  padding: 8px 10px;
  opacity: 0;
  visibility: hidden;
}

.app-tip:hover .tip-bubble,
.app-tip:focus-within .tip-bubble,
.app-tip.open .tip-bubble {
  opacity: 1;
  visibility: visible;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

/* The post-intake workflow (results + draft editor) is the star: it gets the
   wider column, and the intake column stays compact. */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  min-height: calc(100vh - 168px);
}

.intake-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.intake-bar label {
  margin: 0;
}

#intakeToggle {
  padding: 7px 10px;
  font-size: 12px;
}

.pane {
  min-width: 0;
  padding: 20px;
}

.pane:first-child {
  border-right: 1px solid var(--border);
}

label, h2 {
  display: block;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .08em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 26vh;
  resize: vertical;
  border: 1px solid var(--border);
  background: var(--inset);
  color: var(--soft);
  padding: 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.actions button {
  white-space: nowrap;
}

#status {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.score-card {
  border: 1px solid var(--border);
  background: var(--raised);
  padding: 18px;
  margin-bottom: 16px;
}

.score-card span, .score-card small {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.score-card strong {
  display: block;
  color: var(--accent-strong);
  font-size: 30px;
  line-height: 1;
  margin: 9px 0;
}

.issues {
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 16px;
}

.issues ul {
  margin: 0;
  padding-left: 18px;
}

.issues li {
  margin: 6px 0;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.export-bar button {
  padding: 8px 10px;
  font-size: 12px;
}

pre {
  margin: 0;
  min-height: 44vh;
  white-space: pre-wrap;
  overflow: auto;
  border: 1px solid var(--border);
  background: var(--inset);
  color: var(--soft);
  padding: 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 11px;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button svg.fill-icon {
  fill: currentColor;
  stroke: none;
}

html[data-theme="light"] .theme-icon-moon,
html:not([data-theme="light"]) .theme-icon-sun {
  display: none;
}

.actions button[aria-pressed="true"],
.export-bar button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent-strong);
}

button.recording {
  border-color: var(--good);
  color: var(--good);
}

.draft-editor {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.editor-toolbar button {
  padding: 8px 10px;
  font-size: 12px;
}

.editor-toolbar .fmt {
  min-width: 42px;
}

.inline-status {
  align-self: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.list-menu {
  position: relative;
  display: inline-block;
}

.menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  min-width: 150px;
  border: 1px solid var(--border);
  background: var(--raised);
}

.menu.open {
  display: flex;
}

.menu-item {
  border: 0;
  text-align: left;
  font-size: 12px;
}

.rich-editor {
  min-height: 180px;
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--border);
  background: var(--inset);
  color: var(--soft);
  padding: 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}

.rich-editor ul,
.rich-editor ol {
  white-space: normal;
  margin: 6px 0;
  padding-left: 26px;
}

.rich-editor ol.lettered {
  list-style-type: lower-alpha;
}

.agent {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.agent textarea {
  min-height: 90px;
}

.agent-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: none;
  vertical-align: middle;
}

.agent-badge.ok {
  color: var(--good);
  border-color: var(--good);
}

#agentOutput {
  min-height: 18vh;
  margin-top: 12px;
}

@media (max-width: 860px) {
  .shell { width: min(100vw - 20px, 1200px); padding: 10px 0; }
  .topbar { align-items: start; flex-direction: column; }
  .grid { grid-template-columns: 1fr; }
  .pane:first-child { border-right: 0; border-bottom: 1px solid var(--border); }
  textarea { min-height: 24vh; }
}
