/* ============================================================
   診間解說 · Explain — Warm Teal × Peach Design System
   ============================================================ */

:root {
  /* --- Brand / base palette --- */
  --fg:           #0f2a42;   /* deep navy — primary text, dark surfaces */
  --teal:         #0e7c7b;   /* brand */
  --teal-deep:    #0a6968;   /* gradient end */
  --teal-2:       #4a9e94;   /* secondary teal, section labels */
  --bg:           #ffffff;
  --muted:        #56706c;
  --ink:          #1a3942;   /* card titles, brand text */
  --ink-2:        #3a5064;   /* form labels, body */
  --ink-3:        #8aa3a0;   /* placeholder, hints, kbd */

  /* --- Surfaces / borders --- */
  --surface:      #ffffff;
  --surface-pin:  #fffdf5;   /* pinned card cream tint */
  --line:         #eaf2ef;
  --line-strong:  #d7e4e0;
  --tint-1:       #f0f7f4;   /* input bg, soft surface */
  --tint-2:       #f5faf8;   /* tab bar bg, summary bg */

  /* --- Accent --- */
  --peach:        #e5966a;   /* tool active, player highlight */
  --peach-soft:   #fbe7d9;
  --peach-ink:    #a65a2e;
  --gold:         #f2c94c;   /* focus ring, pin */
  --gold-soft:    #fef6dc;

  /* --- Player dark surface --- */
  --player-bg:    #0f2a42;
  --player-bg-2:  #1a3a55;
  --player-bg-3:  #081a2c;

  /* --- Semantic (calc results) --- */
  --ok-fg:        #1a7a4a;
  --ok-bg:        #e7f5ef;
  --warn-fg:      #a07a14;
  --warn-bg:      #fdf4d9;
  --danger-fg:    #c44a2e;
  --danger-bg:    #fde6e0;

  /* --- Tag pills --- */
  --tag-explain-bg:  #e7f3f1;
  --tag-explain-fg:  #0e7c7b;
  --tag-surgery-bg:  #fbe7d9;
  --tag-surgery-fg:  #a65a2e;
  --tag-calc-bg:     #efe9fb;
  --tag-calc-fg:     #6b4ac7;

  /* --- Type --- */
  --font: "Noto Sans TC", -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-serif: "Instrument Serif", "Cormorant Garamond", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* --- Radius --- */
  --r-sm:   6px;
  --r:      10px;
  --r-md:   14px;
  --r-lg:   20px;
  --r-pill: 999px;

  /* --- Shadow --- */
  --shadow-card:  0 1px 2px rgba(15,42,66,0.04);
  --shadow-hover: 0 16px 30px -20px rgba(15,42,66,0.2);
  --shadow-pop:   0 12px 32px -12px rgba(15,42,66,0.18);

  /* --- Motion --- */
  --t-fast: 100ms ease;
  --t:      150ms ease;
  --chrome-fade: 240ms;
  --t-slow: 220ms ease;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: var(--font); margin: 0; text-wrap: pretty; }
button {
  font-family: inherit; cursor: pointer; border: 0; background: none;
  color: inherit;
}
input, button, select, textarea { font: inherit; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* === Views === */
.view { display: none; min-height: 100dvh; }
.view.active { display: flex; flex-direction: column; }

/* === Kbd === */
.kbd, kbd {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--tint-1);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  margin: 0 2px;
}

/* ============================================================
   HOME VIEW
   ============================================================ */

.home-wrap {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 28px 80px;
}

.home-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--teal); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  letter-spacing: 0.02em;
}
.brand-name { font-weight: 700; font-size: 18px; color: var(--ink); }
.brand-sub {
  font-family: var(--font-serif);
  font-weight: 400; font-style: italic;
  color: var(--teal-2);
  font-size: 14px;
  letter-spacing: 0.06em;
  margin-left: 4px;
}

.user-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--tint-1);
  border: 1px solid var(--line);
}

.search-wrap {
  position: relative;
  max-width: 780px;
  margin: 0 auto 12px;
}
.search-icon {
  position: absolute;
  left: 20px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  display: flex;
  pointer-events: none;
}
.search {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 18px 22px 18px 56px;
  font-size: 17px;
  background: #fff;
  color: var(--fg);
  transition: border-color var(--t), box-shadow var(--t);
  -webkit-appearance: none;
}
.search:focus { outline: 0; }
.search::placeholder { color: var(--ink-3); }
.search:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,124,123,0.12);
}
.search::-webkit-search-cancel-button { -webkit-appearance: none; }

