/* ═══════════════════════════════════════════════
   BARE BONES — UI Redesign
   Orange · White · Warm Grey  ·  Font: Outfit
   ═══════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────── */
:root {
  /* Surfaces */
  --bg:        #EDEBE6;
  --panel:     #FFFFFF;
  --panel-2:   #F5F3EE;
  --panel-3:   #ECEAE5;

  /* Ink */
  --ink:       #1A1916;
  --ink-2:     #38362F;
  --muted:     #7A7870;
  --line:      #DEDAD2;

  /* Orange — all original names kept for backward compat */
  --accent:              #fa4c06;
  --accent-2:            #fb6a2e;
  --accent-3:            #fc8a58;
  --accent-light:        #fdd0b0;
  --accent-soft:         #fdd0b0;
  --accent-xlight:       #fff0e6;
  --accent-softer:       #fff0e6;
  --accent-xxlight:      #fff8f4;
  --accent-bg:           #fff8f4;
  --accent-edge:         #fcb48a;
  --accent-strong:       #c23504;
  --accent-ink:          #7a2003;
  --accent-dark:         #7a2003;
  --highlight-orange:    #fdb48a;
  --highlight-orange-soft: #fde0cc;

  /* Semantic */
  --success:  #16A34A;
  --danger:   #DC2626;

  /* Typography */
  --font: 'Outfit', system-ui, sans-serif;

  /* Geometry */
  --r-xs:   8px;
  --r-sm:   12px;
  --r-md:   18px;
  --r-lg:   24px;
  --r-xl:   32px;
  --r-full: 999px;
  --radius: 24px; /* legacy alias */

  /* Shadows */
  --s0: 0 1px 3px rgba(0,0,0,0.04);
  --s1: 0 2px 10px rgba(0,0,0,0.06);
  --s2: 0 6px 24px rgba(0,0,0,0.09);
  --s3: 0 24px 72px rgba(0,0,0,0.15);
  --so: 0 4px 22px rgba(249,115,22,0.32);

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t: 180ms;
}

/* ── Reset ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h2, h3, h4 {
  margin-top: 0;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

/* ── Brand mark ──────────────────────────────── */
.brand-mark {
  position: fixed;
  top: 1rem;
  left: 1.1rem;
  z-index: 20;
  line-height: 0;
  display: block;
}

.brand-mark img {
  height: 32px;
  width: auto;
  display: block;
}

/* ── ASCII header ────────────────────────────── */
.ascii-header {
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(0.5rem, 0.68vw, 0.72rem);
  line-height: 1.3;
  color: var(--accent-strong);
  text-align: center;
  margin: 0 0 1.5rem;
  letter-spacing: 0;
  user-select: none;
  overflow-x: auto;
}

/* ── Login overlay ───────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
}

.login-overlay.is-visible {
  opacity: 1;
  pointer-events: all;
}

.login-overlay.is-exiting {
  animation: overlay-exit 0.55s var(--ease) forwards;
}

@keyframes overlay-exit {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.login-ascii-wrap {
  position: relative;
}

.login-ascii {
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(0.6rem, 1.15vw, 0.85rem);
  line-height: 1.32;
  color: var(--accent);
  white-space: pre;
  margin: 0;
  clip-path: inset(0 0 100% 0);
}

.login-overlay.is-visible .login-ascii {
  animation: ascii-reveal 1s linear forwards;
}

@keyframes ascii-reveal {
  from { clip-path: inset(0 0 100% 0); }
  to   { clip-path: inset(0 0 0% 0); }
}

.login-scan {
  position: absolute;
  top: 0;
  left: -1.5rem;
  right: -1.5rem;
  height: 2px;
  background: linear-gradient(90deg,
    transparent,
    var(--accent-3) 20%,
    var(--accent) 50%,
    var(--accent-3) 80%,
    transparent);
  box-shadow:
    0 0 14px 4px var(--accent-light),
    0 0 4px 1px var(--accent);
  opacity: 0;
  pointer-events: none;
}

.login-overlay.is-visible .login-scan {
  animation: scan-sweep 1s linear forwards;
}

@keyframes scan-sweep {
  0%   { top: 0%;   opacity: 1; }
  88%  { top: 100%; opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.login-welcome {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.1em;
  text-transform: lowercase;
  margin-top: 2rem;
  opacity: 0;
  transform: translateY(8px);
}

.login-overlay.is-visible .login-welcome {
  animation: welcome-rise 0.45s var(--ease) forwards;
  animation-delay: 1.05s;
}

@keyframes welcome-rise {
  to { opacity: 1; transform: translateY(0); }
}

/* ── App shell ───────────────────────────────── */
.app-shell {
  max-width: 1400px;
  margin: 3.5rem auto 2rem;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* ── Card ────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--r-xl);
  padding: 1.25rem;
  box-shadow: var(--s1);
}

