:root {
  --bg: #0e0d0a;
  --bg-elevated: #12110e;
  --surface: #171612;
  --surface-2: #1c1a15;
  --surface-3: #232119;
  --text: #f2ede3;
  --text-soft: #d5cdbf;
  --muted: #958e81;
  --faint: #6b655b;
  --line: rgba(239,228,207,.085);
  --line-strong: rgba(239,228,207,.14);
  --accent: #a6af7e;
  --accent-strong: #c0c89a;
  --accent-ink: #15170f;
  --earth: #a27b5f;
  --amber: #c19c68;
  --danger: #d89587;
  --success: #9fbd9b;
  --warning: #c4a36e;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 60px rgba(0,0,0,.28);
  --sidebar: 238px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 82% -8%, rgba(166,175,126,.075), transparent 31%),
    radial-gradient(circle at 12% 104%, rgba(162,123,95,.055), transparent 28%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(183,201,168,.24); color: var(--text); }

.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 28px 18px 20px;
  border-right: 1px solid var(--line);
  background: rgba(14,13,10,.91);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; margin-bottom: 34px; }
.logo {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: linear-gradient(145deg, #211f19, #14130f);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 760;
  letter-spacing: -.04em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.logo::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--amber);
}
.brand h1 { margin: 0; font-size: 15px; font-weight: 670; letter-spacing: -.02em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 11px; letter-spacing: .01em; }

.nav { display: grid; gap: 5px; }
.nav a {
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #8f8f89;
  font-size: 13px;
  font-weight: 520;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.nav a:hover { color: var(--text-soft); background: rgba(255,255,255,.025); }
.nav a.active {
  color: var(--text);
  background: rgba(255,255,255,.045);
  border-color: var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}
.icon {
  width: 20px;
  display: inline-grid;
  place-items: center;
  color: var(--faint);
  font-size: 15px;
  transition: color .16s ease;
}
.nav a.active .icon { color: var(--accent); }

.sidebar-note {
  margin-top: auto;
  padding: 14px 12px 0;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.55;
}
.sidebar-note strong { color: var(--muted); font-weight: 600; }

.main {
  grid-column: 2;
  width: 100%;
  max-width: 1340px;
  margin: 0 auto;
  padding: 52px 44px 64px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 28px;
  margin-bottom: 34px;
}
.page-copy { max-width: 780px; }
.eyebrow {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .17em;
  text-transform: uppercase;
}
h1, h2, h3, p { text-wrap: pretty; }
h2 {
  margin: 9px 0 10px;
  font-size: clamp(32px, 4.5vw, 54px);
  line-height: .98;
  font-weight: 610;
  letter-spacing: -.055em;
}
h3 { margin: 0; font-weight: 620; letter-spacing: -.025em; }
.lead { max-width: 720px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(25,23,18,.965), rgba(18,17,13,.97));
  padding: 22px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  box-shadow: var(--shadow);
  opacity: .2;
  pointer-events: none;
}
.card h3 { font-size: 17px; }
.card p { color: var(--muted); font-size: 13.5px; line-height: 1.65; }
.metric {
  color: var(--text);
  font-size: clamp(29px, 4vw, 40px);
  line-height: 1;
  font-weight: 590;
  letter-spacing: -.055em;
}
.metric-label { margin-top: 9px; color: var(--muted); font-size: 11.5px; line-height: 1.4; }

.dashboard-stats .card { min-height: 128px; display: flex; flex-direction: column; justify-content: flex-end; }
.tool-grid { margin-top: 14px; }
.tool-card { min-height: 238px; display: flex; flex-direction: column; overflow: hidden; }
.tool-card::after {
  content: attr(data-index);
  position: absolute;
  top: 15px;
  right: 18px;
  color: rgba(255,255,255,.055);
  font-size: 62px;
  font-weight: 700;
  letter-spacing: -.08em;
}
.tool-card h3 { margin-top: 18px; font-size: 21px; }
.tool-card p { max-width: 31ch; }
.tool-card .btn { margin-top: auto; align-self: flex-start; }

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 13px;
  background: rgba(255,255,255,.025);
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 580;
  transition: transform .14s ease, background .14s ease, border-color .14s ease, color .14s ease, opacity .14s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); background: rgba(255,255,255,.055); border-color: rgba(255,255,255,.16); color: var(--text); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .deck-item:focus-visible, .period-tab:focus-visible {
  outline: 2px solid rgba(166,175,126,.55);
  outline-offset: 2px;
}
.btn:disabled { cursor: not-allowed; opacity: .34; }
.btn.primary { border-color: transparent; background: var(--accent); color: var(--accent-ink); font-weight: 680; }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); color: var(--accent-ink); }
.btn.success { border-color: rgba(167,206,180,.22); background: rgba(167,206,180,.09); color: #cee4d5; }
.btn.danger { border-color: rgba(228,154,154,.18); background: rgba(228,154,154,.045); color: #dca7a7; }
.btn.danger:hover:not(:disabled) { border-color: rgba(228,154,154,.3); background: rgba(228,154,154,.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.small { min-height: 34px; padding: 7px 10px; border-radius: 9px; font-size: 11.5px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

label { display: grid; gap: 7px; color: var(--muted); font-size: 11.5px; font-weight: 520; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #11100d;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: #555550; }
input:focus, select:focus, textarea:focus { border-color: rgba(166,175,126,.42); background: #15140f; box-shadow: 0 0 0 3px rgba(166,175,126,.05); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #777 50%), linear-gradient(135deg, #777 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 12px) 50%; background-size: 4px 4px, 4px 4px; background-repeat: no-repeat; padding-right: 34px; }
textarea { min-height: 100px; resize: vertical; line-height: 1.55; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stack { display: grid; gap: 12px; }
.space-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.sep { height: 1px; margin: 7px 0; background: var(--line); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Pomodoro */
.pomodoro-wrap { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(330px, .75fr); gap: 14px; align-items: stretch; }
.timer-card { min-height: 610px; display: grid; place-items: center; overflow: hidden; text-align: center; }
.timer-card::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(183,201,168,.045), transparent 67%);
  pointer-events: none;
}
.timer-card > div { position: relative; z-index: 1; }
.session-domain-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-bottom: 24px;
  padding: 6px 11px;
  border: 1px solid rgba(166,175,126,.21);
  border-radius: 999px;
  background: rgba(166,175,126,.06);
  color: #c4caa8;
  font-size: 11px;
  font-weight: 600;
}
.timer-orb {
  --progress: 0%;
  position: relative;
  width: min(360px, 70vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progress), rgba(255,255,255,.06) 0);
  box-shadow: 0 0 0 1px rgba(255,255,255,.025), 0 35px 80px rgba(0,0,0,.32);
}
.timer-orb::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 34%, #201e18, #11100d 72%);
  border: 1px solid rgba(255,255,255,.055);
}
.timer-inner { position: relative; z-index: 1; }
.timer-mode { color: var(--accent); font-size: 9.5px; font-weight: 760; letter-spacing: .2em; text-transform: uppercase; }
.timer-value { margin: 7px 0 2px; font-size: clamp(64px, 9vw, 94px); line-height: .95; font-variant-numeric: tabular-nums; font-weight: 510; letter-spacing: -.075em; }
.timer-sub { color: var(--faint); font-size: 12px; }
.timer-actions { justify-content: center; margin-top: 28px; }
.settings-card { padding: 24px; }
.settings-card h3 { margin-top: 5px; font-size: 20px; }
.settings-section { display: grid; gap: 11px; }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.domain-manager { display: grid; gap: 6px; max-height: 155px; overflow: auto; padding-right: 2px; }
.domain-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255,255,255,.018);
  color: var(--text-soft);
  font-size: 11.5px;
}
.icon-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--faint);
  font-size: 16px;
}
.icon-btn:hover { background: rgba(228,154,154,.07); color: var(--danger); }
.mini-stats { padding: 3px 0; }
.mini-stats .metric { font-size: 25px; }