.kbd-hint {
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  margin: 14px 0 28px;
}

.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
}
.chip:hover { border-color: var(--teal-2); color: var(--ink); }
.chip[aria-selected="true"] {
  background: var(--fg);
  color: #fff;
  border-color: var(--fg);
  font-weight: 600;
}
.result-count {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* === Card grid === */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}
.card.is-pinned { background: var(--surface-pin); }
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--line-strong);
}

.card-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(45deg, transparent 48%, var(--line-strong) 48% 52%, transparent 52%),
    linear-gradient(-45deg, transparent 48%, var(--line-strong) 48% 52%, transparent 52%),
    var(--tint-1);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
  text-align: center;
  padding: 8px;
  object-fit: cover;
}
img.card-thumb { background: var(--tint-1); }
.card-thumb.is-fallback {
  background:
    linear-gradient(45deg, transparent 48%, var(--line-strong) 48% 52%, transparent 52%),
    linear-gradient(-45deg, transparent 48%, var(--line-strong) 48% 52%, transparent 52%),
    var(--tint-1);
}

.card-info { padding: 14px 16px 12px; flex: 1; display: flex; flex-direction: column; }
.card-title {
  font-size: 15px; font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 2px;
}
.card-sub {
  font-size: 12px; color: var(--muted);
  line-height: 1.45;
  margin-bottom: 10px;
}
.card-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: auto;
}

/* === Tag pills === */
.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.tag-explain { background: var(--tag-explain-bg); color: var(--tag-explain-fg); }
.tag-surgery { background: var(--tag-surgery-bg); color: var(--tag-surgery-fg); }
.tag-calc    { background: var(--tag-calc-bg);    color: var(--tag-calc-fg); }

.pin-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  color: var(--ink-3);
  transition: all var(--t);
}
.pin-btn:hover { background: var(--tint-1); color: var(--peach-ink); }
.pin-btn.is-on {
  background: var(--gold-soft);
  color: var(--gold);
}

/* === Skeleton === */
.skeleton { pointer-events: none; }
.skeleton-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: linear-gradient(90deg, var(--tint-1) 25%, var(--line) 50%, var(--tint-1) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
}
.skeleton-body { padding: 14px 16px; }
.skeleton-line {
  height: 14px; border-radius: 4px; margin-bottom: 6px;
  background: linear-gradient(90deg, var(--tint-1) 25%, var(--line) 50%, var(--tint-1) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
}
.skeleton-line.short { width: 60%; }
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === Empty / error === */
.empty {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 20px; text-align: center; color: var(--ink-3);
  gap: 8px;
}
.empty-mark { font-size: 32px; line-height: 1; margin-bottom: 4px; }
.empty-title { font-size: 15px; font-weight: 500; color: var(--ink-2); }
.empty-sub { font-size: 13px; }

/* === Buttons === */
.btn-primary {
  padding: 10px 22px;
  background: var(--teal);
  color: #fff;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--t);
}
.btn-primary:hover { background: var(--teal-deep); }

.btn-ghost-sm {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: #fff;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  transition: all var(--t);
}
.btn-ghost-sm:hover { border-color: var(--teal-2); color: var(--ink); }

/* ============================================================
   PLAYER VIEW
   ============================================================ */

#slide-view {
  background: var(--player-bg);
  color: #fff;
  position: relative;
  user-select: none;
  height: 100vh;       /* fallback */
  height: 100dvh;      /* reclaim space when mobile browser chrome hides */
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* Immersive mode: hide top bar, back btn, controls, thumbs, scrubber.
   Triggered by center tap or auto-hide timer. Uses max-height:0 +
   padding:0 in addition to opacity so the chrome actually releases its
   layout box and the slide stage expands to fill the viewport. */
.player-topbar,
.player-controls,
.thumb-strip,
.player-scrubber {
  max-height: 200px;
  overflow: hidden;
  transition:
    opacity var(--chrome-fade) ease,
    max-height var(--chrome-fade) ease,
    padding var(--chrome-fade) ease;
}
.player-back {
  transition: opacity var(--chrome-fade) ease, background var(--t);
}
#slide-view.is-immersive .player-back {
  opacity: 0;
  pointer-events: none;
}
#slide-view.is-immersive .player-topbar,
#slide-view.is-immersive .player-controls,
#slide-view.is-immersive .thumb-strip,
#slide-view.is-immersive .player-scrubber {
  opacity: 0;
  pointer-events: none;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
  border-bottom-width: 0;
}