/* ── Profile avatar ──────────────────────────── */
.profile-avatar-wrap {
  position: fixed;
  top: 0.85rem;
  right: 1.25rem;
  z-index: 25;
  display: inline-flex;
  align-items: center;
}

.profile-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.75);
  background: var(--accent);
  box-shadow: var(--s1), 0 0 0 3px var(--accent-light);
  padding: 0;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  letter-spacing: 0;
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.profile-avatar:hover {
  transform: scale(1.08);
  box-shadow: var(--s2), 0 0 0 4px var(--accent-light);
}

.profile-level {
  position: absolute;
  top: 50%;
  right: calc(100% + 0.6rem);
  transform: translateY(-50%);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  font-family: var(--font);
  letter-spacing: 0.02em;
  padding: 0.25rem 0.65rem;
  border-radius: var(--r-full);
  box-shadow: var(--so);
  white-space: nowrap;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  padding: 0.7rem;
  min-width: 210px;
  box-shadow: var(--s3);
  animation: menu-pop 0.18s var(--ease) both;
}

@keyframes menu-pop {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.profile-menu button { width: 100%; }

.profile-menu .button-secondary {
  background: var(--panel);
  color: var(--ink-2);
  border-color: var(--line);
}

.profile-menu .button-secondary:hover {
  background: var(--accent-xlight);
  color: var(--accent-strong);
  border-color: var(--accent-light);
}

/* ── Account switcher ────────────────────────── */
.account-switcher {
  width: 100%;
  margin-bottom: 0.5rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  appearance: auto;
}

/* ── Auth panel ──────────────────────────────── */
.auth-panel {
  max-width: 440px;
  animation: slide-in 0.22s var(--ease) both;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

#openAuthButton { margin-bottom: 0.5rem; }

/* ── Avatar / theme picker ───────────────────── */
.avatar-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.avatar-option {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition:
    transform var(--t) var(--ease),
    border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease);
}

.avatar-option:hover { transform: scale(1.14); }

.avatar-option.selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--ink);
}

/* ── Utility ─────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

.muted  { color: var(--muted); }
.small  { font-size: 0.875rem; }
.hidden { display: none !important; }

.theme-label { margin: 0.45rem 0 0.3rem; font-size: 0.85rem; }

/* ── Inputs ──────────────────────────────────── */
input, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0.65rem 0.9rem;
  font: inherit;
  background: var(--panel);
  color: var(--ink);
  display: block;
  transition:
    border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-xlight);
}

/* ── Buttons — base ──────────────────────────── */
button {
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0.6rem 1rem;
  width: 100%;
  background: var(--panel);
  color: var(--ink);
  transition:
    background var(--t) var(--ease),
    color var(--t) var(--ease),
    border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease),
    transform var(--t) var(--ease);
}

button:active { transform: scale(0.965) !important; }

/* Primary */
.button-primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--so);
  letter-spacing: 0.01em;
}

.button-primary:hover {
  background: var(--accent-strong);
  box-shadow: 0 6px 28px rgba(249,115,22,0.42);
  transform: translateY(-1px);
}

/* Secondary */
.button-secondary {
  background: var(--panel);
  color: var(--ink-2);
  border-color: var(--line);
}

.button-secondary:hover {
  background: var(--accent-xlight);
  color: var(--accent-strong);
  border-color: var(--accent-light);
  transform: translateY(-1px);
}

/* ── Main layout ─────────────────────────────── */
.main-content {
  display: grid;
  gap: 1rem;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.subject-area {
  display: grid;
  grid-template-columns: 270px 1fr;
  grid-template-rows: 1fr;
  gap: 1rem;
  align-items: stretch;
  height: calc(100vh - 5.5rem);
}

/* Left panel — subject/chapter picker */
.subject-list-wrap {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--s1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.subject-list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.1rem 1.1rem 2.5rem;
}

/* Right panel — workbench */
#subjectWorkbench {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--r-xl);
  padding: 1.25rem 1.5rem 2.5rem;
  box-shadow: var(--s1);
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
}

/* ── Subject graph / list ────────────────────── */
.graph-wrap { overflow: visible; }

.subject-panel-btn {
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.6rem 1rem;
  font-size: 0.88rem;
  font-weight: 700;
}

.subject-graph {
  display: grid;
  gap: 0.55rem;
}

.graph-subject {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.graph-subject:hover {
  border-color: var(--accent-light);
  box-shadow: var(--s1);
}

.graph-subject-main {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink);
  border-radius: 0;
}

/* Orange dot indicator — no border-left side-stripe */
.graph-subject-main::before {
  content: '';
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line);
  transition: background var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.graph-subject-main:hover {
  background: var(--accent-light);
}

