/* Layout: header + left rail (desktop) / bottom tab bar (phone); content column ~ 72ch.
   Palette: deep "night shift" navy ink, signal red accent, triage colors as semantic only. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --ink: #16202e;
  --ink-2: #4a5566;
  --line: #d9dee6;
  --accent: #c8102e;
  --accent-ink: #ffffff;
  --accent-soft: #fbe7ea;
  --navy: #1d3557;
  --t-red: #d0021b;
  --t-yellow: #e2b400;
  --t-green: #1f8f4e;
  --t-black: #1a1a1a;
  --ok: #1f8f4e;
  --warn: #b7791f;
  --bad: #c8102e;
  --font-body: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  --font-head: "Zen Kaku Gothic New", "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 10px;
  --header-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --surface: #161d27; --surface-2: #1d2633; --ink: #e8edf4; --ink-2: #a7b2c2;
    --line: #2b3646; --accent: #ff4d63; --accent-ink: #1a0005; --accent-soft: #3a1820; --navy: #9cc0ff;
    --t-red: #ff4d5e; --t-yellow: #ffd23f; --t-green: #3ccf7a; --t-black: #c9d1dc;
    --ok: #3ccf7a; --warn: #f0b44c; --bad: #ff4d63; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --surface: #161d27; --surface-2: #1d2633; --ink: #e8edf4; --ink-2: #a7b2c2;
  --line: #2b3646; --accent: #ff4d63; --accent-ink: #1a0005; --accent-soft: #3a1820; --navy: #9cc0ff;
  --t-red: #ff4d5e; --t-yellow: #ffd23f; --t-green: #3ccf7a; --t-black: #c9d1dc;
  --ok: #3ccf7a; --warn: #f0b44c; --bad: #ff4d63; color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font-body);
  font-size: 15px; line-height: 1.75; -webkit-text-size-adjust: 100%;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--navy); }
a { color: var(--navy); }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.35; text-wrap: balance; margin: 0; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* header */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: #1d3557; color: #fff;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.top-inner { display: flex; align-items: center; gap: 12px; height: var(--header-h); max-width: 1280px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-family: var(--font-head); font-weight: 700; white-space: nowrap; }
.brand-mark { width: 32px; height: 32px; display: block; flex: none; }
.brand small { font-weight: 500; opacity: .75; font-size: 11px; letter-spacing: .08em; display: block; line-height: 1; }
.brand span { line-height: 1.1; }
.search-box { flex: 1; min-width: 0; position: relative; max-width: 520px; margin-left: auto; }
.search-box input {
  width: 100%; height: 38px; border-radius: 19px; border: 0; padding: 0 14px 0 36px;
  background: rgba(255,255,255,.14); color: #fff; font: inherit; font-size: 14px;
}
.search-box input::placeholder { color: rgba(255,255,255,.7); }
.search-box input:focus { background: #fff; color: #16202e; outline: none; }
.search-box svg { position: absolute; left: 12px; top: 11px; opacity: .8; pointer-events: none; }
.theme-btn { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 8px; height: 34px; padding: 0 10px; cursor: pointer; font-size: 13px; }

/* shell */
.shell {
  display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; max-width: 1280px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 24px 64px;
}
.rail { position: sticky; top: calc(var(--header-h) + 16px + env(safe-area-inset-top, 0px)); align-self: start; max-height: calc(100vh - 90px); overflow: auto; }
.rail h4 { font-size: 11px; letter-spacing: .12em; color: var(--ink-2); margin: 18px 8px 6px; font-family: var(--font-body); font-weight: 700; }
.rail a { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: 14px; }
.rail a:hover { background: var(--surface-2); }
.rail a.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.rail .num { font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); width: 22px; }
main { min-width: 0; }

.tabbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding-block: 16px 96px; }
  .rail { display: none; }
  .brand .brand-sub { display: none; }
  .theme-btn { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11px; color: var(--ink-2); text-decoration: none; }
  .tabbar a.on { color: var(--accent); font-weight: 700; }
}