/* Flashcards */
.deck-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: start; }
.deck-panel { position: sticky; top: 24px; }
.deck-list { display: grid; gap: 6px; margin-top: 16px; }
.deck-item {
  position: relative;
  width: 100%;
  min-height: 66px;
  display: block;
  text-align: left;
  padding: 12px 13px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  transition: background .15s ease, border-color .15s ease;
}
.deck-item:hover { background: rgba(255,255,255,.025); }
.deck-item.active { border-color: var(--line); background: rgba(255,255,255,.04); }
.deck-item.active::before { content: ""; position: absolute; left: -1px; top: 15px; bottom: 15px; width: 2px; border-radius: 2px; background: var(--accent); }
.deck-item strong { display: block; margin-bottom: 5px; font-size: 12.5px; font-weight: 610; }
.deck-item span { color: var(--faint); font-size: 10.5px; }
.deck-layout > .stack { min-width: 0; }
.flashcard-stage { min-height: 440px; display: grid; place-items: center; padding: 18px 0; }
.flashcard {
  width: min(760px, 100%);
  min-height: 330px;
  display: grid;
  align-content: center;
  padding: 44px 48px;
  border: 1px solid var(--line-strong);
  border-radius: 21px;
  background: linear-gradient(145deg, #201e18, #12110e);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.03);
}
.flashcard .side-label { color: var(--accent); font-size: 9px; font-weight: 760; letter-spacing: .2em; text-transform: uppercase; }
.flashcard .content { margin-top: 18px; font-size: clamp(27px, 4vw, 42px); line-height: 1.3; font-weight: 540; letter-spacing: -.035em; white-space: pre-wrap; }
.flashcard .extra { max-width: 580px; margin: 24px auto 0; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.7; white-space: pre-wrap; }
.rating-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.rating-grid button { min-height: 60px; display: block; }
.rating-grid small { display: block; margin-top: 4px; color: inherit; opacity: .58; font-size: 9.5px; font-weight: 500; }

.table-wrap { overflow: auto; margin-top: 14px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--faint); font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.table td { color: var(--text-soft); font-size: 12px; line-height: 1.5; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.025);
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}
.badge.due { border-color: rgba(215,191,139,.18); background: rgba(215,191,139,.045); color: #cbb68a; }
.badge.ok { border-color: rgba(167,206,180,.16); background: rgba(167,206,180,.04); color: #a9c7b2; }
.empty { padding: 30px 22px; border: 1px dashed var(--line-strong); border-radius: 13px; color: var(--muted); text-align: center; }
.empty h3 { color: var(--text); margin-bottom: 8px; }
.empty p { margin: 6px auto 16px; max-width: 48ch; }

/* Tracking */
.period-tabs { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.018); }
.period-tab { min-height: 34px; border: 0; border-radius: 8px; padding: 7px 12px; background: transparent; color: var(--faint); font-size: 11px; font-weight: 560; }
.period-tab:hover { color: var(--text-soft); }
.period-tab.active { background: rgba(255,255,255,.06); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,.025); }
.compact-card { padding: 11px 12px; }
.period-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.period-title { color: var(--text-soft); font-size: 12px; font-weight: 600; text-transform: capitalize; text-align: center; }
.tracking-metrics { margin-bottom: 14px; }
.tracking-metrics .card { min-height: 116px; display: flex; flex-direction: column; justify-content: flex-end; }
.tracking-main-grid { grid-template-columns: minmax(0, 1.48fr) minmax(280px, .72fr); }
.chart-heading { margin-bottom: 12px; }
.timeline-chart { min-height: 300px; display: grid; align-items: end; gap: 7px; overflow-x: auto; padding: 10px 2px 0; }
.timeline-chart.week { grid-template-columns: repeat(7, minmax(52px, 1fr)); }
.timeline-chart.month { grid-template-columns: repeat(31, minmax(25px, 1fr)); }
.timeline-chart.year { grid-template-columns: repeat(12, minmax(48px, 1fr)); }
.bar-column { min-height: 265px; display: grid; grid-template-rows: 24px 1fr 27px; align-items: end; text-align: center; }
.bar-value { align-self: center; color: var(--faint); font-size: 9px; white-space: nowrap; }
.bar-track { height: 192px; width: min(25px, 62%); display: flex; align-items: end; margin: 0 auto; border-radius: 7px 7px 3px 3px; overflow: hidden; background: rgba(255,255,255,.045); }
.bar-fill { width: 100%; min-height: 0; border-radius: inherit; background: linear-gradient(180deg, var(--accent-strong), #7f8964); }
.bar-label { align-self: center; color: var(--faint); font-size: 9.5px; white-space: nowrap; }
.domain-breakdown { display: grid; gap: 18px; margin-top: 22px; }
.domain-stat-row { display: grid; gap: 9px; font-size: 11.5px; }
.domain-stat-row strong { color: var(--text-soft); font-weight: 570; }
.domain-stat-row span { color: var(--muted); }
.progress-track { height: 5px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.05); }
.progress-fill { height: 100%; border-radius: inherit; background: var(--accent); }
.session-log { display: grid; margin-top: 13px; }
.session-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 3px; border-bottom: 1px solid var(--line); }
.session-row:last-child { border-bottom: 0; }
.session-row strong { font-size: 12px; font-weight: 590; }
.session-row .muted { margin-top: 4px; color: var(--faint); font-size: 10px; }
.session-duration { color: var(--text-soft); font-size: 12px; font-weight: 600; white-space: nowrap; }