.player-back {
  position: absolute;
  top: 14px; left: 24px;
  z-index: 20;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 13px; font-weight: 500;
  backdrop-filter: blur(4px);
  transition: background var(--t);
}
.player-back:hover { background: rgba(255,255,255,0.2); }

.player-topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px 14px 156px;
  position: relative;
  z-index: 10;
  gap: 16px;
}
.player-counter {
  font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}
.player-title-area { text-align: right; min-width: 0; }
.player-title {
  font-size: 16px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-sub {
  font-size: 12px; font-weight: 400;
  opacity: 0.6;
  margin-top: 2px;
  letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.player-stage {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  position: relative;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}
.player-stage.tool-laser,
.player-stage.tool-spot,
.player-stage.tool-pen   { cursor: none; touch-action: none; }

.player-frame {
  width: 100%;
  height: 100%;
  background: var(--player-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative;
  padding: 0;
  overflow: hidden;
}

.slide-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity var(--t);
  -webkit-user-drag: none;
}
.slide-image.is-loading { opacity: 0.3; }

.image-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 8px;
}
.ph-label {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  font-family: var(--font-mono);
  margin-bottom: 8px;
}
.ph-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  text-wrap: pretty;
  max-width: 640px;
}
.ph-desc {
  font-size: 16px;
  color: rgba(255,255,255,0.7);
  line-height: 1.6;
  max-width: 560px;
}

.laser-dot {
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #ff3b3b;
  box-shadow: 0 0 14px 5px rgba(255,59,59,0.55);
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 30;
}
.pen-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;   /* default off — captures only when tool-pen active */
  z-index: 22;            /* above tap zones (20), below laser/spot overlay */
  touch-action: none;     /* required so drawing doesn't pan the page */
}
.player-stage.tool-pen .pen-canvas { pointer-events: auto; cursor: crosshair; }
.spot-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 25;
  /* Widened from 140px. Responsive via clamp; mobile stays ~180, desktop
     reaches ~280 so the highlighted region is large enough to contain a
     real anatomical feature, not just a single structure. Gradient plateau
     (fully transparent up to 40%) gives a usable "bright core" before the
     fade begins, not a pointwise bright center. */
  background: radial-gradient(
    circle clamp(180px, 24vw, 280px) at var(--spot-x, 50%) var(--spot-y, 50%),
    transparent 0%,
    transparent 40%,
    rgba(0,0,0,0.80) 100%
  );
  transition: background-position var(--t-fast) linear;
}

/* Tap zones (e-book style: left=prev, center=toggle, right=next) */
#tap-zones {
  position: absolute;
  inset: 0;
  display: flex;
  z-index: 20;
  pointer-events: none; /* children take over */
}
.tap-zone {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}
.tap-zone-prev   { flex-basis: 33%; }
.tap-zone-toggle { flex-basis: 34%; }
.tap-zone-next   { flex-basis: 33%; }
.tap-zone:focus-visible {
  outline: 2px dashed rgba(255,255,255,0.35);
  outline-offset: -6px;
}
/* Disable tap zones while a drawing tool is active so pen/spot/laser work */
.player-stage.tool-pen   #tap-zones,
.player-stage.tool-spot  #tap-zones,
.player-stage.tool-laser #tap-zones { pointer-events: none; }
.player-stage.tool-pen   .tap-zone,
.player-stage.tool-spot  .tap-zone,
.player-stage.tool-laser .tap-zone { pointer-events: none; cursor: none; }

/* Player controls bar */
.player-controls {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255,255,255,0.08);
}
.player-nav { display: flex; gap: 8px; }
.player-tools { display: flex; gap: 6px; }