.graph-subject:has(.graph-subject-main:hover) .graph-chapters {
  background: linear-gradient(to bottom, var(--accent-xlight), transparent 0.5rem);
}

.graph-subject-main:hover::before,
.graph-subject-main.active::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-xlight);
}

.graph-chapters {
  padding: 0.5rem 0.65rem 0.7rem;
  display: grid;
  gap: 0.3rem;
}

.graph-chapter {
  text-align: left;
  background: var(--panel-2);
  border-color: transparent;
  border-radius: var(--r-sm);
  padding: 0.45rem 0.85rem;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--muted);
  box-shadow: none;
}

.graph-chapter:hover {
  background: var(--accent-xlight);
  color: var(--accent-strong);
  border-color: var(--accent-light);
  transform: none;
}

.graph-chapter.active {
  background: var(--accent-xlight);
  color: var(--accent-strong);
  font-weight: 600;
  border-color: var(--accent-light);
}

/* ── Subject template button ─────────────────── */
.subject-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 0.5rem;
}

.subject-item { display: grid; }

.subject-open {
  text-align: left;
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
  font-weight: 600;
}

.subject-open:hover {
  background: var(--accent-xlight);
  color: var(--accent-strong);
  border-color: var(--accent-light);
  transform: translateX(2px);
}

.subject-open.active {
  background: var(--accent-xlight);
  color: var(--accent-strong);
  border-color: var(--accent-light);
}

/* ── Workbench ───────────────────────────────── */
.workbench { display: grid; gap: 0.9rem; align-content: start; }

/* ── Tabs — pill group ───────────────────────── */
.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--panel-2);
  border-radius: var(--r-full);
  padding: 0.28rem;
  border: 1.5px solid var(--line);
  width: fit-content;
}

.tab {
  flex: 0 0 auto;
  width: auto;
  min-width: 90px;
  max-width: none;
  height: auto;
  padding: 0.42rem 1.05rem;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  box-shadow: none;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.4;
}

.tab:hover {
  background: var(--panel);
  color: var(--ink);
  transform: none;
  box-shadow: var(--s0);
  border-color: transparent;
}

.tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--so);
  transform: none;
  border-color: transparent;
}

.tab:focus { outline: none; }
.tab:active { transform: scale(0.965) !important; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Toolbar ─────────────────────────────────── */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
  gap: 0.75rem;
}

.toolbar h3 { margin: 0; font-size: 1rem; }

.toolbar > button,
.toolbar button {
  width: auto;
  padding: 0.4rem 0.9rem;
  font-size: 0.84rem;
  flex-shrink: 0;
}

.full-notes-wide {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 1rem;
}

/* ── Flashcard study ─────────────────────────── */
.flashcard-study {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.4rem 1.5rem;
  min-height: 160px;
  display: grid;
  gap: 1rem;
  margin-bottom: 0.9rem;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.flashcard-study:hover {
  border-color: var(--accent-light);
  box-shadow: var(--s1);
}

.study-face {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
}

.study-controls {
  display: flex;
  gap: 0.5rem;
}

.study-controls button {
  width: auto;
  flex: 1;
  font-size: 0.84rem;
  padding: 0.5rem 0.75rem;
}

/* ── Resource list (outcomes) ────────────────── */
.resource-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 0.5rem;
}

/* Notes list below flashcard — hidden; use Full Notes instead */
#flashcardList { display: none !important; }

.resource-item {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.85rem 1rem;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.resource-item:hover {
  border-color: var(--accent-light);
  box-shadow: var(--s0);
}

.resource-item-main p {
  margin: 0.3rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.resource-item-main strong { font-size: 0.94rem; }

/* ── LO item ─────────────────────────────────── */
.lo-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.1rem 0;
}

/* ── Hierarchy panel ─────────────────────────── */
.hierarchy-panel {
  margin-top: 0.9rem;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 1rem;
}

.hierarchy-panel h4 { margin: 0 0 0.65rem; font-size: 0.94rem; }

.hierarchy-panel details {
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.45rem;
  background: var(--panel-2);
}

.hierarchy-panel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hierarchy-panel summary::marker { display: none; }
.hierarchy-panel summary::before {
  content: '▶';
  font-size: 0.65rem;
  color: var(--accent);
  transition: transform var(--t) var(--ease);
}

details[open] > summary::before { transform: rotate(90deg); }

.hierarchy-panel li { margin: 0.25rem 0; font-size: 0.87rem; }

/* ── Progress ring ───────────────────────────── */
.progress-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--accent-strong);
  background:
    radial-gradient(var(--panel) 58%, transparent 60%),
    conic-gradient(var(--accent) var(--pct, 0%), var(--line) 0%);
  border: 1px solid var(--accent-light);
  flex-shrink: 0;
}

