:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  background: #f5f7fa;
  color: #16202f;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1040px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.login-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #eef2f7;
  z-index: 20;
}
.login-overlay[hidden] { display: none; }
.login-card {
  width: min(420px, calc(100vw - 40px));
  background: #fff;
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 14px 40px rgba(21, 32, 47, .12);
}
.login-card h1 { margin: 4px 0 20px; font-size: 28px; }

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: 260px 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 0 22px;
  background: #fff;
  border-bottom: 1px solid #dce3ec;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { margin: 0; font-size: 22px; }
.eyebrow { margin: 0; color: #64748b; font-size: 12px; letter-spacing: 0; }
.tabs { display: flex; gap: 4px; }
.tab, .ghost, .primary {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 12px;
  background: #fff;
  color: #263244;
}
.tab.active, .primary { border-color: #1f6feb; background: #1f6feb; color: white; }
.ghost:hover, .tab:hover { background: #f1f5f9; }
.primary:hover { background: #1a5fd0; }
.top-actions, .inline-actions, .action-row { display: flex; gap: 8px; align-items: center; }
.action-link { text-decoration: none; }
.inline-actions input, .inline-actions select { min-width: 180px; }

main { padding: 18px 22px 48px; }
.guide-panel {
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid #cfe0f7;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 10px 26px rgba(31, 111, 235, .08);
}
body:not(.novice-mode) .guide-panel { display: none; }
.guide-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}
.guide-head h2 { margin: 2px 0 6px; font-size: 20px; }
.guide-subtitle { margin: 0; color: #52627a; line-height: 1.6; }
.guide-step-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(260px, .36fr);
  gap: 12px;
}
.guide-step-card,
.guide-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fbff;
  padding: 12px;
}
.guide-step-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.guide-card h3 { margin: 0 0 8px; font-size: 14px; }
.guide-card ol, .guide-card ul {
  margin: 0;
  padding-left: 20px;
  color: #35465d;
  line-height: 1.7;
  font-size: 13px;
}
.guide-progress-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  color: #64748b;
  font-size: 12px;
}
.guide-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}
.guide-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #1f6feb;
  transition: width .18s ease;
}
.guide-step-card h3 {
  margin: 12px 0 8px;
  font-size: 18px;
}
.guide-step-card p {
  margin: 0;
  color: #35465d;
  line-height: 1.75;
}
.guide-example {
  margin-top: 10px;
  border-left: 4px solid #1f6feb;
  background: #eef6ff;
  border-radius: 6px;
  padding: 10px 12px;
  color: #244469;
  font-size: 13px;
  line-height: 1.65;
  min-height: 42px;
}
.guide-example:empty { display: none; }
.guide-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.guide-focus {
  outline: 3px solid rgba(31, 111, 235, .45) !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 0 7px rgba(31, 111, 235, .10) !important;
}
[data-guide-tip] {
  position: relative;
}
body.novice-mode [data-guide-tip] {
  outline: 1px dashed rgba(31, 111, 235, .55);
  outline-offset: 2px;
}
body.novice-mode [data-guide-tip]:hover::after,
body.novice-mode [data-guide-tip]:focus::after {
  content: attr(data-guide-tip);
  position: absolute;
  left: 0;
  top: calc(100% + 7px);
  z-index: 30;
  width: min(320px, 80vw);
  padding: 9px 10px;
  border-radius: 6px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .22);
  white-space: normal;
  pointer-events: none;
}
.view { display: none; }
.active-view { display: block; }
.workbench-grid {
  display: grid;
  grid-template-columns: minmax(460px, 1fr) minmax(520px, 1.15fr);
  gap: 14px;
}
.autofill-panel { margin-bottom: 14px; }
.autofill-actions { margin-top: 12px; }
.hint-row {
  margin-top: 10px;
  min-height: 22px;
  color: #475569;
  font-size: 13px;
  line-height: 1.5;
}
.autofill-result {
  margin-top: 10px;
}
.autofill-card {
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px 12px;
}
.autofill-card strong { color: #16202f; }
.autofill-card p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.5;
}
.result-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
.panel {
  background: #fff;
  border: 1px solid #dce3ec;
  border-radius: 8px;
  padding: 16px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 { margin: 2px 0 0; font-size: 18px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
label { display: grid; gap: 6px; color: #475569; font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 9px 10px;
  background: white;
  color: #16202f;
}
textarea { min-height: 128px; resize: vertical; line-height: 1.55; }
.wide { grid-column: 1 / -1; }
.toggle { display: flex; grid-auto-flow: column; align-items: center; gap: 8px; color: #334155; }
.toggle input { width: auto; }
.pill {
  display: inline-flex;
  min-width: 54px;
  justify-content: center;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  padding: 4px 10px;
  font-size: 12px;
}
.pill.high { background: #fee2e2; color: #b91c1c; }
.pill.medium { background: #fef3c7; color: #92400e; }
.pill.low { background: #dcfce7; color: #166534; }
.markdown-box {
  min-height: 170px;
  white-space: pre-wrap;
  line-height: 1.65;
  color: #263244;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px;
}
.script-box {
  margin-top: 12px;
  border-left: 4px solid #1f6feb;
  background: #f8fafc;
  padding: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}
.json-box, pre {
  margin: 0;
  min-height: 244px;
  max-height: 520px;
  overflow: auto;
  background: #0f172a;
  color: #dbeafe;
  border-radius: 6px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.table-list {
  display: grid;
  gap: 8px;
}
.row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fbfdff;
}
.reminder-row { grid-template-columns: 26px 1fr minmax(180px, auto); }
.row input { width: auto; }
.row strong { display: block; font-size: 14px; color: #16202f; }
.row p { margin: 4px 0 0; color: #64748b; font-size: 12px; line-height: 1.5; }
.row-actions { display: flex; align-items: center; gap: 6px; }
.small { padding: 5px 8px; font-size: 12px; }
.status {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  background: #e2e8f0;
  color: #334155;
}
.status.dry_run, .status.succeeded { background: #dcfce7; color: #166534; }
.status.failed { background: #fee2e2; color: #b91c1c; }
.status.queued, .status.claimed { background: #fef3c7; color: #92400e; }
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.metric {
  background: #fff;
  border: 1px solid #dce3ec;
  border-radius: 8px;
  padding: 16px;
}
.metric span { color: #64748b; font-size: 13px; }
.metric b { display: block; margin-top: 6px; font-size: 30px; }
.readiness-metrics .metric b { font-size: 24px; }
.launch-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}
.launch-summary strong { display: block; font-size: 16px; }
.launch-summary p { margin: 5px 0 0; color: #64748b; line-height: 1.5; }
.launch-summary-state {
  min-width: 150px;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
  background: #e2e8f0;
  color: #334155;
}
.launch-summary-state b { display: block; font-size: 18px; }
.launch-summary-state span { display: block; margin-top: 4px; font-size: 12px; }
.launch-summary-state.ok { background: #dcfce7; color: #166534; }
.launch-summary-state.warn { background: #fef3c7; color: #92400e; }
.launch-summary-state.bad { background: #fee2e2; color: #b91c1c; }
.readiness-grid,
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.readiness-card,
.mode-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
}
.readiness-card.pass { border-left: 4px solid #22c55e; }
.readiness-card.partial { border-left: 4px solid #f59e0b; }
.readiness-card.blocked { border-left: 4px solid #dc2626; }
.readiness-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.readiness-card h3,
.mode-card h3 {
  margin: 0;
  font-size: 15px;
}
.readiness-card p,
.mode-card p {
  margin: 0 0 8px;
  color: #475569;
  line-height: 1.55;
  font-size: 13px;
}
.readiness-card ul {
  margin: 0;
  padding-left: 18px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.65;
}
.command-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}
.chat-os-grid {
  display: grid;
  grid-template-columns: minmax(480px, .95fr) minmax(560px, 1.05fr);
  gap: 14px;
  margin-bottom: 14px;
}
.compact-textarea { min-height: 92px; }
.weapon-grid, .advice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.weapon-card, .advice, .empty-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
}
.weapon-card h3 {
  margin: 10px 0 8px;
  font-size: 16px;
}
.weapon-card p, .advice p {
  margin: 0;
  color: #475569;
  line-height: 1.55;
  font-size: 13px;
}
.weapon-head, .weapon-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tag {
  display: inline-flex;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  padding: 3px 8px;
  font-size: 12px;
}
.muted, .weapon-meta {
  color: #64748b;
  font-size: 12px;
}
.material {
  margin-top: 10px;
  color: #1d4ed8;
  font-size: 12px;
  line-height: 1.5;
}
.advice { margin-bottom: 12px; border-left: 4px solid #1f6feb; }
.advice.warn { border-left-color: #f59e0b; }
.advice.danger { border-left-color: #dc2626; }
.subhead {
  margin: 18px 0 10px;
  font-size: 15px;
}
.error-line { min-height: 20px; color: #b91c1c; }

@media (max-width: 900px) {
  body { min-width: 0; }
  .topbar { grid-template-columns: 1fr; height: auto; padding: 14px; }
  .tabs, .top-actions { flex-wrap: wrap; }
  main { padding: 12px; }
  .workbench-grid, .result-layout, .command-grid, .metrics-grid, .chat-os-grid, .weapon-grid, .advice-grid, .guide-step-layout, .readiness-grid, .mode-grid, .launch-summary { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
