/* P1 dial at the top: layout and chrome. Wheel colours and font come from ../core/theme.css. */

:root {
  --bg: #e7ebf2;
  --ink: #0d1b33;
  --muted: #5a6478;
  --line: #d3d9e3;
  --top-h: 46px;
  --peek-h: 60px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --page-bg: #fff;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  height: 100vh; height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--mec-font);
  font-stretch: 87.5%;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid #ffbf3c; outline-offset: 2px; }

/* ---- top bar ---------------------------------------------------------------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 30;
  display: flex; align-items: center; gap: 6px; padding: 0 4px 0 10px;
  background: var(--mec-navy); color: #fff;
  padding-top: env(safe-area-inset-top);
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }
.logos { display: flex; align-items: center; gap: 7px; flex: none; }
.logos img { display: block; height: 18px; width: auto; }
.logos .logo-hrp { height: 20px; }
.title { font-weight: 700; font-size: 16px; letter-spacing: 0.01em; white-space: nowrap; font-stretch: 80%; }
.title span { display: inline; }
@media (max-width: 479px) {
  body[data-chrome="a"] .title { font-size: 14px; line-height: 1.05; }
  body[data-chrome="a"] .title span { display: block; }
}
.actions { display: flex; align-items: center; gap: 0; flex: none; }
.icon-btn, .text-btn {
  height: 38px; min-width: 36px; border: 0; background: transparent; color: #fff; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 7px;
}
.text-btn { font-weight: 600; font-size: 14px; font-stretch: 85%; padding: 0 5px; }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-btn.gear { min-width: 32px; padding: 0 4px; opacity: 0.8; }
.icon-btn.gear svg { width: 18px; height: 18px; }
.icon-btn:hover, .text-btn:hover { background: rgba(255, 255, 255, 0.12); }
@media (max-width: 359px) {
  .topbar { gap: 4px; padding-left: 8px; }
  .logos { gap: 5px; }
  .logos img { height: 15px; }
  .logos .logo-hrp { height: 17px; }
  .title { font-size: 14.5px; }
  body[data-chrome="a"] .title { font-size: 13px; }
  .text-btn { padding: 0 4px; font-size: 13.5px; }
  .icon-btn { min-width: 32px; padding: 0 4px; }
}

/* ---- stage + disc ------------------------------------------------------------- */
.stage { position: fixed; inset: 0; overflow: hidden; z-index: 1; perspective: 1400px; }
.disc { position: absolute; transform-origin: 50% 50%; will-change: transform; }
.disc.animate { transition: transform 460ms var(--ease); }
.disc svg { display: block; }
.mec-wheel { cursor: grab; }
.mec-wheel:active { cursor: grabbing; }
.mec-wheel .mec-t-value { transition: opacity 140ms linear; }
body.is-fast .mec-wheel .mec-t-value { opacity: 0.4; }
.p1-outline { fill: none; stroke: #fff; stroke-width: 2px; stroke-linejoin: round; pointer-events: none; transition: opacity 120ms; }
body.is-moving .p1-outline { opacity: 0; }

/* ---- hub caption (fixed cover) ------------------------------------------------ */
.caption {
  position: absolute; z-index: 2; color: #fff; text-align: center; overflow: hidden;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
  --cap-scale: 1;
  transition: opacity 200ms linear;
}
body.is-moving .caption { opacity: 0.55; }
.cap-float.l { float: left; }
.cap-float.r { float: right; }
.cap-cond { margin: 0; padding: 14px 0 4px; text-align: center; line-height: 1.2; }
.cap-cond [role=button], .cap-note { cursor: pointer; }
.cap-group { font-weight: 700; font-size: calc(12.5px * var(--cap-scale)); letter-spacing: 0.03em; line-height: 1.2; font-stretch: 80%; opacity: 0.92; }
.cap-sub { font-weight: 600; font-size: calc(17px * var(--cap-scale)); line-height: 1.2; margin-top: 2px; }
.cap-cond sup, .cap-notes sup { font-size: 0.65em; }
.cap-notes { list-style: none; margin: 4px 0 0; padding: 0; }
.cap-notes li { margin: 0 0 4px; text-align: left; color: #e9eef8; font-size: calc(13.5px * var(--cap-scale)); line-height: 1.32; }
.cap-notes b { display: inline-block; min-width: 1.35em; height: 1.35em; line-height: 1.35em; margin-right: 4px; border-radius: 50%; background: #fff; color: var(--mec-navy); text-align: center; font-size: 0.85em; }
.cap-more { background: rgba(255, 255, 255, 0.14); border: 0; color: #fff; border-radius: 12px; padding: 2px 12px; font-size: 13px; font-weight: 600; margin-top: 2px; }
.cap-more.tight { position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); }

.hint {
  position: absolute; z-index: 3; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--peek-h) + 10px); margin: 0; padding: 5px 12px; border-radius: 14px;
  background: #fff; color: var(--mec-navy); font-weight: 600; font-size: 14px; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.intro-logos {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 4;
  display: flex; gap: 18px; align-items: center; padding: 10px 18px; border-radius: 12px; background: var(--mec-navy);
  opacity: 0; transition: opacity 260ms linear;
}
.intro-logos.show { opacity: 1; }
.intro-logos img { height: 30px; width: auto; display: block; }
.overview-close {
  position: absolute; z-index: 4; left: 50%; transform: translateX(-50%); bottom: 18px;
  border: 0; border-radius: 20px; background: var(--mec-navy); color: #fff; padding: 9px 18px; font-weight: 600; font-size: 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Opening and overview: hide the working-layout overlays. */
body.is-intro .caption, body.is-intro .legend, body.is-intro .hint,
body.is-overview .caption, body.is-overview .legend, body.is-overview .hint { opacity: 0; pointer-events: none; }
.legend, .caption { transition: opacity 300ms linear, transform 300ms var(--ease); }

/* ---- legend: the cover's lower half --------------------------------------------- */
.legend {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--mec-navy); color: #fff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -2px 12px rgba(0, 20, 60, 0.25);
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.legend.animate { transition: transform 300ms var(--ease), opacity 300ms linear; }
.legend-peek { flex: none; height: var(--peek-h); display: flex; align-items: center; gap: 6px; padding: 0 8px 0 6px; }
.mini {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0; background: transparent;
  display: grid; place-items: center; position: relative;
}
.mini svg { pointer-events: none; }
.mini::after { /* window marker at 12 o'clock */
  content: ''; position: absolute; left: 50%; top: 1px; width: 2px; height: 9px; margin-left: -1px; background: #fff; border-radius: 1px;
}
.legend-handle {
  flex: 1 1 auto; min-width: 0; height: 100%; border: 0; background: none; padding: 7px 0 6px; color: #fff;
  display: flex; flex-direction: column; align-items: stretch; justify-content: center; touch-action: none; position: relative; padding-top: 10px;
}
.grip { position: absolute; top: 3px; left: 50%; margin-left: -19px; width: 38px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.5); }
.chips { display: flex; gap: 5px; min-width: 0; flex: 1 1 auto; }
.lchip { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 1px; }
.lc-keys { border-radius: 4px; font-weight: 700; font-size: 14px; line-height: 19px; text-align: center; color: #fff; letter-spacing: 0.08em; }
.lchip.is-green .lc-keys { background: var(--mec-green); }
.lchip.is-red .lc-keys { background: var(--mec-red); }
.lchip.is-amber .lc-keys { background: var(--mec-amber); }
.lc-text {
  font-size: 11px; line-height: 1.12; text-align: center; color: #dfe6f3;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
body[data-layout="phone"] .legend-peek { height: var(--peek-h); }
@media (max-height: 560px) { .lc-keys { line-height: 17px; font-size: 13px; } }
@media (min-width: 480px) { .lc-text { -webkit-line-clamp: 1; font-size: 12px; } }

.legend-body { flex: 1 1 auto; overflow: hidden; padding: 4px 14px 24px; -webkit-overflow-scrolling: touch; }
.lrow { border-radius: 8px; overflow: hidden; margin: 0 0 10px; background: #fff; color: var(--ink); }
.lrow h3 { margin: 0; padding: 7px 12px; font-size: 15px; font-weight: 700; color: #fff; }
.lrow.is-green h3 { background: var(--mec-green); }
.lrow.is-red h3 { background: var(--mec-red); }
.lrow.is-amber h3 { background: var(--mec-amber); color: var(--mec-navy); } /* print: dark text on the amber legend strip */
.lrow ul { list-style: none; margin: 0; padding: 6px 12px 8px; }
.lrow li { display: flex; gap: 10px; padding: 3px 0; font-size: 14.5px; line-height: 1.35; }
.lrow li b { flex: none; width: 1.6em; text-align: center; font-size: 15px; }
.lnotes h3 { margin: 14px 0 6px; font-size: 15px; }
.lnotes ul { margin: 0; padding-left: 18px; font-size: 14.5px; }
.lnotes li { margin-bottom: 5px; }
.lback button { border: 0; background: rgba(255, 255, 255, 0.14); color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 14px; text-align: left; }
body[data-layout="desktop"] .legend-body { max-width: 820px; width: 100%; margin: 0 auto; }
body[data-layout="desktop"] .legend { left: max(0px, calc(50% - 560px)); right: max(0px, calc(50% - 560px)); }

/* ---- bottom sheet ------------------------------------------------------------------ */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 18, 50, 0); transition: background 240ms linear; }
.scrim.open { background: rgba(0, 18, 50, 0.32); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 45vh; max-height: 45dvh; overflow: hidden; display: flex; flex-direction: column;
  background: #fff; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
  transform: translateY(100%); transition: transform 260ms var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.open { transform: translateY(0); }
body[data-layout="desktop"] .sheet { left: 50%; right: auto; width: min(640px, 100vw); transform: translate(-50%, 100%); }
body[data-layout="desktop"] .sheet.open { transform: translate(-50%, 0); }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: #c5ccd8; margin: 7px auto 0; flex: none; }
.sheet-close { position: absolute; top: 6px; right: 8px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eef1f6; font-size: 15px; }
.sheet-body { overflow-y: auto; padding: 4px 16px 14px; }
.sheet-kicker { margin: 4px 44px 0 0; color: var(--muted); font-size: 13px; }
.sheet-title { margin: 2px 44px 10px 0; font-size: 17px; line-height: 1.3; color: var(--mec-navy); }
.sheet-title sup { font-size: 0.62em; }
.chip { display: inline-block; min-width: 2.4em; padding: 1px 7px; border-radius: 5px; text-align: center; color: #fff; font-weight: 700; }
.chip.is-green { background: var(--mec-green); }
.chip.is-red { background: var(--mec-red); }
.chip.is-amber { background: var(--mec-amber); }
.chip.is-blank { background: #fff; color: var(--muted); box-shadow: inset 0 0 0 1px #c8cfdb; }
.cat { border-radius: 8px; overflow: hidden; margin-bottom: 10px; border: 1px solid var(--line); }
.cat h3 { margin: 0; padding: 6px 10px; font-size: 14px; color: #fff; }
.cat.is-green h3 { background: var(--mec-green); }
.cat.is-red h3 { background: var(--mec-red); }
.cat.is-amber h3 { background: var(--mec-amber); color: var(--mec-navy); }
.cat ul { list-style: none; margin: 0; padding: 6px 10px; }
.cat li { font-size: 14.5px; padding: 2px 0; }
.cat li b { display: inline-block; min-width: 1.6em; }
.fns h3 { margin: 6px 0 4px; font-size: 14px; color: var(--mec-navy); }
.fns dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: start; }
.fns dt button { width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--mec-navy); color: #fff; font-weight: 700; padding: 0; }
.fns dd { margin: 0; font-size: 14.5px; line-height: 1.4; }
.muted { color: var(--muted); font-size: 13.5px; }
.sheet-nav { display: flex; gap: 6px; margin-top: 12px; }
.sheet-nav button { flex: 1 1 0; border: 1px solid var(--line); background: #f5f7fb; border-radius: 8px; padding: 7px 4px; font-size: 13.5px; min-height: 38px; }
.sheet-nav button:disabled { visibility: hidden; }
.col-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.col-list button { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 0; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.cl-m { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- reading pages ------------------------------------------------------------------ */
.page {
  position: fixed; inset: 0; z-index: 35; background: var(--page-bg); display: flex; flex-direction: column;
}
.page.enter-up { animation: pageUp 320ms var(--ease) both; }
.page.enter-flip { animation: pageFlipIn 460ms var(--ease) both; transform-origin: 50% 40%; }
.page.leave { animation: pageOut 260ms ease-in both; }
@keyframes pageUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes pageFlipIn { 0% { transform: perspective(1400px) rotateY(-179deg) scale(0.86); opacity: 0; } 35% { opacity: 0; } 50% { opacity: 1; } 100% { transform: perspective(1400px) rotateY(0) scale(1); opacity: 1; } }
@keyframes pageOut { to { transform: translateY(40px); opacity: 0; } }
body.flipping .disc { animation: discFlipOut 460ms var(--ease) both; }
body.unflipping .disc { animation: discFlipIn 420ms var(--ease) both; }
@keyframes discFlipOut { to { transform: perspective(1400px) rotateY(179deg) scale(0.8); opacity: 0; } }
@keyframes discFlipIn { from { opacity: 0.2; } to { opacity: 1; } }
.page-head {
  flex: none; height: var(--top-h); display: flex; align-items: center; gap: 8px; padding: 0 12px 0 4px;
  background: var(--mec-navy); color: #fff; padding-top: env(safe-area-inset-top);
}
.page-close { border: 0; background: rgba(255, 255, 255, 0.12); color: #fff; border-radius: 8px; height: 34px; padding: 0 12px; font-weight: 600; font-size: 14.5px; flex: none; }
.page-title { margin: 0; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px 40px; overscroll-behavior: contain; }
.page-body > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.page-body h2.sec { font-size: 19px; color: var(--mec-navy); margin: 22px 0 8px; }
.page-body h3 { font-size: 16px; color: var(--mec-navy); margin: 16px 0 6px; }
.page-body p, .page-body li, .page-body dd { font-size: 15.5px; line-height: 1.5; }
.page-body ul, .page-body ol { padding-left: 20px; }

.dome {
  margin: 0 -16px; max-width: none; background: var(--mec-navy); color: #fff; text-align: center;
  padding: 26px 24px 30px; border-radius: 0 0 50% 50% / 0 0 34px 34px;
}
.dome h2 { margin: 0 auto; max-width: 560px; font-size: 18px; line-height: 1.35; }
.back-lists section { margin-top: 6px; }
.back-lists ul { margin: 0; }
.refer { background: #f1f4f9; border-left: 4px solid var(--mec-blue); padding: 10px 12px; border-radius: 4px; }
.fn-list { margin: 0; }
.fn { display: grid; grid-template-columns: 2em 1fr; gap: 8px; padding: 7px 6px; border-bottom: 1px solid var(--line); border-radius: 6px; transition: background 600ms; }
.fn dt { font-weight: 700; color: var(--mec-navy); font-size: 16px; }
.fn dd { margin: 0; }
.flash { background: #fff3c4 !important; }
.abbr li { margin-bottom: 4px; }
.edition { color: var(--muted); font-size: 13.5px !important; margin-top: 26px; }
.page-logos { display: flex; gap: 22px; align-items: center; justify-content: center; background: var(--mec-navy); border-radius: 10px; padding: 14px; margin-top: 16px; }
.page-logos img { height: 34px; width: auto; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0 4px; }
.tab { border: 1px solid var(--line); background: #f5f7fb; border-radius: 16px; padding: 5px 11px; font-size: 14px; }
.tab.on { background: var(--mec-navy); border-color: var(--mec-navy); color: #fff; }
.spr-card { border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px 10px; margin: 10px auto; }
.spr-card h3 { margin: 8px 0 6px; font-size: 15.5px; }
.spr-card dl { margin: 0; }
.spr-card dl > div { padding: 5px 0; border-top: 1px solid #edf0f5; }
.spr-card dt { font-weight: 700; font-size: 13.5px; color: var(--mec-blue); }
.spr-card dd { margin: 0; }
.note { color: var(--muted); }
.spr-foot p { font-size: 14px !important; color: var(--muted); }
.deflist div { display: grid; grid-template-columns: minmax(6.5em, auto) 1fr; gap: 8px; padding: 4px 0; border-bottom: 1px solid #edf0f5; }
.deflist dt { font-weight: 700; }
.deflist dd { margin: 0; }

.search-box { position: sticky; top: 0; background: var(--page-bg); padding: 12px 0 8px; z-index: 1; }
.search-box input { width: 100%; height: 44px; border: 2px solid var(--mec-navy); border-radius: 10px; padding: 0 12px; font: inherit; font-size: 16px; }
.results { list-style: none; padding: 0 !important; margin: 0 auto; }
.sgroup h3 { margin: 14px 0 4px; font-size: 13px; letter-spacing: 0.04em; color: #fff; background: var(--mec-navy); padding: 4px 10px; border-radius: 6px; }
.sgroup.back h3 { background: #4a5873; }
.sgroup ul { list-style: none; padding: 0; margin: 0; }
.sgroup li button { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 10px 10px; font-size: 15.5px; min-height: 44px; }
.sgroup li button:hover { background: #f1f4f9; }
.sgroup sup { font-size: 0.65em; }

/* ---- settings drawer --------------------------------------------------------------- */
.settings {
  position: fixed; z-index: 60; top: 0; right: 0; bottom: 0; width: min(340px, 92vw); background: #fff;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.25); padding: 12px 16px 20px; overflow-y: auto;
  transform: translateX(100%); transition: transform 220ms var(--ease);
}
.settings.open { transform: none; }
.set-head { display: flex; align-items: center; justify-content: space-between; }
.set-head h2 { margin: 0; font-size: 17px; color: var(--mec-navy); }
.set-close { width: 36px; height: 36px; border-radius: 50%; border: 0; background: #eef1f6; }
.settings fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 12px 0 0; padding: 6px 10px 8px; }
.settings legend { font-weight: 700; font-size: 14px; padding: 0 4px; }
.settings label { display: block; padding: 5px 0; font-size: 14.5px; }
.set-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.set-row button { border: 1px solid var(--line); background: #f5f7fb; border-radius: 8px; padding: 6px 10px; font-size: 13.5px; }
.set-info { margin: 14px 0 0; font-size: 13.5px; }
.set-info div { padding: 4px 0; border-bottom: 1px solid #edf0f5; }
.set-info dt { font-weight: 700; }
.set-info dd { margin: 0; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Desktop: logos and title at a comfortable size in the 46 px bar. */
body[data-layout="desktop"] .logos img { height: 26px; }
body[data-layout="desktop"] .logos .logo-hrp { height: 30px; }
body[data-layout="desktop"] .logos { gap: 14px; margin-right: 8px; }
body[data-layout="desktop"] .title { font-size: 19px; }
body[data-layout="desktop"] .topbar { padding: 0 12px 0 16px; }
body[data-layout="desktop"] .text-btn { font-size: 15px; padding: 0 10px; }

/* Until the first layout runs, keep the overlays out of sight (no flash on load). */
body:not([data-layout]) .legend, body:not([data-layout]) .caption { visibility: hidden; }
