/* ════════════════════════════════════════════════════════════════
   rechealth · styles
   [REC::HEALTH::DESIGN_MODE] Lab Instrument (Kiln family)
   monospace 14px · #fff paper · #000 ink · 1px black rules · hover-invert
   ════════════════════════════════════════════════════════════════ */

/* ── global motion suppress, then whitelist-only re-enable ── */
* { box-sizing: border-box; transition: none !important; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }

body {
  font-family: "Courier New", Courier, monospace;
  font-size: 14px;
  letter-spacing: 0.2px;
  background: #fff;
  color: #000;
  -webkit-font-smoothing: antialiased;
}

/* diff theme tokens — borrowed from Kiln verbatim */
:root {
  --diff-del-color: #ff0033;
  --diff-del-rgb: 255, 0, 51;
  --diff-add-color: #00c914;
  --diff-add-rgb: 128, 255, 0;
  --ok:    #00c914;
  --bad:   #ff0000;
  --info:  #0000ff;
  --on:    #ea00ff;
  --auto:  #00ffea;
  --cream: #fcf6f2;
  --pri:   #6600ff;
}

button, input, textarea, select {
  appearance: none;
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
}
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }

/* ════════════════════ #app shell ════════════════════ */
#app {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: 40px 1fr 40px;
}

/* ════════════════════ topbar ════════════════════ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid #000;
  background: #fff;
  font-size: 14px;
}
.topbar .crumb {
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap; overflow: hidden;
}
.topbar .crumb .site {
  text-transform: lowercase;
}
.topbar .crumb .sep { color: #ccc; }
.topbar .crumb .view-tab {
  padding: 0 6px; font-size: 13px; cursor: pointer;
  border: 1px solid transparent;
  text-transform: lowercase;
}
.topbar .crumb .view-tab:hover { background: #000; color: #fff; }
.topbar .crumb .view-tab.is-active { border-color: #000; }

.topbar .util { display: flex; gap: 6px; align-items: center; }
.topbar .util .btn-glyph {
  padding: 0 4px; font-size: 16px; line-height: 1;
}
.topbar .util .btn-glyph:hover { background: #000; color: #fff; }

/* lang mini toggle */
.topbar .lang-mini {
  padding: 0 6px;
  font-size: 13px;
  line-height: 1;
  text-transform: lowercase;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}
.topbar .lang-mini:hover { background: #000; color: #fff; }

/* lang gate: show only matching nodes */
body[data-lang="en"] [data-lang-only="zh"],
body[data-lang="zh"] [data-lang-only="en"] { display: none !important; }

/* ════════════════════ desk menu ════════════════════ */
#desk-menu {
  position: absolute;
  top: 40px; right: 8px;
  width: 220px;
  border: 1px solid #000;
  background: #fff;
  display: none; flex-direction: column;
  z-index: 100;
}
#desk-menu.is-open { display: flex; }
.desk-item {
  padding: 6px 10px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid #e8e8e8;
  cursor: pointer;
  text-transform: lowercase;
}
.desk-item:last-child { border-bottom: 0; }
.desk-item:hover { background: #000; color: #fff; }
.desk-item.entry:hover { background: var(--cream); color: #000; }
.desk-sep {
  height: 1px; background: #000;
  margin: 0;
}

/* ════════════════════ main view ════════════════════ */
main {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  scrollbar-width: thin;
}
main::-webkit-scrollbar { width: 6px; }
main::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.25); }

.view { display: none; }
.view.is-active { display: block; }

.workspace {
  width: min(100%, 1100px);
  margin: 0 auto;
}

/* ════════════════════ section heads ════════════════════ */
h1, h2, h3 { margin: 0; font-weight: 400; }
h1 {
  font-size: 18px;
  text-transform: lowercase;
  margin: 0 0 4px;
}
h2 {
  font-size: 14px;
  text-transform: lowercase;
  margin: 16px 0 6px;
  padding-bottom: 2px;
  border-bottom: 1px solid #000;
}
h3 {
  font-size: 14px;
  text-transform: lowercase;
  margin: 8px 0 4px;
}
p { margin: 4px 0; }
.sub { color: #666; font-size: 12px; text-transform: lowercase; }

/* ════════════════════ data tables ════════════════════ */
.scroll {
  overflow-x: auto;
  margin: 6px -12px;
  padding: 0 12px;
  scrollbar-width: thin;
}
.scroll::-webkit-scrollbar { height: 6px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); }

