:root {
  --primary: #1a365d;
  --secondary: #c53030;
  --accent: #2b6cb0;
  --bg: #fafaf7;
  --bg-card: #ffffff;
  --text: #1a202c;
  --text-muted: #4a5568;
  --border: #e2e8f0;
  --success: #38a169;
  --warning: #dd6b20;
  --danger: #c53030;
  --code-bg: #f7fafc;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--primary);
  color: white;
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar h1 {
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
  font-weight: 700;
}
.sidebar .subtitle {
  font-size: 0.78rem;
  opacity: 0.7;
  margin-bottom: 1.5rem;
}
.sidebar nav a {
  display: block;
  padding: 0.6rem 0.75rem;
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.92rem;
  margin-bottom: 0.15rem;
  opacity: 0.85;
  transition: background 0.15s, opacity 0.15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.1); opacity: 1; }
.sidebar nav a.active { background: rgba(255,255,255,0.2); opacity: 1; font-weight: 600; }
.sidebar nav a .num { font-weight: 700; opacity: 0.7; margin-right: 0.4em; }

.sidebar .progress {
  margin-top: 1.5rem;
  padding: 0.75rem;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  font-size: 0.78rem;
}
.sidebar .progress strong { color: #ffd; }

.sidebar .actions {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sidebar .actions button {
  background: white;
  color: var(--primary);
  border: none;
  padding: 0.6rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.88rem;
}
.sidebar .actions button:hover { background: #e6f1ff; }
.sidebar .actions button.secondary {
  background: rgba(255,255,255,0.1);
  color: white;
}
.sidebar .actions button.secondary:hover { background: rgba(255,255,255,0.2); }

/* Main */
main {
  padding: 2rem 3rem;
  max-width: 920px;
}

.page-header {
  border-bottom: 2px solid var(--border);
  padding-bottom: 1rem;
  margin-bottom: 2rem;
}
.page-header h2 {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 0.25rem;
}
.page-header .meta {
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.card h3 {
  color: var(--primary);
  margin-bottom: 0.75rem;
  font-size: 1.15rem;
}
.card h4 {
  color: var(--text);
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
}
.card.warning { border-left: 4px solid var(--warning); }
.card.danger { border-left: 4px solid var(--danger); }
.card.info { border-left: 4px solid var(--accent); }
.card.success { border-left: 4px solid var(--success); }

.card p { margin-bottom: 0.75rem; }
.card ul, .card ol { margin: 0.5rem 0 1rem 1.5rem; }
.card li { margin-bottom: 0.4rem; }

/* Quoted source fragments */
blockquote {
  background: var(--code-bg);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.94rem;
  color: var(--text-muted);
  font-style: italic;
}
blockquote p { margin-bottom: 0.5rem; }
blockquote p:last-child { margin-bottom: 0; }
blockquote strong { color: var(--text); font-style: normal; }

/* Forms */
.form-group {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--code-bg);
  border-radius: 8px;
}
.form-group .label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: block;
}
.form-group .options label {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
}
.form-group .options label:hover { background: white; }
.form-group .options input[type=radio],
.form-group .options input[type=checkbox] {
  margin-right: 0.6em;
  cursor: pointer;
}
.form-group .options label.checked {
  background: white;
  border: 1px solid var(--accent);
  font-weight: 500;
}
.form-group textarea {
  width: 100%;
  min-height: 70px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  margin-top: 0.5rem;
  background: white;
  resize: vertical;
}
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43,108,176,0.15);
}
.form-group input[type=text] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  background: white;
}
.form-group .helper {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.4rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.92rem;
}
th, td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th { background: var(--code-bg); font-weight: 600; color: var(--primary); }
tr:hover { background: rgba(43,108,176,0.03); }

/* Images */
figure {
  margin: 1rem 0;
  text-align: center;
}
figure img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
}
figcaption {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-style: italic;
}

/* Tags */
.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.5em;
}
.tag.danger { background: #fee; color: var(--danger); }
.tag.warning { background: #fef3e7; color: var(--warning); }
.tag.info { background: #e6f1ff; color: var(--accent); }
.tag.success { background: #e6f6ed; color: var(--success); }
.tag.muted { background: var(--border); color: var(--text-muted); }

/* Save indicator */
.save-indicator {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.5rem 1rem;
  background: var(--success);
  color: white;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 100;
}
.save-indicator.show { opacity: 1; }

/* Code/keyboard */
code, kbd {
  background: var(--code-bg);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: "SF Mono", Monaco, monospace;
}
kbd { border: 1px solid var(--border); }

/* Decisions list */
.decisions-list { list-style: none; padding: 0; margin: 1rem 0; }
.decisions-list li {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.4rem;
  background: var(--code-bg);
  border-radius: 6px;
  border-left: 3px solid var(--success);
}

/* Header note */
.note {
  background: #fffaf0;
  border: 1px solid #fbd38d;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
}
.note strong { color: var(--warning); }
.note.danger { background: #fff5f5; border-color: #feb2b2; }
.note.danger strong { color: var(--danger); }
.note.info { background: #ebf8ff; border-color: #90cdf4; }
.note.info strong { color: var(--accent); }

/* Two col */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  main { padding: 1.5rem; }
}