/* ── Progress bar ────────────────────────────── */
.progress-bar {
  height: 8px;
  border-radius: var(--r-full);
  background: var(--accent-xlight);
  overflow: hidden;
  border: none;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: var(--r-full);
  transition: width 0.5s var(--ease);
}

/* ── Test ────────────────────────────────────── */
.test-card {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 1rem 1.2rem;
  margin-bottom: 0.8rem;
  transition: border-color var(--t) var(--ease);
}

.test-card:hover { border-color: var(--accent-light); }

.test-card textarea {
  margin-top: 0.65rem;
  min-height: 88px;
  resize: vertical;
  background: var(--panel-2);
}

.test-container .muted {
  text-align: center;
  padding: 2.5rem 0;
  display: block;
}

.gap-list { margin-top: 0.6rem; padding-left: 1.1rem; }
.gap-list li { margin-bottom: 0.35rem; font-size: 0.87rem; }

/* ── Mark right / wrong ──────────────────────── */
.mark-right {
  background: #F0FDF4;
  border: 1.5px solid #86EFAC;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  display: inline-block;
  margin: 0.15rem 0;
  color: #15803D;
  font-size: 0.87rem;
}

.mark-wrong {
  background: var(--panel-3);
  border: 1.5px solid var(--line);
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  display: inline-block;
  margin: 0.15rem 0;
  color: var(--muted);
  font-size: 0.87rem;
}

.feedback-block {
  margin-top: 0.6rem;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  font-size: 0.9rem;
  line-height: 1.55;
}

.bonus-line {
  margin-top: 0.4rem;
  font-size: 0.88rem;
  color: var(--accent-strong);
  font-weight: 600;
}

/* ── Keyword chips ───────────────────────────── */
.keyword-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1.5px solid var(--line);
}

.keyword-row .kw-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  align-self: center;
  margin-right: 0.25rem;
  font-weight: 600;
}

.keyword-chip {
  font-size: 0.79rem;
  padding: 0.18rem 0.58rem;
  background: var(--accent-xxlight);
  border: 1.5px solid var(--accent-light);
  color: var(--accent-strong);
  border-radius: var(--r-full);
  font-weight: 500;
}

.keyword-chip.hit {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.keyword-chip.miss {
  background: var(--panel-3);
  color: var(--muted);
  border-color: var(--line);
}

/* ── Theme / subject picker ──────────────────── */
.theme-picker {
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 0.6rem;
}

.theme-picker .avatar-option {
  width: 22px;
  height: 22px;
  border-width: 2px;
}

.subject-picker {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}

.subject-picker label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.25rem 0;
}

.subject-picker input[type="checkbox"] {
  accent-color: var(--accent);
  width: auto;
  border: none;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  flex-shrink: 0;
}

/* ── Full-screen overlays ────────────────────── */
.full-notes-screen {
  position: fixed;
  inset: 0;
  background: rgba(26, 25, 22, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
}

.full-notes-card {
  width: min(960px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: var(--panel);
  border-radius: var(--r-xl);
  border: 1.5px solid var(--line);
  padding: 1.5rem 2rem;
  box-shadow: var(--s3);
  animation: modal-in 0.24s var(--ease) both;
}

/* Full Notes fills entire screen */
#fullNotesScreen {
  padding: 0;
  overflow: hidden;
  display: block; /* override grid centering */
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

#fullNotesScreen .full-notes-card {
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  max-width: 100%;
  border-radius: 0;
  border: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  box-shadow: none;
}

#fullNotesScreen .full-notes-card .toolbar {
  padding: 1.25rem 3rem 1rem;
  margin-bottom: 0;
  flex-shrink: 0;
  background: var(--bg);
  border-bottom-color: var(--line);
}

#fullNotesScreen .full-notes-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 3rem 3rem;
  width: 100%;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(14px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.full-notes-card .toolbar {
  position: sticky;
  top: 0;
  background: var(--panel);
  padding-bottom: 0.65rem;
  border-bottom: 1.5px solid var(--line);
  margin-bottom: 0.9rem;
  z-index: 1;
}

.full-notes-body h4 {
  margin: 1.4rem 0 0.55rem;
  color: var(--accent-strong);
  font-size: 1.25rem;
  border-bottom: 2px solid var(--accent-xlight);
  padding-bottom: 0.35rem;
}

.full-notes-body h5 {
  margin: 1rem 0 0.3rem;
  font-size: 1.05rem;
  color: var(--ink-2);
}

.full-notes-body p {
  margin: 0 0 0.85rem;
  line-height: 1.75;
  color: var(--ink-2);
  font-size: 1.05rem;
}

.full-notes-body .lo-block {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--accent-xxlight);
  border: 1.5px solid var(--accent-xlight);
  border-radius: var(--r-md);
}