/* generic blocks */
.crumbs { font-size: 12px; color: var(--ink-2); margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--ink-2); }
.page-head { display: grid; gap: 10px; margin-bottom: 20px; }
.page-head h1 { font-size: clamp(24px, 4vw, 32px); }
.lead { color: var(--ink-2); max-width: 68ch; margin: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip.type { background: var(--navy); color: var(--surface); font-weight: 700; }
.chip.draft { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card {
  display: grid; gap: 6px; align-content: start; padding: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: var(--ink); min-width: 0;
}
a.card:hover { border-color: var(--navy); }
.card h3 { font-size: 16px; }
.card p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.card .k { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; color: var(--accent); font-weight: 700; }

/* home */
.hero { display: grid; gap: 14px; padding: 8px 0 24px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.hero h1 { font-size: clamp(26px, 5vw, 40px); letter-spacing: -.01em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.quick a {
  display: grid; gap: 2px; padding: 14px; border-radius: var(--radius); text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
}
.quick a b { font-family: var(--font-head); font-size: 17px; }
.quick a span { font-size: 12px; color: var(--ink-2); }
.quick a.tool { background: var(--navy); color: var(--surface); border-color: transparent; }
.quick a.tool span { color: var(--surface); opacity: .8; }
.section { margin-top: 32px; display: grid; gap: 12px; }
.section > h2 { font-size: 19px; display: flex; align-items: baseline; gap: 10px; }
.section > h2 small { font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); font-weight: 400; letter-spacing: .1em; }
.scenes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.scene { padding: 16px; border-left: 4px solid var(--navy); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; }
.scene h3 { font-size: 15px; }
.scene p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }

/* article */
.article { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 32px; align-items: start; }
@media (max-width: 1100px) { .article { grid-template-columns: minmax(0, 1fr); } }
.prose { min-width: 0; max-width: 76ch; }
.prose section { padding-top: 8px; margin-bottom: 28px; scroll-margin-top: 80px; }
.prose h2 { font-size: 20px; padding-bottom: 6px; border-bottom: 2px solid var(--line); margin-bottom: 12px; }
.prose h3 { font-size: 16px; margin: 18px 0 6px; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 12px; }
.prose li { margin-bottom: 4px; }
.prose strong { color: var(--ink); background: linear-gradient(transparent 62%, var(--accent-soft) 62%); }
.aside { position: sticky; top: calc(var(--header-h) + 16px); display: grid; gap: 14px; }
@media (max-width: 1100px) { .aside { position: static; } }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; font-size: 13px; }
.box h4 { font-size: 12px; letter-spacing: .1em; color: var(--ink-2); margin-bottom: 8px; font-family: var(--font-body); }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.meta dt { color: var(--ink-2); }
.meta dd { margin: 0; font-variant-numeric: tabular-nums; }
.toc a { display: block; padding: 3px 0; text-decoration: none; color: var(--ink); }
.toc a:hover { color: var(--accent); }

.note { border: 1px solid var(--line); border-left: 4px solid var(--warn); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; padding: 10px 14px; font-size: 13px; margin: 0 0 12px; }
.note.red { border-left-color: var(--bad); }
.note.blue { border-left-color: var(--navy); }
.key { display: grid; gap: 8px; background: var(--surface); border: 2px solid var(--navy); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; }
.key b { font-family: var(--font-head); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 0 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag-red, .tag-yellow, .tag-green, .tag-black { display: inline-block; padding: 1px 10px; border-radius: 4px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.tag-red { background: var(--t-red); color: #fff; }
.tag-yellow { background: var(--t-yellow); color: #1a1a1a; }
.tag-green { background: var(--t-green); color: #fff; }
.tag-black { background: var(--t-black); color: var(--surface); }

/* flow diagrams */
.flow { display: grid; gap: 0; margin: 0 0 16px; }
.flow .step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; display: grid; gap: 2px; }
.flow .step b { font-family: var(--font-head); }
.flow .step small { color: var(--ink-2); font-size: 12px; }
.flow .step.q { border: 2px solid var(--navy); }
.flow .arrow { justify-self: center; color: var(--ink-2); font-size: 13px; padding: 4px 0; line-height: 1.2; text-align: center; }
.flow .branch { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.flow .out { padding: 8px 12px; border-radius: var(--radius); font-weight: 700; font-size: 14px; display: grid; gap: 2px; }
.flow .out small { font-weight: 400; font-size: 12px; }
.out.red { background: var(--t-red); color: #fff; }
.out.yellow { background: var(--t-yellow); color: #1a1a1a; }
.out.green { background: var(--t-green); color: #fff; }
.out.black { background: var(--t-black); color: var(--surface); }
.out.next { background: var(--surface-2); color: var(--ink); }

/* career ladder */
.ladder { display: grid; gap: 10px; counter-reset: lad; margin: 0 0 16px; }
.ladder li { list-style: none; display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; }
.ladder li::before { counter-increment: lad; content: counter(lad); width: 44px; height: 44px; border-radius: 50%; background: var(--navy); color: var(--surface); display: grid; place-items: center; font-family: var(--font-mono); font-weight: 700; }
.ladder li.goal::before { background: var(--accent); content: "★"; }
.ladder .lb { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.ladder .lb b { font-family: var(--font-head); display: block; }
.ladder .lb span { font-size: 13px; color: var(--ink-2); }
.ladder { padding: 0; }

/* sources & related */
.sources { font-size: 13px; padding-left: 1.2em; }
.sources li { margin-bottom: 4px; }
.disclaimer { margin-top: 28px; padding: 14px 16px; background: var(--surface-2); border-radius: var(--radius); font-size: 12px; color: var(--ink-2); line-height: 1.7; }
.print-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }

/* search */
.result { display: grid; gap: 4px; padding: 14px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.result h3 { font-size: 16px; color: var(--navy); }
.result p { margin: 0; font-size: 13px; color: var(--ink-2); }
mark { background: var(--accent-soft); color: var(--accent); padding: 0 2px; border-radius: 2px; }

/* tools */
.tool-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 16px; margin-bottom: 20px; }
.big-time { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: clamp(44px, 11vw, 72px); font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 2px; }
.stat span { font-size: 12px; color: var(--ink-2); }
.stat b { font-family: var(--font-mono); font-size: 22px; font-variant-numeric: tabular-nums; }
.stat.hl { background: var(--navy); color: var(--surface); }
.stat.hl span { color: var(--surface); opacity: .8; }
.state-btn {
  width: 100%; min-height: 120px; border-radius: 14px; border: 0; cursor: pointer; font-family: var(--font-head);
  font-size: clamp(22px, 5vw, 30px); font-weight: 700; display: grid; place-items: center; gap: 4px; padding: 12px;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.state-btn small { font-family: var(--font-body); font-size: 13px; font-weight: 400; opacity: .85; }
.state-btn.idle { background: var(--surface-2); color: var(--ink); border: 2px dashed var(--line); }
.state-btn.comp { background: var(--t-green); color: #fff; }
.state-btn.pause { background: var(--t-red); color: #fff; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { filter: brightness(1.15); } }
@media (prefers-reduced-motion: reduce) { .state-btn.pause { animation: none; } .beat { transition: none !important; } }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 9px 16px; border-radius: 8px; cursor: pointer; font-weight: 700; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.navy { background: var(--navy); color: var(--surface); border-color: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.reason-chips button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.reason-chips button.on { background: var(--t-red); border-color: transparent; color: #fff; }
.bar { height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; position: relative; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--t-green); }
.bar .mk { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.timeline { display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.timeline i { display: block; height: 100%; }
.timeline .c { background: var(--t-green); }
.timeline .p { background: var(--t-red); }
.verdict { padding: 10px 14px; border-radius: var(--radius); font-weight: 700; }
.verdict.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.verdict.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.verdict.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.cycle { font-family: var(--font-mono); font-size: 13px; color: var(--ink-2); }
.cycle.alert { color: var(--accent); font-weight: 700; }

.metro-face { display: grid; justify-items: center; gap: 12px; padding: 8px 0; }
.beat { width: 150px; height: 150px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; transition: transform .06s, background .06s; border: 4px solid var(--line); }
.beat.on { transform: scale(1.06); background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.beat b { font-family: var(--font-mono); font-size: 44px; line-height: 1; }
.beat small { font-size: 12px; display: block; text-align: center; }
.bpm-ctl { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 420px; }
.bpm-ctl input[type=range] { flex: 1; accent-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--ink); padding: 8px 14px; cursor: pointer; font-size: 13px; }
.seg button.on { background: var(--navy); color: var(--surface); font-weight: 700; }
label.inline { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }

.foot { border-top: 1px solid var(--line); margin-top: 40px; padding-top: 16px; font-size: 12px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 6px 16px; }
.foot a { color: var(--ink-2); }

/* print */
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  body::before, .top, .rail, .tabbar, .aside .toc, .no-print, .foot, .print-btn, .tool-panel { display: none !important; }
  .shell { display: block; padding: 0; }
  .article { display: block; }
  .aside { position: static; }
  .card, .box, .table-wrap, .flow .step { border-color: #999; background: #fff; }
  .table-wrap { overflow: visible; }
  th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tag-red, .tag-yellow, .tag-green, .tag-black, .out { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only { display: block; }
  .prose section { break-inside: avoid-page; }
  a { color: #000; text-decoration: none; }
}

/* ===== SNS風パーツ ===== */
:root { --gold: #c99a2e; --shadow: 0 1px 2px rgba(22,32,46,.06), 0 6px 18px rgba(22,32,46,.06); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --gold: #e7c15a; --shadow: 0 1px 2px rgba(0,0,0,.3); } }
:root[data-theme="dark"] { --gold: #e7c15a; --shadow: 0 1px 2px rgba(0,0,0,.3); }

.me-btn { display: inline-flex; align-items: center; text-decoration: none; flex: none; }
.login-pill { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 16px; background: #fff; color: #1d3557; font-weight: 700; font-size: 13px; white-space: nowrap; }
.login-pill.dark { background: var(--navy); color: var(--surface); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; font-family: var(--font-head); font-weight: 900; color: #fff;
  background: linear-gradient(135deg, #c8102e, #1d3557); font-size: 18px; }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
.avatar.xl { width: 104px; height: 104px; font-size: 44px; box-shadow: 0 0 0 5px var(--bg); }

/* ストーリー風のコース一覧 */
.stories { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.stories::-webkit-scrollbar { display: none; }
.hscroll { position: relative; min-width: 0; max-width: 100%; }
.hscroll .stories { scroll-snap-type: x proximity; scroll-padding: 0 4px; }
.hscroll .story { scroll-snap-align: start; }
.hscroll .stories.dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
.hscroll::before, .hscroll::after { content: ""; position: absolute; top: 0; bottom: 8px; width: 28px; pointer-events: none; z-index: 1; transition: opacity .2s; }
.hscroll::before { left: 0; background: linear-gradient(90deg, var(--bg), transparent); }
.hscroll::after { right: 0; background: linear-gradient(270deg, var(--bg), transparent); }
.hscroll.at-start::before, .hscroll.at-end::after { opacity: 0; }
.hs-btn { position: absolute; top: 26px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer; box-shadow: var(--shadow); display: none; place-items: center; padding: 0 0 3px; }
.hs-btn.prev { left: -6px; } .hs-btn.next { right: -6px; }
@media (hover: hover) and (pointer: fine) { .hs-btn { display: grid; } }
.hscroll.at-start .hs-btn.prev, .hscroll.at-end .hs-btn.next { display: none; }
.story { flex: none; display: grid; justify-items: center; gap: 6px; text-decoration: none; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; width: 76px; }
.story .ring { width: 72px; height: 72px; border-radius: 50%; padding: 3px; display: grid;
  background: conic-gradient(from 210deg, var(--cc), color-mix(in srgb, var(--cc) 40%, #ffd23f), var(--cc)); transition: transform .15s; }
.story:hover .ring { transform: scale(1.05); }
.story-in { border-radius: 50%; display: grid; place-items: center; background: var(--cc); color: #fff; font-family: var(--font-head); font-weight: 900;
  font-size: 13px; letter-spacing: -.02em; box-shadow: inset 0 0 0 3px var(--bg); }
.story-label { font-size: 11px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 76px; }
.story.has .story-label { color: var(--ok); font-weight: 700; }
.story:not(.has)[data-add] .ring { background: repeating-conic-gradient(var(--cc) 0 12deg, transparent 12deg 20deg); }

/* ホームのレイアウト */
.hero { grid-template-columns: minmax(0, 1fr); }
.me-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: var(--ink); margin-bottom: 18px; box-shadow: var(--shadow); }
.me-card > span:nth-child(2) { display: grid; min-width: 0; flex: 1; }
.me-card small { color: var(--ink-2); font-size: 12px; }
.me-card em { color: var(--bad); font-style: normal; font-weight: 700; }
.me-card.guest .avatar { background: var(--accent); }
.mini-badges { display: flex; gap: 2px; }
.feed-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.feed-main { display: grid; gap: 18px; min-width: 0; }
.feed-main .section { margin-top: 8px; }
.feed-side { display: grid; gap: 14px; position: sticky; top: calc(var(--header-h) + 16px); }
.feed-side .scene { margin-bottom: 8px; padding: 8px 12px; background: var(--surface-2); }
.side-link { display: flex; gap: 8px; padding: 5px 0; text-decoration: none; color: var(--ink); font-size: 14px; }
.side-link .num { font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); width: 22px; padding-top: 3px; }
@media (max-width: 1100px) { .feed-grid { grid-template-columns: minmax(0, 1fr); } .feed-side { position: static; } }
.quick a { box-shadow: var(--shadow); border-color: transparent; }
.quick a.tool.alt { background: var(--accent); color: var(--accent-ink); }
.quick a.tool.alt span { color: var(--accent-ink); }

/* 今日の1問 */
.daily { background: var(--surface); border-radius: 16px; padding: 16px; display: grid; gap: 12px; box-shadow: var(--shadow); border: 1px solid var(--line);
  background-image: radial-gradient(circle at 100% 0, var(--accent-soft), transparent 40%); }
.daily-head { display: flex; justify-content: space-between; align-items: center; }
.daily .k { font-family: var(--font-head); font-weight: 900; color: var(--accent); }
.daily h3 { font-size: 17px; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.opts button { border: 2px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px; padding: 10px; cursor: pointer; font-weight: 700; text-align: left; }
.opts button:hover:not(:disabled) { border-color: var(--navy); }
.opts button.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, var(--surface)); }
.opts button.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.opts button:disabled { cursor: default; }
.daily-why { margin: 0; font-size: 14px; }

/* フィードカード */
.card.feed { padding: 0; overflow: hidden; gap: 0; border: 0; box-shadow: var(--shadow); transition: transform .15s; }
a.card.feed:hover { transform: translateY(-2px); }
.card.feed .cover { display: grid; align-content: end; gap: 2px; min-height: 92px; padding: 12px 14px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--cc), color-mix(in srgb, var(--cc) 55%, #0b1420)); }
.card.feed .cover::after { content: ""; position: absolute; right: -24px; top: -24px; width: 96px; height: 96px; border-radius: 50%; border: 14px solid rgba(255,255,255,.14); }
.card.feed .cover .k { color: rgba(255,255,255,.85); font-size: 10px; }
.card.feed .cover b { font-family: var(--font-head); font-size: 19px; font-weight: 900; line-height: 1.25; position: relative; z-index: 1; }
.feed-body { display: grid; gap: 8px; padding: 12px 14px 14px; }
.feed-body .chip { background: transparent; padding: 0; color: var(--navy); font-size: 12px; }

/* 記事ヘッダーにコースカラー */
.entry-head { border-top: 6px solid var(--cc); padding-top: 14px; }
.entry-head .chip.type { background: var(--cc); color: #fff; }
.save-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 700; }
.save-btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* 資格バッジ（エンブレム） */
.emblem { --sz: 64px; width: var(--sz); height: var(--sz); border-radius: 50%; flex: none; display: grid; padding: 3px;
  background: conic-gradient(var(--cc), color-mix(in srgb, var(--cc) 50%, #fff), var(--cc)); box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.emblem-in { border-radius: 50%; background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--cc) 70%, #fff), var(--cc) 55%, color-mix(in srgb, var(--cc) 70%, #000));
  color: #fff; display: grid; place-content: center; text-align: center; line-height: 1.05; }
.emblem-in b { font-family: var(--font-head); font-weight: 900; font-size: calc(var(--sz) * .22); letter-spacing: -.02em; }
.emblem-in i { font-style: normal; font-family: var(--font-mono); font-size: calc(var(--sz) * .1); letter-spacing: .06em; opacity: .9; margin-top: 2px; }
.emblem.sm { --sz: 30px; padding: 2px; }
.emblem.sm .emblem-in i { display: none; }
.emblem.lg { --sz: 76px; }

/* マイページ */
.profile { background: var(--surface); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
.profile .cover { height: 120px; background:
  radial-gradient(circle at 20% 120%, rgba(255,255,255,.25) 0 30%, transparent 31%),
  linear-gradient(120deg, var(--c1), #1d3557 70%, #c8102e); }
.profile-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; padding: 0 18px 14px; margin-top: -52px; }
.profile-id { flex: 1; min-width: 180px; display: grid; gap: 4px; padding-bottom: 4px; }
.profile-id h1 { font-size: 24px; }
.handle { color: var(--ink-2); font-size: 13px; }
.title-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.title-chip.instructor { background: linear-gradient(90deg, #ecd58a, #f8edc4); }
.title-chip.provider { background: var(--surface-2); color: var(--ink-2); }
.dup-note { margin: 6px 0 0; font-size: 12px; color: var(--bad); }
.dup-note:empty { display: none; }
.title-chip { justify-self: start; background: linear-gradient(90deg, var(--gold), #f3d98b); color: #3d2b00; font-weight: 700; font-size: 13px; padding: 3px 12px; border-radius: 999px; }
.profile-stats { display: flex; border-top: 1px solid var(--line); }
.profile-stats div { flex: 1; text-align: center; padding: 10px 0; display: grid; }
.profile-stats b { font-family: var(--font-mono); font-size: 20px; }
.profile-stats span { font-size: 12px; color: var(--ink-2); }
.alert-card { margin-top: 16px; border-radius: 14px; padding: 12px 16px; background: color-mix(in srgb, var(--bad) 12%, var(--surface)); border: 1px solid var(--bad); color: var(--ink); display: grid; gap: 4px; font-size: 14px; }
.alert-card b { color: var(--bad); }
.cred-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.cred { display: flex; gap: 14px; align-items: flex-start; background: var(--surface); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); border-left: 6px solid var(--cc); min-width: 0; }
.cred-body { flex: 1; min-width: 0; display: grid; gap: 6px; font-size: 13px; }
.cred-title { font-family: var(--font-head); font-weight: 900; font-size: 18px; }
.cred-title span { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.mono { font-family: var(--font-mono); }
.exp { justify-self: start; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.exp.green { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.exp.amber { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.exp.red { background: var(--bad); color: #fff; animation: blink 1.4s steps(2) infinite; }
.exp.none { background: var(--surface-2); color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { .exp.red { animation: none; } }
.icon-btn { border: 0; background: var(--surface-2); color: var(--ink); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; flex: none; }
.empty { padding: 18px; border: 2px dashed var(--line); border-radius: 14px; color: var(--ink-2); font-size: 14px; text-align: center; }

/* ボトムシート（資格の追加） */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(10,15,25,.5); display: grid; align-items: end; justify-items: center; }
.sheet { width: min(560px, 100%); max-height: 92vh; overflow: auto; background: var(--surface); color: var(--ink); border-radius: 20px 20px 0 0; display: grid; gap: 14px;
  padding: 18px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); animation: up .2s ease-out; }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 20px; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet-head { display: flex; gap: 12px; align-items: center; }
.sheet-head > div { flex: 1; min-width: 0; }
.sheet-head h2 { font-size: 20px; }
.sheet-head small { color: var(--ink-2); font-size: 12px; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 13px; font-weight: 700; }
.form input, .form select { font: inherit; font-weight: 400; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%; }
.lbl { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.seg.wrap { flex-wrap: wrap; }
.chip-btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.btn.big { padding: 12px 22px; font-size: 16px; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.form-err { color: var(--bad); margin: 0; font-size: 13px; min-height: 1em; }

/* ログイン画面 */
.auth { display: grid; grid-template-columns: 1fr minmax(0, 420px); gap: 32px; align-items: center; max-width: 960px; margin: 0 auto; padding-top: 12px; }
.auth-art { display: grid; grid-template-columns: repeat(3, auto); justify-content: center; gap: 18px; }
.auth-art .emblem { --sz: 96px; }
.auth-art .emblem:nth-child(even) { transform: translateY(24px) rotate(-6deg); }
.auth-card { background: var(--surface); border-radius: 18px; padding: 22px; display: grid; gap: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.auth-card h1 { font-size: 24px; }
@media (max-width: 760px) { .auth { grid-template-columns: minmax(0, 1fr); gap: 20px; } .auth-art .emblem { --sz: 64px; } .auth-art { gap: 12px; } }
@media (max-width: 860px) { .top-inner { gap: 8px; } .brand > span:last-child { display: none; } }
.beat.pulse.on { background: var(--t-red); border-color: var(--t-red); color: #fff; }
.quick a.tool.alt2 { background: #b7791f; color: #fff; }
.quick a.tool.alt2 span { color: #fff; }
.quick { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (max-width: 860px) {
  .hero { padding: 0 0 12px; gap: 10px; margin-bottom: 14px; }
  .hero h1 { font-size: 24px; }
  .hero .lead { font-size: 13px; line-height: 1.6; }
  .quick { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .quick a { padding: 12px 10px; min-height: 72px; }
  .quick a b { font-size: 14px; line-height: 1.3; }
  .quick a span { font-size: 11px; line-height: 1.4; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .card.feed .cover { min-height: 76px; }
  .page-head h1 { font-size: 24px; }
  .prose h2 { font-size: 18px; }
  .tool-panel { padding: 14px; }
  .btn { min-height: 44px; }
  .seg button { min-height: 40px; }
}
@media (max-width: 380px) { .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bpm-ctl { flex-wrap: wrap; justify-content: center; }
@media (max-width: 480px) { .bpm-ctl .btn { padding: 9px 10px; } }
.profile-head { align-items: flex-start; }
.profile-id { margin-top: 58px; }
.profile-actions { margin-top: 58px; }
@media (max-width: 600px) { .profile-actions { margin-top: 0; width: 100%; } .profile-id { min-width: 0; flex-basis: calc(100% - 130px); } }
.metro-face { grid-template-columns: minmax(0, 1fr); }
.metro-face > * { max-width: 100%; }
.seg.wrap { display: flex; flex-wrap: wrap; }
.seg.wrap button { flex: 1 0 auto; }
.quick a.tool.alt3 { background: #2b9348; color: #fff; }
.quick a.tool.alt3 span { color: #fff; }
.tri-card { display: grid; gap: 14px; border: 2px solid var(--navy); border-radius: 14px; padding: 14px; background: var(--bg); }
.tri-no { font-family: var(--font-head); font-size: 20px; }
.tri-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.tri-chk { display: flex; align-items: center; gap: 10px; text-align: left; border: 2px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px; padding: 10px 12px; min-height: 52px; cursor: pointer; font-weight: 700; font-size: 14px; }
.tri-chk small { font-family: var(--font-mono); color: var(--ink-2); font-size: 11px; }
.tri-chk .box-ic { width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center; flex: none; font-size: 14px; }
.tri-chk.on { border-color: var(--navy); background: color-mix(in srgb, var(--navy) 10%, var(--surface)); }
.tri-chk.on .box-ic { background: var(--navy); border-color: var(--navy); color: var(--surface); }
.tri-colors { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tri-col { border: 3px solid transparent; border-radius: 12px; min-height: 60px; font-size: 20px; font-weight: 900; font-family: var(--font-head); cursor: pointer; opacity: .55; }
.tri-colors.small .tri-col { min-height: 40px; font-size: 15px; }
.tri-col.c-red { background: var(--t-red); color: #fff; }
.tri-col.c-yellow { background: var(--t-yellow); color: #1a1a1a; }
.tri-col.c-green { background: var(--t-green); color: #fff; }
.tri-col.c-black { background: var(--t-black); color: var(--surface); }
.tri-col.hint { opacity: .85; border-style: dashed; border-color: var(--ink); }
.tri-col.on { opacity: 1; border-color: var(--ink); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); }

/* バッジの枠：プロバイダー＝コース色の縁のみ、インストラクター＝細い金枠（マスター制度ありは黄枠）、マスター＝細い金枠 */
.emblem { padding: 0; background: none; border: 2px solid var(--ccl); box-shadow: 0 2px 8px rgba(0,0,0,.16); }
.emblem-in { color: var(--ink, #fff); background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--cc) 75%, #fff), var(--cc) 55%, var(--cc2, color-mix(in srgb, var(--cc) 75%, #000))); }
.emblem.f-gold, .emblem.f-yellow { border: 0; padding: 2px; }
.emblem.f-gold { background: conic-gradient(from 30deg, #b8860b, #ffe9a0, #c9982e, #fff4c8, #9c7416, #e9c45c, #b8860b); }
.emblem.f-yellow { background: #f5d300; }
.emblem.f-gold .emblem-in, .emblem.f-yellow .emblem-in { box-shadow: inset 0 0 0 2px var(--surface); }
.emblem.long .emblem-in b { font-size: calc(var(--sz) * .13); }
.story-in { color: var(--ink, #fff); box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 4px var(--ccl); }
.story-in.long { font-size: 10px; }
.card.feed .cover { color: var(--ink, #fff); background: linear-gradient(135deg, var(--cc), var(--cc2, color-mix(in srgb, var(--cc) 55%, #0b1420))); }
.card.feed .cover .k { color: inherit; opacity: .8; }
.entry-head { border-top-color: var(--ccl, var(--cc)); }
.entry-head .chip.type { background: var(--ccl, var(--cc)); }
.cred { border-left-color: var(--ccl, var(--cc)); }
.story .ring { background: conic-gradient(from 210deg, var(--ccl), color-mix(in srgb, var(--ccl) 40%, #ffd23f), var(--ccl)); }
.story:not(.has)[data-add] .ring { background: repeating-conic-gradient(var(--ccl) 0 12deg, transparent 12deg 20deg); }
.emblem.f-gold, .emblem.f-yellow { padding: 3px; }
.emblem.f-gold { box-shadow: 0 0 0 1px rgba(184,134,11,.35), 0 2px 10px rgba(201,152,46,.45); }
.emblem.f-gold .emblem-in i { color: inherit; }
.emblem.sm.f-gold, .emblem.sm.f-yellow { padding: 2px; }
@media (max-width: 860px) { .hero h1 { font-size: 22px; } }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.ladder.compact li { grid-template-columns: 32px 1fr; }
.ladder.compact li::before { width: 32px; height: 32px; font-size: 13px; }
.chip-btn.official { background: var(--navy); color: var(--surface); border-color: transparent; font-weight: 700; }
.hp-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.hp-head { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.hp-h { font-size: 16px; margin-top: 4px; }
.hp-h small { font-weight: 400; font-size: 12px; color: var(--ink-2); }
.hp-q input { width: 76px; font: inherit; font-family: var(--font-mono); padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); text-align: right; }
.exp.redstatic { background: var(--bad); color: #fff; }
.hp-group { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 6px; background: var(--bg); }
.hp-gh { font-family: var(--font-head); font-weight: 700; }
.hp-item { display: flex; gap: 10px; align-items: center; justify-content: space-between; border-top: 1px dashed var(--line); padding-top: 6px; font-size: 14px; }
.hp-item > span:first-child { min-width: 0; }
.hp-marks { display: flex; gap: 4px; flex: none; }
.hp-marks button { width: 40px; height: 40px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font-size: 17px; font-weight: 900; cursor: pointer; }
.hp-marks .mk-o.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.hp-marks .mk-t.on { background: var(--warn); border-color: var(--warn); color: #fff; }
.hp-marks .mk-x.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.hp-memo { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.hp-memo input, .hp-kpt textarea { font: inherit; font-size: 15px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 100%; }
.hp-kpt { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.hp-kpt label { display: grid; gap: 4px; font-size: 13px; font-weight: 700; }
@media (max-width: 480px) { .hp-item { flex-direction: column; align-items: stretch; } .hp-marks { justify-content: flex-end; } }
@media print {
  .tool-panel.print-keep { display: grid !important; border: 0; padding: 0; }
  .tool-panel.print-keep .no-print { display: none !important; }
  .hp-marks button { width: 26px; height: 26px; font-size: 12px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (max-width: 600px) {
  .hp-q thead { display: none; }
  .hp-q tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 10px; border-bottom: 1px solid var(--line); }
  .hp-q td { border: 0; padding: 2px 0; }
  .hp-q td:first-child, .hp-q td:nth-child(2) { grid-column: 1 / -1; }
  .hp-q td:nth-child(2) { font-size: 12px; color: var(--ink-2); }
  .hp-q td:nth-child(2)::before { content: "目標："; }
}

/* ===== プロフィール写真・共有 ===== */
.avatar.photo { background: var(--surface); overflow: hidden; }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.pf-photo { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.pf-photo .avatar.xl { box-shadow: 0 0 0 3px var(--line); }
.pf-photo-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; min-width: 180px; }
.pf-photo-btns label.btn { display: inline-flex; align-items: center; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.pf-photo-btns:focus-within label.btn { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { margin: 0; font-size: 12px; color: var(--ink-2); flex-basis: 100%; }
.share-box { display: grid; gap: 10px; }
.share-state { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.share-state.on { border-color: var(--ok); }
.share-url { display: flex; gap: 8px; }
.share-url input { flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-family: var(--font-mono, monospace); font-size: 13px; }
.share-box .row a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); }
