/* Lexicon layout: sidebar on wide screens, bottom tab bar on phones, grouped inset lists, sheets. Colours come from theme.css. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
.hidden { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- frame ---------- */
.app { display: flex; min-height: 100dvh; }
.side { display: none; }
.main { flex: 1; min-width: 0; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

.top { position: sticky; top: 0; z-index: 20; background: var(--bar); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  padding-top: env(safe-area-inset-top); border-bottom: 1px solid transparent; transition: border-color .2s; }
.top.scrolled { border-bottom-color: var(--line); }
.top .bar { display: flex; align-items: center; gap: 8px; height: 48px; }
.top .small-title { flex: 1; text-align: center; font-weight: 650; opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .3s var(--spring); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top.scrolled .small-title { opacity: 1; transform: none; }
.top .bar .slot { width: 88px; display: flex; gap: 4px; }
.top .bar .slot.r { justify-content: flex-end; }
.large-title { font-size: 32px; line-height: 1.15; font-weight: 750; letter-spacing: -.02em; margin: 2px 0 2px; }
.subtitle { color: var(--dim); margin: 0 0 14px; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: var(--r-pill); border: 0; background: transparent; color: var(--accent); transition: background .15s, transform .15s; }
.icon-btn:hover { background: var(--fill); }
.icon-btn:active { transform: scale(.92); background: var(--fill-press); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  background: var(--bar); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabbar button { flex: 1; max-width: 120px; border: 0; background: none; color: var(--faint); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 550; padding: 4px 0; position: relative; }
.tabbar button svg.i { width: 24px; height: 24px; }
.tabbar button.on { color: var(--accent); }
.badge { position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.side .badge { position: static; margin-left: auto; }

@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100dvh; width: 248px; flex: none; padding: 18px 12px; border-right: 1px solid var(--line); background: var(--surface-2); }
  .side .brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; padding: 6px 10px 16px; }
  .side .brand img { width: 28px; height: 28px; border-radius: 7px; }
  .side nav button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 9px 10px; border-radius: var(--r-sm); font-weight: 550; color: var(--muted); text-align: left; }
  .side nav button:hover { background: var(--fill); }
  .side nav button.on { background: var(--accent-soft); color: var(--accent); }
  .side .add-big { margin-top: 14px; }
  .side .spacer { flex: 1; }
  .side .foot { color: var(--faint); font-size: 13px; padding: 8px 10px; }
  .tabbar { display: none; }
  .main { padding-bottom: 40px; }
  .wrap { padding: 0 32px; }
  .large-title { font-size: 34px; }
}