.btn-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600;
  transition: all var(--t);
  min-height: 44px;
}
.btn-pill-light { background: #fff; color: var(--ink); }
.btn-pill-light:hover { background: var(--tint-1); }
.btn-pill-ghost { background: rgba(255,255,255,0.12); color: #fff; }
.btn-pill-ghost:hover { background: rgba(255,255,255,0.2); }
.btn-pill:disabled { opacity: 0.35; cursor: not-allowed; }

.tool {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t);
}
.tool:hover { background: rgba(255,255,255,0.2); }
.tool.is-active {
  background: var(--peach);
  color: var(--fg);
}

/* Thumb strip */
.thumb-strip {
  display: flex; gap: 8px;
  padding: 12px 24px;
  background: var(--player-bg-3);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.thumb-strip::-webkit-scrollbar { height: 6px; }
.thumb-strip::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

/* Scrubber (mobile replacement for thumbs) */
.player-scrubber {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px 16px;
  background: var(--player-bg-3);
}
.player-scrubber input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  background: transparent;
  margin: 0;
  touch-action: manipulation;
}
.player-scrubber input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
}
.player-scrubber input[type="range"]::-moz-range-track {
  height: 4px;
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
}
.player-scrubber input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px; height: 24px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--peach);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  border: 2px solid #fff;
  cursor: grab;
}
.player-scrubber input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--peach);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  border: 2px solid #fff;
  cursor: grab;
}
.player-scrubber input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; }
.player-scrubber-label {
  align-self: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}
.thumb {
  flex: 0 0 auto;
  width: 110px; height: 64px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  border: 2px solid transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: rgba(255,255,255,0.45);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t);
  padding: 4px;
  text-align: center;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.thumb:hover { color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.08); }
.thumb.is-active {
  background: rgba(255,255,255,0.1);
  border-color: var(--peach);
  color: #fff;
}

/* End screen */
.end-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--player-bg);
  z-index: 40;
  gap: 24px;
}
.end-title {
  font-size: 28px; font-weight: 700;
  color: #fff;
}

/* ============================================================
   CALCULATOR VIEW
   ============================================================ */

.calc-wrap {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 28px 80px;
}
.calc-topbar {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 24px;
}
.calc-title { font-size: 24px; font-weight: 700; color: var(--ink); }

.calc-tabs {
  display: flex; gap: 4px;
  margin-bottom: 24px;
  padding: 4px;
  background: var(--tint-2);
  border-radius: var(--r);
  width: fit-content;
}
.calc-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  transition: all var(--t);
}
.calc-tab.is-active {
  background: #fff;
  color: var(--teal);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15,42,66,0.06);
}

.calc-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}
.calc-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 28px;
}
.calc-card h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.calc-card p.lead {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.6;
}

.calc-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.calc-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal-2);
  margin-bottom: 14px;
}

/* Field row */
.field {
  display: grid;
  grid-template-columns: 200px 140px auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.field-label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.field-hint { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.field-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  text-align: right;
  background: #fff;
  transition: border-color var(--t);
  -moz-appearance: textfield;
}
.field-input:focus { outline: 0; }
.field-input::-webkit-outer-spin-button,
.field-input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.field-input:focus { border-color: var(--teal); }
.field-unit { font-size: 13px; color: var(--ink-3); font-weight: 500; min-width: 60px; }

/* Checkbox row */
.check {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--t);
  background: #fff;
}
.check:hover { border-color: var(--teal-2); }
.check input { accent-color: var(--teal); width: 18px; height: 18px; pointer-events: none; }
.check span { font-size: 14px; font-weight: 500; flex: 1; color: var(--ink-2); }
.check.is-on {
  border-color: var(--teal-2);
  background: var(--tag-explain-bg);
}
.check.is-on span { color: var(--ink); }