.full-notes-body .note-block {
  padding: 0.75rem 1rem;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  margin-bottom: 0.65rem;
  font-size: 1rem;
  line-height: 1.7;
}

/* ── Progress screen ─────────────────────────── */
.progress-card { width: min(860px, 96vw); }
.progress-body { display: grid; gap: 1.4rem; }

.progress-summary {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem 1.6rem;
  background: var(--accent-xxlight);
  border: 1.5px solid var(--accent-xlight);
  border-radius: var(--r-lg);
}

.progress-percent {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -0.04em;
}

.progress-summary-meta { display: grid; gap: 0.25rem; }
.progress-summary-meta strong { font-size: 1rem; }

.progress-subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.progress-subject-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 1.4rem 1rem 1.1rem;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  text-align: center;
  transition: box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}

.progress-subject-card:hover {
  box-shadow: var(--s2);
  border-color: var(--accent-light);
}

.progress-subject-pct {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}

.progress-subject-title { font-size: 0.95rem; font-weight: 700; }
.progress-subject-sub   { font-size: 0.78rem; color: var(--muted); }

.progress-subject-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--accent-xlight);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-subject-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: var(--r-full);
  transition: width 0.5s var(--ease);
}

.progress-subject-btn {
  margin-top: 0.2rem;
  width: 100%;
  font-size: 0.82rem;
  padding: 0.4rem 0.7rem;
}

.progress-detail-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.progress-detail-header h4 { margin: 0; font-size: 1rem; flex: 1; }

.progress-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  align-items: end;
  gap: 0.45rem;
  height: 200px;
  padding: 0.75rem;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  overflow-x: auto;
}

.progress-bar-item {
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  justify-items: center;
  gap: 0.3rem;
  height: 100%;
  min-width: 28px;
}

.progress-bar-fill-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--accent-xlight);
  border-radius: var(--r-xs) var(--r-xs) 0 0;
  overflow: hidden;
}

.progress-bar-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-radius: var(--r-xs) var(--r-xs) 0 0;
  transition: height 0.4s var(--ease);
}

.progress-bar-label {
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--accent-strong);
  white-space: nowrap;
}

.progress-bar-value { font-size: 0.61rem; color: var(--muted); }

/* ── Exam tab ────────────────────────────────── */
.exam-container { display: grid; gap: 1.25rem; padding: 0.25rem 0; }
.exam-empty { padding: 2rem 0; text-align: center; color: var(--muted); }

.exam-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 1rem;
  border-radius: var(--r-sm);
  border: 1.5px solid;
  font-size: 0.85rem;
  line-height: 1.55;
}

.exam-disclaimer--warning {
  background: #FFFBEB;
  border-color: #FDE68A;
  color: var(--ink-2);
}

.exam-disclaimer--info {
  background: var(--accent-xxlight);
  border-color: var(--accent-xlight);
  color: var(--ink-2);
}

.exam-disclaimer-icon {
  flex-shrink: 0;
  font-style: normal;
  font-size: 0.9rem;
  margin-top: 0.05rem;
}

.exam-group {
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.exam-group-header {
  background: var(--accent-xxlight);
  border-bottom: 1.5px solid var(--accent-xlight);
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.exam-source-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-strong);
  letter-spacing: 0.01em;
}

.exam-group--case-study { border-color: var(--accent-light); }

.exam-case-study-context {
  background: var(--accent-xxlight);
  border-bottom: 1.5px solid var(--accent-xlight);
  padding: 0.9rem 1rem;
  font-size: 0.88rem;
  line-height: 1.65;
}

.exam-case-study-context-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 0.55rem;
}

.exam-case-study-context-body { line-height: 1.7; }

.exam-part {
  padding: 1rem;
  border-bottom: 1.5px solid var(--line);
  display: grid;
  gap: 0.65rem;
}

.exam-part:last-child { border-bottom: none; }

.exam-part-header {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.exam-part-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-strong);
  background: var(--accent-xlight);
  border: 1.5px solid var(--accent-light);
  border-radius: 6px;
  padding: 0.1rem 0.45rem;
}

.exam-marks { font-size: 0.78rem; color: var(--muted); }

.exam-question-text {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.55;
  font-weight: 500;
  color: var(--ink);
}

.exam-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 0.88rem;
  resize: vertical;
  background: var(--panel-2);
  color: var(--ink);
  line-height: 1.55;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.exam-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-xlight);
}

.exam-toggle-btn {
  justify-self: start;
  font-size: 0.82rem;
  padding: 0.35rem 0.88rem;
  width: auto;
}

