/* Shell styles. Every value derives from tokens.css — no raw colors here. */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font-sans); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.l1 { font-family: var(--font-ja); }
[data-lang="en"] .l1 { display: none !important; }
[data-lang="l1"] .en { display: none !important; }
button { font-family: var(--font-sans); cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand-accent); outline-offset: 2px; }

.app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--brand-deep); color: var(--on-brand);
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
}
.brand { font-weight: 700; font-size: calc(15px * var(--scale)); letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand-dot); box-shadow: 0 0 0 3px rgba(91,141,239,.25); flex-shrink: 0; }
.tb-spacer { margin-left: auto; }
.tb-btn {
  background: rgba(255,255,255,.12); border: none; color: var(--on-brand);
  font-weight: 600; font-size: calc(11px * var(--scale));
  padding: 7px 12px; border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: 6px;
}
.tb-btn:hover { background: rgba(255,255,255,.22); }
.seg { display: flex; background: rgba(255,255,255,.10); border-radius: var(--r-pill); padding: 3px; }
.seg button {
  background: none; border: none; color: var(--on-brand-soft);
  font-size: calc(11px * var(--scale)); font-weight: 600;
  padding: 5px 10px; border-radius: var(--r-pill);
}
.seg button.on { background: var(--card); color: var(--brand); }

/* Main column */
.main { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 20px 16px 90px; }
.main.wide { max-width: none; padding: 0; display: flex; flex-direction: column; }

.kicker { font-size: calc(11px * var(--scale)); font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-muted); }
h1.page-title { color: var(--brand); font-weight: 700; font-size: calc(26px * var(--scale)); line-height: 1.15; margin: 6px 0 2px; }
.page-sub { font-family: var(--font-serif); font-style: italic; color: var(--brand-light); font-size: calc(17px * var(--scale)); margin-bottom: 18px; }

/* Cards & list items */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card);
  padding: 16px 18px; margin-bottom: 12px;
}
.item {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 10px;
  transition: .14s; color: var(--text);
}
.item:hover { border-color: var(--brand-mist-2); box-shadow: var(--shadow-pop); transform: translateY(-1px); }
.item .ph {
  flex-shrink: 0; width: calc(40px * var(--scale)); height: calc(40px * var(--scale));
  border-radius: var(--r-md); background: var(--brand-mist); color: var(--brand);
  font-weight: 700; display: flex; align-items: center; justify-content: center;
  font-size: calc(15px * var(--scale));
}
.item.done .ph { background: var(--success-bg); color: var(--success); }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 700; font-size: calc(15px * var(--scale)); }
.item .desc { font-size: calc(12px * var(--scale)); color: var(--text-muted); margin-top: 2px; }
.item .meta { flex-shrink: 0; font-size: calc(11px * var(--scale)); font-weight: 700; color: var(--brand-light); background: var(--brand-mist); border-radius: var(--r-pill); padding: 5px 11px; white-space: nowrap; }
.item .meta.done { color: var(--success); background: var(--success-bg); }
.item .arrow { flex-shrink: 0; color: var(--text-faint); font-size: calc(17px * var(--scale)); }

.group-lab { font-size: calc(11px * var(--scale)); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); margin: 22px 0 11px; display: flex; align-items: center; gap: 10px; }
.group-lab .line { flex: 1; height: 1px; background: var(--border); }

/* Progress bar */
.pbar { height: 8px; background: var(--surface-100); border-radius: var(--r-pill); overflow: hidden; margin-top: 8px; }
.pbar > div { height: 100%; background: var(--brand-accent); border-radius: var(--r-pill); transition: width .3s; }

/* Unit viewer */
.viewerbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 8px 14px;
}
.viewerbar .vtitle { font-weight: 700; font-size: calc(13px * var(--scale)); color: var(--brand); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewerbar .pageinfo { font-size: calc(11px * var(--scale)); color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.vbtn {
  border: 1px solid var(--border); background: var(--surface-50); color: var(--brand);
  font-weight: 700; font-size: calc(12px * var(--scale));
  padding: 7px 12px; border-radius: var(--r-pill);
}
.vbtn:disabled { opacity: .4; cursor: default; }
.vbtn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.vbtn.primary.is-done { background: var(--success); border-color: var(--success); }
.frame-wrap { flex: 1; display: flex; }
.frame-wrap iframe { flex: 1; width: 100%; border: 0; background: var(--card); }

/* Toast + status */
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: var(--brand-deep); color: var(--on-brand);
  border-radius: var(--r-pill); padding: 10px 18px;
  font-size: calc(12px * var(--scale)); font-weight: 600;
  box-shadow: var(--shadow-pop); z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.toast.show { opacity: 1; }
.sync-chip { font-size: calc(10px * var(--scale)); font-weight: 700; border-radius: var(--r-pill); padding: 3px 9px; }
.sync-chip.offline { background: var(--warn-bg); color: var(--warn); }
.sync-chip.online { background: var(--success-bg); color: var(--success); }

.empty { text-align: center; color: var(--text-muted); padding: 40px 16px; font-size: calc(13px * var(--scale)); }

@media (max-width: 640px) {
  .main { padding: 16px 12px 90px; }
  .item .desc { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
