/* ============================================================
   Yomikit — base stylesheet.
   Palette + layout live in themes.css (body.vN classes).
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }
html { font-size: 20px; }

:root {
  --mono: 'SF Mono', Consolas, 'Cascadia Code', 'Fira Mono', ui-monospace, monospace;
  --jp-serif: 'Hiragino Mincho ProN', 'HiraMinProN-W6', 'Yu Mincho', YuMincho, 'MS PMincho', serif;
  --jp-sans: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', 'Yu Gothic', YuGothic, Meiryo, sans-serif;
}

ruby rt { font-size: 0.65em; color: var(--cool); letter-spacing: 0; }

body {
  height: 100vh;
  overflow: hidden;
  font-family: var(--mono);
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% -10%, var(--bg2) 0%, transparent 62%),
    linear-gradient(180deg, var(--bg2) 0%, var(--bg) 72%);
  background-attachment: fixed;
  padding: 0;
  display: flex;
  justify-content: center;
}

/* CRT scanline overlay + vignette */
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 99;
  background: repeating-linear-gradient(
    0deg, rgba(0,0,0,0.2) 0px, rgba(0,0,0,0.2) 1px,
    transparent 2px, transparent 4px);
  mix-blend-mode: multiply;
  box-shadow: inset 0 0 220px rgba(0,0,0,0.8);
}

.window {
  width: 100%; max-width: none;
  background: var(--panel);
  border-radius: 0;
  overflow: hidden;
  display: flex; flex-direction: column;
}

/* ---- title bar ---- */
.titlebar {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 22px;
  background: linear-gradient(90deg, var(--bg2), var(--panel));
  border-bottom: 1px solid var(--line);
}
.title-sub { display: flex; align-items: center; gap: 12px; }
/* dictionary status LED */
.led {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--hot); box-shadow: 0 0 10px var(--glow);
  animation: led-pulse 1.3s ease-in-out infinite;
}
.led.on  { background: var(--head); box-shadow: 0 0 12px var(--glow); animation: none; }
.led.err { background: var(--faint); box-shadow: none; animation: none; }
@keyframes led-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.titlebar h1 {
  font-size: 1.7rem; letter-spacing: 4px; color: var(--head);
  text-shadow: 0 0 10px var(--glow), 0 0 26px var(--glow);
}
.titlebar h1 .jp { color: var(--cool); letter-spacing: 2px; }
.titlebar h1 ruby rt { font-size: 0.5em; color: inherit; opacity: 0.8; letter-spacing: 0; }
.statustext { font-size: 0.8rem; color: var(--muted); letter-spacing: 1px; white-space: nowrap; }
.statustext.ready { color: var(--head); text-shadow: 0 0 8px var(--glow); }
.tagline { color: var(--muted); font-size: 0.84rem; letter-spacing: 1px; line-height: 2.2; }
.mascot { font-size: 1.3rem; color: var(--cool); text-shadow: 0 0 10px var(--glow); }

/* dictionary status, beside the input label */
.pane-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.pane-head .pane-label { margin-bottom: 0; }
.dictstatus { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.statuswrap { display: flex; flex-direction: column; }
.status-sizer { visibility: hidden; pointer-events: none; height: 0; overflow: hidden; white-space: nowrap; font-size: 0.8rem; letter-spacing: 1px; }

/* ---- theme switcher ---- */
.themeswitch { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tnav {
  background: transparent; border: 1px solid var(--head); color: var(--head);
  border-radius: 4px; cursor: pointer; font-family: var(--mono);
  font-size: 1rem; line-height: 1; padding: 6px 10px; transition: all 0.15s ease;
}
.tnav:hover { box-shadow: 0 0 12px var(--glow); }
#theme-name {
  color: var(--head); font-size: 0.82rem; letter-spacing: 1px;
  min-width: 188px; text-align: center;
}

/* ---- KotobaLab button ---- */
.kb-btn {
  margin-left: 0;
  background: transparent; border: 1px solid var(--cool); color: var(--cool);
  border-radius: 4px; cursor: pointer; font-family: var(--mono);
  font-size: 0.85rem; letter-spacing: 2px; padding: 7px 12px;
  transition: all 0.15s ease;
}
.kb-btn:hover { box-shadow: 0 0 12px var(--glow); }

/* ---- panes (layout overridden per theme) ---- */
.panes { display: flex; flex-direction: column; gap: 1px; background: var(--line); }
.pane { background: var(--panel); padding: 18px 22px; flex: 1; min-width: 0; }
.pane-label { display: block; font-size: 0.9rem; color: var(--head); letter-spacing: 3px; margin-bottom: 12px; }

.input-wrap { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; overflow: hidden; }
.input-ghost {
  position: absolute; inset: 1px; border-radius: 3px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--field); pointer-events: none;
  color: var(--muted); text-shadow: none;
}
.input-ghost.hidden { display: none; }
.input-ghost-face { font-size: 2.5rem; margin-top: 0.75em; }
.input-ghost-jp { font-size: 1rem; line-height: 1.6; font-family: var(--jp-sans); }
.input-ghost-en { font-size: 0.82rem; line-height: 1.5; }
.ghost-tip + .input-ghost-jp { margin-top: 0.9em; }
.input-ghost-jp + .input-ghost-en { margin-top: 0.75em; }

