:root {
  --bg: #0f1115;
  --bg-soft: #161a22;
  --panel: #1b2029;
  --panel-2: #212734;
  --line: #2b3240;
  --line-soft: #232a36;
  --text: #e7ecf3;
  --text-dim: #9aa6b6;
  --text-faint: #6b7788;
  --accent: #4f8cff;
  --accent-soft: #1e2b45;
  --good: #34d399;
  --warn: #f59e0b;
  --danger: #f4736a;
  --reviewed: #8b95a6;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, #1a2740 0%, transparent 55%),
    radial-gradient(900px 500px at 0% 0%, #1d2033 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 17, 21, 0.82);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-size: 30px;
  filter: drop-shadow(0 2px 6px rgba(79, 140, 255, 0.4));
}
.brand h1 { font-size: 19px; margin: 0; letter-spacing: 0.2px; }
.brand-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); }
.topbar-actions { display: flex; gap: 10px; }

.badge {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
}
.badge.zero { background: var(--line); color: var(--text-faint); }

/* ---------- Buttons ---------- */
button { font-family: inherit; cursor: pointer; border: none; }
.primary-btn {
  background: linear-gradient(180deg, #5a95ff, #3f79f0);
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(63, 121, 240, 0.35);
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(63, 121, 240, 0.45); }
.primary-btn:active { transform: translateY(0); }
.ghost-btn {
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px;
  border: 1px solid var(--line);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ghost-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.ghost-btn.small { padding: 6px 11px; font-size: 12px; }
.link-btn {
  background: none;
  color: var(--accent);
  font-size: 12.5px;
  padding: 4px 0 0;
  align-self: flex-start;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 1fr 1.15fr 0.95fr;
  gap: 18px;
  padding: 22px 28px 40px;
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-head h2 { font-size: 15px; margin: 0; color: var(--text); font-weight: 650; }
.completeness { font-size: 12px; color: var(--text-dim); }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field-row { flex-direction: row; gap: 12px; }
.sub-field { display: flex; flex-direction: column; gap: 7px; flex: 1; }
.field-label { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.field-label em { color: var(--danger); font-style: normal; }
.hint-inline { color: var(--text-faint); font-size: 11px; }

input[type="text"], input[type="date"], textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input[type="date"] { color-scheme: dark; }

/* type grid */
.type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.type-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text-dim);
  text-align: left;
  transition: all 0.14s ease;
}
.type-chip .ic { font-size: 17px; }
.type-chip .tl { font-size: 12px; font-weight: 600; color: var(--text); }
.type-chip:hover { border-color: var(--accent); }
.type-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.type-tagline { margin: 9px 0 0; font-size: 12px; color: var(--text-faint); min-height: 16px; }

/* confidence */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 50%, var(--line) 50%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.conf-hint { font-size: 11.5px; color: var(--text-faint); min-height: 15px; }
#conf-band { color: var(--accent); font-weight: 600; }

.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.form-actions .primary-btn { flex: 1; }
.privacy-note { font-size: 11.5px; color: var(--text-faint); margin: 14px 0 0; }

/* ---------- Card view ---------- */
.card-view { display: flex; flex-direction: column; gap: 14px; }
.dcard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.dcard-title { font-size: 17px; font-weight: 650; margin: 0 0 4px; }
.dcard-meta { font-size: 12px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 10px; }
.type-pill {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: #a9c6ff;
  white-space: nowrap;
}
.conf-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 62px;
}
.conf-ring b { font-size: 20px; }
.conf-ring span { font-size: 10.5px; color: var(--text-dim); }

.dsection { }
.dsection h3 {
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 0 0 8px;
  text-transform: none;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dsection h3 .tag {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text-faint);
}
.dlist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.dlist li {
  font-size: 13px;
  padding: 8px 11px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--text);
}
.dlist li.prompt { color: var(--text-dim); border-style: dashed; }
.dlist li.user { border-left: 2px solid var(--good); }
.dsection.premortem li { border-left: 2px solid var(--warn); color: var(--text-dim); }
.dsection.kill li { border-left: 2px solid var(--danger); color: var(--text-dim); }
.leaning-box {
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: 9px;
  font-size: 13.5px;
}
.leaning-box .lb-label { font-size: 11px; color: var(--text-dim); display: block; margin-bottom: 2px; }
.empty-hint { color: var(--text-faint); font-size: 13px; padding: 40px 10px; text-align: center; }

/* ---------- Journal list ---------- */
.list-filters { display: flex; gap: 6px; margin-bottom: 14px; }
.filter-btn {
  background: var(--bg);
  color: var(--text-dim);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
}
.filter-btn.active { background: var(--accent-soft); color: #a9c6ff; border-color: var(--accent); }

.journal-list { display: flex; flex-direction: column; gap: 10px; max-height: 70vh; overflow-y: auto; padding-right: 2px; }
.jitem {
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.14s ease, transform 0.08s ease;
}
.jitem:hover { border-color: var(--accent); transform: translateX(1px); }
.jitem.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.jitem-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.jitem-title { font-size: 13.5px; font-weight: 600; margin: 0; }
.jitem-date { font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.jitem-bottom { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.status-tag { font-size: 11px; padding: 3px 9px; border-radius: 12px; font-weight: 600; }
.status-open { background: var(--accent-soft); color: #a9c6ff; }
.status-soon { background: rgba(245, 158, 11, 0.15); color: var(--warn); }
.status-due { background: rgba(244, 115, 106, 0.16); color: var(--danger); }
.status-reviewed { background: rgba(139, 149, 166, 0.18); color: var(--reviewed); }
.jitem-type { font-size: 11px; color: var(--text-dim); }
.jitem-actions { display: flex; gap: 6px; margin-top: 10px; }
.mini-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 7px;
}
.mini-btn:hover { border-color: var(--accent); color: var(--text); }
.mini-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.list-empty { color: var(--text-faint); font-size: 13px; text-align: center; padding: 30px 10px; }

/* review note editor */
.review-editor { margin-top: 10px; display: none; }
.review-editor.show { display: block; }
.review-editor textarea { margin-bottom: 8px; }

/* ---------- Footer + toast ---------- */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px solid var(--line-soft);
}
.footer a { color: var(--text-dim); text-decoration: none; }
.footer a:hover { color: var(--accent); }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .card-panel { order: 3; }
  .list-panel { order: 2; }
}
@media (max-width: 560px) {
  .topbar { padding: 14px 16px; flex-wrap: wrap; }
  .brand h1 { font-size: 17px; }
  .layout { padding: 16px 14px 32px; }
  .type-grid { grid-template-columns: repeat(2, 1fr); }
  .field-row { flex-direction: column; }
}