table {
  border-collapse: collapse;
  font-size: 13px;
  width: max-content;
}
th, td {
  border: 1px solid #000;
  padding: 3px 7px;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
  font-weight: 400;
}
th {
  background: #f5f5f5;
  text-transform: lowercase;
  font-size: 12px;
}
td.key { background: #fafafa; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* semantic deltas — use diff theme tokens */
.delta-bad,  td.bad  { color: var(--diff-del-color); }
.delta-good, td.good { color: var(--diff-add-color); }
td.warn { color: var(--bad); }
td.muted { color: #888; }

/* rating cell variants */
td.r-low      { color: var(--bad); }
td.r-good     { color: #000; }
td.r-mild_obese, td.r-underweight, td.r-uneven { color: var(--bad); }
td.r-standard, td.r-even { color: #000; }

/* ════════════════════ chips ════════════════════ */
.chip {
  display: inline-block;
  border-radius: 6px;
  padding: 2px 6px 0 6px;
  font-size: 12px;
  text-transform: lowercase;
  border: 1px solid currentColor;
  margin: 0 2px;
}
.chip.cat-core    { color: var(--info); }
.chip.cat-posture { color: var(--on); }
.chip.cat-upper   { color: var(--bad); }
.chip.cat-lower   { color: var(--pri); }
.chip.is-target   { color: var(--ok); border-color: var(--ok); }
.chip.is-current  { background: #000; color: #fff; border-color: #000; }

/* ════════════════════ cards ════════════════════ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.card {
  position: relative;
  border: 1px solid #000;
  background: #fff;
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100px;
}
.card:hover { background: #000; color: #fff; }
.card .card-name {
  font-size: 14px;
  text-transform: lowercase;
  margin: 0 0 2px;
}
.card .card-meta {
  font-size: 12px;
  color: #666;
  text-transform: lowercase;
}
.card:hover .card-meta { color: #fff; }
.card .card-tail {
  display: flex; gap: 4px; align-items: center;
  font-size: 12px;
  margin-top: 4px;
}
.card .star {
  position: absolute; top: 4px; right: 6px;
  font-size: 14px;
  color: #ff0000;
}
.card:hover .star { color: var(--diff-add-color); }

/* session card variant */
.card.session .label {
  font-size: 12px;
  color: #888;
  text-transform: lowercase;
}
.card.session:hover .label { color: #ccc; }
.card.session .row {
  display: flex; justify-content: space-between;
  font-size: 12px;
  margin: 2px 0;
}
.card.session .num { font-variant-numeric: tabular-nums; }

/* ════════════════════ panels ════════════════════ */
.panel {
  border: 1px solid #000;
  background: #fff;
  padding: 10px;
  margin: 12px 0;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  background: #000;
  color: #fff;
  margin: -10px -10px 8px;
  padding: 4px 10px;
  font-size: 13px;
  text-transform: lowercase;
}
.panel-head .title {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.panel-head .actions { display: flex; gap: 6px; }
.panel-head .btn-glyph {
  border: 1px solid #fff;
  background: transparent;
  color: #fff;
  padding: 0 4px;
  font-size: 13px;
}
.panel-head .btn-glyph:hover { background: #fff; color: #000; }

/* ════════════════════ kv ════════════════════ */
.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0;
  border: 1px solid #000;
  margin: 6px 0;
}
.kv .cell {
  padding: 4px 8px;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
  font-size: 13px;
}
.kv .cell:last-child { border-right: 0; }
.kv .cell .k { color: #666; font-size: 12px; text-transform: lowercase; display: block; }
.kv .cell .v { font-size: 15px; }
.kv .cell .v.bad  { color: var(--bad); }
.kv .cell .v.good { color: var(--diff-add-color); }

/* ════════════════════ cue list (moves) ════════════════════ */
.cue-list { margin: 4px 0; padding-left: 14px; list-style: none; }
.cue-list li {
  position: relative;
  margin: 3px 0;
  padding-left: 12px;
  font-size: 13px;
  line-height: 1.4;
}
.cue-list li::before {
  content: '·'; position: absolute; left: 0; color: #000;
}

.warn-note,
.tip-note {
  font-size: 13px;
  padding: 4px 8px;
  margin: 6px 0;
  border-left: 3px solid currentColor;
}
.warn-note { color: var(--bad); }
.tip-note  { color: #000; border-left-color: #000; }

/* ════════════════════ venue tabs (regimen sub-nav) ════════════════════ */
/* 行內小按鈕，與 topbar .view-tab 同階。emoji + 字無空格。 */
.venue-tabs {
  display: flex;
  gap: 6px;
  margin: 6px 0 10px;
}
.venue-btn {
  padding: 0 6px;
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  text-transform: lowercase;
  background: transparent;
  color: #000;
  border: 1px solid transparent;
  cursor: pointer;
}
.venue-btn:hover { background: #000; color: #fff; }
.venue-btn.is-active { border-color: #000; }
.venue-btn.is-active:hover { background: #000; color: #fff; }

/* ════════════════════ regimen block ════════════════════ */
.regimen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.regimen-card {
  border: 1px solid #000;
  background: #fff;
  padding: 10px;
}
.regimen-card .head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px;
}
.regimen-card .head .name {
  font-size: 15px;
  text-transform: lowercase;
}
.regimen-card .head .mins {
  font-size: 12px;
  color: #666;
}
.regimen-card .when {
  font-size: 12px;
  color: #666;
  font-style: italic;
  margin-bottom: 6px;
  text-transform: lowercase;
}
.regimen-card .principle {
  font-size: 12px;
  color: var(--info);
  text-transform: lowercase;
  margin-bottom: 6px;
}
.regimen-card ol {
  padding-left: 18px;
  margin: 4px 0;
  list-style: decimal;
}
.regimen-card ol li {
  font-size: 13px;
  margin: 2px 0;
  text-transform: lowercase;
}
.regimen-card ol li .move-ref {
  color: #000;
  border-bottom: 1px dotted #000;
  cursor: pointer;
}
.regimen-card ol li .move-ref:hover { background: #000; color: #fff; }
.regimen-card ol li .spec {
  color: #666;
  font-variant-numeric: tabular-nums;
}

/* ════════════════════ moves secondary nav ════════════════════ */
.moves-nav {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 6px 0;
  border-bottom: 1px solid #000;
  margin-bottom: 8px;
  position: sticky; top: -12px; background: #fff; z-index: 5;
}
.moves-nav .cat-label {
  font-size: 12px;
  text-transform: lowercase;
  color: #fff;
  background: #000;
  padding: 3px 6px;
  margin-right: 4px;
}
.moves-nav .move-btn {
  border: 1px solid #000;
  background: #fff;
  color: #000;
  padding: 2px 6px;
  font-size: 13px;
  text-transform: lowercase;
}
.moves-nav .move-btn:hover { background: #000; color: #fff; }
.moves-nav .move-btn.is-active { background: #000; color: #fff; }

/* ════════════════════ figure / move image ════════════════════ */
.figure {
  margin: 8px 0;
  border: 1px solid #000;
  background: #fafafa;
  text-align: center;
  padding: 8px;
  min-height: 80px;
}
.figure img { max-width: 100%; max-height: 280px; display: block; margin: 0 auto; }
.figure .ph {
  color: #888;
  font-size: 13px;
  padding: 24px 10px;
  font-style: italic;
  text-transform: lowercase;
}

/* ════════════════════ notes view (long-form) ════════════════════ */
.notes-body {
  max-width: 700px;
  margin: 0 auto;
}
.notes-body h1 {
  font-size: 16px;
  text-transform: lowercase;
  margin: 12px 0 4px;
}
.notes-body h2 {
  font-size: 14px;
  border-bottom: 1px solid #000;
  margin: 14px 0 6px;
  padding-bottom: 2px;
  text-transform: lowercase;
}
.notes-body h3 {
  font-size: 14px;
  margin: 10px 0 4px;
  text-transform: lowercase;
}
.notes-body p {
  font-size: 14px;
  line-height: 1.6;
  margin: 6px 0;
}
.notes-body blockquote {
  border-left: 3px solid #000;
  margin: 6px 0;
  padding: 4px 10px;
  color: #666;
  font-size: 13px;
}
.notes-body ul, .notes-body ol {
  margin: 6px 0;
  padding-left: 18px;
  list-style: disc;
}
.notes-body ol { list-style: decimal; }
.notes-body ul li, .notes-body ol li {
  font-size: 13px;
  line-height: 1.5;
  margin: 3px 0;
}
.notes-body strong { color: var(--bad); font-weight: 400; }

/* ════════════════════ status footer ════════════════════ */
.footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  border-top: 1px solid #000;
  background: #fff;
  font-size: 13px;
  letter-spacing: 0.2px;
}
.footer .stats {
  display: flex; gap: 12px; overflow-x: auto;
  scrollbar-width: none;
}
.footer .stats::-webkit-scrollbar { display: none; }
.footer .stat {
  white-space: nowrap;
  text-transform: lowercase;
}
.footer .stat .k { color: #666; }
.footer .stat .v.bad  { color: var(--bad); }
.footer .stat .v.good { color: var(--diff-add-color); }
.footer .next {
  color: #666;
  white-space: nowrap;
}

/* ════════════════════ CRT empty overlay (招牌) ════════════════════ */
.empty-overlay {
  position: relative;
  min-height: 120px;
  border: 1px solid #000;
  background: #fff;
  overflow: hidden;
  margin: 8px 0;
}
.empty-overlay::before {
  content: "";
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(to bottom,
      rgba(0,0,0,0.11) 0, rgba(0,0,0,0.11) 1px,
      transparent 1px, transparent 3px),
    radial-gradient(ellipse at center, rgba(0,0,0,0.14), transparent 68%);
  mix-blend-mode: multiply;
  opacity: 0.72;
  pointer-events: none;
}
.empty-overlay::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg,
    transparent, transparent 2px, rgba(0,0,0,0.075) 3px);
  animation: crt-wobble 3s linear infinite !important;
  pointer-events: none;
}
@keyframes crt-wobble {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(1px); }
}
@media (prefers-reduced-motion: reduce) {
  .empty-overlay::after { animation: none !important; }
}

/* ════════════════════ trend mini bars (inline svg-less) ════════════════════ */
.spark {
  display: inline-flex; align-items: flex-end; gap: 1px;
  height: 12px; vertical-align: middle;
}
.spark .bar {
  width: 3px; background: #000;
}
.spark .bar.up   { background: var(--bad); }
.spark .bar.down { background: var(--diff-add-color); }

/* ════════════════════ index summary headline ════════════════════ */
.headline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  border: 1px solid #000;
  margin: 8px 0;
}
.headline .item {
  padding: 6px 10px;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
}
.headline .item:last-child { border-right: 0; }
.headline .item .k { font-size: 12px; color: #666; text-transform: lowercase; }
.headline .item .v {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.headline .item .delta {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.headline .item .v.bad  { color: var(--bad); }
.headline .item .v.good { color: var(--diff-add-color); }

/* ════════════════════ photo gallery ════════════════════ */
.photo-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 4px;
  margin: 6px 0;
}
.photo-strip a {
  display: block;
  border: 1px solid #000;
  aspect-ratio: 3 / 4;
  background-color: #f5f5f5;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.photo-strip a:hover { outline: 2px solid #000; outline-offset: -2px; }

/* ════════════════════ phase chips (cycle) ════════════════════ */
.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px;
  margin: 6px 0;
}
.phase {
  border: 1px solid #000;
  padding: 6px 8px;
}
.phase .name {
  font-size: 13px;
  text-transform: lowercase;
  margin-bottom: 2px;
}
.phase .days {
  font-size: 12px;
  color: #666;
  font-variant-numeric: tabular-nums;
}
.phase .pick {
  font-size: 12px;
  color: var(--info);
  margin-top: 4px;
  text-transform: lowercase;
}

/* ════════════════════ entry hover (warm cream) ════════════════════ */
.entry-hover:hover {
  background: var(--cream);
  color: #000;
}

/* ════════════════════ allowed motion: chip pulse ════════════════════ */
@keyframes chip-pulse {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.3); }
}
.chip.is-current { animation: chip-pulse 1.4s ease-in-out infinite !important; }

/* ════════════════════ mobile ════════════════════ */
@media (max-width: 768px) {
  .topbar { padding: 0 8px; }
  .topbar .crumb .view-tab { font-size: 12px; padding: 0 4px; }
  .topbar .crumb .site { font-size: 13px; }
  main { padding: 8px; }
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .regimen-grid { grid-template-columns: 1fr; }
  h1 { font-size: 16px; }
  .footer { font-size: 12px; padding: 0 8px; }
  .footer .stats { gap: 8px; }
}
@media (max-width: 480px) {
  .topbar .crumb .view-tab { padding: 0 3px; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  .moves-nav { gap: 3px; }
  .moves-nav .move-btn { font-size: 12px; padding: 2px 4px; }
}

/* ════════════════════ ios input zoom fix ════════════════════ */
/* [REC::HEALTH::IOS_INPUT_ZOOM_FIX] */
@supports (-webkit-touch-callout: none) {
  input, textarea, select { font-size: 16px; }
}

/* ════════════════════ safe area ════════════════════ */
.footer {
  padding-bottom: env(safe-area-inset-bottom, 0);
}