#input {
  width: 100%; flex: 1; min-height: 0; resize: none;
  background: var(--field); color: var(--text);
  border: 1px solid var(--line); border-radius: 4px;
  font-family: var(--jp-sans); font-size: var(--inputF, 1.4rem); line-height: 2;
  padding: 14px; outline: none;
}
#input::placeholder { color: var(--muted); font-size: 1rem; }
#input:focus { border-color: var(--head); box-shadow: 0 0 16px var(--glow); }

.furigana-out {
  flex: 1; min-height: 0; overflow-y: auto;
  background: var(--field); border: 1px solid var(--line); border-radius: 0;
  padding: 18px; font-size: var(--furiF, 1.9rem); line-height: 2.8;
  white-space: pre-wrap; word-break: break-word;
  text-shadow: 0 0 7px var(--glow);
  font-family: var(--jp-sans);
}
.furigana-out ruby rt { font-size: 0.6em; color: var(--cool); letter-spacing: 0; text-shadow: none; }
.furigana-out.ghost-mode { display: flex; align-items: center; justify-content: center; }
.furigana-out.hidden { display: none; }
.ghost { display: flex; flex-direction: column; align-items: center; gap: 0.15em; color: var(--muted); font-size: 1.2rem; text-shadow: none; }
.ghost .ghost-face { font-size: 3rem; line-height: 1.1; margin-top: 0.6em; }
.ghost-jp { font-size: 1rem; line-height: 1.6; font-family: var(--jp-sans); margin-top: 0.9em; }
.ghost-en { font-size: 0.8rem; margin-top: 0.15em; }
.ghost-divider { font-size: 0.72rem; letter-spacing: 1.5px; margin: 0.6em 0 0.3em; opacity: 0.55; }
.ghost-lead { font-size: 0.8rem; line-height: 1.5; }
.ghost-tip { font-size: 0.75rem; margin-top: 0.5em; opacity: 0.65; }
.ghost-modes { list-style: none; padding: 0; margin: 0; max-width: 400px; font-size: 0.8rem; line-height: 1.55; text-align: left; display: flex; flex-direction: column; gap: 0.55em; }
.ghost-modes b { color: var(--head); }
.ascii-art { font-family: var(--mono); font-size: 0.42rem; line-height: 1.3; color: var(--cool); text-shadow: 0 0 5px var(--glow); white-space: pre; align-self: flex-start; max-width: 100%; overflow: hidden; margin-bottom: 0.6em; }
.empty { color: var(--muted); font-size: 1rem; text-shadow: none; }

/* ---- buttons ---- */
.buttons { display: flex; gap: 8px; padding: 12px 22px; border-top: 1px solid var(--line); flex-shrink: 0; }
.termbtn {
  flex: 1; padding: 10px 6px; cursor: pointer;
  font-family: var(--mono); font-size: 0.9rem; letter-spacing: 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--head); background: transparent;
  border: 1px solid var(--head); border-radius: 4px;
  transition: all 0.15s ease;
}
.btn-jp { font-size: 1.2em; line-height: 2.2; letter-spacing: 1px; }
.btn-en { font-size: 0.7em; opacity: 0.65; letter-spacing: 1px; line-height: 1.4; }
.termbtn:hover { box-shadow: 0 0 14px var(--glow); }
.countbtn { flex: none; margin-left: auto; border-color: var(--cool); color: var(--cool); padding: 10px 12px; }
.termbtn.active { color: var(--panel); background: var(--head); box-shadow: 0 0 20px var(--glow); }

/* ---- split layout ---- */
.layout { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.left-col { width: max-content; min-width: max-content; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); overflow: hidden; }
.right-col { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.input-area { flex: 1; display: flex; flex-direction: column; padding: 18px 22px; min-height: 0; overflow: hidden; }
.right-header { padding: 12px 22px; border-bottom: 1px solid var(--line); flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; }
.right-header .pane-label { margin-bottom: 0; }
.right-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; position: relative; }

