/* Yomikit reader (the main page). The shared design, colours and fonts are in site.css; this is the reader's own layer. */

body.app { height: auto; min-height: 100vh; overflow-x: hidden; overflow-y: auto; display: block; }
.app-main { max-width: 1080px; margin: 0 auto; padding: 0 32px 48px; box-sizing: border-box; }
body.app .card { background: var(--card); border-radius: var(--r-card); }

/* ---- the text card ---- */
.src { padding: 16px 16px 16px 20px; }
.src-hd { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nt { position: relative; }
.nt-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--tint); color: var(--accent); font: 500 11px var(--mono); }
.src-title {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 46ch; padding: 4px 8px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: 500 18px/1.3 var(--serif-jp); cursor: text;
}
.src-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-title svg { flex-shrink: 0; width: 14px; height: 14px; color: var(--muted); opacity: 0; transition: opacity 0.15s; }
.src-title:not(:disabled):hover { background: var(--tint); }
.src-title:not(:disabled):hover svg { opacity: 1; }
.src-title:disabled { cursor: default; color: var(--muted); }
.src-title:disabled svg { display: none; }
.src-status { display: inline-flex; align-items: center; gap: 6px; font: 12px var(--mono); color: var(--muted); white-space: nowrap; }
.src-status:not(:empty)::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.src-spacer { flex: 1; }
body.app .input-wrap { position: relative; flex: none; overflow: visible; margin-top: 10px; }
body.app #input {
  display: block; width: 100%; height: 180px; min-height: 120px; box-sizing: border-box; padding: 8px 4px; resize: vertical;
  border: 0; border-radius: 0; background: transparent; box-shadow: none; outline: none;
  color: var(--text); font: 18px/2.1 var(--jp-sans);
}
body.app #input:focus { border: 0; box-shadow: none; }
body.app .input-ghost {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px dashed var(--line-2); border-radius: 16px; background: var(--card); pointer-events: none;
}
body.app .input-ghost-jp { font: 17px/1.8 var(--jp-sans); color: var(--text-2); }
body.app .input-ghost-jp rt { font-size: 9px; color: var(--accent); }
body.app .input-ghost-en { font: 13px/1.4 var(--ui); color: var(--muted); }
.src-strip { display: none; align-items: center; gap: 16px; margin-top: 10px; padding: 4px; cursor: pointer; color: var(--text-2); }
.src-strip-txt { flex: 1; min-width: 0; font: 15px/1.7 var(--jp-sans); white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.src.collapsed .input-wrap { display: none; }
.src.collapsed .src-strip { display: flex; }

/* ---- the notes menu ---- */
.nt-drop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 200; width: min(360px, calc(100vw - 32px));
  max-height: min(70vh, 520px); overflow-y: auto; padding: 12px 8px 8px;
  background: var(--pop); border: 1px solid var(--line); border-radius: var(--r-pop);
}
.nt-search { display: block; width: calc(100% - 8px); height: 38px; margin: 0 4px 8px; padding: 0 14px; box-sizing: border-box; border: 0; border-radius: 999px; background: var(--bg); color: var(--text); font: 13px var(--ui); outline: none; }
.nt-new { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 12px; background: none; color: var(--accent); font: 500 14px var(--ui); text-align: left; cursor: pointer; }
.nt-new:hover { background: var(--tint); }
.nt-list h4 { margin: 0; padding: 12px 12px 6px; font: 500 11px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.nt-row { position: relative; display: flex; align-items: center; gap: 4px; border-radius: 12px; }
.nt-row:hover, .nt-row.on { background: var(--tint); }
.nt-row.on::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent); }
.nt-open {
  flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 12px; padding: 9px 8px 9px 12px; border: 0; border-radius: 12px;
  background: none; color: var(--text); font: 15px/1.4 var(--jp-sans); text-align: left; cursor: pointer;
}
.nt-list > .nt-open { width: 100%; }
.nt-list > .nt-open:hover, .nt-list > .nt-open.on { background: var(--tint); }
.nt-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-date { flex-shrink: 0; font: 12px var(--mono); color: var(--muted); }
.nt-more { flex-shrink: 0; width: 30px; height: 30px; margin-right: 4px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; }
.nt-more:hover { background: var(--bg); color: var(--text); }
.nt-menu { position: absolute; right: 8px; top: calc(100% - 4px); z-index: 5; display: grid; min-width: 150px; padding: 6px; background: var(--card); border: 1px solid var(--line-2); border-radius: 14px 14px 14px 4px; }
.nt-menu button { padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font: 14px var(--ui); text-align: left; cursor: pointer; }
.nt-menu button:hover { background: var(--tint); }
.nt-menu button:last-child { color: var(--danger); }
.nt-rename { flex: 1; min-width: 0; padding: 4px 8px; border: 1px solid var(--accent); border-radius: 8px; background: var(--bg); color: var(--text); font: 15px var(--jp-sans); outline: none; }
.nt-empty { margin: 4px 12px 8px; font: 13px/1.5 var(--ui); color: var(--muted); }
.nt-login { display: block; width: calc(100% - 24px); height: 36px; margin: 10px 12px 4px; border: 1px dashed var(--accent); border-radius: 999px; background: none; color: var(--accent); font: 500 13px var(--ui); cursor: pointer; }

