:root {
  --ink: #17212b;
  --muted: #667483;
  --navy: #153b5b;
  --navy-2: #1f557a;
  --teal: #0f766e;
  --paper: #ffffff;
  --canvas: #f2f5f7;
  --line: #d9e1e7;
  --soft: #edf3f6;
  --success: #176b52;
  --danger: #a43f3f;
  --shadow: 0 18px 50px rgba(24, 45, 63, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(20px, 5vw, 72px);
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid rgba(217, 225, 231, 0.9);
  backdrop-filter: blur(14px);
}

.brand-wrap, .top-actions, .form-actions, .log-actions, .dialog-heading {
  display: flex;
  align-items: center;
}

.brand-wrap { gap: 12px; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: var(--navy);
  color: white;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.topbar h1 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.top-actions { gap: 10px; }
.badge {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.badge.demo { background: #fff1cf; color: #795300; }
.badge.live { background: #dff3ec; color: var(--success); }

.page-shell {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 46px 0 72px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.8fr);
  gap: 54px;
  align-items: end;
  margin-bottom: 28px;
}
.intro h2 { max-width: 820px; margin: 0; font-size: clamp(30px, 4vw, 54px); line-height: 1.06; letter-spacing: -0.045em; }
.intro p:not(.eyebrow) { max-width: 760px; margin: 18px 0 0; color: var(--muted); font-size: 17px; }
.cadence { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--line); }
.cadence div { padding: 18px; background: var(--paper); }
.cadence span { display: block; color: var(--muted); font-size: 12px; }
.cadence strong { display: block; margin-top: 3px; color: var(--navy); font-size: 15px; }

.auth-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 20px 24px;
  border: 1px solid #ead59e;
  border-radius: 14px;
  background: #fff9e8;
}
.auth-panel h2 { margin: 0 0 4px; font-size: 18px; }
.auth-panel p { margin: 0; color: #695c38; }
.auth-controls { display: grid; grid-template-columns: minmax(180px, 260px) auto; gap: 8px; align-items: end; }
.auth-controls label { grid-column: 1 / -1; font-size: 12px; font-weight: 700; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 20px;
}
.stats-grid article {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}
.stats-grid span { display: block; color: var(--muted); font-size: 12px; }
.stats-grid strong { display: block; margin-top: 2px; color: var(--navy); font-size: 27px; letter-spacing: -0.03em; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr); gap: 20px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.run-panel, .result-panel, .log-panel { padding: clamp(20px, 3vw, 32px); }
.result-panel { position: sticky; top: 94px; }
.section-heading { display: flex; justify-content: space-between; gap: 18px; align-items: end; margin-bottom: 20px; }
.section-heading h2, .dialog-heading h2 { margin: 0; font-size: 23px; line-height: 1.2; letter-spacing: -0.025em; }

.task-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
.task-button {
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: auto auto;
  gap: 1px 10px;
  width: 100%;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  color: var(--ink);
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}
.task-button:hover { transform: translateY(-1px); border-color: #aebfcb; }
.task-button.active { border-color: var(--navy-2); background: #eef5f8; box-shadow: inset 0 0 0 1px var(--navy-2); }
.task-button > span { grid-row: 1 / 3; color: var(--navy-2); font-size: 12px; font-weight: 900; letter-spacing: 0.08em; }
.task-button strong { font-size: 15px; }
.task-button small { color: var(--muted); font-size: 12px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span, .filter-label { color: var(--ink); font-size: 12px; font-weight: 750; }
input, textarea, select {
  width: 100%;
  border: 1px solid #cbd6de;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: box-shadow 120ms ease, border-color 120ms ease;
}
input, select { min-height: 42px; padding: 9px 11px; }
textarea { resize: vertical; min-height: 82px; padding: 10px 11px; }
input:focus, textarea:focus, select:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(31, 85, 122, 0.13); }
::placeholder { color: #94a0a9; }

.form-actions { justify-content: space-between; gap: 18px; margin-top: 6px; }
.form-actions p { margin: 0; color: var(--muted); font-size: 12px; }
.button {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}
.button-primary { background: var(--navy); color: white; }
.button-primary:hover { background: #0d2e49; }
.button-primary:disabled { cursor: wait; opacity: 0.62; }
.button-quiet { border-color: var(--line); background: white; color: var(--navy); }
.button-quiet:hover { background: var(--soft); }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 10px; background: var(--soft); color: var(--navy); font-size: 24px; }

.empty-state { display: grid; min-height: 360px; place-content: center; justify-items: center; padding: 32px; color: var(--muted); text-align: center; }
.empty-state p { max-width: 310px; }
.empty-icon { display: grid; width: 56px; height: 56px; place-items: center; border-radius: 18px; background: var(--soft); color: var(--navy); font-size: 24px; }
.result-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.meta-chip { padding: 4px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 11px; font-weight: 700; }
.response-text, .prompt-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 12px;
  background: #f8fafb;
  color: #25323c;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.62;
}
.response-text { padding: 16px; }
.response-text a { color: var(--navy-2); font-weight: 700; }
.source-list { margin-top: 16px; }
.source-list h3 { margin: 0 0 8px; font-size: 13px; }
.source-list ul { margin: 0; padding-left: 18px; }
.source-list a { color: var(--navy-2); font-size: 12px; }

.log-panel { margin-top: 20px; }
.log-heading { align-items: center; }
.log-actions { gap: 8px; }
.log-actions select { width: 148px; }
.log-list { display: grid; gap: 10px; }
.log-entry { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.log-entry summary { display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center; padding: 15px 16px; list-style: none; cursor: pointer; }
.log-entry summary::-webkit-details-marker { display: none; }
.task-token { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; background: var(--soft); color: var(--navy); font-size: 12px; font-weight: 900; }
.entry-title strong { display: block; font-size: 14px; }
.entry-title span, .entry-time { color: var(--muted); font-size: 11px; }
.status { padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 850; text-transform: uppercase; }
.status.draft { background: #edf1f4; color: #566674; }
.status.reviewed { background: #e8f1ff; color: #26558d; }
.status.approved { background: #dff3ec; color: var(--success); }
.entry-body { display: grid; gap: 14px; padding: 0 16px 18px 64px; border-top: 1px solid var(--line); }
.entry-section { padding-top: 14px; }
.entry-section h3 { margin: 0 0 7px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.prompt-text { margin: 0; padding: 14px; }
.review-grid { display: grid; grid-template-columns: 1fr 160px; gap: 10px; align-items: end; }
.review-grid .field { margin: 0; }
.save-note { justify-self: end; }
.form-message { margin: 6px 0; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.form-message.error { background: #fff0f0; color: var(--danger); }
.form-message.success { background: #e9f6f1; color: var(--success); }
.empty-log { padding: 34px; color: var(--muted); text-align: center; }

dialog { width: min(880px, calc(100% - 32px)); max-height: 86vh; padding: 26px; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 28px 90px rgba(12, 33, 48, 0.28); }
dialog::backdrop { background: rgba(16, 31, 42, 0.58); backdrop-filter: blur(4px); }
.dialog-heading { justify-content: space-between; }
dialog > p { color: var(--muted); }
dialog pre { max-height: 58vh; overflow: auto; padding: 18px; border-radius: 12px; background: #f3f6f8; white-space: pre-wrap; font-size: 12px; line-height: 1.55; }

.hidden { display: none !important; }

@media (max-width: 1050px) {
  .intro, .workspace-grid { grid-template-columns: 1fr; }
  .result-panel { position: static; }
  .empty-state { min-height: 190px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .topbar, .top-actions, .auth-panel, .form-actions, .log-heading { align-items: stretch; }
  .topbar, .auth-panel, .form-actions, .log-heading { flex-direction: column; }
  .page-shell { width: min(100% - 24px, 1480px); padding-top: 28px; }
  .intro { gap: 24px; }
  .cadence, .task-switch, .field-row, .stats-grid, .review-grid { grid-template-columns: 1fr; }
  .auth-controls { grid-template-columns: 1fr; width: 100%; }
  .log-actions { flex-wrap: wrap; }
  .log-entry summary { grid-template-columns: auto 1fr auto; }
  .entry-time { display: none; }
  .entry-body { padding-left: 16px; }
}

@media print {
  .topbar, .run-panel, .result-panel, .log-actions, .auth-panel { display: none !important; }
  body { background: white; }
  .page-shell { width: 100%; padding: 0; }
  .intro, .stats-grid { display: none; }
  .panel { border: 0; box-shadow: none; }
  .log-entry { break-inside: avoid; }
}

