/* anki — same old-pc look as eggi.fyi / lab: pale phosphor green on near-black, VT323 */
:root {
  --fg: #c9e8cf; --hi: #eef7f0; --accent: #6fdc8c; --dim: #6b7f70; --bg: #111312; --tile: #181c1a; --line: #262d29;
  --again: #e5737b; --hard: #e8b25a; --good: #6fdc8c; --easy: #6ab7e8;
  --new: #6ab7e8; --learn: #e5737b; --due: #6fdc8c;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body {
  color: var(--fg); font: 21px/1.4 "VT323", "Courier New", monospace; -webkit-font-smoothing: antialiased;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-x: hidden; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.dim { color: var(--dim); }
.small { font-size: .85em; }
.big { font-size: 1.6em; color: var(--hi); }
code { background: #1c211e; padding: 0 .25em; border-radius: 2px; }
.cursor { display: inline-block; width: .55em; height: 1em; background: var(--accent); vertical-align: -.12em; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.boot { max-width: 760px; margin: 40px auto; }

/* header */
.top { max-width: 760px; margin: 0 auto 22px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line); padding: 8px 0 10px; flex-wrap: wrap; }
.brand { color: var(--hi); font-size: 1.2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.top nav { display: flex; align-items: center; gap: 4px; }
.top nav a { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 6px; color: var(--fg); font-size: 1.05em; }
.top nav a:hover { background: var(--tile); color: var(--accent); }
.sync { display: flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--line); border-radius: 20px; padding: 2px 10px; cursor: pointer; color: var(--dim); font-size: .8em; margin-left: 4px; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.sync.ok i { background: var(--good); } .sync.busy i { background: var(--hard); animation: blink 1s steps(1) infinite; }
.sync.err i { background: var(--again); } .sync.err { color: var(--again); border-color: color-mix(in srgb, var(--again) 40%, transparent); }
main { max-width: 760px; margin: 0 auto; }
main.wide, .top.wide { max-width: 900px; }
h3 { font-weight: normal; color: var(--hi); margin: 1.6em 0 .5em; font-size: 1.1em; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; background: var(--tile); border: 1px solid var(--line); color: var(--fg);
  border-radius: 8px; padding: 6px 14px; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.big { background: color-mix(in srgb, var(--accent) 14%, var(--tile)); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--hi); padding: 8px 20px; }
.btn.danger:hover { border-color: var(--again); color: var(--again); }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0; align-items: center; }
.k { font-size: .7em; color: var(--dim); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 6px; }
@media (hover: none) { .k { display: none; } }

/* home */
.hello { padding: 24px 0; }
.hello p { margin: 0 0 14px; }
.today { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 18px; }
.decks { border-top: 1px solid var(--line); }
.deck, .dhead { display: grid; grid-template-columns: 1fr auto 32px; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); color: var(--fg); }
.dhead { font-size: .8em; padding: 4px; }
.deck:hover { background: var(--tile); }
.dname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cnt { display: grid; grid-template-columns: repeat(3, 52px); text-align: right; font-weight: normal; }
.cnt b, .scount b { font-weight: normal; }
.cn { color: var(--new); } .cl { color: var(--learn); } .cr { color: var(--due); }
.cnt b:not(.cn):not(.cl):not(.cr) { color: var(--dim); }
.cn:is(:empty), .cnt b.cn[data-z] { color: var(--dim); }
.opt { text-align: center; color: var(--dim); border-radius: 6px; padding: 2px 0; }
.opt:hover { color: var(--accent); background: var(--line); }
.done { color: var(--accent); margin: 0; }

/* study */
.bar { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 8px; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }
.scount { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.scount b { opacity: .55; } .scount b.on { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }
.tools { margin-left: auto; display: flex; gap: 4px; }
.tools button { background: none; border: 1px solid transparent; border-radius: 6px; color: var(--dim); width: 38px; height: 34px; cursor: pointer; font-size: 1.05em; }
.tools button:hover { color: var(--accent); border-color: var(--line); }
.card { background: var(--tile); border: 1px solid var(--line); border-radius: 14px; padding: 34px 22px; text-align: center; min-height: 42vh;
  display: flex; flex-direction: column; justify-content: center; gap: 10px; cursor: default; user-select: text; }
.card .es { font-size: 2.6em; line-height: 1.1; color: var(--hi); word-break: break-word; }
.card .es.sent { font-size: 1.8em; }
.card .en { font-size: 1.7em; color: var(--accent); }
.card .en.q { color: var(--hi); font-size: 2em; }
.card .ex { font-size: 1.25em; max-width: 34ch; margin: 0 auto; }
.card .hl { color: var(--accent); font-weight: normal; border-bottom: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent); }
.card hr { width: 100%; border: 0; border-top: 1px dashed var(--line); margin: 14px 0; }
.card .notes { font-size: 1em; color: var(--hard); max-width: 40ch; margin: 6px auto 0; }
.card .tag { color: var(--dim); font-size: .85em; text-transform: uppercase; letter-spacing: .1em; }
.typed { margin: 14px auto 0; width: min(100%, 420px); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; text-align: center; font-size: 1.3em; color: var(--hi); }
.typed:focus { outline: none; border-color: var(--accent); }
.typedres { font-size: 1.2em; } .typedres.ok { color: var(--good); } .typedres.near { color: var(--hard); } .typedres.bad { color: var(--again); }
.answer { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 14px; }
.answer.rev { grid-template-columns: repeat(4, 1fr); }
.show, .rate { min-height: 62px; border-radius: 10px; border: 1px solid var(--line); background: var(--tile); cursor: pointer; font-size: 1.05em; color: var(--hi); }
.show:hover { border-color: var(--accent); }
.rate { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.rate .ivl { font-size: .8em; color: var(--dim); }
.rate .k { margin: 2px 0 0; }
.r1 { border-color: color-mix(in srgb, var(--again) 50%, transparent); } .r1:hover, .r1:active { background: color-mix(in srgb, var(--again) 18%, var(--tile)); }
.r2 { border-color: color-mix(in srgb, var(--hard) 50%, transparent); } .r2:hover, .r2:active { background: color-mix(in srgb, var(--hard) 18%, var(--tile)); }
.r3 { border-color: color-mix(in srgb, var(--good) 50%, transparent); } .r3:hover, .r3:active { background: color-mix(in srgb, var(--good) 18%, var(--tile)); }
.r4 { border-color: color-mix(in srgb, var(--easy) 50%, transparent); } .r4:hover, .r4:active { background: color-mix(in srgb, var(--easy) 18%, var(--tile)); }
.finished { text-align: center; padding: 60px 0; } .finished .actions { justify-content: center; }

/* forms */
.form label { display: block; margin-bottom: 14px; color: var(--dim); font-size: .9em; }
.form input:not([type=checkbox]):not([type=range]), .form select, .form textarea, .filters input, .filters select {
  display: block; width: 100%; margin-top: 4px; background: var(--tile); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; color: var(--hi); font-size: 1.1em; }
.form input:focus, .form select:focus, .form textarea:focus, .filters input:focus { outline: none; border-color: var(--accent); }
.form input[type=range] { width: 100%; accent-color: var(--accent); margin-top: 10px; }
.form .row { display: flex; gap: 8px; align-items: stretch; } .form .row input { flex: 1; } .form .row .btn { margin-top: 4px; white-space: nowrap; }
.form label.check { display: flex; gap: 10px; align-items: center; color: var(--fg); }
.form label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.import { margin-top: 20px; } .import summary { cursor: pointer; color: var(--accent); }
.cardinfo { padding-left: 1.2em; }

/* browse */
.filters { display: grid; grid-template-columns: 1fr 200px; gap: 10px; margin-bottom: 12px; }
.list a { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 12px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--line); color: var(--fg); }
.list a:hover { background: var(--tile); }
.list .es { color: var(--hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .en { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: .75em; border-radius: 10px; padding: 0 8px; border: 1px solid var(--line); }
.pill.n { color: var(--new); } .pill.l { color: var(--learn); } .pill.r { color: var(--due); } .pill.s { color: var(--dim); }

/* library */
.libdeck { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.libdeck p { margin: 4px 0 0; }

/* stats */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; border-bottom: 1px solid var(--line); }
.bars i { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 1px; opacity: .8; }
.bars.fc i { background: var(--easy); } .bars i:hover { opacity: 1; }
.stack { display: flex; height: 18px; border-radius: 4px; overflow: hidden; gap: 2px; }
.stack i, .legend i { background: var(--dim); }
.stack .n, .legend .n { background: var(--new); } .stack .l, .legend .l { background: var(--learn); }
.stack .y, .legend .y { background: #46a563; } .stack .m, .legend .m { background: var(--good); } .stack .s, .legend .s { background: #333; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; } .legend span { display: flex; align-items: center; gap: 6px; } .legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* guide */
.guide p, .guide li { max-width: 64ch; } .guide ul { padding-left: 1.2em; } .guide li { margin-bottom: 6px; } .guide b { color: var(--hi); font-weight: normal; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--tile); border: 1px solid var(--accent);
  color: var(--hi); padding: 8px 16px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; z-index: 10; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  body { font-size: 19px; }
  .top nav a { width: 32px; }
  .sync span { display: none; } .sync { padding: 6px 8px; }
  .card { min-height: 46vh; padding: 26px 14px; }
  .card .es { font-size: 2.2em; } .card .es.sent { font-size: 1.5em; }
  .cnt { grid-template-columns: repeat(3, 40px); }
  .grid2 { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .list a { grid-template-columns: 1fr auto; } .list .en { grid-column: 1; grid-row: 2; font-size: .9em; } .list .pill { grid-row: 1 / span 2; grid-column: 2; }
  /* thumb zone: answer buttons pinned to the bottom while studying */
  .answer { position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); background: var(--bg); padding-top: 8px; }
}
@media (prefers-reduced-motion: reduce) { .cursor, .sync.busy i { animation: none; } .bar i { transition: none; } }

/* ---- heatmap (GitHub-style: fixed cells, columns = weeks) */
.heatwrap { overflow-x: auto; margin: 6px 0 4px; scrollbar-width: thin; }
.heat { display: grid; grid-template-rows: 14px repeat(7, var(--cell)); gap: var(--gap); width: max-content; font-size: 12px; line-height: 1; }
.heat i { width: var(--cell); height: var(--cell); border-radius: 2px; background: #1c221e; }
.heat .mo { grid-row: 1; color: var(--dim); white-space: nowrap; align-self: end; }
.heat .wd { grid-column: 1; color: var(--dim); align-self: center; }
.heat i.l1, .heatlegend i.l1 { background: #1f4a2c; } .heat i.l2, .heatlegend i.l2 { background: #2b7040; }
.heat i.l3, .heatlegend i.l3 { background: #3f9e5b; } .heat i.l4, .heatlegend i.l4 { background: #6fdc8c; }
.heat i.lf { background: transparent; }
.heat i.today { outline: 1px solid var(--hi); outline-offset: -1px; }
.heat i[data-tip]:hover { outline: 1px solid var(--fg); outline-offset: -1px; }
.heatlegend { display: flex; align-items: center; justify-content: flex-end; gap: 3px; margin: 2px 0 22px; }
.heatlegend i { width: 11px; height: 11px; border-radius: 2px; background: #1c221e; }
.heatlegend span { margin: 0 4px; }

/* ---- stats */
.statsf { grid-template-columns: auto 1fr; align-items: center; }
.seg-ctl { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-ctl button { background: var(--tile); border: 0; border-right: 1px solid var(--line); color: var(--dim); padding: 6px 12px; cursor: pointer; min-height: 38px; }
.seg-ctl button:last-child { border-right: 0; }
.seg-ctl button.on { background: color-mix(in srgb, var(--accent) 16%, var(--tile)); color: var(--hi); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0 6px; }
.kpi { background: var(--tile); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; min-width: 0; }
.kpi .big { font-size: 1.7em; line-height: 1.05; }
.kpi .klabel { color: var(--fg); }
.cards2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.panel { background: var(--tile); border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px 12px; min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel h3 { margin: .6em 0 .5em; }
.chart { position: relative; }
.plot { position: relative; margin-left: 30px; }
.plot .grid i { position: absolute; left: 0; right: 0; border-top: 1px dashed #26302a; }
.plot .ytick { position: absolute; right: calc(100% + 6px); transform: translateY(50%); font-size: 13px; line-height: 1; }
.cols { position: absolute; inset: 0; display: flex; align-items: stretch; gap: 2px; border-bottom: 1px solid #39443d; }
.cols.dense { gap: 1px; }
.col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-width: 0; cursor: default; }
.col i { display: block; min-height: 2px; }
.col i:first-child { border-radius: 4px 4px 0 0; }
.cols.dense .col i:first-child { border-radius: 2px 2px 0 0; }
.col:hover { background: rgba(255,255,255,.04); }
.xaxis { display: flex; justify-content: space-between; margin: 4px 0 0 30px; }
.chart .legend { margin: 8px 0 0 30px; }
.plot.line svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.plot.line { border-bottom: 1px solid #39443d; }
.plot .endlabel { position: absolute; right: 0; transform: translateY(-4px); font-size: 14px; color: var(--hi); background: var(--tile); padding: 0 4px; }
.plot .hits { position: absolute; inset: 0; }
.plot .hits div { position: absolute; top: 0; bottom: 0; }
.plot .hits div:hover { background: rgba(255,255,255,.05); }
.segrow { display: grid; grid-template-columns: 76px 1fr 44px; align-items: center; gap: 10px; margin: 6px 0; }
.seg { display: flex; gap: 2px; height: 24px; border-radius: 4px; overflow: hidden; }
.seg i { display: grid; place-items: center; font-style: normal; font-size: 14px; color: #0d0f0e; min-width: 2px; }
.segn { text-align: right; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--fg); }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.stack i[data-tip] { cursor: default; }
#tip { position: fixed; z-index: 20; pointer-events: none; background: #0b0d0c; color: var(--hi); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; font-size: 16px; max-width: min(320px, 90vw); opacity: 0; transition: opacity .1s; }
#tip.show { opacity: 1; }
@media (max-width: 760px) { .cards2 { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(2, 1fr); } .statsf { grid-template-columns: 1fr; } .seg-ctl { width: 100%; } .seg-ctl button { flex: 1; padding: 6px 4px; } }