/* ---- the reading card ---- */
.out { margin-top: 20px; overflow: clip; }
.out-hd {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px 0; background: var(--card); border-bottom: 1px solid var(--line);
}
.out-tabs { display: flex; gap: 26px; }
body.app .out-tabs .tab {
  margin-bottom: -1px; padding: 10px 0 14px; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: none; box-shadow: none; color: var(--muted); font: 500 14px var(--ui); letter-spacing: 0; text-transform: none; cursor: pointer;
}
body.app .out-tabs .tab:hover { color: var(--text); }
body.app .out-tabs .tab.active { color: var(--text); border-bottom-color: var(--accent); }
.out-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; padding-bottom: 10px; }
body.app .disp-select { display: none; }
.stepper { display: inline-flex; align-items: center; height: 36px; border: 1px solid var(--line-2); border-radius: 999px; }
.stepper button { width: 38px; height: 34px; border: 0; background: none; color: var(--text-2); font-family: var(--ui); font-weight: 500; cursor: pointer; }
.stepper button:hover { color: var(--text); }
.stepper .step-dn { font-size: 11px; }
.stepper .step-up { font-size: 15px; }
.stepper span { width: 1px; height: 16px; background: var(--line-2); }

/* the reading itself: about 35 characters a line, centred, plenty of air */
body.app .furigana-out {
  flex: none; min-height: 50vh; max-width: calc(35 * 1.25em); margin: 0 auto; padding: 56px 32px 72px; overflow: visible;
  border: 0; border-radius: 0; background: transparent; color: var(--text); font-family: var(--jp-sans);
}
body.app .fm-r { font-family: var(--ui); }
body.app .tako-link:hover .fm-b { color: var(--accent); }
body.app .result-panel { flex: none; overflow: visible; padding: 28px 32px; }
body.app .stat, body.app .kanji { background: var(--bg); border-color: var(--line); border-radius: 14px 14px 14px 4px; }

/* the empty reading: demo word, dictionary progress, one way in */
body.app .furigana-out.ghost-mode { display: flex; align-items: center; justify-content: center; }
body.app .ghost { gap: 0; color: var(--muted); font-size: 15px; }
body.app .ghost > .eyebrow { margin-bottom: 4px; }
body.app .ghost-decode { color: var(--text); }
body.app .gd-cap { margin-top: 6px; font: 14px var(--mono); color: var(--muted); }
body.app .gd-caret { background: var(--accent); }
.ghost-try { display: flex; flex-direction: column; align-items: center; margin-top: 32px; }
.try-words { margin: 0 0 14px; font: 17px/2.2 var(--jp-sans); color: var(--text-2); letter-spacing: 0; text-align: center; }
.try-words rt { font-size: 9px; color: var(--accent); }
.ghost-try .pill { height: 40px; padding: 0 20px; }
.ghost-try .ghost-paste { margin-top: 10px; }
.dict-load { width: min(300px, 80vw); margin: 28px auto 0; text-align: center; }
.dict-bar { height: 3px; border-radius: 3px; overflow: hidden; background: var(--line); }
#dict-bar-fill { display: block; width: 0; height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.2s; }
.dict-load-txt { display: block; margin-top: 10px; font: 12px var(--mono); color: var(--muted); }
.dict-load.err .dict-load-txt { color: var(--danger); }

/* ---- the undo toast, and the popups ---- */
body.app .toast { gap: 18px; padding: 12px 14px 12px 20px; border-radius: 18px 18px 18px 6px; background: var(--text); color: var(--bg); font: 14px var(--ui); letter-spacing: 0; box-shadow: none; }
body.app .toast button { height: 30px; padding: 0 14px; border-radius: 999px; background: var(--bg); color: var(--text); font: 600 13px var(--ui); text-decoration: none; }
body.app .kb-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-pop); box-shadow: none; }

