/* RadarRisk web demo — calm clinical-information look, phone first. */

@font-face {
  font-family: "Noto Sans JP Subset";
  src: url("fonts/NotoSansJP-Regular.subset.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans JP Subset";
  src: url("fonts/NotoSansJP-Bold.subset.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --g900: #12352b;
  --g800: #1d4d3f;      /* primary */
  --g700: #2a6150;
  --g200: #c9dbd3;
  --g100: #e4eee9;
  --g50:  #f1f6f3;
  --ink:   #17221e;
  --ink-2: #44544e;     /* 8.1:1 on white */
  --ink-3: #5f6e68;     /* 5.3:1 on white */
  --bg:      #f4f5f2;
  --surface: #ffffff;
  --line:        #dfe5e1;
  --line-strong: #c3cdc8;

  --high:    #b3261e;  --high-bg: #fcecea;  --high-ink: #8c1d17;
  --medium:  #9a5b00;  --medium-bg: #fcf1dd; --medium-ink: #7a4800;
  --low:     #2b7448;  --low-bg: #e6f2ea;   --low-ink: #1f5a37;

  --src-record-bg: #e7efeb; --src-record: #1d4d3f;
  --src-pattern-bg: #e9eef5; --src-pattern: #2c4a6e;
  --src-radar-bg: #efecf6;  --src-radar: #4f3d7a;

  --radius: 14px;
  --radius-lg: 18px;
  --gutter: 16px;
  --font: "Noto Sans JP Subset", system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
          "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}
p, li { text-wrap: pretty; }
.title, .step-head, .failed-title { text-wrap: balance; }
html[lang="ja"] :is(.title, .lede, .notice, .hint, .failed-title, .failed-body, .action-hint, .persona-sit, .footer-honest) { word-break: auto-phrase; }
h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button { font: inherit; color: inherit; letter-spacing: inherit; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
svg.ic, button svg, .notice svg, .hint svg { width: 1em; height: 1em; flex: none; }
:focus-visible { outline: 3px solid #3d8f73; outline-offset: 2px; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 var(--gutter);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 0 10px;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--g800); white-space: nowrap; overflow-wrap: normal; }
.brand-mark {
  width: 32px; height: 32px; padding: 6px; border-radius: 9px;
  background: var(--g800); color: #fff; flex: none;
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .01em; }
.brand-tag {
  font-size: 11.5px; font-weight: 700; color: var(--g800);
  border: 1px solid var(--g200); border-radius: 999px; padding: 1px 7px;
}
.lang {
  display: flex; flex: none; padding: 3px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
}
.lang button {
  min-width: 48px; min-height: 44px; padding: 0 10px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 700; cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--g800); color: #fff; }

.fixture-flag {
  margin: 0 0 8px; padding: 6px 12px; border-radius: 10px;
  background: #fff6d6; border: 1px dashed #b88a00; color: #5e4500; font-size: 13px; font-weight: 700;
}

main { flex: 1; }
.view { padding-bottom: 8px; }

/* ---------- loading skeleton ---------- */
.sk { background: #e6e9e6; border-radius: 10px; margin: 12px 0; position: relative; overflow: hidden; }
.sk-title { height: 32px; width: 78%; margin-top: 20px; }
.sk-line { height: 14px; width: 100%; }
.sk-line.short { width: 60%; }
.sk-card { height: 76px; border-radius: var(--radius); }
.sk::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(255, 255, 255, .55);
  transform: translateX(-100%);
  animation: sk 1.3s ease-in-out infinite;
}
@keyframes sk { to { transform: translateX(100%); } }

/* ---------- error ---------- */
.view-error { text-align: center; padding: 56px 8px; color: var(--ink-2); }
.view-error p { margin: 12px 0 20px; }
.error-icon { width: 40px; height: 40px; color: var(--high); }

/* ---------- intro ---------- */
.intro { padding: 18px 0 6px; }
.title {
  font-size: 27px; line-height: 1.35; font-weight: 700; letter-spacing: .01em; color: var(--g900);
  outline: none;
}
.lede { margin-top: 10px; color: var(--ink-2); font-size: 15px; line-height: 1.7; }
.notice {
  display: flex; gap: 8px; align-items: flex-start;
  margin-top: 14px; padding: 10px 12px;
  border-left: 3px solid var(--g800); background: var(--g50);
  border-radius: 0 10px 10px 0;
  color: var(--g900); font-size: 14px; font-weight: 700; line-height: 1.55;
}
.notice svg { margin-top: .2em; font-size: 16px; color: var(--g800); }

/* ---------- steps ---------- */
.step { padding-top: 26px; }
.step-head {
  display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 10px; row-gap: 2px;
  font-size: 19px; line-height: 1.4; font-weight: 700; color: var(--ink);
  margin-bottom: 12px;
}
.step-num {
  align-self: center;
  display: inline-grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--g800); color: #fff; font-size: 15px; line-height: 1;
}
.step-note { font-size: 13px; font-weight: 400; color: var(--ink-3); }

/* personas: radio cards */
.personas { display: grid; gap: 10px; }
.persona {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 76px; padding: 12px 14px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.persona:active { transform: scale(.995); }
.persona[aria-checked="true"] {
  border-color: var(--g800); background: var(--g50);
  box-shadow: inset 0 0 0 1px var(--g800);
}
.avatar {
  display: grid; place-items: center; flex: none;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--g100); font-size: 27px; line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.persona[aria-checked="true"] .avatar { background: #fff; }
.avatar-sm { width: 36px; height: 36px; font-size: 20px; }
.persona-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.persona-line { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 8px; }
.persona-name { font-size: 17px; font-weight: 700; color: var(--ink); }
.persona-meta { font-size: 13px; color: var(--ink-3); }
.persona-sit { font-size: 14px; line-height: 1.5; color: var(--ink-2); margin-top: 1px; }
.radio {
  display: grid; place-items: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--line-strong); color: transparent; font-size: 14px;
  transition: background-color .15s, border-color .15s;
}
.persona[aria-checked="true"] .radio { background: var(--g800); border-color: var(--g800); color: #fff; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 46px; padding: 9px 16px; max-width: 100%;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 999px;
  font-size: 15px; line-height: 1.35; text-align: left; color: var(--ink); cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.chip .chip-check { width: 0; opacity: 0; margin-right: -6px; transition: width .15s var(--ease), opacity .15s, margin .15s; }
.chip[aria-pressed="true"] { background: var(--g800); border-color: var(--g800); color: #fff; font-weight: 700; }
.chip[aria-pressed="true"] .chip-check { width: 1em; opacity: 1; margin-right: 0; }
.chip-or {
  display: flex; align-items: center; gap: 10px; margin: 14px 0 10px;
  color: var(--ink-3); font-size: 12px;
}
.chip-or::before, .chip-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* speed segment */
.segment {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius);
}
.segment button {
  min-height: 50px; padding: 6px 4px; border: 0; border-radius: 10px;
  background: transparent; color: var(--ink-2); font-size: 15px; font-weight: 700; line-height: 1.3; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.segment button[aria-checked="true"] { background: var(--g800); color: #fff; }
.hint {
  display: flex; gap: 6px; align-items: flex-start; margin-top: 10px;
  font-size: 13px; line-height: 1.6; color: var(--ink-3);
}
.hint svg { margin-top: .25em; color: var(--src-radar); }

/* sticky action bar */
.actionbar {
  position: sticky; bottom: 0; z-index: 5;
  margin: 26px calc(-1 * var(--gutter)) 0;
  padding: 10px var(--gutter) max(12px, env(safe-area-inset-bottom));
  background: rgba(244, 245, 242, .94);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.action-hint {
  min-height: 1.5em; margin-bottom: 8px; text-align: center;
  font-size: 13px; line-height: 1.5; color: var(--ink-3);
}
.action-hint.is-ready { color: var(--g800); font-weight: 700; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: 999px; cursor: pointer;
  font-size: 17px; font-weight: 700; border: 1.5px solid transparent;
  transition: background-color .15s, opacity .15s, transform .1s;
}
.btn:active:not(:disabled) { transform: scale(.985); }
.btn-primary { background: var(--g800); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--g900); }
.btn-predict { width: 100%; min-height: 56px; font-size: 18px; letter-spacing: .08em; }
.btn-predict:disabled { background: #b9c4bf; color: #fff; cursor: not-allowed; }
.btn-quiet { background: var(--surface); border-color: var(--line-strong); color: var(--g800); }
.btn-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 2px;
  background: none; border: 0; color: var(--g800); font-size: 14px; font-weight: 700;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.btn-icon {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--g50); border: 0; color: var(--ink-2); font-size: 20px; cursor: pointer;
}

/* ---------- result ---------- */
.result-top { padding-top: 6px; }
.btn-back {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 10px 0 2px;
  background: none; border: 0; color: var(--g800); font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-back svg { font-size: 20px; }

.inputs {
  margin-top: 4px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.inputs-label { font-size: 12px; font-weight: 700; color: var(--ink-3); letter-spacing: .04em; }
.inputs-who { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 16px; }
.inputs-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.inputs-tags li {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; background: var(--g50); border: 1px solid var(--g100);
  font-size: 13px; line-height: 1.5; color: var(--g900);
}
.inputs-tags .tag-speed { background: var(--src-radar-bg); border-color: #e0dbee; color: var(--src-radar); }

.risk {
  margin-top: 14px; padding: 18px 16px;
  border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line);
  border-top: 6px solid var(--line-strong);
}
.risk-high { border-top-color: var(--high); }
.risk-medium { border-top-color: var(--medium); }
.risk-low { border-top-color: var(--low); }
.risk-row { display: flex; align-items: center; gap: 16px; }
.badge {
  display: grid; place-items: center; flex: none;
  width: 92px; height: 92px; border-radius: 22px;
  font-size: 50px; font-weight: 700; line-height: 1; color: #fff;
  background: var(--ink-3);
}
.badge-word { font-size: 24px; letter-spacing: 0; }
.badge-high { background: var(--high); }
.badge-medium { background: var(--medium); }
.badge-low { background: var(--low); }
.badge-failed { background: var(--g50); color: var(--ink-3); border: 2px dashed var(--line-strong); }
.risk-side { flex: 1; min-width: 0; }
.risk-label { font-size: 15px; font-weight: 700; color: var(--ink-2); }
.scale {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 10px;
}
.scale li {
  position: relative; padding-top: 12px; text-align: center;
  font-size: 13px; line-height: 1.3; color: var(--ink-3);
}
.scale li::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; border-radius: 3px;
  background: var(--line);
}
.scale li.on { font-weight: 700; }
.risk-high .scale li.on { color: var(--high-ink); }
.risk-medium .scale li.on { color: var(--medium-ink); }
.risk-low .scale li.on { color: var(--low-ink); }
.risk-high .scale li.on::before { background: var(--high); }
.risk-medium .scale li.on::before { background: var(--medium); }
.risk-low .scale li.on::before { background: var(--low); }
.failed-title { margin-top: 4px; font-size: 18px; line-height: 1.45; font-weight: 700; color: var(--ink); }
.failed-why { display: block; text-wrap: pretty; margin-top: 4px; font-size: 14px; font-weight: 400; line-height: 1.6; color: var(--ink-2); }
.failed-body { margin-top: 14px; font-size: 14px; line-height: 1.7; color: var(--ink-2); }

.block { margin-top: 26px; }
.block-head {
  font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--ink-3);
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
html[lang="en"] .block-head { text-transform: uppercase; letter-spacing: .1em; }
.reason { padding: 14px 0; border-bottom: 1px solid var(--line); }
.src {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px 2px 8px; border-radius: 6px;
  font-size: 12.5px; font-weight: 700; line-height: 1.6;
}
.src svg { font-size: 14px; }
.src-record { background: var(--src-record-bg); color: var(--src-record); }
.src-pattern { background: var(--src-pattern-bg); color: var(--src-pattern); }
.src-radar { background: var(--src-radar-bg); color: var(--src-radar); }
.reason-text { margin-top: 6px; font-size: 16px; line-height: 1.7; color: var(--ink); }
.pattern {
  margin-top: 8px; padding: 8px 12px;
  border-left: 3px solid var(--src-pattern); background: #f5f7fa; border-radius: 0 8px 8px 0;
  display: flex; flex-direction: column; gap: 1px;
}
.pattern-name { font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.pattern-n { font-size: 15px; font-weight: 700; color: var(--src-pattern); font-variant-numeric: tabular-nums; }
.orphan { padding-top: 12px; }
.mini-head { font-size: 13px; font-weight: 700; color: var(--ink-3); }

.cms { margin-top: 4px; }
.cm-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line); font-size: 16px; line-height: 1.6;
}
.cm-num {
  display: grid; place-items: center; flex: none; margin-top: 1px;
  width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--g800); color: var(--g800); font-size: 13px; font-weight: 700; line-height: 1;
}
.cm-text { min-width: 0; }

.result-actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 28px; }

/* reveal animation (skipped with prefers-reduced-motion) */
@media (prefers-reduced-motion: no-preference) {
  .view-result .badge { transform: scale(.6); opacity: 0; }
  .view-result .scale li::before { transform: scaleX(.2); transform-origin: left; opacity: .3; }
  .view-result .rv, .view-result .block-head, .view-result .failed-body { opacity: 0; transform: translateY(8px); }
  .view-result.revealed .badge { animation: pop .48s var(--ease) .05s forwards; }
  .view-result.revealed .scale li::before { animation: grow .5s var(--ease) .25s forwards; }
  .view-result.revealed .block-head,
  .view-result.revealed .failed-body { animation: rise .4s var(--ease) .3s forwards; }
  .view-result.revealed .rv { animation: rise .45s var(--ease) forwards; animation-delay: calc(.42s + var(--i, 0) * .12s); }
}
@keyframes pop {
  0% { transform: scale(.6); opacity: 0; }
  65% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes grow { to { transform: scaleX(1); opacity: 1; } }
@keyframes rise { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- footer ---------- */
.footer {
  margin-top: 36px; padding: 18px 0 max(24px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12.5px; line-height: 1.65;
}
.footer-honest { color: var(--ink-2); font-size: 13px; font-weight: 700; }
.footer-honest + .footer-honest { margin-top: 2px; }
.footer .btn-link { margin-top: 6px; }
.credits { margin-top: 8px; }
.credits p + p { margin-top: 4px; }
body[data-state="pick"] .footer { margin-top: 20px; }

/* ---------- about sheet ---------- */
.sheet {
  width: 100%; max-width: 480px; max-height: 86vh; max-height: 86dvh;
  margin: auto auto 0; padding: 0; border: 0;
  border-radius: 20px 20px 0 0; background: var(--surface); color: var(--ink);
  box-shadow: 0 -8px 30px rgba(18, 53, 43, .18);
}
.sheet::backdrop { background: rgba(18, 30, 26, .45); }
.sheet[open] { animation: sheet-up .32s var(--ease); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-inner { display: flex; flex-direction: column; max-height: inherit; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 10px 20px; border-bottom: 1px solid var(--line);
}
.sheet-head h2 { font-size: 18px; font-weight: 700; outline: none; }
.sheet-body {
  overflow-y: auto; padding: 6px 20px max(24px, env(safe-area-inset-bottom));
  font-size: 14.5px; line-height: 1.75; color: var(--ink-2);
}
.sheet-body h3 { margin-top: 18px; font-size: 15px; font-weight: 700; color: var(--g900); }
.sheet-body p, .sheet-body ul { margin-top: 6px; }
.sheet-body ul li { position: relative; padding-left: 14px; }
.sheet-body ul li + li { margin-top: 4px; }
.sheet-body ul li::before {
  content: ""; position: absolute; left: 2px; top: .75em; width: 5px; height: 5px; border-radius: 50%;
  background: var(--g700);
}
.sheet-body b { color: var(--ink); }
.sheet-body a { color: var(--g800); font-weight: 700; }

/* larger screens: keep the phone column, add breathing room */
@media (min-width: 560px) {
  .intro { padding-top: 32px; }
  .title { font-size: 30px; }
}