/* ---------- grouped inset lists ---------- */
.section-h { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); margin: 22px 4px 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-h .link { text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 550; color: var(--accent); background: none; border: 0; padding: 0; }
.group { background: var(--surface); border-radius: var(--r); box-shadow: var(--card-shadow); overflow: hidden; }
.group + .group { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 11px 16px; border: 0; background: none; text-align: left; position: relative; transition: background .15s; }
.row + .row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--line); }
button.row:hover { background: var(--surface-2); }
button.row:active { background: var(--fill-press); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; }
.row .s { color: var(--dim); font-size: 14px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .s.one { -webkit-line-clamp: 1; }
.row .chev { color: var(--faint); }
.row .val { color: var(--dim); }
.row label { flex: none; width: 112px; color: var(--muted); }
.row input, .row select, .row textarea { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 2px 0; }
.row textarea { resize: vertical; min-height: 44px; }
.row.stack { flex-direction: column; align-items: stretch; gap: 4px; }
.row.stack label { width: auto; font-size: 13px; color: var(--dim); }
.row select { appearance: none; -webkit-appearance: none; text-align: right; color: var(--dim); }
.empty { text-align: center; color: var(--dim); padding: 36px 20px; }
.empty .big { font-size: 40px; margin-bottom: 6px; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

.dots { display: inline-flex; gap: 3px; flex: none; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--line); }
.dots i.on { background: var(--good); }
.star { color: var(--star); }

/* ---------- controls ---------- */
.search { position: relative; margin: 2px 0 12px; }
.search input { width: 100%; height: 38px; border: 0; border-radius: 10px; background: var(--fill); padding: 0 12px 0 36px; outline: none; }
.search input:focus { box-shadow: 0 0 0 2px var(--accent-soft); }
.search svg { position: absolute; left: 10px; top: 9px; width: 18px; height: 18px; color: var(--faint); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; background: var(--fill); color: var(--muted); padding: 6px 12px; border-radius: var(--r-pill); font-size: 14px; font-weight: 550; white-space: nowrap; }
.chip.on { background: var(--text); color: var(--bg); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; padding: 0 18px; border-radius: var(--r); border: 0; background: var(--fill); color: var(--text); font-weight: 600; transition: transform .15s var(--spring), background .15s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.seg { display: flex; background: var(--fill); border-radius: 10px; padding: 2px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: none; height: 32px; border-radius: 8px; font-weight: 600; color: var(--muted); transition: background .2s var(--spring); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.toggle { position: relative; width: 51px; height: 31px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; background: var(--line); border-radius: 16px; transition: background .2s; }
.toggle span::after { content: ''; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .3s var(--spring); }
.toggle input:checked + span { background: var(--good); }
.toggle input:checked + span::after { transform: translateX(20px); }

/* ---------- cards (today, review) ---------- */
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--card-shadow); padding: 20px; }
.card + .card { margin-top: 14px; }
.card .kicker { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-bottom: 10px; }
.card .term { font-size: 30px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; }
.card .meta { color: var(--dim); margin: 4px 0 10px; }
.card .def { font-size: 17px; }
.card .ex { color: var(--muted); font-style: italic; margin-top: 10px; }
.card blockquote { margin: 0; font-family: var(--serif); font-size: 22px; line-height: 1.4; }
.card .by { color: var(--dim); margin-top: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat { background: var(--surface); border-radius: var(--r); box-shadow: var(--card-shadow); padding: 12px 14px; border: 0; text-align: left; }
.stat b { display: block; font-size: 22px; font-weight: 750; }
.stat span { color: var(--dim); font-size: 13px; }
@media (min-width: 700px) { .today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; } .today-grid .card + .card { margin-top: 0; } }

.flash { min-height: 300px; display: flex; flex-direction: column; justify-content: center; text-align: center; cursor: pointer; transition: transform .35s var(--spring); }
.flash:active { transform: scale(.99); }
.flash .answer { text-align: left; margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.grades .btn { flex-direction: column; height: 58px; gap: 0; font-size: 15px; }
.grades .btn small { font-weight: 500; color: var(--dim); font-size: 12px; }
.grades .again { background: var(--bad-soft); color: var(--bad); }
.grades .hard { background: var(--warn-soft); color: var(--warn); }
.grades .good { background: var(--good-soft); color: var(--good); }
.grades .easy { background: var(--accent-soft); color: var(--accent); }
.progress { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-bottom: 14px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .4s var(--spring); }

/* ---------- sheet ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.32); opacity: 0; transition: opacity .25s; }
.scrim.open { opacity: 1; }
.sheet { position: fixed; z-index: 51; left: 0; right: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column; background: var(--bg); border-radius: 14px 14px 0 0; box-shadow: var(--float);
  transform: translateY(100%); transition: transform .45s var(--spring); }
.sheet.open { transform: none; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--border); margin: 6px auto 0; flex: none; }
.sheet .sh { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px 6px; flex: none; }
.sheet .sh h2 { margin: 0; font-size: 17px; font-weight: 650; flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet .sh .txt-btn { border: 0; background: none; color: var(--accent); font-weight: 550; padding: 8px; min-width: 64px; }
.sheet .sh .txt-btn.r { text-align: right; font-weight: 650; }
.sheet .sb { overflow-y: auto; padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 600px; max-height: 86dvh; border-radius: var(--r-lg); transform: translate(-50%, -46%) scale(.97); opacity: 0; transition: transform .4s var(--spring), opacity .2s; }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet .grab { display: none; }
  .sheet .sh { padding-top: 10px; }
}

.tagline { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--fill); color: var(--muted); border-radius: var(--r-pill); padding: 2px 10px; font-size: 13px; }
.note { padding: 10px 14px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); margin-top: 12px; }
.note.good { background: var(--good-soft); color: var(--good); }
.note.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- toast, login, misc ---------- */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 80; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--r-pill); font-weight: 550; max-width: calc(100vw - 32px); box-shadow: var(--float); transition: opacity .25s, transform .4s var(--spring); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) { .toast { bottom: 32px; } }
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login .box { width: 100%; max-width: 400px; text-align: center; }
.login img { width: 72px; height: 72px; border-radius: 16px; box-shadow: var(--card-shadow); }
.login h1 { font-size: 28px; margin: 14px 0 4px; letter-spacing: -.02em; }
.login p { color: var(--dim); margin: 0 0 18px; }
.login .group { text-align: left; margin-bottom: 12px; }
.login-links { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.login-links .link { background: none; border: 0; padding: 4px; font: inherit; font-size: 15px; color: var(--accent); cursor: pointer; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; justify-content: center; padding: 40px; color: var(--faint); }
.fade-in { animation: fadeIn .35s var(--spring); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.more { display: flex; justify-content: center; margin: 14px 0; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* small fixes after the first screenshots */
.row .t svg.star { width: 14px; height: 14px; vertical-align: -1px; margin-left: 2px; }
@media (min-width: 900px) { .top .slot.r .icon-btn[data-add] { display: none; } }
