:root {
  --bg: #faf7f0;
  --paper: #fffdf8;
  --ink: #2b2620;
  --muted: #8a7f70;
  --line: #e6dfd0;
  --accent: #7a2e2e;
  --accent-soft: #f3e6e0;
  --hl: #fff1b8;
  --ja: #3d5a80;
  --fs: 18px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
}
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ── 上部バー */
#bar, #reader-bar {
  position: sticky; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; background: var(--paper); border-bottom: 1px solid var(--line);
}
#bar { top: 0; }
#reader-bar { top: 49px; flex-wrap: wrap; }
.home { font-weight: 700; text-decoration: none; font-family: Georgia, serif; font-size: 18px; }
#work-title { font-family: Georgia, serif; color: var(--muted); }
.grow { flex: 1; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.btn {
  font: inherit; font-size: 14px; padding: 5px 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); border-radius: 6px; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.on { background: var(--accent-soft); border-color: var(--accent); }
.btn.small { font-size: 12px; padding: 2px 7px; }
select { font: inherit; font-size: 14px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; max-width: 46vw; }

main { max-width: 860px; margin: 0 auto; padding: 24px 20px 120px; }

/* ── 作品一覧 */
.lib-head { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.lib-head input { flex: 1; font: inherit; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; }
.lib-section { margin: 28px 0 10px; font-size: 13px; color: var(--muted); letter-spacing: .1em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card {
  display: block; padding: 14px 16px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; text-decoration: none; color: var(--ink);
}
.card:hover { border-color: var(--accent); }
.card .ja { font-weight: 700; font-size: 16px; }
.card .en { font-family: Georgia, serif; color: var(--muted); font-size: 13px; margin-top: 2px; }
.card .syn { font-size: 13px; margin-top: 8px; line-height: 1.6; }
.card .meta { font-size: 12px; color: var(--muted); margin-top: 8px; }
.card .resume { color: var(--accent); font-weight: 600; }

/* ── 本文 */
.scene-head { margin: 8px 0 20px; }
.scene-head h1 { font-family: Georgia, serif; font-size: 26px; margin: 0; }
.scene-head .sub { color: var(--muted); font-family: Georgia, serif; }
details.persons { margin: 0 0 20px; font-size: 14px; }
details.persons summary { cursor: pointer; color: var(--muted); }
details.persons ul { columns: 2; margin: 8px 0; padding-left: 18px; font-family: Georgia, serif; }

.text { font-family: Georgia, "Times New Roman", serif; font-size: var(--fs); line-height: 1.75; }
.dir { color: var(--muted); font-style: italic; margin: 14px 0 14px 2em; font-size: .9em; }
.sp { margin: 0 0 18px; padding: 6px 10px; border-radius: 8px; scroll-margin-top: 130px; }
.sp.cur { background: var(--accent-soft); }
.sp-head { display: flex; align-items: center; gap: 6px; font-family: "Segoe UI", sans-serif; }
.who { font-weight: 700; letter-spacing: .06em; font-size: 13px; color: var(--accent); text-transform: uppercase; }
.sp-tools { opacity: .25; transition: opacity .15s; display: flex; gap: 4px; }
.sp:hover .sp-tools, .sp.cur .sp-tools { opacity: 1; }
.ln { position: relative; padding-left: 1.6em; }
.ln .lp {
  position: absolute; left: 0; top: .35em; border: 0; background: none; cursor: pointer;
  font-size: .7em; color: var(--muted); opacity: 0; padding: 0;
}
.ln:hover .lp { opacity: 1; }
.ln.speaking .lt { background: var(--hl); }
.ln-d { padding-left: 1.6em; color: var(--muted); font-style: italic; font-size: .88em; }
.br { height: .7em; }
.stanza { margin: 0 0 22px; }
.w { cursor: pointer; border-radius: 3px; }
.w:hover { background: #f0e6d0; }
.w.saved { border-bottom: 2px solid #d9b26a; }
.ja {
  font-family: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", serif;
}
.tr { color: var(--ja); font-size: .82em; line-height: 1.7; margin: 6px 0 2px 1.9em; padding-left: 10px; border-left: 3px solid #c9d6e6; white-space: pre-wrap; }
.tr.ai { border-left-color: #d6c3e6; color: #5a3d80; }
.tr .src { display: block; font-family: "Segoe UI", sans-serif; font-size: 11px; color: var(--muted); margin-top: 2px; }
.scene-nav { display: flex; justify-content: space-between; margin-top: 40px; }

/* ── 単語ポップアップ */
#pop {
  position: absolute; z-index: 50; width: 380px; max-width: calc(100vw - 20px); max-height: 70vh; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  box-shadow: 0 8px 28px rgba(60, 40, 20, .18); font-size: 14px; line-height: 1.6;
}
#pop .pw { display: flex; align-items: center; gap: 8px; }
#pop .pw b { font-family: Georgia, serif; font-size: 20px; }
#pop .ph { color: var(--muted); font-size: 13px; }
#pop .x { margin-left: auto; border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }
#pop .sec { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
#pop .lab { font-size: 11px; color: var(--muted); letter-spacing: .08em; }
#pop .old { background: #fbf3df; border-radius: 6px; padding: 6px 8px; margin-top: 8px; }
#pop .old .lab { color: #9a7a2a; }
#pop .pos { font-style: italic; color: var(--accent); font-size: 13px; }
#pop ol { margin: 2px 0 6px; padding-left: 20px; }
#pop .links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#pop .links a { font-size: 12px; }
#pop .ctx { font-family: Georgia, serif; font-size: 13px; color: var(--muted); }
.loading { color: var(--muted); font-size: 13px; }

/* ── 単語帳 */
.words-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.words-head h1 { margin: 0; flex: 1; font-size: 22px; }
table.words { width: 100%; border-collapse: collapse; background: var(--paper); font-size: 14px; }
table.words th, table.words td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
table.words td.w1 { font-family: Georgia, serif; font-size: 16px; font-weight: 700; white-space: nowrap; }
table.words td.ctx { font-family: Georgia, serif; color: var(--muted); font-size: 13px; }
table.words textarea { width: 100%; font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 4px; resize: vertical; min-height: 2.2em; }
.flash { text-align: center; padding: 40px 20px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.flash .fw { font-family: Georgia, serif; font-size: 36px; font-weight: 700; }
.flash .fc { font-family: Georgia, serif; color: var(--muted); margin: 12px 0; }
.flash .fa { font-size: 18px; margin: 16px 0; min-height: 1.6em; }

/* ── 設定 */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; width: 460px; max-width: 94vw; }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog h3 { margin: 18px 0 4px; font-size: 14px; }
dialog label { display: block; margin: 12px 0 4px; font-size: 14px; }
dialog label select { display: block; width: 100%; max-width: none; margin-top: 4px; }
dialog label.check { display: flex; gap: 6px; align-items: center; }
dialog menu { padding: 0; margin: 18px 0 0; text-align: right; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0; line-height: 1.6; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 8px 16px; border-radius: 8px; font-size: 14px; z-index: 100;
}

/* ── スラッシュリーディング */
.sl::before { content: "/"; color: #c0392b; opacity: .55; font-weight: 700; margin: 0 .3em 0 0; }
.slash { margin: 8px 0 2px 1.9em; padding: 8px 10px; background: #fbf8f1; border-left: 3px solid #e4c9a8; border-radius: 0 6px 6px 0; }
.slash .chs { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 4px; }
.slash .ch { display: inline-flex; flex-direction: column; padding: 2px 4px; }
.slash .ch .en { font-size: .9em; }
.slash .ch .jp { font-size: .72em; color: var(--ja); line-height: 1.5; }
.slash .chsl { color: #c0392b; opacity: .55; font-weight: 700; padding-top: 2px; }
.slash .src { font-family: "Segoe UI", sans-serif; font-size: 11px; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── あらすじ */
details.summary { margin: 0 0 16px; padding: 10px 14px; background: #f4f0e6; border-radius: 8px; font-size: 14px; }
details.summary summary { cursor: pointer; font-weight: 700; color: var(--accent); font-size: 13px; }
details.summary p { margin: 8px 0 0; line-height: 1.85; white-space: pre-wrap; }

/* ── 学習プラン（Day の区切り） */
.day-mark { font-family: "Segoe UI", "Yu Gothic UI", sans-serif; font-size: 12px; color: var(--muted); border-top: 2px dashed var(--line); padding-top: 6px; margin: 26px 0 12px; }
.day-mark.today { color: var(--accent); border-top-color: var(--accent); font-weight: 700; }
.day-end { text-align: center; margin: 8px 0 28px; }
