/* Deck — study and the word list. The look is the website's Deck v2: one
 * hue per meaning on the rating row (crimson Again, indigo Got it, green Easy)
 * and ink on paper everywhere else. */

.deck-wrap { max-width: 620px; margin: 0 auto; }

/* The decks as one switch (a level of words ▾ | Kanji), the lists beside it. */
.deck-tabs { display: flex; align-items: center; justify-content: space-between; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: 0 -2px; }
.deck-tabs::-webkit-scrollbar { display: none; }
.deck-seg { flex: none; display: inline-flex; gap: 2px; padding: 3px; border-radius: 13px; background: var(--border); }
.deck-tab {
  appearance: none; flex: none; display: inline-flex; align-items: center; gap: 4px;
  height: 34px; padding: 0 13px; border-radius: 10px; border: 0; background: transparent;
  color: var(--ink-mid); font-weight: 700; font-size: .86rem; white-space: nowrap; transition: background .15s, color .15s;
}
.deck-tab:hover:not(.active) { color: var(--ink); }
.deck-tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(22, 24, 26, .12), 0 0 0 .5px rgba(22, 24, 26, .06); }
html[data-theme="dark"] .deck-seg { background: var(--sunken); }
html[data-theme="dark"] .deck-tab.active { background: var(--line-2); }
.tab-chev { display: inline-flex; color: var(--ink-soft); margin-right: -3px; }
.tab-chev svg { width: 14px; height: 14px; }
.deck-lists { flex: none; display: inline-flex; gap: 4px; }
.deck-list {
  appearance: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--ink-mid); font-weight: 700; font-size: .84rem; white-space: nowrap;
}
.deck-list:hover:not(:disabled) { color: var(--ink); background: var(--surface); }
.deck-list.active { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.deck-list:disabled { opacity: .45; cursor: default; }
.dl-star { display: inline-flex; }
.dl-star svg { width: 15px; height: 15px; }
.tab-saved.active .dl-star, .tab-saved .dl-star { color: var(--ink-soft); }
.tab-n { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: .7rem; font-weight: 800; background: var(--border); color: var(--ink-mid); font-variant-numeric: tabular-nums; }
.tab-weak .tab-n { background: var(--red-bg); color: var(--red); }
.tab-level-wrap { position: relative; flex: none; }
.level-dropdown {
  display: none; position: fixed; z-index: 50; margin-top: 6px; min-width: 190px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-2);
}
.tab-level-wrap.open .level-dropdown { display: block; }
.level-option { appearance: none; width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; background: transparent; padding: 10px 12px; border-radius: 9px; font-weight: 650; font-size: .9rem; color: var(--ink); text-align: left; }
.level-option:hover { background: var(--sunken); }
.level-option.active { color: var(--red); }
.lo-n { font-size: .75rem; color: var(--ink-soft); font-weight: 600; }