/* ---- size overlay (top-left of output box) ---- */
.sz-overlay { position: absolute; top: 8px; left: 8px; z-index: 10; display: flex; flex-direction: row; gap: 3px; align-items: center; }

/* ---- result panels ---- */

/* ---- result panels ---- */
.result-panel { flex: 1; overflow-y: auto; padding: 16px 22px 24px; }
.result-panel.hidden { display: none; }

.bucket { margin-bottom: 22px; }
.bucket h3 {
  font-size: 0.95rem; color: var(--head); letter-spacing: 3px;
  margin-bottom: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 5px;
}
.row { display: flex; align-items: center; gap: 12px; padding: 8px 0; font-size: 1.2rem; }
.row .rank { color: var(--faint); width: 2em; }
.row .word { color: var(--text); }
.row .word ruby rt { font-size: 0.5em; color: var(--cool); letter-spacing: 0; }
.row .count { margin-left: auto; color: var(--hot); }
.row .pct { color: var(--muted); font-size: 0.9rem; min-width: 4em; text-align: right; }

.note { color: var(--cool); font-size: 0.95rem; line-height: 1.6; margin-bottom: 12px; }

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); gap: 12px; margin-bottom: 24px; }
.stat { position: relative; border: 1px solid var(--line); border-radius: 4px; padding: 16px; background: rgba(0,0,0,0.3); }
body.v7 .stat, body.v7 .kanji { background: rgba(0,0,0,0.05); }
.stat[data-tip] { cursor: help; }
.stat[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: 0; top: calc(100% + 8px);
  width: max(280px, 100%);
  background: var(--field); border: 1px solid var(--line); color: var(--text);
  padding: 13px 15px; border-radius: 4px;
  font-size: 0.82rem; line-height: 1.7; letter-spacing: 0; text-shadow: none;
  z-index: 60; box-shadow: 0 10px 38px rgba(0,0,0,0.75);
}
.statgrid .stat:last-child[data-tip]:hover::after { left: auto; right: 0; }
.stat .num { font-size: 2rem; color: var(--hot); text-shadow: 0 0 12px var(--glow); }
.stat .lbl { font-size: 0.8rem; color: var(--muted); letter-spacing: 1px; margin-top: 6px; }

.kanjigrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px,1fr)); gap: 10px; }
.kanji { border: 1px solid var(--line); border-radius: 4px; padding: 10px; background: rgba(0,0,0,0.3); text-align: center; }
.kanji .ch { font-size: 2.1rem; color: var(--text); text-shadow: 0 0 9px var(--glow); }
.kanji .meta { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.kanji .meta b { color: var(--hot); }

.footer {
  padding: 14px 22px; font-size: 0.8rem; color: var(--muted);
  border-top: 1px solid var(--line); background: rgba(0,0,0,0.35);
  flex-shrink: 0;
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
}
.footer-right { opacity: 0.75; letter-spacing: 0.02em; }
.footer-team-btn {
  background: none; border: none; padding: 0; font: inherit; color: var(--muted);
  cursor: pointer; transition: color 0.15s;
}
.footer-team-btn:hover { color: var(--head); }

/* ---- KotobaLab team modal ---- */
.kb-modal {
  position: fixed; inset: 0; z-index: 200; display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.74);
}
.kb-modal.open { display: flex; }
.kb-card {
  width: min(560px, 92vw);
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 30px 90px rgba(0,0,0,0.85);
  overflow: hidden;
}
.kb-head {
  display: flex; align-items: baseline; gap: 12px;
  padding: 16px 22px;
  background: linear-gradient(90deg, var(--bg2), var(--panel));
  border-bottom: 1px solid var(--line);
}
.kb-head h2 { font-size: 1.25rem; letter-spacing: 3px; color: var(--head); text-shadow: 0 0 10px var(--glow); }
.kb-head .sub { font-size: 0.8rem; color: var(--muted); letter-spacing: 1px; }
.kb-close {
  margin-left: auto; background: transparent;
  border: 1px solid var(--muted); color: var(--muted);
  border-radius: 4px; cursor: pointer; font-family: var(--mono);
  font-size: 0.9rem; line-height: 1; padding: 5px 9px; transition: all 0.15s ease;
}
.kb-close:hover { color: var(--head); border-color: var(--head); }
.kb-body { padding: 6px 22px 18px; }
.kb-member { display: flex; align-items: center; gap: 16px; padding: 13px 0; border-bottom: 1px dashed var(--line); }
.kb-member:last-child { border-bottom: none; }
.kb-kaomoji { flex-shrink: 0; min-width: 7.5em; font-size: 1.2rem; color: var(--cool); text-shadow: 0 0 8px var(--glow); text-align: center; white-space: nowrap; }
.kb-info { flex: 1; }
.kb-member .name { font-size: 1.1rem; color: var(--text); }
.kb-member .name b { color: var(--head); }
.kb-member .name .loc { color: var(--cool); }
.kb-member .role { font-size: 0.9rem; color: var(--muted); margin-top: 4px; letter-spacing: 1px; }