.exam-diagram-btn {
  font-size: 0.78rem;
  padding: 0.2rem 0.65rem;
  margin-left: auto;
  color: var(--accent-strong);
  border-color: var(--accent-light);
  background: var(--accent-xxlight);
  width: auto;
}

/* ── Full-screen exam questions (breakdown flow) ─ */
.exam-container--fullscreen {
  max-width: 820px;
  margin: 0 auto;
  gap: 2.5rem;
}

.exam-container--fullscreen .exam-part {
  padding: 1.5rem 1.5rem;
  gap: 1.1rem;
}

.exam-container--fullscreen .exam-question-text {
  font-size: 1rem;
  line-height: 1.65;
}

.exam-container--fullscreen .exam-textarea {
  min-height: 120px;
  font-size: 0.92rem;
}

.exam-diagram-inline {
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--panel-2);
  text-align: center;
  padding: 0.75rem;
}

.exam-diagram-inline img {
  max-width: 100%;
  max-height: 520px;
  display: block;
  margin: 0 auto;
  border-radius: var(--r-sm);
}

.exam-diagram-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

/* ── Diagram modal ───────────────────────────── */
.diagram-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.diagram-modal.open { display: flex; }

.diagram-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 25, 22, 0.6);
  backdrop-filter: blur(4px);
}

.diagram-modal-box {
  position: relative;
  background: var(--panel);
  border-radius: var(--r-xl);
  padding: 1.25rem;
  max-width: min(92vw, 780px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--s3);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  animation: modal-in 0.22s var(--ease) both;
}

.diagram-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.9rem;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem 0.55rem;
  width: auto;
  line-height: 1;
}

.diagram-modal-close:hover {
  background: var(--panel-3);
  color: var(--ink);
}

.diagram-modal-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--r-sm);
}

body.modal-open { overflow: hidden; }

/* ── Exam answer ─────────────────────────────── */
.exam-answer-wrap {
  background: var(--accent-xxlight);
  border: 1.5px solid var(--accent-xlight);
  border-radius: var(--r-sm);
  padding: 0.8rem 1rem;
}

.exam-answer-label {
  margin: 0 0 0.35rem;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.exam-answer-text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--ink-2);
}

/* ── Model answer formatting ─────────────────── */
.model-subheading {
  margin: 14px 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-strong);
  font-family: var(--font);
}

.model-subheading:first-child { margin-top: 2px; }

.model-srp {
  margin: 3px 0 3px 12px;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--ink-2);
}

.applies-to-block {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--accent-xxlight);
  border: 1.5px solid var(--accent-xlight);
  border-radius: var(--r-sm);
}

.applies-to-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.applies-to-chip {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: var(--r-full);
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 500;
}

/* ── Subject overview ────────────────────────── */
#subjectWorkbench.overview-mode .tabs,
#subjectWorkbench.overview-mode .tab-content { display: none !important; }

.overview-header {
  margin-bottom: 1rem;
}

.overview-header-text {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.overview-header-text h3 { margin: 0; font-size: 1rem; }

.overview-total-bar {
  height: 20px;
  background: var(--accent-xlight);
  border-radius: var(--r-full);
  overflow: hidden;
  border: 1.5px solid var(--accent-light);
}

.overview-total-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: var(--r-full);
  transition: width 0.5s var(--ease);
}

.overview-chapter-list { display: grid; gap: 0.4rem; }

.overview-chapter-row {
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 0 1rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  box-shadow: none;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease);
}

.overview-chapter-row:hover {
  border-color: var(--accent-light);
  background: var(--accent-xxlight);
  box-shadow: var(--s1);
  transform: translateY(-1px);
}

.overview-chapter-text {
  flex-shrink: 0;
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.overview-chapter-title { font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.overview-chapter-score { font-size: 0.75rem; color: var(--muted); }

.overview-progress-bar {
  flex: 1;
  height: 36px;
  background: var(--accent-xlight);
  border-radius: var(--r-full);
  overflow: hidden;
}

.overview-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: var(--r-full);
  transition: width 0.4s var(--ease);
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar h1 {
  margin: 0;
  letter-spacing: -0.04em;
  text-transform: lowercase;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    margin-top: 5rem;
    padding: 0 1rem;
  }

  .subject-area {
    grid-template-columns: 1fr;
    height: calc(100vh - 7rem);
  }

  .tabs {
    width: 100%;
    justify-content: stretch;
  }

  .tab {
    flex: 1;
    text-align: center;
    min-width: 0;
  }

  .full-notes-card {
    padding: 1.1rem 1.25rem;
  }
}

/* ── Exam Breakdown Modal ─────────────────────────── */
.breakdown-modal-card {
  position: relative;
  width: min(860px, 96vw);
  max-height: 88vh;
  overflow: auto;
  padding: 2rem 2rem 1.5rem;
}

.full-notes-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.full-notes-close:hover { color: var(--ink); border-color: var(--ink-2); }

.breakdown-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2rem;
  margin-top: 1rem;
}
@media (max-width: 700px) {
  .breakdown-layout { grid-template-columns: 1fr; }
}