.deck-stats { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin: 12px 0 10px; font-size: .78rem; color: var(--ink-soft); font-weight: 600; letter-spacing: .02em; }
.deck-stats .st { display: inline-flex; align-items: center; gap: 6px; }
.deck-stats b { color: var(--ink); font-weight: 800; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.new { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.dot.learning { background: var(--ink-soft); }
.dot.mastered { background: var(--green); }

.daily-goal { margin: 2px 2px 12px; }
.dg-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.dg-label { font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.dg-count { font-weight: 800; font-variant-numeric: tabular-nums; }
.dg-of { font-weight: 600; color: var(--ink-soft); font-size: .85rem; }
.dg-bar { height: 6px; border-radius: 999px; background: var(--paper); overflow: hidden; margin-top: 8px; }
.dg-bar span { display: block; height: 100%; background: var(--ink); border-radius: inherit; transition: width .3s; }
.daily-goal.is-hit .dg-label { color: var(--green); }
.daily-goal.is-hit .dg-bar span { background: var(--green); }

.study-counter { text-align: center; font-size: .78rem; font-weight: 700; color: var(--ink-soft); letter-spacing: .06em; margin: 6px 0 8px; font-variant-numeric: tabular-nums; min-height: 1.2em; }

.flashcard {
  position: relative; display: flex; flex-direction: column; justify-content: center;
  min-height: 300px; padding: 46px 22px 26px; border-radius: 20px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
  -webkit-user-select: none; user-select: none; outline: none;
}
/* Unrevealed, the card reaches down to where the rating row will be, so a tap
   "where Easy is" flips the card and lands the finger on Easy next. */
.flashcard.front-only { min-height: 380px; }
.flashcard.flip-in { animation: cardIn .22s var(--ease); }
@keyframes cardIn { from { opacity: .4; transform: translateY(6px) scale(.99); } to { opacity: 1; transform: none; } }
.fc-corner { position: absolute; top: 14px; left: 16px; display: flex; gap: 8px; align-items: center; }
.fc-num { font-size: .7rem; font-weight: 800; letter-spacing: .1em; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.fc-lapses { font-size: .66rem; font-weight: 800; color: var(--red); background: var(--red-bg); border: 1px solid var(--red-ln); padding: 2px 7px; border-radius: 999px; }
.fc-save { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink-soft); border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
.fc-save svg { width: 20px; height: 20px; }
.fc-save:hover { color: var(--casual); }
.fc-save.is-saved { color: var(--casual); }
.fc-save.is-saved svg { fill: currentColor; }
.fc-body { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.fc-word { font-size: clamp(2.6rem, 11vw, 3.6rem); font-weight: 700; line-height: 1.35; color: var(--ink); word-break: keep-all; overflow-wrap: anywhere; }
.fc-word.is-long { font-size: clamp(2rem, 8vw, 2.8rem); }
.fc-word rt { font-size: .38em; }
.fc-hint {
  appearance: none; font: inherit; font-size: .74rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-soft); background: transparent; border: 1px solid var(--border); border-radius: 999px;
  min-height: 36px; padding: 0 16px; margin-top: 6px;
}
.fc-hint:hover { color: var(--ink); border-color: var(--line-2); }
.fc-back { width: 100%; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; text-align: center; animation: fadeUp .18s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.fc-pos { font-size: .72rem; font-weight: 700; letter-spacing: .06em; color: var(--ink-soft); text-transform: uppercase; }
.fc-meaning { font-size: 1.3rem; font-weight: 800; color: var(--ink); margin: 4px 0 10px; line-height: 1.35; }
.fc-ex-label { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); margin-top: 8px; }
.tts-btn.sm { width: 30px; height: 30px; }
.tts-btn.sm svg { width: 13px; height: 13px; }
.fc-example { font-size: 1.12rem; line-height: 2; color: var(--ink); margin-top: 2px; }
.fc-example-en { font-size: .9rem; color: var(--ink-soft); line-height: 1.5; }

.rate-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.rate-btn {
  appearance: none; position: relative; min-height: 58px; border-radius: 14px; font-weight: 800; font-size: 1rem;
  border: 1.5px solid; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: background .12s, transform .1s;
}
.rate-btn:active, .rate-btn.is-hit { transform: scale(.97); }
.rate-btn.again { color: var(--red); border-color: var(--red-ln); }
.rate-btn.got { color: var(--polite); border-color: var(--polite-ln); }
.rate-btn.easy { color: var(--green); border-color: var(--green-ln); }
.rate-btn.again:hover, .rate-btn.again.is-hit { background: var(--red-bg); }
.rate-btn.got:hover, .rate-btn.got.is-hit { background: var(--polite-bg); }
.rate-btn.easy:hover, .rate-btn.easy.is-hit { background: var(--green-bg); }
.rate-key { display: none; font-size: .7rem; opacity: .7; font-weight: 700; }
body.has-keyboard .rate-key { display: block; }

.card-tools { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.tool-btn { appearance: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-mid); height: 36px; padding: 0 12px; border-radius: 10px; font-weight: 700; font-size: .82rem; }
.tool-btn svg { width: 16px; height: 16px; }
.tool-btn:disabled { opacity: .45; }
.tool-link { text-decoration: none; }
.tool-link:hover { color: var(--ink); border-color: var(--line-2); }
.tool-hint { font-size: .74rem; color: var(--ink-soft); display: none; }
@media (hover: hover) and (pointer: fine) { .tool-hint { display: inline; } }

.study-done { text-align: center; padding: 34px 18px 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; }
.done-check { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 900; color: var(--green); background: var(--green-bg); border: 1px solid var(--green-ln); }
.done-title { font-size: 1.2rem; font-weight: 800; color: var(--ink); }
.done-sub { color: var(--ink-soft); margin-top: 6px; }
.done-backlog { color: var(--casual); font-weight: 650; margin-top: 10px; font-size: .9rem; }
.done-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }

/* ── Words ── */
.words-wrap { max-width: 720px; margin: 0 auto; }
.words-search { position: sticky; top: calc(var(--top-h) + var(--safe-t)); z-index: 10; padding: 8px 0 10px; background: var(--paper); }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-soft); pointer-events: none; }
.search-box .input { padding-left: 42px; border-radius: 14px; }
.acc { border: 1px solid var(--border); background: var(--surface); border-radius: 14px; margin-bottom: 10px; overflow: hidden; }
.acc-head { appearance: none; width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; min-height: 54px; padding: 0 16px; text-align: left; font-weight: 800; color: var(--ink); }
.acc-head:disabled { cursor: default; color: var(--ink-soft); }
.acc-label { flex: 1; }
.acc-count { font-size: .8rem; color: var(--ink-soft); font-weight: 650; font-variant-numeric: tabular-nums; }
.acc-chev { color: var(--ink-soft); transition: transform .2s; }
.acc.open .acc-chev { transform: rotate(180deg); }
.acc-empty { padding: 0 16px 14px; color: var(--ink-soft); font-size: .86rem; margin-top: -4px; }
.word-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.word-item + .word-item { border-top: 1px solid var(--border); }
.word-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer; min-height: 52px; }
.word-row:hover { background: var(--sunken); }
.word-row:focus-visible { outline-offset: -3px; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--line-2); }
.state-dot.learning { background: var(--ink-soft); }
.state-dot.mastered { background: var(--green); }
.w-main { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.w-word { font-size: 1.12rem; font-weight: 600; color: var(--ink); line-height: 1.8; }
.w-meaning { font-size: .88rem; color: var(--ink-soft); }
.w-right { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: .78rem; }
.w-star { color: var(--casual); }
.w-lapse { color: var(--red); font-weight: 700; }
.freq-tag { font-size: .64rem; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: var(--sunken); border: 1px solid var(--border); }
.word-detail { display: none; padding: 0 16px 14px 36px; }
.word-item.open .word-detail { display: block; }
.detail-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.detail-pos { font-size: .72rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }
.detail-example { font-size: 1.02rem; line-height: 2; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-example-en { font-size: .86rem; color: var(--ink-soft); }
.words-more { display: block; margin: 0 auto; }

/* A phone: Saved as its star and count, so the row fits without scrolling. */
@media (max-width: 420px) { .deck-list .dl-text { display: none; } .deck-tab { padding: 0 11px; } .deck-list { padding: 0 9px; } }

/* On a computer the word list sits in the rail (as on the website): the same
   lists, drawn small. The rail scrolls; its search stays at the top. */

@media (min-width: 900px) { .narrow-only { display: none !important; } }
.rail-words { padding-top: 4px; }
.rail-words .words-search { top: -6px; padding: 6px 0 8px; background: var(--surface); }
html[data-theme="dark"] .rail-words .words-search { background: var(--sunken); }
.rail-words .search-box svg { left: 11px; width: 15px; height: 15px; }
.rail-words .search-box .input { padding: 8px 10px 8px 34px; font-size: .86rem; border-radius: 10px; min-height: 0; }
.rail-words .acc { border-radius: 10px; margin-bottom: 6px; }
.rail-words .acc-head { min-height: 40px; padding: 0 10px; font-size: .84rem; }
.rail-words .acc-empty { padding: 0 10px 10px; font-size: .78rem; }
.rail-words .word-row { gap: 8px; padding: 6px 10px; min-height: 40px; }
.rail-words .w-main { gap: 0 8px; }
.rail-words .w-word { font-size: .95rem; line-height: 1.7; }
.rail-words .w-meaning { font-size: .76rem; flex-basis: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
.rail-words .freq-tag { display: none; }
.rail-words .word-detail { padding: 0 10px 10px 26px; }
.rail-words .detail-example { font-size: .88rem; line-height: 1.8; }
.rail-words .detail-example-en { font-size: .76rem; }
