:root {
  --bg: #f5f6fa; --panel: #ffffff; --panel2: #f0f2f8; --line: #e2e5ee; --text: #161a2b; --muted: #636a82;
  --brand: #c8102e; --brand2: #9c0c23; --brandSoft: #fde8eb; --ok: #138a4c; --okSoft: #e3f6ec; --warn: #a15c00; --warnSoft: #fff3dd; --bad: #c62f2f; --badSoft: #fde8e8;
  --star: #e8a300; --shadow: 0 1px 2px rgba(20,25,50,.06), 0 4px 16px rgba(20,25,50,.05); --r: 14px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1220; --panel: #171b2d; --panel2: #1e2338; --line: #2a3050; --text: #e9ecf7; --muted: #9aa2bf;
  --brand: #ff5c74; --brand2: #ff8a9b; --brandSoft: #3a1820; --ok: #4fd18b; --okSoft: #183a2a; --warn: #ffb547; --warnSoft: #3a2c12; --bad: #ff7a7a; --badSoft: #3d1d22;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
small, .muted { color: var(--muted); }
[hidden] { display: none !important; }

.boot { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: 12px; color: var(--muted); }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }
.logo-mark.big { width: 56px; height: 56px; font-size: 28px; margin: 0 auto; }
img.logo-mark { display: block; background: none; object-fit: contain; }

