/* Rempip — soft UI: one warm surface, shapes raised out of it or pressed into it, mint for action */

/* self-hosted so the extension and the phone app both work offline */
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 300 900; font-display: swap; src: url(fonts/figtree.woff2) format('woff2'); }
@font-face { font-family: 'Fredoka'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(fonts/fredoka.woff2) format('woff2'); }

:root {
  color-scheme: light;

  --blue: #23926e;
  --blue-press: #1b7a5b;
  --red: #cf4d4d;
  --amber: #b97a00;
  --green: #3f8f4f;

  --bg: #ecebe7;
  --surface: #ecebe7;
  --surface-2: #e4e3df;
  --surface-3: #d9d8d3;
  --outline: #d2d1cb;
  --outline-soft: #e0dfda;
  --text: #2b2c2e;
  --text-2: #5f6064;
  --text-3: #7f8084;
  --accent-soft: #d3f1e5;
  --accent-text: #1c7a5b;

  /* soft UI: every raised thing is lit from the top left */
  --mint: #8fe3c3;
  --on-mint: #173a2e;
  /* the forest: branch health (forest.js mirrors these for the 3D leaves) */
  --leaf-strong: #4fae7e;
  --leaf-due: #e9b949;
  --leaf-wilt: #d9794f;
  --leaf-new: #9fd9c0;
  --bark: #8b6a4e;
  --hi: rgba(255, 255, 255, .92);
  --lo: rgba(160, 156, 146, .5);
  --raise: 7px 7px 16px var(--lo), -7px -7px 16px var(--hi);
  --raise-sm: 3px 3px 8px var(--lo), -3px -3px 8px var(--hi);
  --inset: inset 3px 3px 7px var(--lo), inset -3px -3px 7px var(--hi);
  --glow: 0 0 0 3px rgba(143, 227, 195, .45);

  --sh-1: var(--raise-sm);
  --sh-2: var(--raise);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-pill: 999px;

  --font: Figtree, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --display: Fredoka, ui-rounded, 'SF Pro Rounded', var(--font);
  --max: 760px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --blue: #6fd3ae;
    --blue-press: #8fe3c3;
    --red: #f08e8e;
    --amber: #f2c45a;
    --green: #8fd39e;
    --bg: #2a2c30;
    --surface: #2a2c30;
    --surface-2: #26282b;
    --surface-3: #34363b;
    --outline: #3a3d42;
    --outline-soft: #33353a;
    --text: #e9eaec;
    --text-2: #a4a7ad;
    --text-3: #868a91;
    --accent-soft: #24443a;
    --accent-text: #8fe3c3;
    --mint: #6fd3ae;
    --on-mint: #10271f;
  --leaf-strong: #5cc08e;
  --leaf-due: #e9b949;
  --leaf-wilt: #e0845a;
  --leaf-new: #7cc7a8;
  --bark: #9a7a5e;
    --leaf-strong: #5cc08e;
    --leaf-due: #e9b949;
    --leaf-wilt: #e0845a;
    --leaf-new: #7cc7a8;
    --bark: #9a7a5e;
    --hi: rgba(255, 255, 255, .055);
    --lo: rgba(0, 0, 0, .5);
    --glow: 0 0 0 3px rgba(111, 211, 174, .35);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --blue: #6fd3ae;
  --blue-press: #8fe3c3;
  --red: #f08e8e;
  --amber: #f2c45a;
  --green: #8fd39e;
  --bg: #2a2c30;
  --surface: #2a2c30;
  --surface-2: #26282b;
  --surface-3: #34363b;
  --outline: #3a3d42;
  --outline-soft: #33353a;
  --text: #e9eaec;
  --text-2: #a4a7ad;
  --text-3: #868a91;
  --accent-soft: #24443a;
  --accent-text: #8fe3c3;
  --mint: #6fd3ae;
  --on-mint: #10271f;
  --hi: rgba(255, 255, 255, .055);
  --lo: rgba(0, 0, 0, .5);
  --glow: 0 0 0 3px rgba(111, 211, 174, .35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

svg { fill: currentColor; display: block; }
h1, h2, h3, .brand-name, .tile-v { font-family: var(--display); }
h2 { font-size: 22px; font-weight: 500; margin: 0; letter-spacing: -.1px; }
h3 { font-size: 15px; font-weight: 500; margin: 0 0 12px; }
kbd {
  font-family: inherit; font-size: 11px; opacity: .65;
  border: 1px solid currentColor; border-radius: 4px;
  padding: 0 4px; margin-left: 6px; line-height: 1.5;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 64px; padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--outline-soft);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text); flex: 0 0 auto;
}
.brand-mark { display: block; width: 32px; height: 32px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.brand-name { font-size: 20px; letter-spacing: -.2px; }

.search {
  flex: 1 1 auto; max-width: 640px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 8px 0 16px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  transition: background .15s, box-shadow .15s, border-color .15s;
}
.search:focus-within {
  background: var(--surface);
  border-color: transparent;
  box-shadow: var(--sh-1);
}
.search-icon { color: var(--text-2); flex: 0 0 auto; }
.search input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: none;
  font: inherit; font-size: 15px; color: var(--text);
}
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { display: none; }

.topbar-actions { display: flex; gap: 4px; flex: 0 0 auto; }

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 50%;
  background: none; color: var(--text-2); cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { background: var(--surface-3); }
.icon-btn.subtle { width: 32px; height: 32px; }

/* ---------- tabs ---------- */

.tabs {
  display: flex; gap: 4px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--outline-soft);
  position: sticky; top: 64px; z-index: 19;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  border: 0; background: none;
  font: inherit; font-size: 14px; font-weight: 500;
  color: var(--text-2); cursor: pointer; white-space: nowrap;
  transition: color .12s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent-text); }