/* ---- saves panel ---- */
.saves-panel { border-bottom: 1px solid var(--line); flex-shrink: 0; }
.saves-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 22px; cursor: pointer; user-select: none;
  font-size: 0.88rem; color: var(--head); letter-spacing: 2px;
}
.saves-toggle:hover { background: rgba(255,255,255,0.03); }
.saves-chevron { transition: transform 0.2s ease; }
.saves-panel.open .saves-chevron { transform: rotate(180deg); }
.saves-body { overflow: hidden; max-height: 0; transition: max-height 0.22s ease; }
.saves-panel.open .saves-body { max-height: 360px; }
.save-row { display: flex; gap: 8px; padding: 10px 22px 0; }
.save-name-input {
  flex: 1; background: var(--field); color: var(--text);
  border: 1px solid var(--line); border-radius: 4px;
  font-family: var(--mono); font-size: 0.85rem; padding: 7px 10px; outline: none;
}
.save-name-input::placeholder { color: var(--muted); }
.save-name-input:focus { border-color: var(--head); box-shadow: 0 0 10px var(--glow); }
.save-submit-btn {
  background: transparent; border: 1px solid var(--head); color: var(--head);
  border-radius: 4px; cursor: pointer; font-family: var(--mono);
  font-size: 0.82rem; letter-spacing: 2px; padding: 7px 14px; flex-shrink: 0;
  transition: all 0.15s ease;
}
.save-submit-btn:hover { box-shadow: 0 0 12px var(--glow); }
.saves-list {
  max-height: 200px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 22px 14px;
}
.save-empty { color: var(--faint); font-size: 0.82rem; letter-spacing: 1px; text-align: center; padding: 8px 0; }
.save-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 4px;
  background: rgba(0,0,0,0.25); min-width: 0;
}
.save-item-load {
  background: transparent; border: none; cursor: pointer; font-family: var(--mono);
  font-size: 0.85rem; color: var(--head); padding: 0 2px; flex-shrink: 0;
}
.save-item-load:hover { text-shadow: 0 0 8px var(--glow); }
.save-item-name {
  flex: 1; font-size: 0.85rem; color: var(--text); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.save-item-name:hover { color: var(--head); }
.save-item-del {
  background: transparent; border: none; cursor: pointer; font-family: var(--mono);
  font-size: 0.9rem; color: var(--faint); padding: 0 2px; flex-shrink: 0; line-height: 1;
}
.save-item-del:hover { color: var(--hot); }
.save-rename-input {
  flex: 1; min-width: 0; background: transparent; color: var(--text);
  border: none; border-bottom: 1px solid var(--head);
  font-family: var(--mono); font-size: 0.85rem; padding: 0 2px; outline: none;
}

/* ---- app layout ---- */
body.as .left-col { width: 260px; min-width: 260px; }
body.as .input-area { padding: 18px 10px 18px 16px; }

.as-lhd {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 18px 12px; flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}
.as-lhd-jp { font-size: 1.6rem; color: var(--cool); letter-spacing: 2px; text-shadow: 0 0 18px var(--glow), 0 0 36px var(--glow), 0 0 54px var(--glow); font-family: var(--jp-serif); white-space: nowrap; }
.as-lhd-jp ruby rt { font-size: 0.5em; color: inherit; opacity: 0.8; letter-spacing: 0; }
.as-lhd-en { font-size: 1.1rem; color: var(--head); letter-spacing: 5px; text-shadow: 0 0 14px var(--glow), 0 0 28px var(--glow); }

body.as .input-ghost-face { font-size: 1.5rem; }
body.as .input-ghost-jp { font-size: 0.85rem; line-height: 1.6; }
body.as .input-ghost-jp + .input-ghost-en { margin-top: 0.6em; }
body.as .input-ghost-en { font-size: 0.75rem; line-height: 1.5; }

.as-left-hd {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 44px; padding: 0 16px; border-bottom: 1px solid var(--line); flex-shrink: 0;
  position: relative; z-index: 1;
}
.as-left-hd .as-stat-kana { font-size: 0.85rem; color: var(--cool); text-shadow: 0 0 8px var(--glow); }
.as-left-hd .as-stat-kana.ready { color: var(--head); text-shadow: 0 0 8px var(--glow); }

.mid-brand {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 16px 12px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.mid-brand-ctrl {
  display: flex; justify-content: flex-end; width: 100%; margin-bottom: 2px;
}

.right-hd {
  min-height: 44px; height: auto; padding: 8px 16px 0; border-bottom: 1px solid var(--line); flex-shrink: 0;
  display: flex; align-items: flex-end; justify-content: space-between;
}
.right-hd .termbtn { flex: none; padding: 5px 14px; font-size: 0.78rem; letter-spacing: 2px; }
.right-hd .kb-btn { align-self: center; }
body.as .right-col { border-left: 1px solid var(--line); }

.right-tabs { display: flex; gap: 2px; align-items: flex-end; }
.right-tabs .termbtn {
  border: 1px solid var(--line); border-bottom: none;
  border-radius: 3px 3px 0 0; background: var(--field);
}
.right-tabs .termbtn.active {
  background: var(--panel); color: var(--head);
  box-shadow: none; border-bottom: 1px solid var(--panel);
  margin-bottom: -1px; position: relative; z-index: 1;
}

.mid-col {
  width: 220px; min-width: 220px; flex-shrink: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line); overflow: hidden;
  transition: width 0.22s ease, min-width 0.22s ease;
}
.mid-col.collapsed { width: 0; min-width: 0; }

.mid-header {
  height: 44px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 0 16px; flex-shrink: 0;
  font-size: 0.85rem; color: var(--head); letter-spacing: 3px;
  border-bottom: 1px solid var(--line);
}

.mid-collapse {
  background: transparent; border: none; cursor: pointer; font-family: var(--mono);
  color: var(--muted); font-size: 0.9rem; padding: 4px 6px; line-height: 1; flex-shrink: 0;
  transition: color 0.15s ease;
}
.mid-collapse:hover { color: var(--head); }

.mid-expand {
  display: none; align-items: center; justify-content: center;
  width: 18px; flex-shrink: 0;
  background: transparent; border: none; border-right: 1px solid var(--line);
  cursor: pointer; font-family: var(--mono);
  color: var(--muted); font-size: 0.75rem; padding: 0;
  transition: color 0.15s ease, background 0.15s ease;
}
.mid-expand:hover { color: var(--head); background: rgba(255,255,255,0.03); }
.mid-col.collapsed + .mid-expand { display: flex; }

.as-actions { display: flex; flex-direction: column; gap: 6px; padding: 12px 16px 8px; flex-shrink: 0; }

.as-input-actions { display: flex; gap: 8px; padding: 8px 0 0; flex-shrink: 0; position: relative; z-index: 1; }
.as-input-btn {
  flex: 1; background: transparent; border: 1px solid var(--muted); color: var(--muted);
  border-radius: 4px; cursor: pointer; font-family: var(--mono);
  font-size: 0.78rem; letter-spacing: 1px; padding: 6px;
  transition: all 0.15s ease;
}
.as-input-btn:hover { border-color: var(--head); color: var(--head); }
.as-input-btn-save { border-color: var(--head); color: var(--head); }
.as-input-btn-save:hover { box-shadow: 0 0 10px var(--glow); }
.as-save-item.as-save-active { border-left: 2px solid var(--head); }

.as-action-btn {
  flex: 1; background: transparent; border: 1px solid var(--head); color: var(--head);
  border-radius: 4px; cursor: pointer; font-family: var(--mono);
  font-size: 0.8rem; letter-spacing: 1px; padding: 8px 6px;
  transition: all 0.15s ease;
}
.as-action-btn:hover { box-shadow: 0 0 12px var(--glow); }

.as-save-row { padding: 0 16px 8px; }

.as-name-input {
  width: 100%; background: var(--field); color: var(--text);
  border: 1px solid var(--line); border-radius: 4px;
  font-family: var(--mono); font-size: 0.8rem; padding: 6px 10px; outline: none;
}
.as-name-input::placeholder { color: var(--muted); }
.as-name-input:focus { border-color: var(--head); box-shadow: 0 0 8px var(--glow); }

.as-saves-heading {
  padding: 4px 16px 4px;
  font-size: 0.72rem; color: var(--muted); letter-spacing: 2px;
}

.as-saves-list {
  flex: 1; overflow-y: auto;
  padding: 4px 0 10px;
  display: flex; flex-direction: column; gap: 1px;
}

.as-save-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-top: 1px solid var(--line); border-radius: 0;
  background: transparent; min-width: 0;
}
.as-save-item:hover { background: rgba(255,255,255,0.04); }
.as-save-item[draggable="true"] { cursor: grab; }
.as-save-item.dragging { opacity: 0.35; }
.as-save-item.drag-over { box-shadow: inset 0 2px 0 var(--head); }
.as-save-name-el {
  flex: 1; font-size: 0.8rem; color: var(--text); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.as-save-name-el:hover { color: var(--head); }
.as-save-del {
  background: transparent; border: none; cursor: pointer; font-family: var(--mono);
  font-size: 0.85rem; color: var(--faint); padding: 0 2px; flex-shrink: 0; line-height: 1;
}
.as-save-del:hover { color: var(--hot); }
.as-save-menu {
  position: fixed; z-index: 100;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  display: flex; flex-direction: column; overflow: hidden; min-width: 100px;
}
.as-save-menu-opt {
  background: transparent; border: none; cursor: pointer; font-family: var(--mono);
  font-size: 0.82rem; color: var(--text); letter-spacing: 1px;
  padding: 8px 14px; text-align: left; transition: background 0.1s ease;
}
.as-save-menu-opt:hover { background: rgba(255,255,255,0.06); color: var(--head); }

.as-save-load {
  background: transparent; border: none; cursor: pointer; font-family: var(--mono);
  font-size: 0.85rem; color: var(--cool); padding: 0 2px; flex-shrink: 0; line-height: 1;
}
.as-save-load:hover { text-shadow: 0 0 8px var(--glow); }

.as-info {
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  flex-shrink: 0; gap: 3px; text-align: center;
}
.as-title-jp {
  font-size: 1.3rem; color: var(--cool); letter-spacing: 2px;
  text-shadow: 0 0 10px var(--glow);
}
.as-title-jp ruby rt { font-size: 0.55em; color: inherit; opacity: 0.8; letter-spacing: 0; }
.as-title-en { font-size: 1rem; color: var(--head); letter-spacing: 4px; text-shadow: 0 0 8px var(--glow); }
.as-tag-jp { font-size: 0.76rem; color: var(--muted); letter-spacing: 1px; margin-top: 5px; }
.as-tag-en { font-size: 0.73rem; color: var(--muted); letter-spacing: 1px; }
.as-divider { width: 60%; height: 1px; background: var(--line); margin: 7px 0; }
.as-stat-jp { font-size: 0.75rem; color: var(--muted); letter-spacing: 1px; }
.as-stat-en { font-size: 0.72rem; color: var(--muted); letter-spacing: 2px; }
.as-stat-kana { font-size: 0.8rem; color: var(--cool); text-shadow: 0 0 8px var(--glow); margin-top: 2px; }
.as-stat-jp.ready { color: var(--head); text-shadow: 0 0 6px var(--glow); }
.as-stat-en.ready { color: var(--head); text-shadow: 0 0 6px var(--glow); }

/* ---- TOP N radio ---- */
.topn-radio { display: flex; gap: 4px; align-items: center; }
.topn-radio.hidden { display: none; }
.topn-opt {
  cursor: pointer; user-select: none;
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 1px;
  color: var(--muted); border: 1px solid var(--line); border-radius: 4px;
  padding: 4px 8px; transition: all 0.15s ease;
}
.topn-opt input[type=radio] { display: none; }
.topn-opt:has(input:checked) { color: var(--cool); border-color: var(--cool); box-shadow: 0 0 8px var(--glow); }
.topn-opt:hover { border-color: var(--head); }

@media (max-width: 900px) {
  .mid-col { display: none; }
}

@media (max-width: 760px) {
  html { font-size: 16px; }
  body { height: auto; overflow: auto; }
  .window { height: auto; }
  .layout { flex-direction: column; }
  .left-col { width: 100%; border-right: none; border-bottom: 1px solid var(--line); }
  .input-area { min-height: 200px; }
  #input { min-height: 140px; }
  .right-col { min-height: 400px; }
  .kb-btn { margin-left: 0; }
}

/* ---- font size controls ---- */
.sz-ctrl { display: flex; gap: 3px; align-items: center; flex-shrink: 0; }
.sz-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 3px;
  color: var(--muted); cursor: pointer; font-family: var(--mono);
  font-size: 0.75rem; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center; line-height: 1;
  transition: color 0.1s, border-color 0.1s;
}
.sz-btn:hover { color: var(--head); border-color: var(--head); }