/* ---- desktop and tablet: the page holds still, only the reading scrolls, the footer stays in view ---- */
@media (min-width: 801px) and (min-height: 640px) {
  body.app { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
  body.app .app-top { flex-shrink: 0; width: 100%; }
  body.app .app-main { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; padding-bottom: 16px; }
  body.app .src { flex-shrink: 0; }
  body.app #input { height: 150px; }
  body.app .out { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 16px; }
  body.app .out-hd { position: static; flex-shrink: 0; }
  .out-body { flex: 1; min-height: 0; overflow-y: auto; }
  body.app .furigana-out { min-height: calc(100% - 128px); }
  /* the footer folds to one row so the reading keeps its room */
  body.app .app-foot { flex-shrink: 0; width: 100%; grid-template-columns: 1fr auto; align-items: center; padding: 12px 32px 16px; }
  body.app .af-books { display: flex; align-items: center; gap: 12px; }
  body.app .af-lead, body.app .af-book small { display: none; }
  body.app .af-book { padding: 4px 14px 4px 4px; }
  body.app .af-book img { width: 18px; height: 29px; }
  body.app .af-side { display: flex; align-items: center; gap: 12px; }
  body.app .footer-sub { height: 38px; }
  body.app .footer-sub-input { width: 180px; }
  body.app .footer-sub-btn { height: 30px; }
}

@media (max-width: 800px) {
  .app-main { padding: 0 16px 32px; }
  .src { padding: 14px 14px 14px 16px; }
  .src-title { flex: 1; max-width: none; font-size: 16px; }
  #src-new { display: none; }
  .out-hd { gap: 0; padding: 6px 12px 0; }
  .out-tabs { width: 100%; gap: 0; }
  body.app .out-tabs .tab { flex: 1; }
  .out-tools { width: 100%; margin: 0; padding: 10px 0; border-top: 1px solid var(--line); }
  body.app .disp-modes { display: none; }
  body.app .disp-select {
    display: block; flex: 1; height: 36px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px;
    background: none; color: var(--text); font: 500 13px var(--ui); appearance: none; -webkit-appearance: none;
  }
  body.app .furigana-out { padding: 36px 12px 48px; }
  body.app .toast { bottom: 96px; }
}
@media (prefers-reduced-motion: reduce) { #dict-bar-fill, .src-title svg { transition: none; } }

/* ---- the empty reading, laid out to fit without scrolling ----
   The demo word gets its own size instead of the reading size, and on wider screens the
   word and the way in sit side by side instead of stacked. */
body.app .furigana-out.ghost-mode { padding: 28px 24px; min-height: 0; }
body.app .ghost {
  display: grid; grid-template-columns: auto auto; grid-template-areas: "label try" "word try" "load try";
  align-items: center; justify-content: center; column-gap: 48px; row-gap: 0;
}
body.app .ghost > .eyebrow { grid-area: label; justify-self: center; margin: 0; }
body.app .ghost-decode { grid-area: word; align-items: center; }
body.app .gd-word { font-size: clamp(34px, 4.6vw, 50px); line-height: 2.3; }
body.app .gd-cap { margin-top: 0; text-align: center; padding-left: 0; }
body.app .dict-load { grid-area: load; width: min(260px, 100%); margin: 14px auto 0; }
body.app .ghost-try { grid-area: try; align-self: center; max-width: 340px; margin: 0; padding-left: 48px; border-left: 1px solid var(--line); }
body.app .try-words { font-size: 16px; line-height: 2.1; }

@media (min-width: 801px) and (min-height: 640px) {
  body.app .furigana-out.ghost-mode { min-height: calc(100% - 56px); }
}
@media (max-width: 800px) {
  body.app .ghost { grid-template-columns: 1fr; grid-template-areas: "label" "word" "load" "try"; }
  body.app .furigana-out.ghost-mode { padding: 22px 12px 26px; }
  body.app .gd-word { font-size: clamp(32px, 11vw, 44px); line-height: 2.2; }
  body.app .ghost-try { max-width: none; margin-top: 18px; padding: 16px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  body.app .try-words { margin-bottom: 12px; }
}
body.app .ghost > .eyebrow { margin-bottom: 18px; }
/* the demo word changes length every few seconds; a fixed column keeps the button from sliding.
   320px holds the longest word (頑張って) at the largest demo size. */
@media (min-width: 801px) { body.app .ghost { grid-template-columns: 320px auto; } }