/* Pie */
.breakdown-pie-wrap { text-align: center; }
.breakdown-pie-wrap svg { width: 180px; height: 180px; overflow: visible; }
.breakdown-wedge { cursor: pointer; transition: opacity 0.15s var(--ease); }
.breakdown-wedge:hover { opacity: 0.82; }
.breakdown-wedge.active { stroke: var(--panel); stroke-width: 3; }

/* Section list */
.breakdown-section-list {
  list-style: none; padding: 0; margin: 1rem 0 0;
  display: flex; flex-direction: column; gap: 0.45rem;
}
.breakdown-section-item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 0.75rem; border-radius: var(--r-md);
  border: 1.5px solid var(--line); cursor: pointer;
  font-size: 0.84rem; font-weight: 500; color: var(--ink);
  background: var(--panel);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.breakdown-section-item:hover { background: var(--panel-2); }
.breakdown-section-item.active { background: var(--panel-2); }
.breakdown-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.breakdown-marks { margin-left: auto; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

/* Detail panel */
.breakdown-detail { display: flex; flex-direction: column; gap: 1.1rem; min-height: 200px; }
.breakdown-detail-empty { color: var(--muted); font-size: 0.88rem; padding-top: 0.5rem; }
.breakdown-tip-group {
  background: var(--panel-2); border-radius: var(--r-md);
  padding: 0.85rem 1rem; border: 1.5px solid var(--line);
}
.breakdown-tip-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.3rem;
}
.breakdown-tip-text { font-size: 0.86rem; line-height: 1.55; color: var(--ink-2); }
.breakdown-reminders { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.breakdown-reminders li {
  font-size: 0.83rem; color: var(--ink-2);
  padding-left: 1.1rem; position: relative; line-height: 1.4;
}
.breakdown-reminders li::before {
  content: "→"; position: absolute; left: 0;
  color: var(--accent); font-weight: 700;
}

/* Practice questions */
.breakdown-questions-header { font-size: 0.84rem; font-weight: 600; color: var(--ink); margin-bottom: 0.45rem; }
.breakdown-q-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 240px; overflow-y: auto; }
.breakdown-q-item {
  padding: 0.55rem 0.75rem; border: 1.5px solid var(--line);
  border-radius: var(--r-md); cursor: pointer; background: var(--panel);
  transition: border-color 0.15s var(--ease);
}
.breakdown-q-item:hover { border-color: var(--accent); }
.breakdown-q-source { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.2rem; }
.breakdown-q-text { font-size: 0.81rem; color: var(--ink-2); line-height: 1.4; }

/* Question detail view */
.breakdown-q-part { border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 0.85rem 1rem; background: var(--panel); }
.breakdown-q-part + .breakdown-q-part { margin-top: 0.6rem; }
.breakdown-q-part-header { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 0.4rem; }
.breakdown-q-text-body { font-size: 0.86rem; line-height: 1.55; color: var(--ink-2); margin: 0.3rem 0 0.6rem; }
.breakdown-q-answer { background: var(--accent-xlight); border-radius: var(--r-sm); padding: 0.75rem 0.85rem; margin-top: 0.5rem; font-size: 0.84rem; line-height: 1.55; color: var(--ink-2); }

/* Subject header split (name → breakdown, chevron → expand) */
.graph-subject-header {
  display: flex; align-items: stretch; width: 100%;
}
.graph-subject-name {
  flex: 1; text-align: left; background: transparent;
  border: none; box-shadow: none; padding: 0.8rem 0.5rem 0.8rem 1rem;
  font-weight: 700; font-size: 0.88rem; color: var(--ink);
  cursor: pointer; display: flex; align-items: center; gap: 0.65rem;
}
.graph-subject-name::before {
  content: ''; flex-shrink: 0; width: 9px; height: 9px;
  border-radius: 50%; background: var(--line);
  transition: background var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.graph-subject-name:hover { background: var(--accent-light); }
.graph-subject-name:hover::before,
.graph-subject-name.active::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-xlight);
}
.graph-subject-name.has-breakdown:hover { color: var(--accent); }
.graph-subject-chevron {
  flex-shrink: 0; background: transparent; border: none; box-shadow: none;
  padding: 0.8rem 0.9rem 0.8rem 0.4rem;
  font-size: 1rem; color: var(--muted); cursor: pointer;
  display: flex; align-items: center;
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
  border-left: 1px solid transparent;
}
.graph-subject-chevron:hover { color: var(--accent); background: var(--accent-xlight); }