/* ---- sidebar how-to ---- */
.as-how-to {
  padding: 22px 0 0; flex-shrink: 0; align-self: stretch; text-align: left;
}
.as-how-title {
  font-size: 0.5rem; letter-spacing: 2px; color: var(--head); margin-bottom: 6px;
}
.as-how-list { display: flex; flex-direction: column; gap: 4px; }
.as-how-list span { font-size: 0.52rem; color: var(--muted); line-height: 1.3; }

/* ---- takoboto links ---- */
.tako-link { color: inherit; text-decoration: none; cursor: pointer; }
.tako-link:hover { color: var(--head); }
.furigana-out .tako-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- theme picker ---- */
.theme-picker { display: flex; gap: 7px; justify-content: center; margin-top: 8px; }
.theme-dot {
  width: 13px; height: 13px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform 0.12s, border-color 0.12s;
}
.theme-dot:hover { transform: scale(1.25); }
.theme-dot.active { border-color: var(--text); }
.theme-dot[data-theme="v3"] { background: #ff6ec7; }
.theme-dot[data-theme="v5"] { background: #33ff66; }
.theme-dot[data-theme="v6"] { background: #38b6ff; }
.theme-dot[data-theme="v7"] { background: #c8b89a; }

/* ---- stat card english sub-label ---- */
.lbl-en { font-size: 0.7em; opacity: 0.65; letter-spacing: 1px; }

/* ---- mid-col login prompt (logged-out state) ---- */
.as-login-prompt {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 24px 16px;
}
.as-login-btn {
  display: block; width: 100%; text-align: center; text-decoration: none;
  padding: 8px; font-size: 0.78rem; letter-spacing: 2px;
}
.as-login-hint {
  font-size: 0.72rem; color: var(--muted); letter-spacing: 1px;
}

/* ---- mid-col user row ---- */
.mid-user {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; gap: 6px;
}
.mid-user-email {
  font-size: 0.68rem; color: var(--muted); letter-spacing: 0.3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.mid-logout {
  background: transparent; border: none; cursor: pointer;
  font-family: var(--mono); font-size: 0.68rem; color: var(--muted);
  letter-spacing: 1px; padding: 2px 0; flex-shrink: 0;
}
.mid-logout:hover { color: var(--head); }
.del-trigger { margin-top: 14px; }
.del-logged-out { font-size: 0.84rem; color: var(--muted); margin-top: 12px; }
.del-card { max-width: 400px; }
.del-warn { font-size: 0.88rem; color: var(--muted); line-height: 1.7; margin: 4px 0 24px; }
.del-warn-2 { color: var(--text); }
.del-actions { display: flex; gap: 10px; justify-content: flex-end; }
.del-confirm { color: var(--hot) !important; border-color: var(--hot) !important; }
.del-confirm:hover { background: var(--hot) !important; color: var(--bg, #000) !important; }

/* ---- login modal (inline, main page) ---- */
.login-modal-card { width: min(380px, 92vw); }
.login-modal-card .login-form { padding-top: 22px; }
.login-modal-card .login-google { margin-left: auto; margin-right: auto; }

/* ---- login page ---- */
.login-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
}
.login-card {
  display: flex; flex-direction: column; align-items: center;
  width: 340px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.login-brand {
  position: static; width: 100%; border-bottom: 1px solid var(--line);
}
.login-form {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; padding: 20px 24px 0; box-sizing: border-box;
}
.login-form input {
  width: 100%; box-sizing: border-box;
  background: transparent; border: 1px solid var(--line);
  color: var(--text); font-family: var(--mono);
  font-size: 0.83rem; letter-spacing: 1px;
  padding: 9px 12px; outline: none;
  transition: border-color 0.15s ease;
}
.login-form input:focus { border-color: var(--cool); }
.login-form input::placeholder { color: var(--muted); }
.login-actions { display: flex; gap: 8px; margin-top: 2px; }
.login-btn { flex: 1; padding: 8px; font-size: 0.78rem; letter-spacing: 2px; }
.login-error {
  width: 100%; box-sizing: border-box;
  color: #f77; font-size: 0.78rem; letter-spacing: 0.5px;
  padding: 7px 10px; margin-bottom: 4px;
  border: 1px solid #f77; background: rgba(255,80,80,0.07);
}
.login-divider {
  display: flex; align-items: center; width: 100%;
  padding: 0 24px; box-sizing: border-box;
  margin: 16px 0 12px; color: var(--muted); font-size: 0.75rem; letter-spacing: 1px;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.login-divider span { padding: 0 10px; }
.login-google {
  display: block; width: calc(100% - 48px); box-sizing: border-box;
  text-align: center; text-decoration: none; margin-bottom: 24px;
  padding: 8px; font-size: 0.78rem; letter-spacing: 1.5px;
}

/* ---- right header text links ---- */
.right-hd-links { display: flex; gap: 28px; align-items: center; margin-bottom: 6px; }
.right-hd-link {
  background: transparent; border: none; cursor: pointer;
  font-family: var(--mono); font-size: 0.73rem; color: var(--muted);
  letter-spacing: 0.5px; padding: 0; transition: color 0.12s ease;
}
.right-hd-link:hover { color: var(--head); }

/* ---- save note ---- */
.as-save-note { font-size: 0.62rem; color: var(--muted); letter-spacing: 0.3px; padding: 4px 0 0; position: relative; z-index: 1; }
.as-save-note-warn { color: #f77; }

/* ---- inline topN picker ---- */
.topn-inline { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.topn-inline-opt {
  background: transparent; border: 1px solid var(--line); border-radius: 3px;
  color: var(--muted); cursor: pointer; font-family: var(--mono);
  font-size: 0.72rem; padding: 2px 7px; letter-spacing: 0;
  transition: all 0.12s ease;
}
.topn-inline-opt:hover { border-color: var(--head); color: var(--head); }
.topn-inline-opt.active { border-color: var(--cool); color: var(--cool); box-shadow: 0 0 6px var(--glow); }

/* ---- overview bucket header row (label + inline picker) ---- */
.bucket-hd-row {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px dashed var(--line); padding-bottom: 5px; margin-bottom: 10px; gap: 10px;
}
.bucket-hd-row h3 { border-bottom: none; margin-bottom: 0; padding-bottom: 0; flex-shrink: 0; }

/* ---- frequency 2x2 grid ---- */
.freq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.freq-picker-row { display: flex; align-items: center; gap: 10px; padding: 8px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.freq-picker-lbl { font-size: 0.65rem; color: var(--muted); letter-spacing: 2px; flex-shrink: 0; }

/* ---- guide modal ---- */
.right-hd-btns { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.guide-modal {
  display: none; position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,0.6); align-items: center; justify-content: center;
}
.guide-modal.open { display: flex; }
.guide-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  width: 540px; max-width: 95vw; max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
}
.guide-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.guide-title {
  font-size: 1.1rem; letter-spacing: 2px; color: var(--head);
  text-shadow: 0 0 10px var(--glow); font-weight: normal;
}
.guide-body { overflow-y: auto; padding: 22px 22px 26px; flex: 1; }
.guide-panel.hidden { display: none; }
.guide-lead {
  font-size: 0.88rem; color: var(--text); line-height: 1.65; margin-bottom: 20px;
}
.guide-item { margin-bottom: 16px; }
.guide-item-hd {
  display: block; font-size: 0.72rem; letter-spacing: 3px;
  color: var(--head); margin-bottom: 4px;
}
.guide-item-bd { font-size: 0.85rem; color: var(--muted); line-height: 1.55; }
.guide-tip {
  font-size: 0.82rem; color: var(--muted); margin-top: 22px;
  padding-top: 14px; border-top: 1px dashed var(--line);
}
.guide-tier {
  margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line);
}
.guide-tier:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.guide-tier-hd {
  font-size: 0.7rem; letter-spacing: 3px; color: var(--head); margin-bottom: 9px;
}
.guide-tier-bd {
  font-size: 0.84rem; color: var(--muted); line-height: 1.75;
}
.guide-list { list-style: none; padding: 0; margin: 0; }
.guide-list li {
  font-size: 0.84rem; color: var(--muted); line-height: 1.55;
  padding: 5px 0 5px 16px; position: relative;
}
.guide-list li::before { content: '↳'; position: absolute; left: 0; color: var(--head); }
.guide-link { color: var(--head); text-decoration: none; }
.guide-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- privacy page ---- */
.privacy-wrap { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 40px 24px; overflow-y: auto; }
.privacy-card { max-width: 640px; width: 100%; }
.privacy-head { margin-bottom: 32px; }
.privacy-back { font-size: 0.78rem; color: var(--muted); text-decoration: none; letter-spacing: 1px; }
.privacy-back:hover { color: var(--head); }
.privacy-head h1 { font-size: 1.4rem; color: var(--head); margin: 12px 0 4px; letter-spacing: 2px; }
.privacy-sub { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.5px; }
.privacy-body h2 { font-size: 0.78rem; letter-spacing: 2px; color: var(--head); margin: 28px 0 10px; }
.privacy-body p, .privacy-body li { font-size: 0.84rem; color: var(--muted); line-height: 1.75; }
.privacy-body ul { list-style: none; padding: 0; margin: 0 0 8px; }
.privacy-body li { padding: 3px 0 3px 16px; position: relative; }
.privacy-body li::before { content: '↳'; position: absolute; left: 0; color: var(--faint); }
.privacy-body b { color: var(--text); }