/* Sex picker */
.seg {
  display: flex; gap: 4px;
  background: var(--tint-1);
  border-radius: var(--r);
  padding: 3px;
  width: fit-content;
}
.seg button {
  padding: 8px 20px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  color: var(--muted);
  transition: all var(--t);
}
.seg button.is-on { background: var(--teal); color: #fff; }

/* Result card */
.result-sticky { position: sticky; top: 20px; }
.result-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.result-head {
  padding: 20px 22px;
  background: linear-gradient(180deg, var(--teal) 0%, var(--teal-deep) 100%);
  color: #fff;
}
.result-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}
.result-value {
  font-size: 42px;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.result-unit {
  font-size: 18px; font-weight: 500;
  opacity: 0.8; margin-left: 4px;
}

.result-body { padding: 20px 22px; }
.verdict {
  padding: 12px 14px;
  border-radius: var(--r);
  margin-bottom: 14px;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px;
  line-height: 1.5;
}
.verdict-shape { font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.verdict.ok      { background: var(--ok-bg);      color: var(--ok-fg); }
.verdict.warn    { background: var(--warn-bg);    color: var(--warn-fg); }
.verdict.danger  { background: var(--danger-bg);  color: var(--danger-fg); }
.verdict.info    { background: var(--tag-explain-bg); color: var(--teal); }

.rules-label {
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal-2);
  margin: 14px 0 8px;
}
.rules { list-style: none; padding: 0; margin: 0; }
.rule {
  display: flex; gap: 10px;
  padding: 10px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  line-height: 1.5;
}
.rule:last-child { border-bottom: 0; }
.rule-mark { flex-shrink: 0; font-weight: 700; margin-top: 1px; }
.rule-mark.ok { color: var(--ok-fg); }
.rule-mark.no { color: var(--ink-3); }
.rule.is-met .rule-text { font-weight: 600; color: var(--ink); }

.calc-explain {
  padding: 14px 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.7;
}
.calc-explain strong { color: var(--ink); font-weight: 700; }

.summary {
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  background: var(--tint-2);
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
}
.summary-label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 700;
}

.result-actions {
  display: flex; gap: 8px;
  margin-top: 16px;
}
.result-actions button {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600;
  transition: all var(--t);
}
.result-actions .primary { background: var(--teal); color: #fff; }
.result-actions .primary:hover { background: var(--teal-deep); }
.result-actions .ghost {
  background: #fff; color: var(--fg);
  border: 1px solid var(--line-strong);
}
.result-actions .ghost:hover { border-color: var(--teal-2); }

.result-disclaimer {
  margin: 0 22px 20px;
  padding: 12px 14px;
  background: var(--tint-2);
  border-radius: var(--r);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
}
.result-disclaimer strong {
  color: var(--teal-2);
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ============================================================
   BANNERS
   ============================================================ */
.banner {
  position: fixed; left: 0; right: 0;
  text-align: center;
  padding: 10px 16px;
  font-size: 13px;
  z-index: 100;
}
.banner-offline {
  bottom: 0;
  background: var(--tint-2);
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.banner-update {
  top: 0;
  background: var(--teal);
  color: #fff;
}
.banner-link {
  color: #fff;
  text-decoration: underline;
  font-weight: 600;
}

/* iOS Safari install hint (one-time) */
.install-hint {
  position: fixed;
  left: 12px; right: 12px; bottom: 12px;
  z-index: 101;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--fg);
  color: #fff;
  border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(15,42,66,0.25);
  animation: install-hint-slide-in 260ms ease;
}
@keyframes install-hint-slide-in {
  from { transform: translateY(110%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.install-hint-icon {
  font-size: 22px; flex-shrink: 0;
}
.install-hint-body { flex: 1; min-width: 0; }
.install-hint-title { font-size: 14px; font-weight: 600; line-height: 1.3; }
.install-hint-desc {
  font-size: 12px; color: rgba(255,255,255,0.75);
  line-height: 1.4; margin-top: 2px;
}
.install-hint-close {
  background: transparent; color: rgba(255,255,255,0.7);
  border: 0; padding: 4px 8px;
  cursor: pointer; font-size: 16px;
  flex-shrink: 0;
}
.install-hint-close:hover { color: #fff; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}
@media (max-width: 768px) {
  .home-wrap, .calc-wrap { padding: 20px 16px 60px; }
  .player-topbar { padding: 14px 16px 14px 130px; }
  .player-stage { padding: 0; }
  .player-controls { padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
  .calc-layout { grid-template-columns: 1fr; gap: 16px; }
  .result-sticky { position: static; }
  .field { grid-template-columns: 1fr; gap: 6px; }
  .field-unit { display: none; }
  .ph-title { font-size: 22px; }
  .ph-desc { font-size: 14px; }
  .home-topbar { flex-wrap: wrap; gap: 12px; }
  .user-chip { font-size: 12px; }
  /* mobile: scrubber replaces thumb strip for one-handed scrubbing */
  .thumb-strip { display: none; }
  .player-scrubber { display: flex; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
  .player-back { padding: 6px 10px; font-size: 12px; }
  .player-topbar { padding: 12px 12px 12px 110px; }
  .btn-pill { padding: 8px 14px; }
  .thumb { width: 90px; height: 56px; }
}