/* ── Exam section badge ── */
.exam-section-badge {
  display: inline-flex; align-items: center;
  font-size: 0.75rem; font-weight: 600;
  padding: 0.2rem 0.55rem; border-radius: var(--r-xs);
  border: 1px solid; white-space: nowrap;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────
   Study Timer Widget
──────────────────────────────────────────── */

#confettiCanvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
  display: none;
}

.timer-widget {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

/* ── Idle: picker + clock ── */
.timer-idle {
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem;
}

.timer-picker {
  display: flex; flex-direction: column; gap: 0.35rem;
  opacity: 0; pointer-events: none;
  transform: translateY(6px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
  /* padding bridges the gap to the clock button so hover stays live */
  padding-bottom: 0.6rem;
}

/* Picker open state — toggled by JS with delay so gap between button and menu doesn't dismiss it */
.timer-picker.picker-open {
  opacity: 1; pointer-events: all;
  transform: translateY(0) scale(1);
}

.timer-opt {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--r-full);
  padding: 0.45rem 1.1rem;
  font-family: var(--font);
  font-size: 0.82rem; font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  box-shadow: var(--s1);
  white-space: nowrap;
  text-align: left;
  display: flex; flex-direction: column; gap: 1px;
  transition: border-color 140ms, color 140ms, background 140ms, box-shadow 140ms;
}
.timer-opt:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-xxlight);
  box-shadow: var(--so);
}
.timer-opt-pomo { border-color: var(--accent-edge); background: var(--accent-bg); }
.timer-opt-sub {
  font-size: 0.66rem; font-weight: 400; color: var(--muted);
}

/* ── Custom toggle: revealed input row ── */
.timer-custom-row {
  display: flex; align-items: center; gap: 0;
  background: var(--panel);
  border: 1.5px solid var(--accent-edge);
  border-radius: var(--r-full);
  padding: 0.35rem 0.35rem 0.35rem 1.1rem;
  box-shadow: var(--s1);
  transition: border-color 140ms, box-shadow 140ms;
}
.timer-custom-row:focus-within {
  border-color: var(--accent); box-shadow: var(--so);
}
.timer-custom-input {
  flex: 1; min-width: 0; border: none; background: transparent;
  font-family: var(--font); font-size: 0.82rem; font-weight: 600;
  color: var(--ink-2); outline: none;
  -moz-appearance: textfield; appearance: textfield;
}
.timer-custom-input::placeholder { color: var(--muted); font-weight: 400; }
.timer-custom-input::-webkit-inner-spin-button,
.timer-custom-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.timer-custom-go {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); border: none;
  font-family: var(--font); font-size: 0.72rem; font-weight: 700;
  color: white; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 130ms, transform 130ms;
}
.timer-custom-go:hover { background: var(--accent-strong); transform: scale(1.1); }

/* ── Clock button — circle restored, 30% bigger than original 44px ── */
.timer-clock-btn {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--panel);
  border: 1.5px solid var(--line);
  box-shadow: var(--s2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: color 150ms, border-color 150ms, box-shadow 150ms, transform 150ms;
}
.timer-clock-btn:hover {
  color: var(--accent); border-color: var(--accent);
  box-shadow: var(--so); transform: scale(1.08);
}

/* ── Active timer bar ── */
.timer-active {
  position: relative;
  height: 44px; min-width: 210px;
  border-radius: var(--r-full);
  background: var(--panel);
  border: 1.5px solid var(--accent-edge);
  box-shadow: var(--s2);
  overflow: hidden;
  display: flex; align-items: center;
  gap: 0.45rem;
  padding: 0 0.6rem 0 0.85rem;
}

.timer-active-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent-light);
  border-radius: var(--r-full);
  transition: width 1s linear;
  width: 100%;
}
.timer-active.break-mode .timer-active-fill { background: #BBF7D0; }

.timer-phase-icon {
  position: relative; z-index: 1;
  font-size: 0.9rem; flex-shrink: 0;
}
.timer-active-text {
  position: relative; z-index: 1;
  font-family: var(--font);
  font-size: 0.88rem; font-weight: 700;
  color: var(--ink); flex: 1;
  white-space: nowrap; letter-spacing: 0.01em;
}
.timer-stop-btn {
  position: relative; z-index: 1;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.65);
  border: 1.5px solid rgba(0,0,0,0.13);
  font-size: 1rem; font-weight: 900;
  color: var(--ink-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; line-height: 1;
  transition: background 130ms, color 130ms, border-color 130ms, transform 130ms;
}
.timer-stop-btn:hover {
  background: var(--danger); color: white;
  border-color: var(--danger); transform: scale(1.1);
}
