:root {
  --bg: #0b1020;
  --bg-2: #0f1729;
  --panel: rgba(20, 28, 48, 0.72);
  --panel-solid: #141c30;
  --line: rgba(120, 140, 190, 0.16);
  --line-strong: rgba(120, 140, 190, 0.32);
  --text: #e7ecf6;
  --text-dim: #9aa6c2;
  --text-faint: #6b768f;
  --accent: #5b8cff;
  --accent-2: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --high: #f87171;
  --med: #fbbf24;
  --low: #6ee7b7;
  --radius: 14px;
  --shadow: 0 18px 50px -22px rgba(0, 0, 0, 0.7);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: radial-gradient(1200px 700px at 78% -10%, #1a2547 0%, transparent 55%),
              radial-gradient(900px 600px at 0% 110%, #112138 0%, transparent 50%),
              var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px),
                    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 0%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 0%, transparent 75%);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

/* ---------- Topbar ---------- */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 22px;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #1c2942, #121a2d);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; letter-spacing: 0.2px; }
.brand-text span { font-size: 11.5px; color: var(--text-faint); letter-spacing: 1px; text-transform: uppercase; }
.topbar-meta { display: flex; align-items: center; gap: 10px; }
.pill {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
  text-decoration: none;
}
.pill-quiet { background: rgba(52, 211, 153, 0.08); color: var(--accent-2); border-color: rgba(52, 211, 153, 0.25); }
.pill-link:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Layout ---------- */
.layout {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(360px, 42%) 1fr;
  gap: 20px;
  padding: 22px clamp(16px, 4vw, 40px);
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

.pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 22px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pane-result { min-height: 540px; }

.pane-head h1 {
  margin: 0 0 8px;
  font-size: clamp(20px, 2.6vw, 26px);
  line-height: 1.25;
  letter-spacing: -0.3px;
}
.pane-head p { margin: 0 0 16px; color: var(--text-dim); font-size: 14px; }

.input-controls { margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-faint); }
.field input[type="date"] {
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: var(--sans);
  font-size: 14px;
  color-scheme: dark;
  width: max-content;
}

textarea#rawInput {
  flex: 1;
  min-height: 280px;
  resize: vertical;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--text);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea#rawInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.16); }
textarea#rawInput::placeholder { color: var(--text-faint); }

.input-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.btn {
  font-family: var(--sans);
  font-size: 14px;
  border-radius: 10px;
  padding: 11px 18px;
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.08s, border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, #5b8cff, #3f6ddb);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 24px -10px rgba(91, 140, 255, 0.7);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-mini { font-size: 12px; padding: 6px 11px; border-radius: 8px; }

.hint-row { margin-top: 12px; }
.hint { font-size: 12px; color: var(--text-faint); }
.hint code, .footer code {
  font-family: var(--mono);
  background: rgba(91, 140, 255, 0.12);
  color: #a9c2ff;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 11.5px;
}

/* ---------- Result tabs ---------- */
.result-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  background: none;
  border: none;
  color: var(--text-faint);
  font-family: var(--sans);
  font-size: 13.5px;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.tab:hover { color: var(--text-dim); }
.tab-active { color: var(--text); border-bottom-color: var(--accent); }
.count {
  font-size: 11px;
  min-width: 20px;
  text-align: center;
  background: rgba(91, 140, 255, 0.16);
  color: #a9c2ff;
  border-radius: 999px;
  padding: 1px 7px;
}

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 36px 16px; color: var(--text-dim); }
.empty-icon { font-size: 44px; margin-bottom: 10px; }
.empty p { font-size: 14.5px; }
.linkbtn, .footer .linkbtn {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: inherit; padding: 0; text-decoration: underline;
}
.empty-bullets {
  list-style: none;
  padding: 0;
  margin: 22px auto 0;
  max-width: 380px;
  text-align: left;
  display: grid;
  gap: 8px;
}
.empty-bullets li {
  font-size: 13px;
  color: var(--text-dim);
  padding: 10px 14px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* ---------- Panels ---------- */
.panel { animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panel-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 10px; flex-wrap: wrap;
}
.panel-title { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.toolbar-btns { display: flex; gap: 8px; }

/* ---------- Action table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.action-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.action-table th {
  text-align: left;
  background: rgba(91, 140, 255, 0.07);
  color: var(--text-dim);
  font-weight: 600;
  padding: 10px 12px;
  font-size: 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.action-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.action-table tr:last-child td { border-bottom: none; }
.action-table tbody tr:hover { background: rgba(91, 140, 255, 0.05); }
.action-table td[contenteditable] { outline: none; cursor: text; border-radius: 5px; }
.action-table td[contenteditable]:focus { background: rgba(91, 140, 255, 0.12); box-shadow: inset 0 0 0 1px var(--accent); }
.idx-cell { color: var(--text-faint); font-family: var(--mono); width: 30px; }
.owner-cell { white-space: nowrap; font-weight: 600; color: #cdd9f5; }
.owner-cell.unassigned { color: var(--text-faint); font-weight: 400; font-style: italic; }
.due-cell { white-space: nowrap; font-family: var(--mono); font-size: 12.5px; color: #bfe6d4; }
.due-cell.none { color: var(--text-faint); }

.prio { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.prio-high { background: rgba(248, 113, 113, 0.16); color: #fca5a5; border: 1px solid rgba(248, 113, 113, 0.3); }
.prio-med { background: rgba(251, 191, 36, 0.14); color: #fcd34d; border: 1px solid rgba(251, 191, 36, 0.28); }
.prio-low { background: rgba(110, 231, 183, 0.13); color: #6ee7b7; border: 1px solid rgba(110, 231, 183, 0.28); }

/* ---------- Risk list ---------- */
.risk-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.risk-list li {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px;
  background: rgba(248, 113, 113, 0.06);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: 11px;
  font-size: 13.5px;
}
.risk-list li::before { content: "⚠️"; font-size: 14px; line-height: 1.5; }
.risk-tag {
  font-size: 10.5px; color: var(--warn); border: 1px solid rgba(251,191,36,0.4);
  padding: 1px 7px; border-radius: 6px; margin-left: auto; white-space: nowrap; align-self: center;
}

/* ---------- Owners ---------- */
.owners-wrap { display: grid; gap: 12px; }
.owner-card {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.owner-card h3 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.owner-card h3 .badge { font-size: 11px; color: var(--text-faint); font-weight: 400; }
.owner-card ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.owner-card li { font-size: 13px; color: var(--text-dim); }
.owner-card li .due-inline { font-family: var(--mono); font-size: 11.5px; color: #bfe6d4; margin-left: 6px; }

/* ---------- Message box ---------- */
.msg-box {
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d7e0f5;
  margin: 0;
  max-height: 480px;
  overflow-y: auto;
}

/* ---------- Footer ---------- */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 18px;
  color: var(--text-faint);
  font-size: 12px;
  border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.footer-dot { opacity: 0.5; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1c2942;
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .pane-result { min-height: 420px; }
  textarea#rawInput { min-height: 200px; }
}
@media (max-width: 560px) {
  .topbar { padding: 12px 16px; }
  .brand-text span { display: none; }
  .pane { padding: 16px; }
  .input-actions .btn { flex: 1; }
}