.tab.is-active::after {
  content: ''; position: absolute; inset: auto 8px 0 8px; height: 3px;
  background: var(--blue); border-radius: 3px 3px 0 0;
}
.pill {
  min-width: 20px; padding: 0 6px;
  background: var(--surface-3); color: var(--text-2);
  border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; text-align: center; line-height: 18px;
}
.tab.is-active .pill { background: var(--accent-soft); color: var(--accent-text); }
.pill[data-hot='1'] { background: var(--blue); color: #fff; }

/* ---------- layout ---------- */

main { max-width: var(--max); margin: 0 auto; padding: 24px 16px 96px; }
.view { display: none; }
.view.is-active { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.sub { margin: 4px 0 0; color: var(--text-2); }

.card {
  background: var(--surface);
  border: 1px solid var(--outline-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.panel { padding: 20px; margin-bottom: 16px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 24px;
  border: 0; border-radius: var(--r-pill);
  font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: box-shadow .12s, background .12s, filter .12s;
}
.btn.filled { background: var(--blue); color: #fff; }
.btn.filled:hover { box-shadow: var(--sh-1); filter: brightness(1.05); }
.btn.tonal { background: var(--accent-soft); color: var(--accent-text); }
.btn.tonal:hover { box-shadow: var(--sh-1); }
.btn.text { background: none; color: var(--accent-text); padding: 0 12px; }
.btn.text:hover { background: var(--accent-soft); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .4; cursor: default; box-shadow: none; }

/* on dark surfaces the filled button needs dark text against the light-blue fill */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .btn.filled { color: #202124; }
}
:root[data-theme='dark'] .btn.filled { color: #202124; }

/* ---------- review ---------- */

.stage { display: flex; flex-direction: column; gap: 16px; }

.progress { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--blue); border-radius: 2px; transition: width .3s ease; }

.queue-counts { display: flex; flex-wrap: wrap; gap: 4px 18px; justify-content: center; font-size: 13px; color: var(--text-2); }
.count b { font-weight: 600; }
.count-new b { color: var(--blue); }
.count-learn b { color: var(--amber); }
.count-due b { color: var(--green); }

.studycard { padding: 0; overflow: hidden; }

.studycard-meta {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--outline-soft);
  background: var(--surface);
}
.src-badge {
  flex: 0 0 auto; padding: 3px 10px;
  background: var(--accent-soft); color: var(--accent-text);
  border-radius: var(--r-pill); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
}
.src-text { flex: 1; min-width: 0; }
.src-title {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.src-author { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.studycard-body { padding: 28px; min-height: 120px; }

.prompt { margin: 0; font-size: 20px; line-height: 1.45; letter-spacing: -.2px; }
.part-label { display: block; margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); }
.part-label[hidden] { display: none; }
.rule { border: 0; border-top: 1px solid var(--outline-soft); margin: 24px 0; }
.cloze-gap {
  display: inline-block; min-width: 3.5em; padding: 0 6px;
  border-radius: var(--r-sm); background: var(--accent-soft);
  color: var(--accent-text); font-weight: 500; text-align: center;
}
.cloze-fill {
  padding: 0 4px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent-text); font-weight: 500;
}
.answer { margin: 0 0 20px; font-size: 17px; line-height: 1.6; color: var(--text); }
.picture { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; margin: 0 0 20px; border-radius: var(--r-md); box-shadow: var(--raise-sm); }
.edit-picture { margin-right: auto; }
.field input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--mint); }

.quote {
  margin: 0; padding: 14px 18px;
  background: var(--surface-2);
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 14px; line-height: 1.65; color: var(--text-2);
  white-space: pre-wrap;
}
.note {
  margin: 14px 0 0; padding: 12px 14px;
  background: var(--accent-soft); color: var(--accent-text);
  border-radius: var(--r-sm); font-size: 13px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.chip {
  padding: 4px 10px;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--outline); border-radius: var(--r-pill);
  font-size: 12px; cursor: pointer;
}
.chip:hover { background: var(--surface-3); color: var(--text); }
.chip-add { background: none; border-style: dashed; }

/* the moments of a video a highlight came from */
.clips { margin: 0 0 16px; }
.clips .chips { margin-top: 0; }
.clips .chips { display: block; }
.clips .clip-btn + .clip-btn { margin-top: 10px; }
.quote-para + .quote-para { margin-top: 1em; }
.clip-row { margin-top: 10px; white-space: normal; }
.quote-para .clip-player { margin: 10px 0 0; }

/* a play button and a rail, with the moment marked where it falls in the video */
.clip-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 2px 0; background: none; border: 0; box-shadow: none;
  color: var(--text-2); font: inherit; text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.clip-play {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 50%; background: var(--mint); color: var(--on-mint); box-shadow: var(--raise-sm);
}
.clip-play svg { display: block; width: 15px; height: 15px; fill: currentColor; }
.clip-icon-pause, .clip-btn.is-playing .clip-icon-play { display: none !important; }
.clip-btn.is-playing .clip-icon-pause { display: block !important; }
.clip-track { position: relative; flex: 1; min-width: 0; height: 38px; }
.clip-track::before {
  content: ''; position: absolute; left: 0; right: 0; top: 7px; height: 8px;
  border-radius: var(--r-pill); background: var(--surface-2); box-shadow: inset 1px 1px 3px var(--lo), inset -1px -1px 2px var(--hi);
}
.clip-seg {
  position: absolute; top: 4px; height: 14px; min-width: 20px; border-radius: var(--r-pill);
  left: min(var(--at, 0%), calc(100% - 20px)); width: var(--len, 0%);
  background: var(--mint); box-shadow: 0 0 0 1px color-mix(in srgb, var(--on-mint) 22%, transparent);
  transition: opacity .2s;
}
.clip-time {
  position: absolute; top: 21px; line-height: 16px; font-size: 12px; font-weight: 500;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  left: clamp(var(--half, 0px), var(--mid, 0%), calc(100% - var(--half, 0px))); transform: translateX(-50%);
  transition: opacity .2s;
}
.clip-btn:active .clip-play { box-shadow: var(--inset); transform: scale(.96); }
.clip-btn.is-measuring .clip-seg, .clip-btn.is-measuring .clip-time { opacity: 0; }
.clip-btn.is-on .clip-time { color: var(--text); }
.clip-player {
  display: block; width: 100%; max-height: 60vh; margin-bottom: 8px; white-space: normal;
  background: #000; border: 0; border-radius: var(--r-sm);
}
iframe.clip-player { aspect-ratio: 16 / 9; height: auto; }
.clip-error { margin: 6px 0 0; font-size: 12px; color: var(--text-2); }

.inline-link { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.inline-link:hover { text-decoration-thickness: 2px; }
.inline-img-link { display: block; width: fit-content; max-width: 100%; margin: 8px 0; }
.inline-img {
  display: block; max-width: 100%; max-height: 420px; height: auto;
  border: 1px solid var(--outline-soft); border-radius: var(--r-md); background: var(--surface-2);
}
.inline-img-link:hover .inline-img { box-shadow: var(--sh-1); }

.tag-editor {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--outline-soft);
}
.chips .tag-editor { width: 100%; margin-top: 0; padding-top: 0; border-top: 0; }
.tag-pill {
  display: inline-flex; align-items: center;
  background: var(--accent-soft); border: 1px solid var(--outline); border-radius: var(--r-pill);
  padding: 0 2px 0 6px;
}
.tag-pill:focus-within { border-color: var(--accent-text); }
.tag-name {
  border: 0; background: none; outline: none; padding: 4px 2px;
  font: inherit; font-size: 12px; color: var(--accent-text);
}
.tag-del {
  width: 20px; height: 20px; border: 0; border-radius: 50%;
  background: none; color: var(--text-2); font-size: 14px; line-height: 1; cursor: pointer;
}
.tag-del:hover { background: var(--surface-3); color: var(--red); }
.tag-new {
  flex: 1 1 120px; min-width: 120px; padding: 5px 10px;
  border: 1px dashed var(--outline); border-radius: var(--r-pill); outline: none;
  background: none; color: var(--text); font: inherit; font-size: 12px;
}
.tag-new:focus { border-style: solid; border-color: var(--accent-text); }
.btn.tag-done { height: 28px; font-size: 12px; }
.icon-btn.is-on { background: var(--accent-soft); color: var(--accent-text); }

.actions { position: sticky; bottom: 16px; }
.actions-extra { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.edit-form .text-field { font-size: 15px; line-height: 1.5; resize: vertical; }
.edit-form .edit-actions { margin-top: 8px; }
.btn.danger, .icon-btn.danger { color: var(--red, #d93025); }
.btn.danger:hover { background: color-mix(in srgb, var(--red, #d93025) 12%, transparent); }
.icon-btn.danger:hover { background: color-mix(in srgb, var(--red, #d93025) 12%, transparent); color: var(--red, #d93025); }
.btn.danger svg { fill: currentColor; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px;
  border: 1px solid var(--outline);
  border-radius: var(--r-md);
  background: var(--surface);
  font: inherit; color: var(--text); cursor: pointer;
  transition: background .12s, border-color .12s, transform .06s;
}
.grade:hover { box-shadow: var(--sh-1); }
.grade:active { transform: scale(.98); }
.grade b { font-size: 14px; font-weight: 500; }
.grade span { font-size: 12px; color: var(--text-2); }
.grade kbd { margin: 0; border: 0; opacity: .45; }
.g1 b { color: var(--red); }  .g1:hover { border-color: var(--red); }
.g2 b { color: var(--amber); } .g2:hover { border-color: var(--amber); }
.g3 b { color: var(--blue); }  .g3:hover { border-color: var(--blue); }
.g4 b { color: var(--green); } .g4:hover { border-color: var(--green); }

/* ---------- empty state ---------- */

.empty { text-align: center; padding: 64px 16px; }
.empty-art {
  width: 72px; height: 72px; margin: 0 auto 20px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text);
  border-radius: 50%; font-size: 32px;
}
.empty p { color: var(--text-2); margin: 8px 0 24px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- streak ---------- */

.streak-chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px;
  height: 32px; padding: 0 10px; border: 1px solid var(--outline); border-radius: var(--r-pill);
  background: none; color: var(--text-2); font: inherit; font-size: 14px; cursor: pointer;
}
.streak-chip b { font-weight: 600; font-variant-numeric: tabular-nums; }
/* grey until today's goal is met */
.streak-chip[data-done='0'] span { filter: grayscale(1); opacity: .6; }
.streak-chip[data-done='1'] { border-color: var(--amber); color: var(--text); }
.streak-chip[data-done='1'] b { color: var(--amber); }

.streak-done { margin: -8px 0 24px; }
.streak-week { display: flex; justify-content: center; gap: 10px; }
.day-dot { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); }
.day-dot i {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%;
  border: 2px solid var(--outline); font-style: normal; font-size: 13px; font-weight: 600;
}
.day-dot.is-done i { background: var(--amber); border-color: var(--amber); color: var(--surface); }
.day-dot.is-frozen i { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-text); }
.day-dot.is-today i { border-style: dashed; border-color: var(--amber); }
.streak-kept { margin: 18px 0 0 !important; color: var(--text) !important; }
.streak-kept b { color: var(--green); font-size: 18px; }

/* ---------- feed (digest + library) ---------- */

.feed { display: flex; flex-direction: column; gap: 12px; }

.item {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--outline-soft);
  border-radius: var(--r-lg);
  transition: box-shadow .12s, border-color .12s;
}
.item:hover { box-shadow: var(--sh-1); }
.item-text { margin: 0 0 12px; font-size: 15px; line-height: 1.65; white-space: pre-wrap; }
.item-q { margin: 0 0 8px; font-size: 14px; font-weight: 500; color: var(--accent-text); }
.item-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--text-2); font-size: 12px; }
.item-foot .dot { opacity: .5; }
.item-src { font-weight: 500; color: var(--text); }
.item-actions { margin-left: auto; display: flex; gap: 2px; }
.item mark { background: #fef7c3; color: inherit; border-radius: 2px; padding: 0 1px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .item mark { background: #5c4a1a; } }
:root[data-theme='dark'] .item mark { background: #5c4a1a; }

.state-tag { padding: 2px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; }
.state-new { background: var(--accent-soft); color: var(--accent-text); }
.state-learning { background: #fef7e0; color: #b06000; }
.state-review { background: #e6f4ea; color: #137333; }
.state-suspended { background: var(--surface-3); color: var(--text-2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .state-learning { background: #3d3521; color: #fdd663; }
  :root:not([data-theme='light']) .state-review { background: #1f3626; color: #81c995; }
}
:root[data-theme='dark'] .state-learning { background: #3d3521; color: #fdd663; }
:root[data-theme='dark'] .state-review { background: #1f3626; color: #81c995; }

/* ---------- filters ---------- */

.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.select {
  height: 36px; padding: 0 32px 0 14px;
  border: 1px solid var(--outline); border-radius: var(--r-pill);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%235f6368'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 8px center / 18px;
  color: var(--text); font: inherit; font-size: 13px;
  appearance: none; cursor: pointer; max-width: 210px;
  text-overflow: ellipsis;
}
.select:hover { background-color: var(--surface-2); }

/* ---------- stats ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { padding: 18px 20px; background: var(--surface); border: 1px solid var(--outline-soft); border-radius: var(--r-lg); }
.tile-v { font-size: 28px; font-weight: 500; letter-spacing: -.5px; line-height: 1.2; }
.tile-l { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.chart { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.chart { position: relative; }
.chart-tip {
  position: absolute; z-index: 2; pointer-events: none; white-space: nowrap;
  padding: 6px 10px; border-radius: var(--r-sm); font-size: 12px; line-height: 1.45;
  background: var(--text); color: var(--surface); box-shadow: var(--sh-1);
}
.chart-tip[hidden] { display: none; }
.bar { flex: 1; min-width: 2px; background: var(--blue); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; }
.bar:hover { opacity: 1; }
.bar.empty-bar { background: var(--surface-3); }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 8px; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 60; max-width: min(90vw, 520px);
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  background: #323232; color: #fff;
  border-radius: var(--r-sm); box-shadow: var(--sh-2);
  font-size: 14px; animation: rise .2s ease-out;
}
.toast button { background: none; border: 0; color: #8ab4f8; font: inherit; font-weight: 500; cursor: pointer; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- settings sheet ---------- */

.sheet {
  width: min(92vw, 480px); padding: 0;
  border: 0; border-radius: var(--r-lg);
  background: var(--surface); color: var(--text);
  box-shadow: var(--sh-2);
}
.sheet::backdrop { background: rgba(32,33,36,.5); }
.sheet form { padding: 24px; }
.sheet h2 { margin-bottom: 20px; }
.sheet h3 { margin-top: 28px; }
#new-dialog { width: min(92vw, 620px); max-height: 92vh; }
.new-grid > *, .new-form .text-field { min-width: 0; }
.new-form .field.stack span i { font-style: normal; color: var(--text-3); }
.new-form textarea.text-field { resize: vertical; line-height: 1.5; }
.new-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .new-grid { grid-template-columns: 1fr; } }
.field { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; font-size: 14px; }
.field span { flex: 1; }
.field input[type='number'] {
  width: 84px; height: 36px; padding: 0 10px;
  border: 1px solid var(--outline); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font: inherit;
}
.field input[type='range'] { width: 140px; accent-color: var(--blue); }

.field.stack { display: grid; align-items: stretch; gap: 6px; }
.field.stack span { flex: none; color: var(--text-2); font-size: 13px; }
.text-field {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--outline); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px;
}
.text-field:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.hint.hint-top { margin-top: 4px; }
.field output { width: 40px; text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin: 24px 0 0; padding: 0; }
.hint { font-size: 12px; color: var(--text-2); margin: 12px 0 0; }
.advanced { margin-top: 14px; }
.advanced summary { cursor: pointer; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.advanced .text-field[readonly] { color: var(--text-2); font-family: ui-monospace, Menlo, monospace; }

@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .brand-name { display: none; }
  .studycard-body { padding: 24px 18px; }
  .prompt { font-size: 18px; }
  .grades { grid-template-columns: repeat(2, 1fr); }
  main { padding: 16px 12px 80px; }
}

/* ---------- phone ----------
 * The same app runs as the study screen of the phone's web app. These only
 * apply there (body.is-phone) or on a touch screen; the extension is untouched.
 */

.phone-only { display: none !important; }
body.is-phone .phone-only { display: grid !important; }
body.is-phone .ext-only { display: none !important; }

body.is-phone .topbar {
  height: calc(56px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
}
body.is-phone .tabs { top: calc(56px + env(safe-area-inset-top)); }
body.is-phone main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
body.is-phone .actions { bottom: calc(12px + env(safe-area-inset-bottom)); }
body.is-phone .topbar { gap: 6px; padding-left: 10px; padding-right: 4px; }
body.is-phone .search { height: 40px; padding-left: 12px; min-width: 0; }
body.is-phone .topbar-actions { gap: 0; }
body.is-phone .topbar-actions .icon-btn { width: 38px; height: 38px; }
body.is-phone #theme-btn { display: none; }
body.is-phone .sheet { width: min(96vw, 560px); max-height: 92dvh; }
body.is-phone .sheet form { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }

@media (hover: none) {
  /* no keyboard to press them with */
  kbd { display: none; }
  /* four across, under the thumb, the way a grading row reads in Anki */
  .grades { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .grade { padding: 12px 2px; }
  .item-actions .icon-btn.subtle { width: 40px; height: 40px; }
  .text-field, .search input { font-size: 16px; } /* below 16px iOS zooms the page on focus */
}

/* ---------- how it works ---------- */

#view-explain h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 17px; }
#view-explain p { line-height: 1.6; margin: 0 0 12px; }
#view-explain .panel > p:last-child { margin-bottom: 0; }
.x-n {
  flex: 0 0 auto; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-text); font-size: 14px; font-weight: 600;
}
.x-hero p { margin: 0; }
.x-plants { display: flex; align-items: flex-end; justify-content: center; gap: 6px; margin: 4px 0 16px; font-size: 30px; line-height: 1; }
.x-plants span:nth-of-type(1) { font-size: 22px; }
.x-plants span:nth-of-type(2) { font-size: 28px; }
.x-plants span:nth-of-type(3) { font-size: 34px; }
.x-plants span:nth-of-type(4) { font-size: 42px; }
.x-plants i { font-style: normal; font-size: 16px; opacity: .7; padding-bottom: 4px; }

.x-chart { width: 100%; margin: 8px 0 4px; touch-action: pan-y; }
.x-chart svg { display: block; overflow: visible; }
.x-grid { stroke: var(--outline-soft); stroke-width: 1; }
.x-axis { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.x-label { fill: var(--text-2); font-size: 12px; font-family: var(--font); }
.x-label-strong { fill: var(--text); font-weight: 600; }
.x-line { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.x-line-muted { stroke: var(--text-3); stroke-dasharray: 2 4; }
.x-threshold { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 5 4; }
.x-drop { stroke: var(--blue); stroke-width: 1; stroke-dasharray: 2 3; opacity: .6; }
/* a 2px surface ring keeps the dot readable where it sits on the line */
.x-dot { fill: var(--blue); stroke: var(--surface); stroke-width: 2; }
.x-cross { stroke: var(--text-3); stroke-width: 1; }
.x-target { cursor: pointer; }
.x-tip {
  position: absolute; z-index: 2; pointer-events: none; white-space: nowrap;
  padding: 6px 10px; border-radius: var(--r-sm); font-size: 12px; line-height: 1.45;
  background: var(--text); color: var(--surface); box-shadow: var(--sh-1);
}
.x-slider { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; color: var(--text-2); margin: 8px 0 12px; }
.x-slider b { color: var(--text); min-width: 64px; }
.x-slider input { flex: 1 1 160px; accent-color: var(--blue); }
.x-note { color: var(--text-2); font-size: 14px; }
.x-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); margin: 4px 0 12px; }
.x-legend span { display: inline-flex; align-items: center; gap: 6px; }
.x-key { width: 18px; height: 0; border-top: 2px solid var(--blue); }
.x-key-muted { border-top: 2px dotted var(--text-3); }
.x-key-dot { width: 10px; height: 10px; border: 0; border-radius: 50%; background: var(--blue); }

.x-bars { display: grid; gap: 10px; margin: 12px 0 16px; }
.x-bar-row { display: grid; grid-template-columns: 52px 1fr 84px; align-items: center; gap: 10px; font-size: 14px; }
.x-bar-name { font-weight: 600; }
.x-bar-track { height: 14px; }
.x-bar { display: block; height: 100%; background: var(--blue); border-radius: 0 4px 4px 0; }
.x-bar-value { color: var(--text-2); font-variant-numeric: tabular-nums; }
.x-grades, .x-tips { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; font-size: 14px; line-height: 1.55; }
.x-grades li { padding-left: 12px; border-left: 3px solid var(--outline); }
.x-tips li { display: flex; gap: 12px; }
.x-tips li > span { font-size: 22px; line-height: 1.2; }
.x-small { font-size: 13px; color: var(--text-2); margin-top: 16px !important; }
.x-library .tiles { margin-bottom: 8px; }

/* ---------- soft UI ----------
 * Everything sits on one surface colour. Things you can press, and things that
 * hold content, are raised out of it (--raise); places you type into, tracks
 * and wells are pressed into it (--inset). Borders are dropped: the shadows
 * draw the edges. Mint marks the one action that matters on a screen.
 */

.topbar, .tabs { background: var(--bg); border-bottom: 0; }

.search { background: var(--bg); border: 0; box-shadow: var(--inset); }
.search:focus-within { box-shadow: var(--inset), var(--glow); }

.icon-btn { transition: box-shadow .15s, color .15s; }
.icon-btn:hover { background: var(--bg); box-shadow: var(--raise-sm); }
.icon-btn:active, .icon-btn.is-on { background: var(--bg); box-shadow: var(--inset); color: var(--accent-text); }

/* tabs: a pressed-in track with the open tab raised in mint */
.tabs { gap: 2px; margin: 6px 12px 4px; padding: 5px; border-radius: var(--r-pill); box-shadow: var(--inset); }
.tab { padding: 8px 16px; border-radius: var(--r-pill); transition: color .15s, box-shadow .15s, background .15s; }
.tab.is-active { background: var(--mint); color: var(--on-mint); box-shadow: var(--raise-sm); }
.tab.is-active::after { display: none; }
.pill { background: var(--bg); box-shadow: var(--inset); }
.tab.is-active .pill { background: rgba(255, 255, 255, .45); color: var(--on-mint); box-shadow: none; }
.pill[data-hot='1'] { background: var(--mint); color: var(--on-mint); box-shadow: none; }
.tab.is-active .pill[data-hot='1'] { background: rgba(255, 255, 255, .55); }

/* raised containers */
.card, .item, .tile, .sheet {
  background: var(--bg); border: 0; box-shadow: var(--raise);
}
.item:hover { box-shadow: var(--raise); }
.studycard-meta { background: none; border-bottom: 0; padding: 18px 20px 0; }
.studycard-body { padding-top: 20px; }
.src-badge, .state-tag { box-shadow: var(--raise-sm); }

/* buttons */
.btn { height: 44px; transition: box-shadow .15s, transform .06s; }
.btn.filled { background: var(--mint); color: var(--on-mint); box-shadow: var(--raise-sm); font-weight: 600; }
.btn.filled:hover { filter: none; box-shadow: var(--raise-sm), var(--glow); }
.btn.tonal { background: var(--bg); color: var(--accent-text); box-shadow: var(--raise-sm); }
.btn.tonal:hover { box-shadow: var(--raise-sm), var(--glow); }
.btn.text:hover { background: none; box-shadow: var(--raise-sm); }
.btn:active:not(:disabled) { box-shadow: var(--inset); transform: scale(.99); }
.btn:disabled { background: var(--surface-3); color: var(--text-3); box-shadow: none; opacity: .7; }
:root .btn.filled { color: var(--on-mint); }

.grade { background: var(--bg); border: 0; border-radius: var(--r-md); box-shadow: var(--raise-sm); padding: 12px 4px; }
.grade:hover { box-shadow: var(--raise-sm), var(--glow); }
.grade:active { box-shadow: var(--inset); }
.g1:hover, .g2:hover, .g3:hover, .g4:hover { border-color: transparent; }
.g4 b { color: #3a73b3; }

/* chips and tags */
.chip { background: var(--bg); border: 0; box-shadow: var(--raise-sm); padding: 5px 12px; }
.chip:hover { background: var(--bg); box-shadow: var(--raise-sm), var(--glow); }
.chip-add { box-shadow: var(--inset); }
.tag-pill { border: 0; box-shadow: var(--inset); }
.tag-new { border: 0; box-shadow: var(--inset); }

/* wells: things pressed into the surface */
.progress { height: 10px; border-radius: var(--r-pill); background: var(--bg); box-shadow: var(--inset); padding: 2px; }
.progress-bar { border-radius: var(--r-pill); background: var(--mint); }
.quote { background: var(--bg); border-left: 0; border-radius: var(--r-md); box-shadow: var(--inset); color: var(--text-2); }
.note { border-radius: var(--r-md); }
.select, .text-field, .field input[type='number'] {
  background-color: var(--bg); border: 0; box-shadow: var(--inset);
}
.select { height: 38px; }
.select:hover { background-color: var(--bg); box-shadow: var(--inset), var(--glow); }
.text-field:focus, .field input[type='number']:focus { outline: 0; box-shadow: var(--inset), var(--glow); }
/* sliders: a groove pressed into the surface, a raised knob with a mint core */
input[type='range'] {
  -webkit-appearance: none; appearance: none;
  height: 12px; padding: 0 2px; border-radius: var(--r-pill);
  background: var(--bg); box-shadow: var(--inset); cursor: pointer;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border: 0; border-radius: 50%;
  background: radial-gradient(circle, var(--mint) 0 4px, var(--bg) 5px);
  box-shadow: var(--raise-sm);
}
input[type='range']::-moz-range-thumb {
  width: 24px; height: 24px; border: 0; border-radius: 50%;
  background: radial-gradient(circle, var(--mint) 0 4px, var(--bg) 5px);
  box-shadow: var(--raise-sm);
}
input[type='range']::-moz-range-track { background: transparent; }
input[type='range']:focus { outline: 0; }
input[type='range']:focus-visible::-webkit-slider-thumb { box-shadow: var(--raise-sm), var(--glow); }
input[type='range']:focus-visible::-moz-range-thumb { box-shadow: var(--raise-sm), var(--glow); }
input[type='range']:active::-webkit-slider-thumb { box-shadow: var(--inset); }
input[type='range']:active::-moz-range-thumb { box-shadow: var(--inset); }
.rule { border-top-color: var(--outline); }
.inline-img { border: 0; box-shadow: var(--raise-sm); }

/* review stage */
.empty-art { background: var(--bg); box-shadow: var(--raise); color: var(--accent-text); }
.queue-counts { gap: 6px 18px; }

/* streak */
.streak-chip { border: 0; background: var(--bg); box-shadow: var(--raise-sm); }
.streak-chip[data-done='1'] { box-shadow: var(--raise-sm), 0 0 0 2px rgba(242, 196, 90, .55); }
.day-dot i { border: 0; background: var(--bg); box-shadow: var(--inset); }
.day-dot.is-done i { background: #f2c45a; color: #3d2c00; box-shadow: var(--raise-sm); }
.day-dot.is-frozen i { background: #cfe3f7; color: #24527f; box-shadow: var(--raise-sm); }
.day-dot.is-today i { box-shadow: var(--inset), 0 0 0 2px rgba(242, 196, 90, .6); }

/* soft status fills, as in the styleguide */
.state-new { background: var(--accent-soft); }
.state-learning { background: #f6e7b4; color: #6b4b00; }
.state-review { background: #cdeedd; color: #1d5e3f; }
.state-suspended { background: var(--surface-3); }

/* stats + how it works */
.bar { background: var(--mint); border-radius: 4px 4px 0 0; opacity: 1; }
.bar:hover { background: var(--blue); }
.bar.empty-bar { background: var(--surface-3); }
.x-n { background: var(--mint); color: var(--on-mint); box-shadow: var(--raise-sm); }
.x-bar-track { border-radius: var(--r-pill); box-shadow: var(--inset); padding: 2px; height: 18px; }
.x-bar { border-radius: var(--r-pill); background: var(--mint); }
.x-grades li { border-left: 0; padding: 10px 14px; border-radius: var(--r-md); box-shadow: var(--inset); }

/* toast: a dark pill floating over the surface */
.toast { border-radius: var(--r-pill); background: #2b2c2e; box-shadow: var(--raise); padding: 12px 22px; }
.toast button { color: var(--mint); }
.sheet::backdrop { background: rgba(43, 44, 46, .35); backdrop-filter: blur(2px); }

/* dark mode: the same shapes, with a fainter highlight and status fills toned down */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .g4 b { color: #8db8ea; }
  :root:not([data-theme='light']) .state-learning { background: #4a3d1c; color: #f2d98a; }
  :root:not([data-theme='light']) .state-review { background: #1f4434; color: #a6e6c8; }
  :root:not([data-theme='light']) .toast { background: #e9eaec; color: #2b2c2e; }
  :root:not([data-theme='light']) .day-dot.is-frozen i { background: #2d4560; color: #cfe3f7; }
}
:root[data-theme='dark'] .g4 b { color: #8db8ea; }
:root[data-theme='dark'] .state-learning { background: #4a3d1c; color: #f2d98a; }
:root[data-theme='dark'] .state-review { background: #1f4434; color: #a6e6c8; }
:root[data-theme='dark'] .toast { background: #e9eaec; color: #2b2c2e; }
:root[data-theme='dark'] .day-dot.is-frozen i { background: #2d4560; color: #cfe3f7; }

/* keyboard focus: a mint ring instead of the browser's square box */
:focus { outline: none; }
:focus-visible { outline: 0; box-shadow: var(--glow); border-radius: var(--r-sm); }
.btn:focus-visible, .chip:focus-visible, .tab:focus-visible, .grade:focus-visible { box-shadow: var(--raise-sm), var(--glow); }

/* ---------- motion ----------
 * Things move instead of appearing: the tab highlight slides, views slide in
 * from the side their tab is on, cards and answers rise into place, and every
 * button sinks when pressed and springs back. One easing for all of it, so it
 * feels like one material. Nothing moves for people who ask for less motion.
 */

:root {
  --ease: cubic-bezier(.22, .8, .3, 1);       /* fast out, soft landing */
  --spring: cubic-bezier(.3, 1.4, .5, 1);     /* a small overshoot, for presses */
}

/* the tab highlight is one shape that travels, not a background per tab */
.tabs { position: sticky; }
.tab-glider {
  position: absolute; top: 5px; bottom: 5px; left: 0; width: 0; z-index: 0;
  border-radius: var(--r-pill); background: var(--mint); box-shadow: var(--raise-sm);
  transition: transform .42s var(--ease), width .42s var(--ease);
  pointer-events: none;
}
.tab-glider.no-anim { transition: none; }
.tab { z-index: 1; transition: color .3s var(--ease); }
.tab.is-active { background: none; box-shadow: none; }
.tab .pill { transition: background-color .3s var(--ease), color .3s var(--ease), box-shadow .3s var(--ease); }

/* views slide in from the direction of travel */
.view.is-active { animation: view-in .38s var(--ease); }
main[data-dir='back'] .view.is-active { animation-name: view-in-back; }
@keyframes view-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes view-in-back { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }

/* a new card rises into place; the answer and the grades follow it in */
.studycard.is-entering { animation: card-in .42s var(--ease); }
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.reveal:not([hidden]) { animation: rise-in .34s var(--ease); }
.grades:not([hidden]) .grade { animation: rise-in .34s var(--ease) backwards; }
.grades:not([hidden]) .grade:nth-child(2) { animation-delay: .03s; }
.grades:not([hidden]) .grade:nth-child(3) { animation-delay: .06s; }
.grades:not([hidden]) .grade:nth-child(4) { animation-delay: .09s; }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* the done screen pops, then its week fills in day by day */
.empty:not([hidden]) .empty-art { animation: pop .5s var(--spring); }
.empty:not([hidden]) h2, .empty:not([hidden]) > p { animation: rise-in .4s var(--ease) backwards .08s; }
.streak-done:not([hidden]) .day-dot { animation: rise-in .35s var(--ease) backwards; }
.streak-done:not([hidden]) .day-dot:nth-child(2) { animation-delay: .04s; }
.streak-done:not([hidden]) .day-dot:nth-child(3) { animation-delay: .08s; }
.streak-done:not([hidden]) .day-dot:nth-child(4) { animation-delay: .12s; }
.streak-done:not([hidden]) .day-dot:nth-child(5) { animation-delay: .16s; }
.streak-done:not([hidden]) .day-dot:nth-child(6) { animation-delay: .2s; }
.streak-done:not([hidden]) .day-dot:nth-child(7) { animation-delay: .24s; }
@keyframes pop { 0% { opacity: 0; transform: scale(.6); } 100% { opacity: 1; transform: none; } }

/* the flame comes alive when today's goal is met */
.streak-chip { transition: box-shadow .3s var(--ease), color .3s var(--ease); }
.streak-chip span { transition: filter .4s var(--ease), opacity .4s var(--ease); }
.streak-chip[data-done='1'] span { animation: pop .55s var(--spring); }

/* every control: sinks when pressed, springs back on release */
.btn, .icon-btn, .grade, .chip, .tab, .streak-chip, .select, .item-actions .icon-btn {
  transition: transform .22s var(--spring), box-shadow .25s var(--ease), background-color .25s var(--ease), color .25s var(--ease), opacity .25s var(--ease);
}
.btn:active:not(:disabled), .grade:active, .chip:active, .streak-chip:active { transform: scale(.96); transition-duration: .08s; }
.icon-btn:active { transform: scale(.9); transition-duration: .08s; }
.progress-bar { transition: width .45s var(--ease); }
.x-bar, .bar { transition: width .5s var(--ease), height .5s var(--ease), background-color .08s var(--ease); }
.search { transition: box-shadow .25s var(--ease); }
.text-field, .field input[type='number'] { transition: box-shadow .25s var(--ease); }

/* dialogs rise from below and fade their backdrop */
.sheet[open] { animation: sheet-in .34s var(--ease); }
.sheet[open]::backdrop { animation: fade-in .3s var(--ease); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.toast { animation: rise .32s var(--spring); }

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

/* ---------- forest: the library as a 3D world (forest.js) ---------- */

body.forest-open { overflow: hidden; }
#view-forest.is-active {
  position: fixed; left: 0; right: 0; bottom: 0; top: var(--forest-top, 112px); z-index: 5;
  background: var(--bg); animation: none;
}
.forest-stage { position: absolute; inset: 0; }
.forest-stage canvas { display: block; touch-action: none; }
.forest-loading {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-2);
  font-family: var(--display); font-size: 18px;
}
#view-forest:not(.is-loading) .forest-loading { display: none; }

.forest-bar {
  position: absolute; top: 12px; left: max(16px, env(safe-area-inset-left)); z-index: 2;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; pointer-events: none;
}
.forest-bar > * { pointer-events: auto; }
.forest-seg { display: flex; gap: 2px; padding: 4px; border-radius: var(--r-pill); background: var(--bg); box-shadow: var(--raise-sm); }
.forest-seg button {
  border: 0; background: none; color: var(--text-2); font: inherit; font-weight: 600; font-size: 13px;
  padding: 6px 14px; border-radius: var(--r-pill); cursor: pointer; transition: background .25s var(--ease), color .25s var(--ease);
}
.forest-seg button[aria-pressed='true'] { background: var(--mint); color: var(--on-mint); box-shadow: var(--raise-sm); }
.forest-sum {
  font-size: 12.5px; color: var(--text-2); padding: 6px 12px; border-radius: var(--r-pill);
  background: var(--bg); box-shadow: var(--inset); font-variant-numeric: tabular-nums;
}

.forest-panel {
  position: absolute; z-index: 2; top: 12px; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom));
  width: 360px; display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--r-lg); background: var(--bg); box-shadow: var(--raise);
  transition: transform .35s var(--ease, ease), opacity .25s, visibility 0s .35s;
}
#view-forest:not(.panel-open) .forest-panel { transform: translateX(calc(100% + 32px)); opacity: 0; visibility: hidden; }
#view-forest.panel-open .forest-panel { transition-delay: 0s; }
.forest-hide {
  position: absolute; top: 10px; right: 10px; z-index: 1; width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--bg); box-shadow: var(--raise-sm); color: var(--text-2); cursor: pointer;
}
.forest-panel-in > :first-child { padding-right: 40px; }
.forest-pip {
  position: absolute; z-index: 2; top: 12px; right: max(16px, env(safe-area-inset-right));
  width: 56px; height: 56px; display: grid; place-items: center; padding: 0; cursor: pointer;
  border: 0; border-radius: 50%; background: var(--bg); box-shadow: var(--raise);
  transition: transform .3s var(--spring, ease), opacity .2s;
}
.forest-pip:active { transform: scale(.92); }
#view-forest.panel-open .forest-pip { transform: scale(.6); opacity: 0; pointer-events: none; }
.forest-panel-in { overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.forest-panel h2 { font-size: 22px; font-weight: 600; line-height: 1.15; text-wrap: balance; }
.forest-panel h3 {
  margin: 4px 0 0; font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2);
}
.forest-meta { margin: 0; color: var(--text-2); font-size: 13px; }
.forest-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.forest-crumbs button { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--accent-text); cursor: pointer; }
.forest-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); }
.forest-legend span { display: flex; align-items: center; gap: 6px; }
.forest-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.forest-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.forest-row {
  width: 100%; display: grid; grid-template-columns: 11px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 11px 12px; border: 0; border-radius: var(--r-md); background: var(--bg); box-shadow: var(--raise-sm);
  color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: transform .2s var(--spring, ease);
}
.forest-row:hover { transform: translateY(-1px); }
.forest-row:active { transform: scale(.98); }
.forest-row .t { min-width: 0; }
.forest-row .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.forest-row .t span { font-size: 12px; color: var(--text-2); }
.forest-chip { align-self: flex-start; padding: 3px 9px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--text); }
.forest-chip.is-strong { background: color-mix(in srgb, var(--leaf-strong) 24%, transparent); }
.forest-chip.is-due { background: color-mix(in srgb, var(--leaf-due) 32%, transparent); }
.forest-chip.is-wilt { background: color-mix(in srgb, var(--leaf-wilt) 30%, transparent); }
.forest-chip.is-new { background: color-mix(in srgb, var(--leaf-new) 32%, transparent); }
.forest-bar-h { display: flex; height: 6px; border-radius: var(--r-pill); overflow: hidden; box-shadow: var(--inset); }
.forest-bar-h i { display: block; height: 100%; }
.forest-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.forest-stats div { padding: 10px 6px; border-radius: var(--r-md); box-shadow: var(--inset); text-align: center; }
.forest-stats b { display: block; font-family: var(--display); font-weight: 600; font-size: 19px; font-variant-numeric: tabular-nums; }
.forest-stats span { font-size: 11.5px; color: var(--text-2); }
.forest-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: var(--r-lg); box-shadow: var(--inset); }
.forest-q { margin: 0; font-family: var(--display); font-weight: 500; font-size: 20px; line-height: 1.3; }
.forest-a { margin: 0; font-size: 15px; }
.forest-quote { margin: 0; padding-left: 10px; border-left: 3px solid var(--mint); color: var(--text-2); font-size: 13px; max-height: 9.5em; overflow-y: auto; }
.forest-grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.forest-grades .btn { padding: 0 4px; }
.forest-steps { display: flex; gap: 8px; flex-wrap: wrap; }
.forest-note { margin: 0; min-height: 1em; font-size: 12.5px; font-weight: 600; color: var(--accent-text); }

.forest-labels { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.forest-label {
  position: absolute; left: 0; top: 0; white-space: nowrap; pointer-events: none; transition: opacity .2s;
  font-family: var(--display); font-weight: 600; font-size: 13px; padding: 4px 11px; border-radius: var(--r-pill);
  background: var(--bg); color: var(--text); box-shadow: var(--raise-sm);
}
.forest-label small { margin-left: 6px; font-family: var(--font); font-weight: 500; color: var(--text-2); }
.forest-label.is-tag {
  border: 0; pointer-events: auto; cursor: pointer; font-family: var(--font); font-size: 12px; color: var(--accent-text);
}
.forest-label.is-tag.is-on { background: var(--mint); color: var(--on-mint); font-size: 13.5px; padding: 6px 14px; }
.forest-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.forest-tag {
  border: 0; padding: 6px 12px; border-radius: var(--r-pill); background: var(--bg); box-shadow: var(--raise-sm);
  color: var(--accent-text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.forest-tag small { margin-left: 4px; color: var(--text-2); font-weight: 500; }
.forest-tag:active { transform: scale(.96); }
.forest-tip {
  position: absolute; z-index: 3; max-width: 260px; display: flex; flex-direction: column; gap: 2px; pointer-events: none;
  padding: 8px 12px; border-radius: var(--r-md); background: var(--bg); box-shadow: var(--raise-sm); font-size: 13px;
}
.forest-tip span { color: var(--text-2); font-size: 12px; }
.forest-hint {
  position: absolute; z-index: 2; left: max(16px, env(safe-area-inset-left)); bottom: calc(16px + env(safe-area-inset-bottom));
  padding: 7px 14px; border-radius: var(--r-pill); box-shadow: var(--inset); background: var(--bg); color: var(--text-2); font-size: 12.5px;
}
@media (max-width: 760px) {
  .forest-panel { left: 12px; right: 12px; top: auto; width: auto; max-height: 23%; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .forest-panel-in { padding: 14px; gap: 10px; }
  #view-forest:not(.panel-open) .forest-panel { transform: translateY(calc(100% + 24px)); }
  .forest-hide { transform: rotate(90deg); }
  .forest-pip { top: auto; bottom: calc(16px + env(safe-area-inset-bottom)); }
  .forest-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { .forest-row, .forest-seg button, .forest-panel, .forest-pip { transition: none; } }

/* The review controls float over the card as they scroll; give them a frosted
   card of their own so the answer and picture underneath don't show through. */
.actions {
  padding: 14px;
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 10px 30px -12px var(--lo), 0 0 0 1px color-mix(in srgb, var(--hi) 60%, transparent) inset;
  z-index: 5;
}
body.is-phone .actions { padding: 10px; }

/* the review dock: small enough to leave the card room */
.actions { padding: 10px; }
.grades { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.grade { padding: 8px 2px; gap: 0; }
.grade b { font-size: 13px; }
.grade span { font-size: 11px; }
.grade kbd { display: none; }
.actions-extra { margin-top: 4px; gap: 4px; }
.actions-extra .btn { height: 28px; padding: 0 8px; font-size: 12px; }
.actions-extra .btn svg { width: 14px; height: 14px; }
.actions-extra kbd { display: none; }
@media (hover: hover) and (min-width: 700px) {
  .grade kbd, .actions-extra kbd { display: inline; }
}

/* today's streak, above the review card */
.goal-line { display: flex; align-items: center; gap: 12px; }
.goal-line .progress { flex: 1; min-width: 40px; }
.goal-text { flex: none; margin: 0; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.goal-text b { font-weight: 600; color: var(--text); }
.goal-line[data-done='1'] .goal-text b { color: var(--accent-text); }

/* the oak, between one card and the next */
.tree-beat {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; background: var(--bg);
  color: var(--text-2); font-size: 15px; cursor: pointer;
  animation: beat-in .16s ease-out backwards;
  -webkit-tap-highlight-color: transparent;
}
.tree-beat.is-leaving { opacity: 0; transition: opacity .16s ease-in; }
.tree-beat p { margin: 0; }
.tree-beat b { font-weight: 600; color: var(--text); }
.tree-beat-art { position: relative; width: 220px; height: 220px; }
.tree-beat-art span { position: absolute; inset: 0; transform-origin: 50% 90%; }
.tree-beat-art svg { display: block; width: 100%; height: 100%; }
/* the low-poly oak: each facet takes one shade (--c), mixed from the theme's
   leaf and bark colours; the same-colour stroke hides seams between facets */
.lowpoly path { fill: var(--c); stroke: var(--c); stroke-width: .35; stroke-linejoin: round; }
.lp-g0, .lp-g1 { --c: var(--leaf-new); }
.lp-g2, .lp-g3, .lp-g4, .lp-t0, .lp-t1, .lp-t2 { --c: var(--leaf-strong); }
.lp-b0, .lp-b1, .lp-b2, .lp-c0, .lp-c1, .lp-d0, .lp-d1, .lp-d2 { --c: var(--bark); }
@supports (color: color-mix(in oklab, red, blue)) {
  .lp-g0 { --c: color-mix(in oklab, var(--leaf-strong), #fff 34%); }
  .lp-g1 { --c: color-mix(in oklab, var(--leaf-strong), #fff 16%); }
  .lp-g3 { --c: color-mix(in oklab, var(--leaf-strong), #000 18%); }
  .lp-g4 { --c: color-mix(in oklab, var(--leaf-strong), #000 34%); }
  .lp-t0 { --c: color-mix(in oklab, color-mix(in oklab, var(--leaf-strong), var(--leaf-due) 28%), #fff 18%); }
  .lp-t1 { --c: color-mix(in oklab, var(--leaf-strong), var(--leaf-due) 28%); }
  .lp-t2 { --c: color-mix(in oklab, color-mix(in oklab, var(--leaf-strong), var(--leaf-due) 28%), #000 14%); }
  .lp-b0 { --c: color-mix(in oklab, var(--bark), #fff 18%); }
  .lp-b2 { --c: color-mix(in oklab, var(--bark), #000 28%); }
  .lp-c0 { --c: color-mix(in oklab, var(--bark), #000 40%); }
  .lp-c1 { --c: color-mix(in oklab, var(--bark), #000 55%); }
  .lp-d0 { --c: color-mix(in oklab, var(--bark), #000 8%); }
  .lp-d1 { --c: color-mix(in oklab, var(--bark), #000 22%); }
  .lp-d2 { --c: color-mix(in oklab, var(--bark), #000 36%); }
}
.tree-beat.has-grown .tree-old { animation: tree-out .3s ease-in .3s forwards; }
.tree-beat.has-grown .tree-new { animation: tree-grow .7s var(--spring, ease-out) .3s backwards; }
@keyframes beat-in { from { opacity: 0; } }
@keyframes tree-out { to { opacity: 0; } }
@keyframes tree-grow { from { opacity: 0; transform: scale(.82); } 60% { opacity: 1; transform: scale(1.06); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .tree-beat, .tree-beat .tree-old, .tree-beat .tree-new { animation: none; }
  .tree-beat.has-grown .tree-old { display: none; }
}

/* tags Gemini chose: the same chip, quieter, until the reader edits them */
.chip.is-auto { opacity: .72; border-style: dashed; }

/* the revealed card: each part under its own label */
.reveal .note { margin-top: 0; }
#s-nlabel { margin-top: 16px; }

/* ---------------- waiting for a reel just saved on the phone ---------------- */
.wait-pip { display: block; margin: 0 auto 12px; border-radius: 18px; animation: wait-bob 1.1s ease-in-out infinite alternate; }
@keyframes wait-bob { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-8px) rotate(3deg); } }
@media (prefers-reduced-motion: reduce) { .wait-pip { animation: none; } }

/* the Community card's link is an <a> styled as a button */
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.group-btns { display: flex; gap: 2px; }
.group-edit { display: flex; gap: 8px; width: 100%; }
.group-edit .text-field { width: 90px; }

/* ---------- "Text me" help bubble (always on, bottom left; above the sign-in screen, z 1000) ---------- */
.helpbubble {
  position: fixed; z-index: 1001; left: 12px; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px 8px 10px;
  border-radius: var(--r-pill); background: var(--surface); color: var(--text);
  text-decoration: none; font-size: 14px; font-weight: 600; box-shadow: var(--sh-2);
}
.helpbubble svg { width: 20px; height: 20px; }
/* on phones the review buttons stick to the bottom: keep them above the bubble */
@media (max-width: 600px) { .actions { bottom: 72px; } }

/* first run: a new account has nothing yet */
.first-run h2 { margin-bottom: 6px; }
.first-steps { max-width: 380px; margin: 18px auto 22px; padding: 0; list-style: none; counter-reset: fs; text-align: left; }
.first-steps li { position: relative; padding: 0 0 14px 40px; counter-increment: fs; line-height: 1.45; }
.first-steps li::before { content: counter(fs); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; background: var(--mint); color: var(--on-mint); box-shadow: var(--raise-sm); }
.first-steps a { color: inherit; font-weight: 700; text-decoration: underline; }
