/* ---------- Theme tokens ---------- */
:root {
  --bg: #f1f4f2;
  --header: #0b3d2e;
  --surface: #ffffff;
  --surface-2: #f6f9f7;
  --text: #1c2a24;
  --muted: #5d6f66;
  --heading: #0b3d2e;
  --accent: #1faa52;
  --accent-bright: #25d366;
  --border: #e4eae6;
  --shadow: 0 6px 20px rgba(11, 61, 46, .07), 0 1px 3px rgba(11, 61, 46, .06);
  --radius: 16px;
  --maxread: 860px;
}
:root[data-theme="dark"] {
  --bg: #0d1512;
  --header: #0a2c21;
  --surface: #16211d;
  --surface-2: #1c2925;
  --text: #e7efe9;
  --muted: #9bafa6;
  --heading: #bff0d2;
  --accent: #2bbf63;
  --accent-bright: #25d366;
  --border: #27352f;
  --shadow: 0 8px 26px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: 58px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  background: var(--header);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.menu-btn {
  display: none; /* shown on mobile only */
  border: 0; cursor: pointer; color: #fff;
  background: rgba(255,255,255,.12); border-radius: 10px;
  font-size: 20px; line-height: 1; padding: 7px 11px;
}
.menu-btn:hover { background: rgba(255,255,255,.24); }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .2px; }
.brand-mark { color: var(--accent-bright); font-size: 20px; }
.brand-name { font-size: 17px; white-space: nowrap; }

.book-tabs { display: flex; gap: 8px; flex: 1; overflow-x: auto; padding: 0 4px; }
.book-tabs::-webkit-scrollbar { height: 0; }
.book-tab {
  border: 0; cursor: pointer; white-space: nowrap;
  background: rgba(255,255,255,.10); color: #e9f5ee;
  padding: 7px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  transition: background .15s, color .15s;
}
.book-tab:hover { background: rgba(255,255,255,.20); }
.book-tab.active { background: #fff; color: var(--header); }

.actions { display: flex; align-items: center; gap: 8px; }
.btn-ghost {
  border: 0; cursor: pointer; color: #eafff4;
  background: rgba(255,255,255,.12); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; font-weight: 600;
  transition: background .15s;
}
.btn-ghost:hover { background: rgba(255,255,255,.24); }
#themeBtn { font-size: 17px; padding: 6px 12px; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  height: calc(100vh - 58px);
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px 10px 40px;
}
.content { overflow-y: auto; padding: 30px 28px 80px; }

/* ---------- Sidebar ---------- */
.part-title {
  font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); padding: 16px 12px 6px;
}
.tactic-link {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left; cursor: pointer;
  border: 0; background: transparent; color: var(--text);
  padding: 9px 12px; border-radius: 10px; font-size: 14px; line-height: 1.3;
  border-left: 3px solid transparent;
}
.tactic-link:hover { background: var(--surface-2); }
.tactic-link.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-left-color: var(--accent);
  color: var(--heading); font-weight: 600;
}
.tactic-link .tnum { color: var(--muted); font-size: 12px; min-width: 26px; }
.tactic-link.active .tnum { color: var(--accent); }
.tactic-link .dot {
  margin-left: auto; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-bright); opacity: 0; flex: none;
}
.tactic-link.has-note .dot { opacity: 1; }

.pdf-link { margin-top: 18px; }
.pdf-link .tnum { font-size: 15px; }

/* ---------- Content / cards ---------- */
.reader { max-width: var(--maxread); margin: 0 auto; }
.tactic-head { margin-bottom: 22px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); }
.tactic-title { font-size: 32px; line-height: 1.15; margin: 8px 0 10px; color: var(--heading); font-weight: 800; }
.tactic-principle { font-size: 18px; line-height: 1.5; margin: 0 0 4px; }
.tactic-oneliner { font-style: italic; color: var(--muted); margin: 4px 0 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin: 16px 0;
}
.card-label {
  font-size: 11px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase;
  color: var(--accent); margin: 0 0 12px;
}
.card ul { margin: 0; padding: 0; list-style: none; }
.card li { position: relative; padding: 7px 0 7px 20px; line-height: 1.55; }
.card li::before {
  content: ""; position: absolute; left: 2px; top: 15px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.card li + li { border-top: 1px solid var(--border); }

/* quote card */
.card.quotes li { padding-left: 18px; font-style: italic; color: var(--text); }
.card.quotes li::before { display: none; }
.card.quotes li { border-left: 3px solid var(--accent); padding-left: 16px; margin: 6px 0; }
.card.quotes li + li { border-top: 0; }

/* apply card = checklist */
.card.apply li::before {
  content: "✓"; background: transparent; color: var(--accent-bright);
  width: auto; height: auto; top: 7px; left: 0; font-weight: 800;
}
.card.apply li { padding-left: 24px; }

.empty-note { color: var(--muted); font-style: italic; margin: 6px 0 0; }

/* notes */
.notes-card { background: var(--surface-2); }
.notes-card textarea {
  width: 100%; min-height: 150px; resize: vertical;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
  padding: 14px; font: inherit; line-height: 1.55;
}
.notes-card textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.notes-status { font-size: 12px; color: var(--muted); margin-top: 8px; height: 14px; }

/* ---------- PDF view ---------- */
.pdf-wrap { display: flex; flex-direction: column; height: 100%; }
.pdf-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.pdf-toolbar .ptitle { font-weight: 700; color: var(--heading); margin-right: auto; }
.pdf-toolbar .hint { font-size: 12.5px; color: var(--muted); margin-right: auto; }
.btn {
  border: 0; cursor: pointer; font: inherit; font-weight: 600; font-size: 13.5px;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 10px;
}
.btn:hover { background: var(--accent-bright); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.pdf-status { font-size: 12.5px; color: var(--muted); }
.pdf-frame { flex: 1; width: 100%; border: 0; background: #525659; }
.content.pdf-mode { padding: 0; overflow: hidden; }

/* scrollbars */
.sidebar::-webkit-scrollbar, .content::-webkit-scrollbar { width: 10px; }
.sidebar::-webkit-scrollbar-thumb, .content::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 8px;
}

/* scrim behind the mobile drawer */
.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.45);
  opacity: 0; transition: opacity .2s ease;
}
.scrim.show { opacity: 1; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { gap: 10px; padding: 0 12px; }
  .brand-name { display: none; }
  .btn-ghost { padding: 7px 11px; }

  .layout { grid-template-columns: 1fr; }

  /* sidebar becomes an off-canvas drawer */
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 70;
    width: 82%; max-width: 320px; height: 100%;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.28);
    padding-top: 14px;
  }
  body.drawer-open .sidebar { transform: translateX(0); }

  .content { padding: 22px 18px 80px; }
  .tactic-title { font-size: 26px; }
  .card { padding: 18px 16px; }

  /* PDF view fits the small screen */
  .pdf-toolbar .hint { display: none; }
  .pdf-toolbar { padding: 10px 12px; gap: 8px; }
  .pdf-toolbar .ptitle { font-size: 14px; }
}

/* on desktop the scrim is never needed */
@media (min-width: 761px) {
  .scrim { display: none !important; }
}