/* Dialogs & feedback */
dialog {
  width: min(560px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #171510;
  color: var(--text);
  box-shadow: 0 32px 100px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(0,0,0,.68); backdrop-filter: blur(5px); }
dialog .card { border: 0; background: transparent; box-shadow: none; }
dialog h3 { font-size: 20px; margin-bottom: 7px; }
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 28px));
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(25,23,18,.96);
  color: var(--text-soft);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  font-size: 11.5px;
  opacity: 0;
  transform: translateY(7px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1040px) {
  :root { --sidebar: 210px; }
  .main { padding: 42px 28px 58px; }
  .pomodoro-wrap { grid-template-columns: 1fr; }
  .timer-card { min-height: 560px; }
  .settings-card { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; }
  .settings-card > .settings-section:first-of-type { grid-column: 1; }
  .settings-card > .sep { display: none; }
  .tracking-main-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  body { padding-bottom: 72px; }
  .shell { display: block; }
  .sidebar {
    position: fixed;
    inset: auto 10px 10px;
    width: auto;
    height: 58px;
    display: block;
    padding: 5px;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: rgba(20,18,14,.95);
    box-shadow: 0 16px 50px rgba(0,0,0,.38);
  }
  .brand, .sidebar-note { display: none; }
  .nav { height: 100%; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 3px; }
  .nav a { min-height: 46px; justify-content: center; gap: 7px; padding: 0 7px; font-size: 10px; border-radius: 11px; }
  .nav a.active { background: rgba(255,255,255,.055); }
  .icon { width: auto; font-size: 13px; }
  .main { width: 100%; padding: 34px 18px 38px; }
  .topbar { align-items: flex-start; }
  h2 { font-size: 40px; }
  .grid.three, .grid.two, .deck-layout { grid-template-columns: 1fr; }
  .deck-panel { position: static; }
  .deck-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-card { display: grid; grid-template-columns: 1fr; }
  .settings-card > .sep { display: block; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .main { padding-left: 14px; padding-right: 14px; }
  .topbar { display: block; margin-bottom: 26px; }
  .topbar > .actions, .tracking-topbar .period-tabs { margin-top: 18px; }
  h2 { font-size: 36px; }
  .lead { font-size: 13px; }
  .card { padding: 18px; border-radius: 15px; }
  .tool-card { min-height: 200px; }
  .pomodoro-wrap { gap: 10px; }
  .timer-card { min-height: 500px; }
  .timer-orb { width: min(305px, 78vw); }
  .timer-value { font-size: 68px; }
  .timer-actions { gap: 6px; }
  .timer-actions .btn { padding-inline: 11px; }
  .inline-form { grid-template-columns: 1fr; }
  .deck-list { grid-template-columns: 1fr; }
  .flashcard-stage { min-height: 370px; }
  .flashcard { min-height: 285px; padding: 34px 20px; }
  .rating-grid { grid-template-columns: repeat(2, 1fr); }
  .tracking-topbar .period-tabs { width: 100%; }
  .period-tab { flex: 1; }
  .period-nav { display: grid; grid-template-columns: auto 1fr auto; }
  .period-nav .actions { flex-wrap: nowrap; }
  .period-nav #todayPeriod { display: none; }
  .timeline-chart { min-height: 250px; }
  .bar-column { min-height: 220px; }
  .bar-track { height: 150px; }
  .space-between.mobile-stack { align-items: flex-start; flex-direction: column; }
  .sidebar { inset-inline: 8px; bottom: 8px; }
  .nav a { flex-direction: column; gap: 1px; line-height: 1; }
}


/* V4 — warm editorial refinement */
.sidebar {
  box-shadow: 18px 0 70px rgba(0,0,0,.12);
}
.nav a.active {
  background: linear-gradient(90deg, rgba(166,175,126,.075), rgba(255,255,255,.022));
  border-color: rgba(239,228,207,.095);
}
.logo {
  border-color: rgba(193,156,104,.17);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035), 0 10px 28px rgba(0,0,0,.12);
}
.logo::after { background: var(--amber); }
.eyebrow { color: #aeb68b; }
h2 { color: #f4eee3; }
.card {
  border-color: rgba(239,228,207,.075);
  box-shadow: inset 0 1px 0 rgba(255,247,233,.025), 0 18px 55px rgba(0,0,0,.08);
}
.card::before { opacity: .12; }
.tool-card::after { color: rgba(220,202,170,.045); }
.btn {
  border-color: rgba(239,228,207,.115);
  background: rgba(239,228,207,.022);
}
.btn:hover:not(:disabled) {
  background: rgba(239,228,207,.05);
  border-color: rgba(239,228,207,.18);
}
.btn.primary {
  background: #aab283;
  color: #15160f;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 8px 26px rgba(78,85,55,.12);
}
.btn.primary:hover:not(:disabled) { background: #bdc493; }
.badge.due { border-color: rgba(193,156,104,.2); background: rgba(193,156,104,.055); color: #c9a979; }
.badge.ok { border-color: rgba(166,175,126,.18); background: rgba(166,175,126,.045); color: #adb790; }

/* Focus: keep the timer large, reduce the visual container around it. */
.pomodoro-wrap {
  grid-template-columns: minmax(0, 1.18fr) minmax(330px, .82fr);
  align-items: start;
  gap: 16px;
}
.timer-card {
  min-height: 0;
  padding: 30px 26px 28px;
  align-self: start;
  background:
    radial-gradient(circle at 50% 41%, rgba(166,175,126,.035), transparent 44%),
    linear-gradient(180deg, rgba(24,22,17,.9), rgba(17,16,12,.92));
  border-color: rgba(239,228,207,.07);
}
.timer-card::after {
  width: 390px;
  height: 390px;
  background: radial-gradient(circle, rgba(166,175,126,.03), rgba(162,123,95,.018) 46%, transparent 70%);
}
.session-domain-pill { margin-bottom: 18px; }
.timer-orb {
  /* Intentionally unchanged in size from V3. */
  box-shadow: 0 0 0 1px rgba(239,228,207,.025), 0 28px 68px rgba(0,0,0,.28), 0 0 70px rgba(121,130,83,.025);
}
.timer-orb::before { border-color: rgba(239,228,207,.05); }
.timer-actions { margin-top: 22px; }
.settings-card { background: linear-gradient(180deg, rgba(25,23,18,.94), rgba(18,17,13,.96)); }
.domain-row { background: rgba(239,228,207,.014); }

.flashcard {
  border-color: rgba(239,228,207,.1);
  box-shadow: 0 30px 80px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,247,233,.025);
}
.period-tab.active { background: rgba(166,175,126,.075); }
.progress-track, .bar-track { background: rgba(239,228,207,.045); }

@media (max-width: 1040px) {
  .pomodoro-wrap { grid-template-columns: 1fr; }
  .timer-card { min-height: 0; padding-block: 28px; }
}

@media (max-width: 820px) {
  .sidebar { background: rgba(20,18,14,.96); }
}

@media (max-width: 600px) {
  .timer-card { min-height: 0; padding: 24px 14px 22px; }
  .session-domain-pill { margin-bottom: 16px; }
  .timer-actions { margin-top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* =========================================================
   V5 — viewport balance & legibility
   Goal: a more harmonious scale and a no-page-scroll desktop UI.
   ========================================================= */
:root {
  --sidebar: 264px;
  --ui-xs: 11.5px;
  --ui-sm: 12.5px;
  --ui-md: 14px;
  --ui-lg: 16px;
}

/* Sidebar: slightly larger and more deliberate. */
.sidebar {
  padding: 28px 20px 22px;
}
.brand {
  gap: 13px;
  padding-inline: 7px;
  margin-bottom: 30px;
}
.logo {
  width: 43px;
  height: 43px;
  flex-basis: 43px;
  border-radius: 12px;
  font-size: 15px;
}
.brand h1 { font-size: 17px; font-weight: 660; }
.brand p { margin-top: 4px; font-size: 12px; }
.nav { gap: 6px; }
.nav a {
  min-height: 48px;
  gap: 12px;
  padding-inline: 13px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 550;
}
.icon { width: 22px; font-size: 17px; }
.sidebar-note { font-size: 11.5px; line-height: 1.55; }

/* A calmer, more consistent typography scale. */
.eyebrow { font-size: 10.5px; }
.lead { font-size: 14px; line-height: 1.58; }
.card h3 { font-size: 18px; }
.card p { font-size: 13.5px; line-height: 1.55; }
.metric { font-size: clamp(28px, 2.7vw, 38px); }
.metric-label { font-size: 12px; }
.btn { min-height: 39px; font-size: 13px; }
.btn.small { min-height: 33px; font-size: 12px; }
label { font-size: 12px; }
input, select, textarea { padding: 10px 12px; }
.muted { font-size: 12px; }

/* Desktop app framing: content fits inside the viewport rather than extending the page. */
@media (min-width: 821px) {
  html, body { height: 100%; overflow: hidden; }
  .shell { height: 100vh; min-height: 0; }
  .main {
    height: 100vh;
    min-height: 0;
    max-width: 1480px;
    padding: clamp(24px, 3.2vh, 38px) clamp(28px, 3vw, 44px);
    overflow: hidden;
  }
  .topbar {
    gap: 24px;
    margin-bottom: clamp(16px, 2.1vh, 24px);
  }
  h2 {
    margin: 7px 0 8px;
    font-size: clamp(34px, 4vh, 46px);
    line-height: 1;
  }
}

/* Dashboard */
@media (min-width: 821px) {
  .page-dashboard .main {
    display: grid;
    grid-template-rows: auto minmax(92px, .75fr) minmax(210px, 1.4fr);
    gap: 14px;
  }
  .page-dashboard .topbar { margin-bottom: 0; }
  .page-dashboard .dashboard-stats,
  .page-dashboard .tool-grid { min-height: 0; }
  .page-dashboard .dashboard-stats .card { min-height: 0; padding: 18px 20px; }
  .page-dashboard .tool-grid { margin-top: 0; }
  .page-dashboard .tool-card { min-height: 0; padding: 20px; }
  .page-dashboard .tool-card h3 { margin-top: 14px; font-size: 20px; }
  .page-dashboard .tool-card p { max-width: 35ch; margin-top: 9px; }
  .page-dashboard .tool-card::after { font-size: 54px; }
}

/* Focus */
@media (min-width: 821px) {
  .page-focus .main {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .page-focus .pomodoro-wrap {
    min-height: 0;
    height: 100%;
    grid-template-columns: minmax(0, 1.16fr) minmax(350px, .84fr);
    align-items: stretch;
  }
  .page-focus .timer-card {
    height: 100%;
    min-height: 0;
    padding: clamp(20px, 2.5vh, 28px) 24px;
  }
  .page-focus .settings-card {
    height: 100%;
    min-height: 0;
    padding: clamp(18px, 2.3vh, 24px);
    align-content: space-between;
    gap: clamp(8px, 1.3vh, 12px);
    overflow: hidden;
  }
  .page-focus .settings-section { gap: 9px; }
  .page-focus .settings-card h3 { font-size: 18px; }
  .page-focus .domain-manager { max-height: clamp(76px, 13vh, 128px); }
  .page-focus .domain-row { min-height: 34px; font-size: 12px; }
  .page-focus .timer-orb {
    width: min(360px, 45vh, 34vw);
    min-width: 285px;
  }
  .page-focus .timer-value { font-size: clamp(68px, 9vh, 94px); }
  .page-focus .timer-actions { margin-top: clamp(16px, 2.2vh, 22px); }
  .page-focus .session-domain-pill { margin-bottom: clamp(12px, 1.7vh, 18px); }
  .page-focus .mini-stats .metric { font-size: 24px; }
}

/* Flashcards: same visual rhythm as the rest of the app. */
@media (min-width: 821px) {
  .page-flashcards .main {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .page-flashcards .deck-layout {
    height: 100%;
    min-height: 0;
    grid-template-columns: 315px minmax(0, 1fr);
  }
  .page-flashcards .deck-panel {
    position: static;
    height: 100%;
    min-height: 0;
    padding: 20px;
    overflow: hidden;
  }
  .page-flashcards .deck-list {
    max-height: calc(100% - 48px);
    overflow: auto;
    scrollbar-width: thin;
  }
  .page-flashcards .deck-item { min-height: 62px; padding: 11px 12px; }
  .page-flashcards .deck-item strong { font-size: 13px; }
  .page-flashcards .deck-item span { font-size: 11.5px; }
  .page-flashcards .deck-layout > .stack {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .page-flashcards #deckOverview,
  .page-flashcards #reviewArea,
  .page-flashcards #manageArea {
    max-height: 100%;
    overflow: hidden;
  }
  .page-flashcards .flashcard-stage {
    min-height: 0;
    height: clamp(300px, 46vh, 420px);
    padding: 12px 0;
  }
  .page-flashcards .flashcard {
    min-height: clamp(250px, 35vh, 320px);
    padding: 34px 42px;
  }
  .page-flashcards .flashcard .content { font-size: clamp(27px, 4vh, 38px); }
  .page-flashcards .rating-grid button { min-height: 54px; }
  .page-flashcards .table-wrap {
    max-height: calc(100vh - 220px);
    overflow: auto;
    scrollbar-width: thin;
  }
}

/* Tracking: compress vertical chrome, never horizontally scroll the 31-day month. */
@media (min-width: 821px) {
  .page-tracking .main {
    display: grid;
    grid-template-rows: auto 44px 88px minmax(250px, 1fr) minmax(112px, 17vh);
    gap: 10px;
  }
  .page-tracking .topbar { margin-bottom: 0; align-items: end; }
  .page-tracking .tracking-topbar .lead { max-width: 600px; }
  .page-tracking .period-nav { height: 44px; margin: 0; padding: 6px 8px; }
  .page-tracking .tracking-metrics { min-height: 0; margin: 0; gap: 10px; }
  .page-tracking .tracking-metrics .card {
    min-height: 0;
    height: 88px;
    padding: 14px 18px;
  }
  .page-tracking .tracking-metrics .metric { font-size: 30px; }
  .page-tracking .tracking-main-grid {
    min-height: 0;
    height: 100%;
    grid-template-columns: minmax(0, 1.55fr) minmax(270px, .65fr);
    gap: 10px;
  }
  .page-tracking .tracking-main-grid > .card {
    min-height: 0;
    height: 100%;
    padding: 17px 18px;
    overflow: hidden;
  }
  .page-tracking .chart-heading { margin-bottom: 4px; }
  .page-tracking .timeline-chart {
    width: 100%;
    min-height: 0;
    height: calc(100% - 40px);
    gap: 5px;
    overflow: hidden;
    padding: 6px 0 0;
  }
  .page-tracking .timeline-chart.week { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .page-tracking .timeline-chart.month { grid-template-columns: repeat(31, minmax(0, 1fr)); gap: 2px; }
  .page-tracking .timeline-chart.year { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 5px; }
  .page-tracking .bar-column {
    min-width: 0;
    min-height: 0;
    height: 100%;
    grid-template-rows: 21px minmax(0, 1fr) 22px;
  }
  .page-tracking .bar-value { font-size: 9px; }
  .page-tracking .bar-track {
    width: min(24px, 58%);
    height: 100%;
    min-height: 60px;
  }
  .page-tracking .timeline-chart.month .bar-track {
    width: min(10px, 76%);
    border-radius: 4px 4px 2px 2px;
  }
  .page-tracking .timeline-chart.month .bar-value {
    color: transparent;
    font-size: 0;
  }
  .page-tracking .timeline-chart.month .bar-label {
    font-size: 9px;
    overflow: visible;
  }
  .page-tracking .timeline-chart.month .bar-column:not(:nth-child(1)):not(:nth-child(5n)):not(:last-child) .bar-label {
    visibility: hidden;
  }
  .page-tracking .bar-label { font-size: 10px; }
  .page-tracking .domain-breakdown {
    gap: clamp(8px, 1.3vh, 14px);
    margin-top: 12px;
  }
  .page-tracking .domain-stat-row { gap: 6px; font-size: 12px; }
  .page-tracking .main > .card:last-of-type {
    min-height: 0;
    height: 100%;
    margin-top: 0 !important;
    padding: 14px 18px;
    overflow: hidden;
  }
  .page-tracking .session-log {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
    margin-top: 6px;
  }
  .page-tracking .session-row {
    min-height: 40px;
    padding: 7px 2px;
  }
  .page-tracking .session-row strong { font-size: 12.5px; }
  .page-tracking .session-row .muted { margin-top: 1px; font-size: 10.5px; }
  .page-tracking .session-duration { font-size: 12px; }
}

/* Extra vertical compaction for common 768px-tall laptop screens. */
@media (min-width: 821px) and (max-height: 820px) {
  .main { padding-top: 20px; padding-bottom: 20px; }
  .topbar { margin-bottom: 12px; }
  h2 { font-size: 34px; }
  .lead { font-size: 13px; line-height: 1.45; }
  .card { padding: 16px; }

  .page-dashboard .main { grid-template-rows: auto 90px minmax(190px, 1fr); gap: 10px; }
  .page-dashboard .dashboard-stats .card { padding: 14px 17px; }
  .page-dashboard .tool-card { padding: 17px; }
  .page-dashboard .tool-card h3 { margin-top: 10px; }
  .page-dashboard .tool-card p { line-height: 1.45; }

  .page-focus .pomodoro-wrap { gap: 10px; }
  .page-focus .settings-card { padding: 16px; gap: 7px; }
  .page-focus .settings-section { gap: 7px; }
  .page-focus .settings-card .sep { margin: 2px 0; }
  .page-focus .domain-manager { max-height: 78px; }
  .page-focus .timer-orb { width: min(330px, 43vh, 32vw); min-width: 270px; }
  .page-focus .timer-value { font-size: clamp(64px, 8.5vh, 86px); }
  .page-focus .timer-actions { margin-top: 14px; }
  .page-focus .session-domain-pill { margin-bottom: 10px; }

  .page-flashcards .flashcard-stage { height: min(355px, 45vh); }
  .page-flashcards .flashcard { min-height: 245px; padding: 28px 34px; }

  .page-tracking .main {
    grid-template-rows: auto 40px 76px minmax(220px, 1fr) 104px;
    gap: 8px;
  }
  .page-tracking .tracking-metrics .card { height: 76px; padding: 10px 15px; }
  .page-tracking .tracking-metrics .metric { font-size: 26px; }
  .page-tracking .tracking-main-grid > .card { padding: 13px 15px; }
  .page-tracking .domain-breakdown { gap: 7px; margin-top: 8px; }
  .page-tracking .main > .card:last-of-type { padding: 10px 15px; }
  .page-tracking .session-row { min-height: 34px; padding: 5px 2px; }
}

/* Mobile keeps natural document flow: fitting an arbitrary amount of content without scrolling
   is not physically possible on a phone, so readability wins there. */
@media (max-width: 820px) {
  :root { --sidebar: 210px; }
  .nav a { font-size: 10.5px; }
}

/* V5.1 — final balance pass */
.session-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.session-fields label { position: relative; }
.session-fields .field-unit {
  position: absolute;
  right: 10px;
  bottom: 11px;
  color: var(--faint);
  font-size: 10.5px;
  pointer-events: none;
}
.session-fields label:has(.field-unit) input { padding-right: 34px; }

@media (min-width: 821px) {
  .page-dashboard .main {
    grid-template-rows: auto auto auto;
    align-content: start;
  }
  .page-dashboard .tool-card { min-height: clamp(205px, 28vh, 250px); }

  .page-focus .settings-card .session-fields label { gap: 6px; }
  .page-focus .settings-card .session-fields input { min-width: 0; padding-block: 9px; }

  .page-tracking .bar-value { font-size: 10px; }
  .page-tracking .bar-label { font-size: 10.5px; }
  .page-tracking .timeline-chart.month .bar-label { font-size: 10px; }
}

@media (min-width: 821px) and (max-height: 820px) {
  .page-focus .settings-card { align-content: start; }
  .page-focus .settings-section { gap: 6px; }
  .page-focus .domain-manager { max-height: 64px; }
  .page-focus .domain-row { min-height: 30px; padding-block: 4px; }
  .page-focus .mini-stats { padding: 0; }
  .page-focus .mini-stats .metric { font-size: 22px; }
  .page-focus .settings-card .btn { min-height: 35px; padding-block: 7px; }
  .page-focus .settings-card input,
  .page-focus .settings-card select { padding-top: 8px; padding-bottom: 8px; }
}

@media (max-width: 600px) {
  .session-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* =========================================================
   V6 — manual Cloudflare sync
   ========================================================= */
.cloud-trigger { min-width: 86px; }
.cloud-dot,
.cloud-status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(166,175,126,.07);
}
.cloud-dialog { width: min(560px, calc(100vw - 28px)); }
.cloud-card { padding: 24px !important; }
.cloud-card h3 { font-size: 22px; }
.cloud-copy,
.cloud-hint { margin: 0; color: var(--muted); line-height: 1.55; }
.cloud-copy { font-size: 13.5px; }
.cloud-hint { font-size: 11.5px; }
.cloud-close { font-size: 20px; }
.cloud-status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.018);
  color: var(--muted);
  font-size: 12px;
}
.cloud-status.ok { color: #bdc9a7; border-color: rgba(166,175,126,.16); background: rgba(166,175,126,.035); }
.cloud-status.error { color: #ddb0a5; border-color: rgba(216,149,135,.18); background: rgba(216,149,135,.035); }
.cloud-status.busy { color: var(--text-soft); }
.cloud-status.error .cloud-status-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(216,149,135,.06); }
.cloud-status.busy .cloud-status-dot { background: var(--amber); box-shadow: 0 0 0 4px rgba(193,156,104,.06); }
.cloud-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (max-width: 600px) {
  .cloud-dialog { width: calc(100vw - 20px); }
  .cloud-card { padding: 20px !important; }
  .cloud-actions { grid-template-columns: 1fr; }
}

/* Global running timer indicator on non-Focus pages */
.global-timer-badge {
  position: fixed;
  z-index: 40;
  left: 18px;
  bottom: 82px;
  width: calc(var(--sidebar) - 36px);
  min-height: 42px;
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(27,25,19,.94);
  box-shadow: 0 10px 32px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.025);
  backdrop-filter: blur(16px);
  color: var(--text-soft);
  font-size: 11px;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.global-timer-badge:hover { transform: translateY(-1px); border-color: rgba(192,200,154,.24); background: rgba(31,29,22,.97); }
.global-timer-badge[hidden] { display: none !important; }
.global-timer-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(166,175,126,.08); }
.global-timer-badge.is-break .global-timer-dot { background: var(--amber); box-shadow: 0 0 0 4px rgba(193,156,104,.08); }
.global-timer-mode { color: var(--muted); font-weight: 620; letter-spacing: .02em; }
.global-timer-time { color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }

@media (max-width: 760px) {
  .global-timer-badge {
    left: 14px;
    right: 14px;
    bottom: 76px;
    width: auto;
    min-height: 38px;
  }
}

/* =========================================================
   V7 — chromatic lounge direction + domain color system
   Dark, warm, colorful, restrained. No literal 420 imagery.
   ========================================================= */
:root {
  --bg: #0b0b0d;
  --bg-elevated: #101014;
  --surface: #16151a;
  --surface-2: #1d1b21;
  --surface-3: #25212a;
  --text: #f4f0e8;
  --text-soft: #ddd7cc;
  --muted: #9d968d;
  --faint: #716c67;
  --line: rgba(239,233,220,.085);
  --line-strong: rgba(239,233,220,.145);
  --accent: #b7d85b;
  --accent-strong: #c9e278;
  --accent-ink: #101307;
  --earth: #b77d61;
  --amber: #d6a857;
  --violet: #9273d0;
  --teal: #62b29b;
  --coral: #cf776b;
  --danger: #db8175;
  --success: #82bf8d;
  --warning: #d6a857;
  --shadow: 0 24px 70px rgba(0,0,0,.34);
}

html { background: var(--bg); }
body {
  background:
    radial-gradient(circle at 92% -12%, rgba(146,115,208,.115), transparent 31%),
    radial-gradient(circle at 68% 112%, rgba(98,178,155,.075), transparent 30%),
    radial-gradient(circle at -8% 72%, rgba(183,216,91,.065), transparent 27%),
    linear-gradient(150deg, #0a0a0c 0%, #0d0c10 55%, #0c0d0b 100%);
}
::selection { background: rgba(183,216,91,.28); color: var(--text); }

.sidebar {
  background:
    radial-gradient(circle at 18% 7%, rgba(183,216,91,.07), transparent 25%),
    radial-gradient(circle at 110% 88%, rgba(146,115,208,.07), transparent 32%),
    rgba(13,13,15,.93);
  border-right-color: rgba(239,233,220,.09);
}
.logo {
  border-color: rgba(183,216,91,.18);
  background: linear-gradient(145deg, rgba(183,216,91,.12), rgba(146,115,208,.08) 65%, #141318);
  color: #d4e99a;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 10px 30px rgba(0,0,0,.22);
}
.logo::after { background: var(--violet); box-shadow: 0 0 0 3px rgba(146,115,208,.08); }
.nav a:hover { background: rgba(183,216,91,.03); }
.nav a.active {
  background: linear-gradient(90deg, rgba(183,216,91,.075), rgba(146,115,208,.025));
  border-color: rgba(183,216,91,.12);
}
.nav a.active .icon { color: #c3dc78; }

.card {
  border-color: rgba(239,233,220,.09);
  background:
    linear-gradient(180deg, rgba(255,255,255,.018), transparent 23%),
    linear-gradient(145deg, rgba(25,24,29,.97), rgba(18,17,21,.97));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}
.card::before { opacity: .26; }
.tool-card:nth-child(1)::before { box-shadow: inset 2px 0 0 rgba(183,216,91,.2), var(--shadow); }
.tool-card:nth-child(2)::before { box-shadow: inset 2px 0 0 rgba(146,115,208,.2), var(--shadow); }
.tool-card:nth-child(3)::before { box-shadow: inset 2px 0 0 rgba(98,178,155,.2), var(--shadow); }
.eyebrow { color: #b8cf72; }

.btn.primary {
  background: linear-gradient(135deg, #bddb67, #a8cb52);
  box-shadow: 0 7px 24px rgba(183,216,91,.09), inset 0 1px 0 rgba(255,255,255,.16);
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(135deg, #c8e376, #b5d65c); }
input, select, textarea { background: rgba(11,11,14,.72); }
input:focus, select:focus, textarea:focus {
  border-color: rgba(183,216,91,.38);
  background: rgba(15,15,18,.92);
  box-shadow: 0 0 0 3px rgba(183,216,91,.045);
}
.period-tab.active {
  background: linear-gradient(135deg, rgba(183,216,91,.10), rgba(146,115,208,.055));
  color: var(--text);
}

/* Focus: domain color becomes the session's live accent. */
.timer-orb {
  background: conic-gradient(var(--timer-accent, var(--accent)) var(--progress), rgba(255,255,255,.052) 0);
  box-shadow: 0 0 0 1px rgba(255,255,255,.025), 0 30px 75px rgba(0,0,0,.34), 0 0 70px color-mix(in srgb, var(--timer-accent, var(--accent)) 7%, transparent);
}
.timer-orb::before {
  background:
    radial-gradient(circle at 42% 29%, color-mix(in srgb, var(--timer-accent, var(--accent)) 7%, transparent), transparent 28%),
    radial-gradient(circle at 50% 34%, #201e22, #101014 72%);
}
.timer-mode { color: var(--timer-accent, var(--accent)); }
.session-domain-pill {
  border-color: color-mix(in srgb, var(--domain-color, var(--accent)) 30%, transparent);
  background: color-mix(in srgb, var(--domain-color, var(--accent)) 9%, transparent);
  color: color-mix(in srgb, var(--domain-color, var(--accent)) 78%, white);
}

/* Domain color controls */
.domain-create { display: grid; gap: 7px; }
.domain-create-row { grid-template-columns: minmax(0,1fr) 58px auto; }
.color-input {
  position: relative;
  min-width: 58px;
  display: grid;
  place-items: center;
  gap: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255,255,255,.02);
  cursor: pointer;
}
.color-input input[type="color"] {
  position: absolute;
  inset: -8px;
  width: calc(100% + 16px);
  height: calc(100% + 16px);
  padding: 0;
  border: 0;
  opacity: .92;
  cursor: pointer;
}
.color-input span {
  position: relative;
  z-index: 1;
  padding: 3px 5px;
  border-radius: 6px;
  background: rgba(9,9,11,.72);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  pointer-events: none;
  backdrop-filter: blur(5px);
}
.domain-color-presets { display: flex; gap: 6px; padding: 1px 2px; overflow: hidden; }
.color-swatch {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
  transition: transform .14s ease, box-shadow .14s ease;
}
.color-swatch:hover, .color-swatch.active { transform: scale(1.13); box-shadow: 0 0 0 3px color-mix(in srgb, var(--swatch) 16%, transparent); }
.domain-row { border-color: color-mix(in srgb, var(--domain-color) 18%, var(--line)); }
.domain-row-name { min-width: 0; display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.domain-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--domain-color, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--domain-color, var(--accent)) 9%, transparent);
}
.domain-row-actions { display: flex; align-items: center; gap: 4px; }
.domain-recolor {
  position: relative;
  width: 25px;
  height: 25px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  cursor: pointer;
}
.domain-recolor input[type="color"] {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  padding: 0;
  border: 0;
  cursor: pointer;
}

/* Tracking: the chart is now a domain-color stacked chart. */
.bar-track { position: relative; overflow: hidden; }
.bar-stack {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  border-radius: inherit;
  overflow: hidden;
}
.bar-segment {
  width: 100%;
  min-height: 1px;
  flex: 0 0 auto;
  display: block;
  background: var(--segment-color);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.domain-stat-row strong { display: inline-flex; align-items: center; gap: 8px; }
.progress-fill { box-shadow: inset 0 1px 0 rgba(255,255,255,.15); }
.tracking-history { margin-top: 0 !important; }
.history-heading .actions { flex-wrap: nowrap; }
.correction-trigger {
  border-color: rgba(146,115,208,.20);
  background: rgba(146,115,208,.055);
  color: #d6c8f0;
}
.correction-trigger:hover:not(:disabled) { border-color: rgba(146,115,208,.32); background: rgba(146,115,208,.09); }
.session-main { min-width: 0; display: flex; align-items: center; gap: 9px; }
.session-row-actions { display: flex; align-items: center; gap: 7px; }
.session-row .edit-log-btn { opacity: .5; }
.session-row:hover .edit-log-btn { opacity: 1; }
.session-row.is-manual { background: linear-gradient(90deg, color-mix(in srgb, var(--domain-color) 4%, transparent), transparent 38%); }
.session-row.is-negative .session-duration { color: #df9185; }
.log-note { display: block; margin-top: 2px; max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; }

/* Correction dialog */
.correction-dialog { width: min(720px, calc(100vw - 28px)); }
.correction-card { padding: 24px !important; }
.correction-card h3 { margin: 5px 0 0; font-size: 23px; }
.correction-copy { margin: 2px 0 3px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.correction-grid { display: grid; grid-template-columns: .8fr 1fr 1.15fr; gap: 10px; margin-top: 15px; }
.correction-duration { display: grid; grid-template-columns: 110px 110px minmax(0,1fr); gap: 10px; margin-top: 10px; }
.correction-preview {
  min-height: 48px;
  margin-top: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: linear-gradient(90deg, rgba(183,216,91,.035), rgba(146,115,208,.025));
  color: var(--muted);
  font-size: 12px;
}
.correction-preview span { display: inline-flex; align-items: center; gap: 8px; }
.correction-preview strong { font-size: 15px; }
.correction-preview .positive { color: #bed779; }
.correction-preview .negative { color: #df9185; }
.correction-footer { margin-top: 14px; }
.correction-submit-actions { margin-left: auto; }

/* Cloud + global timer brought into the new palette. */
.global-timer-badge {
  background: linear-gradient(135deg, rgba(25,24,29,.96), rgba(18,18,21,.96));
  border-color: rgba(183,216,91,.13);
}
.global-timer-dot { background: #b7d85b; box-shadow: 0 0 0 4px rgba(183,216,91,.075); }
.global-timer-badge.is-break .global-timer-dot { background: var(--violet); box-shadow: 0 0 0 4px rgba(146,115,208,.075); }
.cloud-dot, .cloud-status-dot { background: #b7d85b; box-shadow: 0 0 0 4px rgba(183,216,91,.07); }

@media (min-width: 821px) {
  /* Keep V7 inside the viewport despite the new controls. */
  .page-pomodoro .main {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .page-pomodoro .pomodoro-wrap { min-height: 0; height: 100%; }
  .page-pomodoro .timer-card, .page-pomodoro .settings-card { min-height: 0; height: 100%; }
  .page-pomodoro .settings-card { align-content: start; overflow: hidden; }
  .page-pomodoro .domain-manager { max-height: clamp(58px, 9vh, 106px); }

  .page-tracking .history-heading { min-height: 31px; }
  .page-tracking .tracking-history { overflow: hidden; }
  .page-tracking .session-log { margin-top: 4px; }
  .page-tracking .session-row { padding-top: 5px; padding-bottom: 5px; }
}

@media (min-width: 821px) and (max-height: 820px) {
  .page-pomodoro .domain-color-presets { gap: 4px; }
  .page-pomodoro .color-swatch { width: 14px; height: 14px; flex-basis: 14px; }
  .page-pomodoro .domain-create { gap: 4px; }
  .page-pomodoro .domain-manager { max-height: 60px; }
  .page-tracking .correction-trigger { min-height: 30px; padding: 5px 9px; }
}

@media (max-width: 820px) {
  .domain-color-presets { flex-wrap: wrap; overflow: visible; }
  .correction-grid { grid-template-columns: 1fr; }
  .correction-duration { grid-template-columns: 1fr 1fr; }
  .correction-note { grid-column: 1 / -1; }
  .correction-footer { align-items: stretch; flex-direction: column; }
  .correction-submit-actions { width: 100%; margin-left: 0; }
  .correction-submit-actions .btn { flex: 1; }
}

@media (max-width: 560px) {
  .domain-create-row { grid-template-columns: minmax(0,1fr) 54px; }
  .domain-create-row .btn { grid-column: 1 / -1; }
  .correction-dialog { width: calc(100vw - 18px); }
  .correction-card { padding: 18px !important; }
}

/* Flashcards: restrained color cues make grading faster to parse. */
.deck-item.active {
  border-color: rgba(146,115,208,.16);
  background: linear-gradient(90deg, rgba(146,115,208,.07), rgba(183,216,91,.025));
}
.deck-item.active::before { background: linear-gradient(180deg, var(--violet), var(--accent)); }
.flashcard {
  border-color: rgba(146,115,208,.13);
  background:
    radial-gradient(circle at 88% 8%, rgba(146,115,208,.045), transparent 27%),
    radial-gradient(circle at 8% 104%, rgba(183,216,91,.035), transparent 30%),
    linear-gradient(145deg, rgba(25,24,29,.98), rgba(17,17,20,.98));
}
.flashcard .side-label { color: #c5d97c; }
.rating-grid button:nth-child(1) { border-color: rgba(207,119,107,.22); background: rgba(207,119,107,.055); color: #e8aaa2; }
.rating-grid button:nth-child(2) { border-color: rgba(214,168,87,.20); background: rgba(214,168,87,.05); color: #e3c387; }
.rating-grid button:nth-child(3) { border-color: rgba(98,178,155,.21); background: rgba(98,178,155,.055); color: #9ed3c4; }
.rating-grid button:nth-child(4) { border-color: rgba(146,115,208,.22); background: rgba(146,115,208,.06); color: #c5b1e7; }
