:root {
  --ink: #102219;
  --forest: #123c30;
  --moss: #31755a;
  --mint: #b9e2c8;
  --cream: #f2f0e7;
  --paper: #fbfaf5;
  --orange: #f47b45;
  --blue: #227eb1;
  --line: rgba(16, 34, 25, .16);
  --shadow: 0 24px 70px rgba(20, 50, 38, .14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 12%, rgba(185, 226, 200, .8), transparent 27rem),
    linear-gradient(135deg, #ebeade 0%, var(--cream) 55%, #e5eadf 100%);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}

button, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, textarea:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 3px solid rgba(34, 126, 177, .4);
  outline-offset: 3px;
}
.noise {
  position: fixed; inset: 0; pointer-events: none; opacity: .22;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}

.shell { position: relative; width: min(1100px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0 38px; }
.masthead, .masthead-actions, .brand, .service-state { display: flex; align-items: center; }
.masthead { justify-content: space-between; gap: 16px; }
.masthead-actions { gap: 9px; }
.brand { gap: 12px; color: var(--ink); text-decoration: none; }
.brand-icon { width: 48px; height: 48px; border-radius: 11px; box-shadow: 0 5px 13px rgba(9,34,50,.2); }
.brand > span { display: grid; gap: 2px; }
.brand strong { font-size: 19px; letter-spacing: .04em; }
.brand small { color: rgba(16,34,25,.55); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.service-state { gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(251,250,245,.55); font-size: 12px; font-weight: 700; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: #d3a848; box-shadow: 0 0 0 4px rgba(211,168,72,.13); }
.service-state.ready .state-dot { background: #3d9b68; box-shadow: 0 0 0 4px rgba(61,155,104,.13); }
.service-state.error .state-dot { background: #d6534d; }
.menu-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: rgba(251,250,245,.65); font-weight: 900; letter-spacing: 1px; cursor: pointer; }

.hero { padding: clamp(56px, 8vw, 104px) 0 38px; }
.eyebrow, .result-kicker { margin: 0 0 14px; color: var(--moss); font: 800 11px/1.2 ui-monospace, SFMono-Regular, monospace; letter-spacing: .18em; }
h1 { max-width: 800px; margin: 0; font-size: clamp(48px, 8vw, 92px); line-height: .98; letter-spacing: -.075em; font-weight: 800; }
h1 em { color: var(--moss); font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-weight: 600; font-style: normal; letter-spacing: -.08em; }
.lead { max-width: 650px; margin: 26px 0 0; color: rgba(16,34,25,.7); font-size: clamp(15px, 2vw, 18px); line-height: 1.85; }
.runtime-note { max-width: 700px; margin: 18px 0 0; padding-left: 13px; border-left: 3px solid var(--blue); color: rgba(16,34,25,.67); font-size: 12px; line-height: 1.7; }

.search-panel, .result-panel { border: 1px solid rgba(255,255,255,.8); border-radius: 28px; background: rgba(251,250,245,.8); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.search-panel { padding: clamp(24px, 4vw, 42px); }
label { display: block; margin-bottom: 13px; font-size: 13px; font-weight: 800; }
textarea { width: 100%; min-height: 112px; resize: vertical; border: 0; border-bottom: 2px solid var(--ink); outline: 0; padding: 6px 0 17px; color: var(--ink); background: transparent; font: 600 clamp(20px, 3vw, 31px)/1.55 inherit; letter-spacing: -.025em; }
textarea::placeholder { color: rgba(16,34,25,.27); }
textarea:focus { border-color: var(--moss); }
.input-tools { display: flex; justify-content: flex-end; margin-top: 8px; }
#dismissKeyboard { display: none; padding: 6px 10px; border: 0; border-radius: 999px; color: var(--moss); background: rgba(185,226,200,.42); font-size: 11px; font-weight: 800; cursor: pointer; }
textarea:focus + .input-tools #dismissKeyboard { display: inline-block; }
.form-footer { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 16px; }
.hint { max-width: 560px; color: rgba(16,34,25,.55); font-size: 12px; line-height: 1.6; }
#submitButton { display: inline-flex; align-items: center; gap: 28px; flex: none; padding: 15px 17px 15px 23px; border: 0; border-radius: 999px; color: white; background: var(--forest); font-weight: 800; cursor: pointer; transition: transform .2s, background .2s; }
#submitButton:hover { transform: translateY(-2px); background: var(--moss); }
#submitButton:disabled { cursor: wait; opacity: .64; transform: none; }
#submitButton svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; padding-top: 21px; border-top: 1px solid var(--line); }
.examples button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: transparent; font-size: 12px; cursor: pointer; transition: background .2s, border-color .2s; }
.examples button:hover { background: var(--mint); border-color: transparent; }
.boundary-note { margin: 16px 0 0; color: rgba(16,34,25,.58); font-size: 11px; line-height: 1.7; }

.result-panel { margin-top: 24px; padding: clamp(24px, 4vw, 40px); }
.result-header { display: flex; align-items: start; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.result-header h2 { margin: 0; font-size: 24px; letter-spacing: -.04em; }
#elapsed { color: rgba(16,34,25,.54); font: 12px ui-monospace, monospace; }
.progress-steps { display: flex; gap: 0; margin: 20px 0 0; padding: 0; list-style: none; }
.progress-steps li { position: relative; flex: 1; padding-top: 17px; color: rgba(16,34,25,.4); font-size: 10px; font-weight: 800; text-align: center; }
.progress-steps li::before { content: ""; position: absolute; z-index: 1; top: 0; left: calc(50% - 5px); width: 10px; height: 10px; border: 2px solid var(--paper); border-radius: 50%; background: #b9c0bc; box-shadow: 0 0 0 1px rgba(16,34,25,.12); }
.progress-steps li:not(:last-child)::after { content: ""; position: absolute; top: 5px; left: 50%; width: 100%; height: 2px; background: #cfd5d1; }
.progress-steps li.active, .progress-steps li.done { color: var(--moss); }
.progress-steps li.active::before { background: var(--blue); box-shadow: 0 0 0 4px rgba(34,126,177,.14); }
.progress-steps li.done::before, .progress-steps li.done::after { background: var(--moss); }
.loading { display: flex; gap: 18px; align-items: center; padding-top: 28px; }
.loading strong, .loading small { display: block; }
.loading small { margin-top: 6px; color: rgba(16,34,25,.55); }
.rail-loader { position: relative; width: 48px; height: 48px; overflow: hidden; border-radius: 50%; background: var(--mint); }
.rail-loader::before { content: ""; position: absolute; left: 22px; width: 4px; height: 100%; background: var(--forest); }
.rail-loader i { position: absolute; left: 16px; width: 16px; height: 7px; border-radius: 6px; background: var(--orange); animation: ride 1.4s infinite ease-in-out; }
@keyframes ride { from { transform: translateY(-10px); } to { transform: translateY(58px); } }
.answer { padding: 24px 0 0; white-space: pre-wrap; color: var(--ink); font: 600 15px/2 "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif; }
.answer:empty { display: none; }
.error { margin: 24px 0 0; padding: 16px 18px; border-left: 4px solid #d6534d; background: rgba(214,83,77,.08); line-height: 1.7; white-space: pre-line; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 11px; margin-top: 20px; }
.choice-question { grid-column: 1 / -1; margin: 0 0 3px; font-size: 14px; font-weight: 800; }
.choice-button { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-height: 82px; padding: 17px 18px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: rgba(255,255,255,.52); text-align: left; cursor: pointer; transition: transform .18s, border-color .18s, background .18s; }
.choice-button:hover { transform: translateY(-2px); border-color: var(--moss); background: rgba(185,226,200,.3); }
.choice-button strong { font-size: 15px; }
.choice-button span { color: rgba(16,34,25,.58); font-size: 12px; line-height: 1.5; }
.choice-action { min-height: 68px; border-color: rgba(49,117,90,.36); background: rgba(185,226,200,.18); }
.map-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.map-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.map-heading span { color: var(--moss); font-size: 10px; font-weight: 800; letter-spacing: .06em; }
.map-heading h3 { margin: 3px 0 0; font-size: 18px; }
.map-heading small { color: rgba(16,34,25,.52); }
.map-frame { display: block; width: 100%; height: 420px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }

footer { max-width: 760px; padding: 32px 4px 0; color: rgba(16,34,25,.52); font-size: 11px; line-height: 1.8; }
footer p { margin: 0 0 7px; }
.footer-menu { padding: 0; border: 0; color: var(--moss); background: none; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.app-menu { width: min(620px, calc(100% - 24px)); max-height: min(760px, calc(100dvh - 32px)); margin: auto; padding: 0; border: 1px solid rgba(255,255,255,.8); border-radius: 24px; color: var(--ink); background: var(--paper); box-shadow: 0 28px 90px rgba(9,34,50,.3); }
.app-menu::backdrop { background: rgba(9,24,32,.47); backdrop-filter: blur(4px); }
.menu-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.menu-header h2 { margin: 0; font-size: 18px; }
.menu-header button { border: 0; color: var(--blue); background: none; font-weight: 800; cursor: pointer; }
.menu-scroll { max-height: calc(min(760px, 100dvh - 32px) - 62px); overflow: auto; padding: 12px 20px 22px; overscroll-behavior: contain; }
.menu-scroll > section, .menu-scroll > details { border-bottom: 1px solid var(--line); }
.menu-scroll > section { padding: 10px 0 13px; }
.menu-scroll > section h3 { margin: 0 0 8px; color: rgba(16,34,25,.52); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0; cursor: pointer; }
.toggle-row span { display: grid; gap: 4px; }
.toggle-row small { color: rgba(16,34,25,.58); font-weight: 400; line-height: 1.5; }
.toggle-row input { width: 44px; height: 24px; accent-color: var(--blue); }
.menu-scroll details { padding: 0; }
.menu-scroll summary { padding: 16px 2px; font-size: 14px; font-weight: 800; cursor: pointer; }
.menu-copy { margin: 0 2px 14px; color: rgba(16,34,25,.7); font-size: 12px; line-height: 1.75; }
.about-grid { display: grid; grid-template-columns: 1fr auto; gap: 7px 15px; padding: 11px 12px; border-radius: 12px; background: rgba(185,226,200,.2); }
.about-grid strong { color: var(--ink); text-align: right; }
.menu-links { display: grid; gap: 1px; margin: 0 0 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.menu-links a { padding: 11px 12px; color: var(--moss); background: var(--paper); font-size: 12px; font-weight: 700; text-decoration: none; }
.menu-links a:hover { background: rgba(185,226,200,.2); }
.notice { margin: 0 2px 14px; padding: 10px; border-radius: 9px; background: rgba(16,34,25,.05); font: 10px/1.6 ui-monospace, monospace; }
.prototype-note { margin-top: 18px; padding: 13px 15px; border-left: 4px solid var(--orange); background: rgba(244,123,69,.08); color: rgba(16,34,25,.68); font-size: 11px; line-height: 1.7; }
.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; }

@media (max-width: 640px) {
  .shell { width: min(100% - 24px, 1100px); padding-top: max(14px, env(safe-area-inset-top)); }
  .brand-icon { width: 42px; height: 42px; }
  .brand strong { font-size: 16px; }
  .service-state { padding: 7px 9px; }
  .service-state span:last-child { max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hero { padding-top: 50px; }
  .form-footer { align-items: stretch; flex-direction: column; }
  #submitButton { justify-content: space-between; width: 100%; }
  .search-panel, .result-panel { border-radius: 21px; }
  .progress-steps li { font-size: 9px; }
  .map-heading { align-items: start; flex-direction: column; }
  .app-menu { border-radius: 20px; }
}

@media (hover: none) and (pointer: coarse) {
  #dismissKeyboard { display: inline-block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
