/* ===== 設計變數 ===== */
:root {
  --bg: #f6f2ea;
  --surface: #fffdf8;
  --surface-2: #f0ebe1;
  --ink: #1f2430;
  --muted: #6b6f7a;
  --line: #e4dccd;
  --accent: #284b7d;      /* 藍 */
  --accent-ink: #ffffff;
  --accent-soft: #e3eaf5;
  --vermilion: #c4502f;   /* 朱 */
  --ok: #2f7d55;
  --ok-soft: #e1f2e8;
  --warn: #a8641a;
  --marker: rgba(255, 210, 0, .55);
  --marker-done: rgba(255, 210, 0, .22);
  --shadow: 0 1px 2px rgba(31, 36, 48, .06), 0 6px 20px rgba(31, 36, 48, .06);
  --radius: 14px;
  --header-h: 60px;
  --font-sans: "Noto Sans TC", "Noto Sans JP", system-ui, sans-serif;
  --font-jp: "Noto Sans JP", "Noto Sans TC", sans-serif;
  --font-serif: "Noto Serif JP", "Noto Serif TC", serif;
  --font-hand: "Klee One", "Noto Serif JP", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161b; --surface: #1c1f26; --surface-2: #232731; --ink: #ebe7df; --muted: #9ba1ad;
    --line: #2e333d; --accent: #8db0ea; --accent-ink: #10131a; --accent-soft: #233149;
    --vermilion: #f08b6b; --ok: #6fcf97; --ok-soft: #1d3428; --warn: #e3a857;
    --marker: rgba(250, 204, 21, .38); --marker-done: rgba(250, 204, 21, .12);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161b; --surface: #1c1f26; --surface-2: #232731; --ink: #ebe7df; --muted: #9ba1ad;
  --line: #2e333d; --accent: #8db0ea; --accent-ink: #10131a; --accent-soft: #233149;
  --vermilion: #f08b6b; --ok: #6fcf97; --ok-soft: #1d3428; --warn: #e3a857;
  --marker: rgba(250, 204, 21, .38); --marker-done: rgba(250, 204, 21, .12);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

/* ===== 基礎 ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: 16px; line-height: 1.65;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-serif); line-height: 1.3; margin: 0 0 .5em; text-wrap: balance; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.jp { font-family: var(--font-jp); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.container { width: min(1120px, 100% - 32px); margin-inline: auto; }
main.container { padding: 28px 0 64px; }

/* ===== 頁首 ===== */
.site-header {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.site-header .container { display: flex; align-items: center; gap: 16px; height: 100%; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-serif); font-weight: 700; font-size: 1.15rem; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .seal { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--vermilion); color: #fff; font-size: .95rem; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: .93rem; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active { color: var(--accent); background: var(--accent-soft); }
.site-header .nav-toggle { display: none; margin-left: auto; }
@media (max-width: 860px) {
  .site-header .nav-toggle { display: inline-flex; }
  .nav { display: none; position: absolute; top: var(--header-h); left: 0; right: 0; flex-direction: column; align-items: stretch;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px 16px; box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .nav a { padding: 10px 12px; }
}

/* ===== 元件 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: .93rem; line-height: 1.2; cursor: pointer;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--vermilion); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
.btn.icon { padding: 7px; width: 36px; height: 36px; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid > .card + .card, .stat-grid > .card + .card, .hero > .card + .card { margin-top: 0; }  /* 格狀排列時用 gap 控制間距 */
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }

.badge { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.red { background: color-mix(in srgb, var(--vermilion) 15%, transparent); color: var(--vermilion); }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], textarea, select {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
textarea { resize: vertical; min-height: 120px; }
label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 4px; }
.field + .field { margin-top: 12px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs button { font: inherit; background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: inherit; transition: width .3s; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 200;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.page-head { margin-bottom: 24px; }
.page-head .eyebrow { color: var(--vermilion); font-weight: 600; font-size: .85rem; letter-spacing: .08em; }
.section { margin-top: 36px; }
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; border-radius: 0 10px 10px 0; }
.callout.warn { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }

table.simple { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.simple th, table.simple td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.simple th { color: var(--muted); font-weight: 500; font-size: .85rem; }
.table-wrap { overflow-x: auto; }

.speak { cursor: pointer; border: 0; background: none; color: var(--accent); padding: 2px 4px; border-radius: 6px; font-size: 1rem; }
.speak:hover { background: var(--accent-soft); }

/* ===== 首頁 ===== */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: stretch; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }
.hero-text h1 .accent { color: var(--vermilion); }
.daily-card { position: relative; overflow: hidden; }
.daily-card .thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: var(--surface-2); display: block; }
.stage-card { display: flex; flex-direction: column; gap: 8px; color: var(--ink); transition: transform .15s, border-color .15s; }
.stage-card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.stage-card .num { font-family: var(--font-serif); color: var(--vermilion); font-weight: 700; }
.stage-card ul { margin: 0; padding-left: 1.1em; color: var(--muted); font-size: .9rem; }

/* ===== 歌曲清單 ===== */
.song-card { display: flex; flex-direction: column; gap: 10px; color: var(--ink); padding: 12px; }
.song-card:hover { text-decoration: none; border-color: var(--accent); }
.song-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.song-card .title { font-weight: 700; font-family: var(--font-jp); line-height: 1.35; }

/* ===== 歌曲播放頁（左影片、右歌詞） ===== */
.player-layout {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px;
  width: min(1440px, 100% - 32px); margin: 0 auto; padding: 20px 0;
}
.player-left { position: sticky; top: calc(var(--header-h) + 20px); align-self: start; }
.video-box { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.video-box iframe, .video-box #yt { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.song-meta { margin-top: 14px; }
.song-meta h1 { font-family: var(--font-jp); font-size: 1.4rem; margin-bottom: 2px; }
.yt-link { display: inline-block; margin-top: 4px; color: var(--accent); text-decoration: none; font-weight: 500; }
.yt-link:hover { text-decoration: underline; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.controls .group { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.controls .group .btn { border: 0; border-radius: 0; }
.controls .group .btn + .btn { border-left: 1px solid var(--line); }

.lyrics-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  height: calc(100vh - var(--header-h) - 40px); display: flex; flex-direction: column; position: sticky; top: calc(var(--header-h) + 20px);
}
.lyrics-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; border-bottom: 1px solid var(--line); align-items: center; }
.lyrics-scroll { flex: 1; overflow-y: auto; padding: 30vh 18px 40vh; scroll-behavior: smooth; overscroll-behavior: contain; }
.lyric {
  padding: 10px 12px; border-radius: 10px; cursor: pointer; transition: background .2s, opacity .2s;
  opacity: .6; position: relative;
}
.lyric:hover { background: var(--surface-2); opacity: .9; }
.lyric.past { opacity: .45; }
.lyric.active { opacity: 1; background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.lyric .ja { font-family: var(--font-jp); font-size: 1.28rem; line-height: 1.9; font-weight: 500; }
.lyric .ja .mark {
  background-image: linear-gradient(transparent 58%, var(--marker) 58%, var(--marker) 92%, transparent 92%);
  background-repeat: no-repeat; background-size: 0% 100%;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.lyric.past .ja .mark { background-image: linear-gradient(transparent 58%, var(--marker-done) 58%, var(--marker-done) 92%, transparent 92%); background-size: 100% 100%; }
.lyric .ja ruby rt { font-size: .5em; color: var(--muted); font-weight: 400; }
.lyric .romaji { font-size: .9rem; color: var(--accent); letter-spacing: .01em; }
.lyric .zh { font-size: .95rem; color: var(--muted); }
.lyric .time { position: absolute; right: 10px; top: 8px; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; opacity: 0; }
.lyric:hover .time { opacity: 1; }
.lyric.gap { cursor: default; padding: 4px 12px; color: var(--muted); font-size: .85rem; text-align: center; }
.lyric.gap::before { content: "♪ ♪ ♪"; letter-spacing: .3em; }
.lyric.loop { outline: 2px dashed var(--vermilion); outline-offset: -2px; }
.hide-romaji .lyric .romaji, .hide-zh .lyric .zh { display: none; }
.hide-furigana .lyric .ja rt, .hide-furigana .lyric .ja rp { display: none; }
.follow-btn { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); box-shadow: var(--shadow); }
.lyrics-panel { position: sticky; }

@media (max-width: 900px) {
  .player-layout { grid-template-columns: 1fr; padding-top: 0; width: 100%; gap: 0; }
  .player-left { top: var(--header-h); z-index: 10; background: var(--bg); padding: 0 0 8px; }
  .video-box { border-radius: 0; }
  .song-meta, .controls { padding-inline: 16px; }
  .song-meta h1 { font-size: 1.1rem; }
  .player-left .more { display: none; }
  .song-meta { margin-top: 8px; }
  .controls { margin-top: 6px; }
  .lyrics-panel { margin: 8px 16px 16px; height: auto; min-height: 60vh; position: relative; top: 0; }
  .lyrics-scroll { padding: 16px 12px 40vh; max-height: none; overflow: visible; }
}

/* ===== 五十音 ===== */
.kana-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.kana-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kana-cell {
  aspect-ratio: 5 / 4; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; user-select: none;
  transition: transform .1s, border-color .15s, background .15s; font: inherit; color: var(--ink); padding: 4px;
}
.kana-cell:hover { border-color: var(--accent); transform: translateY(-1px); }
.kana-cell.empty { visibility: hidden; }
.kana-cell .k { font-family: var(--font-jp); font-size: clamp(1.4rem, 4vw, 2.1rem); line-height: 1.1; }
.kana-cell .r { font-size: .78rem; color: var(--muted); }
.kana-cell.mastered { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.kana-cell.selected { border-color: var(--vermilion); box-shadow: 0 0 0 2px color-mix(in srgb, var(--vermilion) 30%, transparent); }

.writing { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .writing { grid-template-columns: 1fr; } }
.stroke-box, .canvas-box { position: relative; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.stroke-box svg { width: 100%; height: 100%; }
.canvas-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.canvas-box .guide { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-hand); font-size: min(52vw, 220px); color: var(--ink); opacity: .1; pointer-events: none; line-height: 1; }
.canvas-box::before, .canvas-box::after, .stroke-box::before, .stroke-box::after { content: ""; position: absolute; background: none; pointer-events: none; }
.canvas-box::before, .stroke-box::before { left: 50%; top: 0; bottom: 0; border-left: 1px dashed var(--line); }
.canvas-box::after, .stroke-box::after { top: 50%; left: 0; right: 0; border-top: 1px dashed var(--line); }
.big-kana { font-family: var(--font-hand); font-size: 4.5rem; line-height: 1; }

.quiz-q { font-family: var(--font-jp); font-size: 4rem; text-align: center; line-height: 1.2; margin: 10px 0; }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.choices .btn { padding: 14px; font-size: 1.05rem; }
.choices .btn.correct { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.choices .btn.wrong { border-color: var(--vermilion); color: var(--vermilion); }

/* 例句 */
.ex { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.ex:last-child { border-bottom: 0; }
.ex .ja { font-family: var(--font-jp); font-size: 1.12rem; }
.ex .ro { color: var(--accent); font-size: .88rem; }
.ex .zh { color: var(--muted); font-size: .92rem; }
.pattern { font-family: var(--font-jp); background: var(--surface-2); padding: 8px 12px; border-radius: 8px; display: inline-block; margin: 4px 0; }
.pitch { display: inline-flex; gap: 2px; font-family: var(--font-jp); font-size: 1.3rem; }
.pitch span { padding: 0 3px; border-top: 2px solid transparent; border-bottom: 2px solid transparent; }
.pitch span.h { border-top-color: var(--vermilion); }
.pitch span.l { border-bottom-color: var(--accent); }
.pitch span.drop { border-right: 2px solid var(--vermilion); }

/* 單字卡 */
.flash {
  min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  cursor: pointer; user-select: none; gap: 6px;
}
.flash .front { font-family: var(--font-jp); font-size: 2.4rem; }
.vocab-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 10px; }
.vocab { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.vocab .w { font-family: var(--font-jp); font-size: 1.1rem; }
.vocab .m { color: var(--muted); font-size: .88rem; }
.dialog-line { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); align-items: start; }
.dialog-line .who { font-size: .8rem; color: #fff; background: var(--accent); border-radius: 6px; text-align: center; padding: 2px 4px; margin-top: 4px; }
.dialog-line .who.b { background: var(--vermilion); }

.mic-result { min-height: 2.4em; font-family: var(--font-jp); font-size: 1.1rem; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.score-big { font-size: 2rem; font-weight: 700; font-family: var(--font-serif); }

/* 後台 */
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .admin-grid { grid-template-columns: 1fr; } }
.admin-left { position: sticky; top: calc(var(--header-h) + 16px); }
.edit-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.edit-table td, .edit-table th { border-bottom: 1px solid var(--line); padding: 6px 4px; vertical-align: top; }
.edit-table th { text-align: left; color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.edit-table input { padding: 5px 7px; font-size: .9rem; border-radius: 7px; }
.edit-table .t-input { width: 82px; font-variant-numeric: tabular-nums; }
.edit-table tr.active { background: var(--accent-soft); }
.edit-table tr.next-tap td:first-child { box-shadow: inset 3px 0 0 var(--vermilion); }
.edit-scroll { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.result-item { padding: 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.result-item:hover { border-color: var(--accent); }
.result-item + .result-item { margin-top: 8px; }
.kbd { font-family: ui-monospace, monospace; font-size: .8rem; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); }

.site-footer { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); font-size: .85rem; }
.kana-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 760px) { .kana-layout { grid-template-columns: 1fr; } .kana-layout aside { position: static !important; } }

/* ===== 我的學習 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 14px 16px; }
.stat-name { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-unit { font-size: .85rem; font-weight: 500; color: var(--muted); margin-left: 4px; }
.stat-note { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.study-cal { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); grid-auto-columns: 14px; gap: 4px; overflow-x: auto; padding-bottom: 2px; }
.study-cal .day { border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); }
.study-cal .day.on { background: var(--ok); border-color: var(--ok); }
.study-cal .day.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.study-cal .day.future { visibility: hidden; }
.history-day { padding: 14px 18px; }
.history-day h3 { font-size: 1rem; margin: 0 0 8px; }
.history-day ul { list-style: none; margin: 0; padding: 0; }
.history-day li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--line); }
.history-day li:first-child { border-top: 0; }
.h-text { flex: 1; min-width: 0; }
.h-extra { white-space: nowrap; font-size: .85rem; font-variant-numeric: tabular-nums; }
.song-card .fav { color: var(--vermilion); }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 520px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat-value { font-size: 1.5rem; } }

/* ===== 後台：編輯中、剛儲存的歌 ===== */
#song-rows tr.editing td { background: var(--accent-soft); }
#song-rows tr.just-saved td { animation: saved-flash 2.4s ease-out; }
@keyframes saved-flash { from { background: var(--ok-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { #song-rows tr.just-saved td { animation: none; background: var(--ok-soft); } }

/* ===== JLPT 程度與標籤 ===== */
.badge.lv { font-weight: 700; letter-spacing: .02em; }
.badge.lv5 { background: var(--ok-soft); color: var(--ok); }
.badge.lv4 { background: color-mix(in srgb, var(--ok) 10%, var(--accent-soft)); color: var(--accent); }
.badge.lv3 { background: var(--accent-soft); color: var(--accent); }
.badge.lv2 { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.lv1 { background: color-mix(in srgb, var(--vermilion) 15%, transparent); color: var(--vermilion); }
.tag { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
a.tag:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.song-card .row { gap: 6px; flex-wrap: wrap; }
.song-intro { margin-top: 14px; padding: 14px 16px; }
.song-intro p { margin: 6px 0; line-height: 1.7; }

/* ===== JLPT 模擬測驗 ===== */
.jlpt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.jlpt-layout > .card + .card { margin-top: 0; }
.jlpt-q { font-size: 1.35rem; line-height: 1.8; margin: 0 0 18px; }
.jlpt-q u { text-decoration-thickness: 2px; text-underline-offset: 5px; text-decoration-color: var(--vermilion); }
.jlpt-layout .choices .btn { text-align: left; justify-content: flex-start; }
.jlpt-fb { min-height: 3em; margin-top: 14px; }
.jlpt-fb p { margin: 0 0 8px; line-height: 1.7; }
.jlpt-review { border-top: 1px solid var(--line); padding: 12px 0; }
.jlpt-review u { text-decoration-color: var(--vermilion); }
.lv-song { display: flex; gap: 10px; align-items: center; color: var(--ink); }
.lv-song:hover { text-decoration: none; color: var(--accent); }
.lv-song img { width: 84px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; flex: none; background: var(--surface-2); }
@media (max-width: 900px) { .jlpt-layout { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .jlpt-layout .choices { grid-template-columns: 1fr; } .jlpt-q { font-size: 1.15rem; } }
/* 格狀清單裡的提示文字（例如「還沒有歌曲」）佔滿整列 */
.grid > p { grid-column: 1 / -1; }

/* ===== 密碼欄：顯示／隱藏按鈕 ===== */
.pw-wrap { position: relative; display: block; }
.row .pw-wrap { display: inline-block; flex: 1; max-width: 260px; }
.pw-wrap .pw-input { padding-right: 46px; width: 100%; ime-mode: disabled; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 8px; border-radius: 8px; color: var(--muted); }
.pw-toggle:hover { background: var(--surface-2); }
.pw-hint { display: block; color: var(--warn); margin-top: 4px; min-height: 0; }
.pw-hint:empty { display: none; }