.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.brand b { display: block; font-size: 17px; } .brand small { font-size: 12px; }
.nav-h { font-size: 11px; letter-spacing: .08em; font-weight: 700; color: var(--muted); margin: 14px 10px 6px; }
.nav-a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text); font-size: 14px; }
.nav-a:hover { background: var(--panel2); }
.nav-a.on { background: var(--brandSoft); color: var(--brand); font-weight: 600; }
.nav-a .n { margin-left: auto; font-size: 12px; color: var(--muted); }
.nav-a .tag { margin-left: auto; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--warnSoft); color: var(--warn); }
.side-foot { margin-top: auto; padding: 12px 10px 0; font-size: 12px; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; max-width: 560px; }
.search input { width: 100%; padding: 10px 40px 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); outline: none; }
.search input:focus { border-color: var(--brand); }
.search kbd { position: absolute; right: 10px; top: 9px; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; color: var(--muted); }
.qres { position: absolute; left: 0; right: 0; top: 46px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; padding: 6px; }
.qres a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.qres a:hover, .qres a.sel { background: var(--panel2); }
.icon-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; width: 40px; height: 40px; cursor: pointer; flex: none; }
.view { padding: 24px; max-width: 1180px; width: 100%; }
.foot { margin-top: auto; padding: 18px 24px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gauto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt { margin-top: 18px; } .mt2 { margin-top: 28px; } .mb { margin-bottom: 14px; }

.hero { background: linear-gradient(135deg, #c8102e, #2b2d6e); color: #fff; border: 0; }
.hero p { opacity: .92; margin: 4px 0 14px; }
.hero .btn { background: #fff; color: var(--brand2); }
.stat b { display: block; font-size: 1.7rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }
.stat i { font-style: normal; font-size: 20px; float: right; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 11px; font-weight: 600; cursor: pointer; text-align: center; justify-content: center; }
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--panel); color: var(--text); border-color: var(--line); }
.btn.soft { background: var(--brandSoft); color: var(--brand); }
.btn.ok { background: var(--ok); }
.btn.danger { background: var(--panel); color: var(--bad); border-color: var(--line); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn.big { padding: 14px 20px; font-size: 16px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 13px; color: var(--text); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--panel2); color: var(--muted); }
.tag.Easy { background: var(--okSoft); color: var(--ok); } .tag.Medium { background: var(--warnSoft); color: var(--warn); } .tag.Hard { background: var(--badSoft); color: var(--bad); }
.code { font: 600 12px ui-monospace, Menlo, monospace; color: var(--brand); }
.star { background: none; border: 0; cursor: pointer; font-size: 18px; color: var(--muted); padding: 2px 4px; line-height: 1; }
.star.on { color: var(--star); }

.item { display: flex; flex-direction: column; gap: 6px; cursor: pointer; transition: transform .08s, border-color .08s; }
.item:hover { border-color: var(--brand); transform: translateY(-1px); }
.item h3 { margin: 0; }
.cat { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.cat .ic { font-size: 24px; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--panel2); }
.cat:hover { border-color: var(--brand); }

.list-row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .t { flex: 1; min-width: 0; cursor: pointer; }
.list-row .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

label.f { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.in, select.in, textarea.in { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); outline: none; }
.in:focus { border-color: var(--brand); }
textarea.in { min-height: 90px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.fgrid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fgrid .full { grid-column: 1 / -1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--panel); padding: 9px 14px; cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; }
.check { display: inline-flex; gap: 8px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--panel); }
.check input { accent-color: var(--brand); }

.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps div { flex: 1; height: 6px; border-radius: 6px; background: var(--line); }
.steps div.on { background: var(--brand); }
.stepname { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.note { padding: 12px 14px; border-radius: 12px; background: var(--warnSoft); color: var(--warn); font-size: 14px; }
.note.info { background: var(--brandSoft); color: var(--brand); }
.note.ok { background: var(--okSoft); color: var(--ok); }
.note.bad { background: var(--badSoft); color: var(--bad); }
.opt { border: 2px solid var(--line); border-radius: var(--r); padding: 16px; }
.opt.on { border-color: var(--brand); }
.ai-btns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty .e { font-size: 36px; }
.spin { width: 18px; height: 18px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; display: inline-block; }
@keyframes sp { to { transform: rotate(360deg); } }
.loading { text-align: center; padding: 40px 10px; }
.loading .spin { width: 34px; height: 34px; color: var(--brand); }
.bar { height: 8px; border-radius: 8px; background: var(--line); overflow: hidden; margin: 14px auto 0; max-width: 360px; }
.bar i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .6s; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.sticky-act { position: sticky; top: 66px; z-index: 3; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; z-index: 50; font-size: 14px; max-width: calc(100vw - 32px); }
.only-m { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 19; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 20; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .only-m { display: inline-grid; place-items: center; } .only-d { display: none; }
  .top { padding: 10px 16px; }
  .view { padding: 16px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3, .g2 { grid-template-columns: 1fr; }
  .fgrid { grid-template-columns: 1fr; }
  .paper { padding: 18px 16px; font-size: 14px; }
  .ai-btns { grid-template-columns: 1fr; }
  .sticky-act { top: 60px; }
  h1 { font-size: 1.35rem; }
}

/* ---- Nihonjob: latihan soal ---- */
.jp { font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif; }
.count { display: flex; align-items: baseline; gap: 6px; }
.count b { font-size: 2.6rem; line-height: 1; }
.skor-big { font-size: 3rem; font-weight: 800; line-height: 1; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.ok { background: var(--okSoft); color: var(--ok); } .pill.warn { background: var(--warnSoft); color: var(--warn); } .pill.bad { background: var(--badSoft); color: var(--bad); }
.qwrap { max-width: 760px; margin: 0 auto; }
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.prog { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin-bottom: 16px; }
.prog i { display: block; height: 100%; background: var(--brand); transition: width .3s; }
.qtext { font-size: 1.35rem; line-height: 1.7; white-space: pre-line; margin: 6px 0 4px; }
.qtext ruby rt { font-size: .5em; color: var(--muted); }
.furi { color: var(--muted); font-size: 14px; }
.passage { white-space: pre-line; background: var(--panel2); border-radius: 12px; padding: 14px 16px; font-size: 1.08rem; line-height: 1.8; margin-bottom: 12px; border: 1px solid var(--line); }
.qask { font-weight: 600; margin: 10px 0 14px; }
.opts { display: grid; gap: 10px; }
.optb { text-align: left; border: 2px solid var(--line); background: var(--panel); border-radius: 12px; padding: 13px 16px; cursor: pointer; font-size: 1.08rem; display: flex; gap: 12px; align-items: center; color: var(--text); }
.optb .k { width: 28px; height: 28px; border-radius: 8px; background: var(--panel2); display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; color: var(--muted); }
.optb:hover:not([disabled]) { border-color: var(--brand); }
.optb.pick { border-color: var(--brand); background: var(--brandSoft); }
.optb.right { border-color: var(--ok); background: var(--okSoft); }
.optb.wrong { border-color: var(--bad); background: var(--badSoft); }
.optb[disabled] { cursor: default; }
.explain { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--panel2); font-size: 14px; }
.listen { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.script { white-space: pre-line; font-size: 15px; line-height: 1.8; }
.timer { font: 700 15px ui-monospace, Menlo, monospace; padding: 4px 10px; border-radius: 8px; background: var(--panel2); }
.timer.low { background: var(--badSoft); color: var(--bad); }
.navq { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 6px; }
.navq button { height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 12px; color: var(--text); }
.navq button.done { background: var(--brandSoft); border-color: var(--brand); }
.navq button.cur { outline: 2px solid var(--brand); }
.navq button.flag { box-shadow: inset 0 -3px 0 var(--warn); }
.bars .b { display: grid; grid-template-columns: 150px 1fr 54px; gap: 10px; align-items: center; margin: 8px 0; font-size: 14px; }
.bars .t { height: 10px; background: var(--line); border-radius: 10px; overflow: hidden; }
.bars .t i { display: block; height: 100%; background: var(--brand); }
.spark { width: 100%; height: 70px; }
.vocab { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.vocab .w { font-size: 1.3rem; }
.flash { min-height: 220px; display: grid; place-items: center; text-align: center; cursor: pointer; user-select: none; }
.flash .w { font-size: 2.6rem; }
.kbdhint { font-size: 12px; color: var(--muted); }
@media (max-width: 900px) {
  .qtext { font-size: 1.2rem; }
  .bars .b { grid-template-columns: 110px 1fr 46px; }
  .flash .w { font-size: 2.1rem; }
}
