/* 生產力模擬器 companion site
   僅供本機預覽，尚未上線。禁止部署到 Surge 或其他主機。
   請勿使用舊名 MNCS。色票沿用封面 contrast.md。 */
:root {
  --bg: #F7F4EF;
  --card: #FFFFFF;
  --ink: #1C1917;
  --muted: #44403C;
  --line: #908782;
  --accent: #9A3412;
  --ok: #166534;
  --blue: #1E5A9A;
  --blue-ink: #1E3A8A;
  --soft-accent: #FFF1E6;
  --soft-ok: #ECFDF5;
  --soft-blue: #EFF6FF;
  --btn-bg: #9A3412;
  --btn-ink: #FFFFFF;
  --todo-bg: #FFF3C4;
  --todo-ink: #7A4A00;
  --badge-bg: #E7E5E4;
  --badge-ink: #44403C;
  --badge-line: #867D77;
  --reuse-bg: #E7F0FE;
  --reuse-ink: #1A4A8A;
  --phone-rim: #1C1917;
  --display: #F3F0E9;
  --grid: #867D77;
  --header-bg: color-mix(in srgb, var(--bg) 92%, transparent);
  --shadow: 0 12px 32px rgba(28, 25, 23, 0.12);
  --radius-card: 16px;
  --radius-control: 12px;
  --radius-pill: 999px;
  --radius: var(--radius-card);
  --max: 1120px;
  --max-text: 820px;
  --font: "SF Pro Text", "SF Pro Display", Inter, "PingFang TC", "Noto Sans CJK TC", "Noto Sans TC", sans-serif;
  --font-num: Inter, "SF Pro Text", "Noto Sans CJK TC", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12110F;
    --card: #1C1917;
    --ink: #F5F0E8;
    --muted: #D6D3D1;
    --line: #6F6962;
    --accent: #FB923C;
    --ok: #4ADE80;
    --blue: #78C8FC;
    --blue-ink: #78C8FC;
    --soft-accent: #3A220F;
    --soft-ok: #0F2E1C;
    --soft-blue: #0C2438;
    --btn-bg: #FB923C;
    --btn-ink: #1C1917;
    --todo-bg: #524100;
    --todo-ink: #FFF3C4;
    --badge-bg: #3F3A36;
    --badge-ink: #D6D3D1;
    --badge-line: #8E8880;
    --reuse-bg: #042D6C;
    --reuse-ink: #E7F0FE;
    --phone-rim: #C8CCD2;
    --display: #0A0A0B;
    --grid: #6F6962;
    --header-bg: color-mix(in srgb, var(--bg) 92%, transparent);
    --shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  }
  html { color-scheme: dark; }
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #F7F4EF;
  --card: #FFFFFF;
  --ink: #1C1917;
  --muted: #44403C;
  --line: #908782;
  --accent: #9A3412;
  --ok: #166534;
  --blue: #1E5A9A;
  --blue-ink: #1E3A8A;
  --soft-accent: #FFF1E6;
  --soft-ok: #ECFDF5;
  --soft-blue: #EFF6FF;
  --btn-bg: #9A3412;
  --btn-ink: #FFFFFF;
  --todo-bg: #FFF3C4;
  --todo-ink: #7A4A00;
  --badge-bg: #E7E5E4;
  --badge-ink: #44403C;
  --badge-line: #867D77;
  --reuse-bg: #E7F0FE;
  --reuse-ink: #1A4A8A;
  --phone-rim: #1C1917;
  --display: #F3F0E9;
  --grid: #867D77;
  --header-bg: color-mix(in srgb, var(--bg) 92%, transparent);
  --shadow: 0 12px 32px rgba(28, 25, 23, 0.12);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12110F;
  --card: #1C1917;
  --ink: #F5F0E8;
  --muted: #D6D3D1;
  --line: #6F6962;
  --accent: #FB923C;
  --ok: #4ADE80;
  --blue: #78C8FC;
  --blue-ink: #78C8FC;
  --soft-accent: #3A220F;
  --soft-ok: #0F2E1C;
  --soft-blue: #0C2438;
  --btn-bg: #FB923C;
  --btn-ink: #1C1917;
  --todo-bg: #524100;
  --todo-ink: #FFF3C4;
  --badge-bg: #3F3A36;
  --badge-ink: #D6D3D1;
  --badge-line: #8E8880;
  --reuse-bg: #042D6C;
  --reuse-ink: #E7F0FE;
  --phone-rim: #C8CCD2;
  --display: #0A0A0B;
  --grid: #6F6962;
  --header-bg: color-mix(in srgb, var(--bg) 92%, transparent);
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; scroll-padding-top: 96px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.num, .stats, table, .hero-stats {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.num, .hero-stats .n {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 20;
  background: var(--btn-bg);
  color: var(--btn-ink);
  padding: 8px 14px;
  border-radius: var(--radius-control);
  font-weight: 700;
  text-decoration: none;
}
.skip:focus { top: 12px; }

.draftbar {
  background: var(--btn-bg);
  color: var(--btn-ink);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  padding: 8px 16px;
}

header {
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.bar {
  max-width: var(--max);
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  color: var(--ink);
  text-decoration: none;
  min-height: 44px;
}
.brand img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-control);
  border: 1px solid var(--line);
}
nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  border: 1.5px solid transparent;
}
nav a:hover { border-color: var(--line); color: var(--ink); }
nav a.on {
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-weight: 700;
  border-color: var(--btn-bg);
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px 20px 64px;
}
.wrap-text {
  max-width: var(--max-text);
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.hero {
  max-width: var(--max-text);
  margin: 0 auto;
  padding: 32px 20px 8px;
}
.hero h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.hero p { margin: 0; color: var(--muted); }

.hero-landing {
  display: grid;
  grid-template-columns: 1fr;
  gap: 36px;
  align-items: center;
  padding: 28px 0 16px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
}
.lede {
  margin: 12px 0 24px;
  font-size: 18px;
  color: var(--muted);
  max-width: 36em;
}
.store-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: var(--radius-control);
  background: var(--badge-bg);
  color: var(--badge-ink);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  border: 1.5px solid var(--badge-line);
  margin: 0 0 14px;
  cursor: default;
  pointer-events: none;
}
.store-badge:hover,
.store-badge:focus,
.store-badge:focus-visible,
.store-badge:active {
  /* 狀態標示，不是按鈕：不做 hover／focus 樣式 */
  background: var(--badge-bg);
  color: var(--badge-ink);
  border-color: var(--badge-line);
  outline: none;
}
.hero-links { margin: 0; color: var(--muted); font-size: 16px; }
.hero-links a { font-weight: 700; }

.hero-visual { display: flex; justify-content: center; }

.phone {
  position: relative;
  width: min(260px, 70vw);
  border: 3px solid var(--phone-rim);
  border-radius: 32px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}
.shot-tag {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-ink);
  border: 1.5px solid var(--btn-bg);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
  pointer-events: none;
}
.phone img { width: 100%; height: auto; display: block; }
.phone figcaption, .shots figcaption {
  margin: 8px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.hero-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 28px 0 8px;
}
.hero-stats article {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.hero-stats .k {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
}
.hero-stats .n {
  display: block;
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.hero-stats .u {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.sample-tag {
  display: inline-block;
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
}

.section { margin: 36px 0; }
.section > h2 {
  margin: 0 0 16px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.section-lead { margin: -4px 0 20px; color: var(--muted); }

.features {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.feature {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.feature h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 800;
}
.feature p { margin: 0; color: var(--muted); }
.feature .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 28px;
  margin-bottom: 8px;
  border-radius: var(--radius-control);
  background: var(--soft-accent);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  padding: 0 8px;
}

.shots {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}
.shots figure { margin: 0; width: min(220px, 46vw); }
.shots .phone { width: 100%; border-radius: 28px; }

.notice, .callout {
  background: var(--soft-accent);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-card);
  padding: 16px 20px;
  margin: 18px 0;
  font-size: 15px;
  color: var(--ink);
}
.notice b, .callout b { display: block; font-size: 17px; margin-bottom: 4px; }

.legal-card, main.legal section, .card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 22px 16px;
  margin: 14px 0;
}
.legal-card h2, main.legal section h2, .card h2, .step h2 {
  font-size: 19px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 10px;
}
.legal-card h2::before, main.legal section h2::before {
  content: "";
  width: 6px;
  height: 22px;
  border-radius: 3px;
  background: var(--accent);
  flex: 0 0 6px;
}
.legal-card h3, main.legal section h3 { font-size: 17px; margin: 18px 0 8px; }
main.legal li::marker { color: var(--accent); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 10px 0 14px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
td, th {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}
th { background: var(--soft-accent); font-weight: 700; }

.todo, .reuse {
  display: inline;
  border-radius: var(--radius-pill);
  padding: 0 5px;
  font-weight: 700;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.todo { background: var(--todo-bg); color: var(--todo-ink); }
.reuse { background: var(--reuse-bg); color: var(--reuse-ink); }

.step {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 18px 0;
}
.step .copy h2 { margin-top: 0; }
.step ol, .step ul { padding-left: 1.2em; }
.step .shot { justify-self: center; }
.step .phone { width: min(240px, 70vw); }
.step-kicker {
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  margin: 0 0 4px;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}
.caption-note {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

footer {
  background: var(--card);
  border-top: 3px solid var(--accent);
  color: var(--muted);
  font-size: 14px;
}
footer .bar {
  display: block;
  padding: 22px 20px;
  text-align: center;
  max-width: var(--max);
}
footer nav {
  justify-content: center;
  margin: 8px 0;
}
footer .fine { margin: 8px 0 0; }

hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

[id], h2, h3 { scroll-margin-top: 120px; }

@media (max-width: 640px) {
  .bar { justify-content: center; }
  .brand { flex: 0 0 100%; justify-content: center; }
  nav { flex: 0 0 100%; justify-content: center; }
  nav a { flex: 1 1 auto; min-width: 28%; }
  .hero h1 { font-size: 28px; }
  .legal-card, main.legal section, .card { padding: 6px 16px 14px; }
  .table-wrap table, .table-wrap thead, .table-wrap tbody,
  .table-wrap th, .table-wrap td, .table-wrap tr { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr {
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    margin: 0 0 10px;
    overflow: hidden;
    background: var(--card);
  }
  .table-wrap th, .table-wrap td { border: none; border-bottom: 1px solid var(--line); padding: 8px 10px; }
  .table-wrap tr > *:first-child { background: var(--soft-accent); font-weight: 700; }
  .table-wrap tr > *:last-child { border-bottom: none; }
  .table-wrap td[data-label]::before {
    content: attr(data-label) "：";
    font-weight: 700;
    color: var(--accent);
    margin-right: .25em;
  }
}

@media (min-width: 860px) {
  .hero-landing { grid-template-columns: 1.15fr 0.85fr; gap: 48px; padding: 48px 0 24px; }
  .hero-stats { grid-template-columns: repeat(3, 1fr); }
  .features { grid-template-columns: repeat(2, 1fr); }
  .step { grid-template-columns: 1fr 240px; padding: 28px; }
  .step:nth-child(even) { grid-template-columns: 240px 1fr; }
  .step:nth-child(even) .shot { order: -1; }
  .lede { font-size: 19px; }
}

/* 不使用會改變元件尺寸的動畫；連結僅變色 */

.back-toc {
  display: none;
}
@media (max-width: 640px) {
  .back-toc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 8;
    min-height: 44px;
    min-width: 44px;
    padding: 10px 16px;
    border-radius: var(--radius-pill);
    background: var(--btn-bg);
    color: var(--btn-ink);
    border: 1.5px solid var(--btn-bg);
    font-weight: 800;
    font-size: 15px;
    text-decoration: none;
    line-height: 1;
    box-shadow: var(--shadow);
  }
  .back-toc:hover { color: var(--btn-ink); text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* ==========================================================================
   Direction A（鋼構工業）tokens + login + legal links
   Role-named tokens match brown-ui-1129 / rollout-a. Marketing page colours
   above are unchanged. Login, legal nav, and user-panel use these tokens.
   Dark mappings are defined so ?theme=dark and prefers-color-scheme work;
   a visible toggle is not wired in this pass.
   ========================================================================== */
:root {
  --surface-page: #EEF1F4;
  --surface: #FFFFFF;
  --surface-field: #F4F6F8;
  --surface-active: #E8EEF4;
  --text-primary: #141C24;
  --text-strong: #2C3742;
  --text-secondary: #46525E;
  --text-placeholder: #5F6B77;
  --text-on-accent: #FFFFFF;
  --border: #B9C3CD;
  --control-border: #6B7885;
  --track: #D5DCE3;
  --accent-da: #1D4E78;
  --accent-strong: #163E60;
  --accent-secondary: #B23A0A;
  --status-ontrack: #1C6B3C;
  --status-ontrack-soft: #E3EEE6;
  --status-ontrack-text: #1C5C34;
  --status-warn: #F0B23E;
  --status-warn-bar: #9A6200;
  --status-warn-soft: #FBE3B8;
  --status-warn-text: #8A5300;
  --status-warn-ink: #5E3A00;
  --status-behind: #A3201B;
  --status-behind-soft: #F8E1DF;
  --status-behind-text: #7A1712;
  --focus-ring: #1D4E78;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-page: #10171D;
    --surface: #1A232C;
    --surface-field: #262F39;
    --surface-active: #2E3944;
    --text-primary: #E3E9EF;
    --text-strong: #E6ECF2;
    --text-secondary: #B7C5D1;
    --text-placeholder: #8E9DAA;
    --text-on-accent: #141C24;
    --border: #7A8B9A;
    --control-border: #7A8B9A;
    --track: #313B46;
    --accent-da: #8BB4D0;
    --accent-strong: #8BB4D0;
    --accent-secondary: #D4A07A;
    --status-ontrack: #7BC9A0;
    --status-ontrack-soft: #163028;
    --status-ontrack-text: #7BC9A0;
    --status-warn: #E0B56A;
    --status-warn-bar: #E0B56A;
    --status-warn-soft: #332A12;
    --status-warn-text: #E0B56A;
    --status-warn-ink: #E0B56A;
    --status-behind: #E8A39C;
    --status-behind-soft: #2A1614;
    --status-behind-text: #E8A39C;
    --focus-ring: #8BB4D0;
  }
}

html[data-theme="light"] {
  --surface-page: #EEF1F4;
  --surface: #FFFFFF;
  --surface-field: #F4F6F8;
  --surface-active: #E8EEF4;
  --text-primary: #141C24;
  --text-strong: #2C3742;
  --text-secondary: #46525E;
  --text-placeholder: #5F6B77;
  --text-on-accent: #FFFFFF;
  --border: #B9C3CD;
  --control-border: #6B7885;
  --track: #D5DCE3;
  --accent-da: #1D4E78;
  --accent-strong: #163E60;
  --accent-secondary: #B23A0A;
  --status-ontrack: #1C6B3C;
  --status-ontrack-soft: #E3EEE6;
  --status-ontrack-text: #1C5C34;
  --status-warn: #F0B23E;
  --status-warn-bar: #9A6200;
  --status-warn-soft: #FBE3B8;
  --status-warn-text: #8A5300;
  --status-warn-ink: #5E3A00;
  --status-behind: #A3201B;
  --status-behind-soft: #F8E1DF;
  --status-behind-text: #7A1712;
  --focus-ring: #1D4E78;
}

html[data-theme="dark"] {
  --surface-page: #10171D;
  --surface: #1A232C;
  --surface-field: #262F39;
  --surface-active: #2E3944;
  --text-primary: #E3E9EF;
  --text-strong: #E6ECF2;
  --text-secondary: #B7C5D1;
  --text-placeholder: #8E9DAA;
  --text-on-accent: #141C24;
  --border: #7A8B9A;
  --control-border: #7A8B9A;
  --track: #313B46;
  --accent-da: #8BB4D0;
  --accent-strong: #8BB4D0;
  --accent-secondary: #D4A07A;
  --status-ontrack: #7BC9A0;
  --status-ontrack-soft: #163028;
  --status-ontrack-text: #7BC9A0;
  --status-warn: #E0B56A;
  --status-warn-bar: #E0B56A;
  --status-warn-soft: #332A12;
  --status-warn-text: #E0B56A;
  --status-warn-ink: #E0B56A;
  --status-behind: #E8A39C;
  --status-behind-soft: #2A1614;
  --status-behind-text: #E8A39C;
  --focus-ring: #8BB4D0;
}

/* --- Legal links (all pages): quiet text, 44px targets, no pill --- */
nav.site-legal {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 0;
  margin-left: auto;
}
nav.site-legal a,
nav.site-legal a.site-legal__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0;
  text-decoration: none;
  flex: 0 0 auto;
}
nav.site-legal a:hover,
nav.site-legal a.site-legal__link:hover {
  color: var(--text-primary);
  background: transparent;
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
nav.site-legal a:focus-visible,
nav.site-legal a.site-legal__link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  color: var(--text-primary);
}
nav.site-legal a.on,
nav.site-legal a.site-legal__link.on {
  background: transparent;
  color: var(--text-primary);
  font-weight: 600;
  border-color: transparent;
}

@media (max-width: 640px) {
  nav.site-legal {
    flex: 0 0 100%;
    justify-content: center;
    margin-left: 0;
  }
  nav.site-legal a,
  nav.site-legal a.site-legal__link {
    flex: 0 0 auto;
    min-width: 44px;
  }
}

/* --- Login page: split layout, brand buttons, states, user panel --- */
body:has(.login-page) {
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: "IBM Plex Sans", "Noto Sans TC", "Noto Sans CJK TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.login-page {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.login-page {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

#login-panel {
  order: -1; /* mobile: panel first */
  background: var(--surface);
  color: var(--text-primary);
  border: 1.5px solid var(--control-border);
  border-radius: var(--radius-card);
  padding: 28px 24px 24px;
  max-width: 28rem;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

#login-panel h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text-primary);
  line-height: 1.25;
  white-space: nowrap;
}

.login-lead {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-strong);
  line-height: 1.55;
}

.login-hint {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
}

#login-status:empty,
#login-error:empty {
  display: none;
}

#login-status {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-card);
  background: var(--surface-field);
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 600;
}

#login-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-card);
  background: var(--status-behind-soft);
  color: var(--status-behind-text);
  font-size: 14px;
  font-weight: 600;
}

body.is-offline #login-error:empty {
  display: block;
}
body.is-offline #login-error:empty::before {
  content: "目前沒有網路連線，請連線後再試。";
}

#login-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#btn-apple,
#btn-google,
#btn-facebook,
#btn-signout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border-radius: var(--radius-control);
  box-sizing: border-box;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}

#btn-apple .btn-auth__logo,
#btn-google .btn-auth__logo,
#btn-facebook .btn-auth__logo {
  width: 20px;
  height: 20px;
  flex: none;
  display: block;
}

#btn-apple {
  background: #000000;
  color: #FFFFFF;
  border: 1px solid #000000;
  font-family: -apple-system, "SF Pro Text", "SF Pro Display", "IBM Plex Sans", "Noto Sans TC", sans-serif;
  font-weight: 600;
  order: 0;
}

#btn-google {
  background: #FFFFFF;
  color: #1F1F1F;
  border: 1px solid #747775;
  font-family: Roboto, "IBM Plex Sans", "Noto Sans TC", sans-serif;
  font-weight: 500;
}

#btn-facebook {
  /* Official Facebook blue. White-on-#1877F2 is ~4.23:1 (below 4.5). Brand colour kept as specified. */
  background: #1877F2;
  color: #FFFFFF;
  border: 1px solid #1877F2;
  font-family: "IBM Plex Sans", "Noto Sans TC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 600;
}

#btn-apple:hover { background: #1a1a1a; }
#btn-google:hover { background: #F8F8F8; }
#btn-facebook:hover { background: #166FE5; }

#btn-apple:focus-visible,
#btn-google:focus-visible,
#btn-facebook:focus-visible,
#btn-signout:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

#btn-apple:disabled,
#btn-google:disabled,
#btn-facebook:disabled,
#btn-signout:disabled,
body.is-loading #btn-apple,
body.is-loading #btn-google,
body.is-loading #btn-facebook {
  opacity: 0.55;
  cursor: not-allowed;
}

#user-panel {
  margin: 4px 0 16px;
  padding: 16px 0 0;
  border-top: 1.5px solid var(--control-border);
  color: var(--text-primary);
}
#user-panel[hidden] {
  display: none !important;
}
#user-panel p {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--text-strong);
}
#user-name {
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

#btn-signout {
  min-height: 44px;
  background: var(--surface);
  color: var(--text-primary);
  border: 1.5px solid var(--text-primary);
  font-family: "IBM Plex Sans", "Noto Sans TC", sans-serif;
  font-weight: 600;
  font-size: 15px;
}
#btn-signout:hover {
  background: var(--surface-field);
}

.login-legal-note,
.login-home {
  margin: 16px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  text-align: center;
}
.login-legal-note a,
.login-home a {
  color: var(--accent-da);
  text-underline-offset: 3px;
}
.login-legal-note a:focus-visible,
.login-home a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

#login-cover {
  order: 1;
  min-width: 0;
}
#login-cover picture,
#login-cover img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-card);
  border: 1.5px solid var(--control-border);
  background: var(--surface);
}

#login-feature-gifs,
#login-feature-gifs[hidden] {
  display: none !important;
}

@media (min-width: 900px) {
  .login-page {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(22rem, 26rem);
    grid-template-areas: "cover panel";
    gap: 40px;
    align-items: center;
    min-height: 0;
  }
  #login-cover {
    grid-area: cover;
    order: 0;
  }
  #login-cover img {
    height: auto;
    max-height: none;
    object-fit: contain;
    object-position: center center;
  }
  #login-panel {
    grid-area: panel;
    order: 0;
    margin: 0;
    max-width: none;
  }
}


/* --- Theme toggle + language selector (login chrome) --- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.site-chrome {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
}
#theme-toggle,
#lang-select {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: var(--radius-control);
  border: 1.5px solid var(--control-border, #6B7885);
  background: var(--surface, #fff);
  color: var(--text-primary, #141C24);
  font-family: "IBM Plex Sans", "Noto Sans TC", "Noto Sans CJK TC", sans-serif;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
#lang-select { padding-right: 28px; }
#theme-toggle:hover,
#lang-select:hover { background: var(--surface-field, #F4F6F8); }
#theme-toggle:focus-visible,
#lang-select:focus-visible {
  outline: 2px solid var(--focus-ring, #1D4E78);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .site-chrome {
    flex: 0 0 100%;
    justify-content: center;
    margin-left: 0;
  }
}

.btn-auth__label {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
  text-align: center;
}
#login-actions .btn-auth__label .i18n-vi,
.login-lead .i18n-vi,
.login-hint .i18n-vi {
  display: block;
  font-size: 11px;
  font-weight: 500;
  opacity: 0.92;
  margin-top: 2px;
}
html[data-lang="zh-vi"] #btn-apple,
html[data-lang="zh-vi"] #btn-google,
html[data-lang="zh-vi"] #btn-facebook {
  min-height: 56px;
}

/* Dark / light cover swap */
#login-cover .cover-img--dark { display: none; }
html[data-theme="dark"] #login-cover .cover-img--light { display: none; }
html[data-theme="dark"] #login-cover .cover-img--dark { display: block; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) #login-cover .cover-img--light { display: none; }
  html:not([data-theme="light"]) #login-cover .cover-img--dark { display: block; }
}

/* Login page header/footer follow Direction A when themed */
body:has(.login-page) header,
body:has(.login-page) footer {
  background: var(--surface);
  border-color: var(--control-border);
  color: var(--text-primary);
}
body:has(.login-page) header .brand,
body:has(.login-page) footer strong { color: var(--text-primary); }
body:has(.login-page) header nav:not(.site-legal) a {
  color: var(--text-secondary);
}
body:has(.login-page) header nav:not(.site-legal) a.on {
  background: var(--accent-da);
  color: var(--text-on-accent);
  border-color: var(--accent-da);
}
body:has(.login-page) footer,
body:has(.login-page) footer .fine { color: var(--text-secondary); }
body:has(.login-page) footer a { color: var(--accent-da); }


/* --- Compact login top bar (56–64pt) --- */
body:has(.login-page) .site-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
}
body:has(.login-page) .site-topbar .bar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  min-height: 56px;
  max-height: 64px;
  padding: 6px 12px;
  box-sizing: border-box;
}
body:has(.login-page) .site-topbar .brand {
  flex: 0 0 auto;
  min-height: 44px;
  justify-content: flex-start;
  font-size: 16px;
  gap: 8px;
  white-space: nowrap;
}
body:has(.login-page) .site-topbar .brand img {
  width: 40px;
  height: 40px;
}
body:has(.login-page) .primary-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
}
body:has(.login-page) .primary-nav a,
body:has(.login-page) .site-menu a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  flex: 0 0 auto;
  min-width: 44px;
}
body:has(.login-page) .primary-nav a:hover,
body:has(.login-page) .site-menu a:hover {
  color: var(--text-primary);
  background: var(--surface-field);
  border-color: transparent;
}
body:has(.login-page) .primary-nav a[aria-current="page"],
body:has(.login-page) .site-menu a[aria-current="page"] {
  background: transparent;
  color: var(--accent-da);
  font-weight: 700;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}
body:has(.login-page) .primary-nav a[aria-current="page"]:hover,
body:has(.login-page) .site-menu a[aria-current="page"]:hover {
  background: var(--surface-field);
  color: var(--accent-da);
}
body:has(.login-page) .site-chrome {
  flex: 0 0 auto;
  margin-left: auto;
  gap: 6px;
}
body:has(.login-page) #lang-select {
  min-height: 44px;
  max-width: 10.5rem;
  font-size: 12px;
  padding: 0 24px 0 8px;
}
body:has(.login-page) .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: var(--radius-control);
  border: 1.5px solid var(--control-border);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
}
body:has(.login-page) .icon-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}
body:has(.login-page) .icon-btn:hover { background: var(--surface-field); }
body:has(.login-page) .icon-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.site-menu {
  display: flex;
  flex-direction: column;
  padding: 8px 12px 12px;
  border-top: 1.5px solid var(--control-border);
  background: var(--surface);
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}
.site-menu[hidden] { display: none !important; }

@media (max-width: 640px) {
  body:has(.login-page) .bar {
    justify-content: space-between;
  }
  body:has(.login-page) .brand {
    flex: 0 0 auto;
    justify-content: flex-start;
    font-size: 15px;
    white-space: nowrap;
  }
  body:has(.login-page) .site-chrome {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
  }
  body:has(.login-page) #lang-select {
    max-width: 7rem;
    min-width: 0;
    width: 100%;
    flex: 1 1 auto;
    padding: 0 20px 0 6px;
  }
  body:has(.login-page) .primary-nav { display: none; }
  body:has(.login-page) .wrap.login-page {
    padding: 16px 16px 24px;
  }
  body:has(.login-page) #login-panel {
    padding: 20px 16px 16px;
  }
  body:has(.login-page) #login-panel h1 { font-size: 24px; }
}
@media (max-width: 379px) {
  body:has(.login-page) #lang-select {
    max-width: 6.1rem;
  }
}
@media (min-width: 641px) {
  #nav-menu-btn, #site-menu { display: none !important; }
}


/* Shared footer nav: one row at 375/390pt (Brown 2026-11-30 21:46). CSS only. */
footer nav {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: 4px 0;
}
footer nav a {
  flex: 0 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 8px 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}
footer nav a:not(:last-child) { padding-right: 0; }
footer nav a:not(:first-child) { padding-left: 0; }
footer nav a:not(:last-child)::after {
  content: "·";
  margin-left: 8px;
  margin-right: 8px;
  font-weight: 500;
  pointer-events: none;
}
@media (max-width: 390px) {
  footer nav a {
    font-size: 12px;
    padding: 8px 4px;
  }
  footer nav a:not(:last-child) { padding-right: 0; }
  footer nav a:not(:first-child) { padding-left: 0; }
  footer nav a:not(:last-child)::after {
    margin-left: 8px;
    margin-right: 8px;
  }
}


/* Radius safety net: cards 16, controls 12, pills 999. Footer one-row rules stay above. */
#login-panel,
#login-cover picture,
#login-cover img,
#login-status,
#login-error,
.card,
.legal-card,
.feature,
.step,
.notice,
.callout,
main.legal section,
.table-wrap,
.site-menu {
  border-radius: var(--radius-card);
}
.site-menu {
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}
input,
select,
button,
textarea,
#btn-apple,
#btn-google,
#btn-facebook,
#btn-signout,
#lang-select,
#theme-toggle,
.icon-btn,
.site-topbar .brand img,
nav.site-legal a,
body:has(.login-page) .primary-nav a,
body:has(.login-page) .site-menu a,
body:has(.login-page) .icon-btn {
  border-radius: var(--radius-control);
}
.badge,
.pill,
.back-toc,
.todo,
.reuse,
nav a,
footer nav a {
  border-radius: var(--radius-pill);
}


/* Desktop login (≥900px): one-row nav/footer, rounded tokens, wider canvas. Mobile unchanged. */
@media (min-width: 900px) {
  body:has(.login-page) .site-topbar .bar {
    max-width: 1320px;
    margin: 0 auto;
    padding-left: 32px;
    padding-right: 32px;
    flex-wrap: nowrap;
  }
  body:has(.login-page) footer .bar {
    max-width: 1320px;
    margin: 0 auto;
    padding-left: 32px;
    padding-right: 32px;
  }
  body:has(.login-page) .wrap.login-page {
    max-width: 1320px;
    margin: 0 auto;
    padding: 28px 32px 28px;
    gap: 40px;
    align-items: center;
    min-height: 0;
  }
  body:has(.login-page) .primary-nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
  }
  body:has(.login-page) #nav-menu-btn,
  body:has(.login-page) #site-menu {
    display: none !important;
  }
  #login-panel {
    border-radius: var(--radius-card);
  }
  #login-cover img,
  #login-cover picture {
    border-radius: var(--radius-card);
  }
  #btn-apple,
  #btn-google,
  #btn-facebook,
  #lang-select,
  body:has(.login-page) .icon-btn {
    border-radius: var(--radius-control);
  }
}


/* iPhone layout pass 2026-12-01 21:43: index/guide/privacy/terms only.
   Login and desktop (≥900px) unchanged. */
@media (max-width: 899px) {
  body:not(:has(.login-page)) .bar {
    justify-content: center;
    gap: 4px 8px;
    padding: 8px 12px;
    max-width: 100%;
    box-sizing: border-box;
  }
  body:not(:has(.login-page)) .brand {
    flex: 0 0 100%;
    justify-content: center;
    min-width: 0;
  }
  body:not(:has(.login-page)) header nav[aria-label="網站分類"] {
    flex: 1 1 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0 2px;
    min-width: 0;
    max-width: 100%;
  }
  body:not(:has(.login-page)) header nav[aria-label="網站分類"] a {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    padding: 8px 6px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    box-sizing: border-box;
    border-radius: var(--radius-pill);
  }
  body:not(:has(.login-page)) nav.site-legal {
    flex: 1 1 100%;
    justify-content: center;
    margin-left: 0;
    max-width: 100%;
  }
  body:not(:has(.login-page)) nav.site-legal a,
  body:not(:has(.login-page)) nav.site-legal a.site-legal__link {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 8px;
    font-size: 13px;
  }
  body:not(:has(.login-page)) .hero-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 4px;
  }
  body:not(:has(.login-page)) .hero-stats article,
  body:not(:has(.login-page)) .feature,
  body:not(:has(.login-page)) .legal-card,
  body:not(:has(.login-page)) main.legal section,
  body:not(:has(.login-page)) .card,
  body:not(:has(.login-page)) .notice,
  body:not(:has(.login-page)) .callout,
  body:not(:has(.login-page)) .step,
  body:not(:has(.login-page)) .table-wrap {
    border-radius: var(--radius-card);
  }
  body:not(:has(.login-page)) .store-badge,
  body:not(:has(.login-page)) .feature .mark {
    border-radius: var(--radius-control);
  }
  body:not(:has(.login-page)) .sample-tag,
  body:not(:has(.login-page)) header nav a,
  body:not(:has(.login-page)) .back-toc {
    border-radius: var(--radius-pill);
  }
  body:not(:has(.login-page)) .wrap,
  body:not(:has(.login-page)) .wrap-text {
    max-width: 100%;
    padding-left: 16px;
    padding-right: 16px;
    box-sizing: border-box;
    overflow-x: clip;
  }
  html[data-theme="dark"] body:not(:has(.login-page)) {
    --bg: var(--surface-page);
    --card: var(--surface);
    --ink: var(--text-primary);
    --muted: var(--text-secondary);
    --line: var(--control-border);
    --header-bg: color-mix(in srgb, var(--surface-page) 92%, transparent);
    --phone-rim: var(--control-border);
    --display: var(--surface-field);
    --badge-bg: var(--surface-field);
    --badge-ink: var(--text-secondary);
    --badge-line: var(--control-border);
    --shadow: 0 12px 36px rgba(16, 23, 29, 0.45);
  }
}
@media (max-width: 390px) {
  body:not(:has(.login-page)) header nav[aria-label="網站分類"] a {
    font-size: 12px;
    padding: 8px 4px;
  }
}

@media (max-width: 899px) {
  body:not(:has(.login-page)) .hero-links a,
  body:not(:has(.login-page)) .section-lead a,
  body:not(:has(.login-page)) .lede a,
  body:not(:has(.login-page)) .notice a,
  body:not(:has(.login-page)) .callout a,
  body:not(:has(.login-page)) #toc a,
  body:not(:has(.login-page)) main.legal a,
  body:not(:has(.login-page)) main a[href$="guide.html"],
  body:not(:has(.login-page)) main a[href$="privacy.html"],
  body:not(:has(.login-page)) main a[href$="terms.html"],
  body:not(:has(.login-page)) main a[href^="mailto:"] {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 2px;
    box-sizing: border-box;
  }
}


/* iPhone follow-up 2026-12-01 21:47: hide duplicate legal privacy; 44pt mailto hit area. <900px, not login. */
@media (max-width: 899px) {
  body:not(:has(.login-page)) nav.site-legal a[href$="privacy.html"] {
    display: none;
  }
  body:not(:has(.login-page)) a[href^="mailto:"] {
    display: inline;
    position: relative;
    min-height: 0;
    padding: 0;
    margin: 0;
    line-height: inherit;
    vertical-align: baseline;
  }
  body:not(:has(.login-page)) a[href^="mailto:"]::after {
    content: "";
    position: absolute;
    left: -4px;
    right: -4px;
    top: 50%;
    height: 44px;
    margin-top: -22px;
  }
}

/* Brown 2026-12-02: cover above login card on phones */
@media (max-width: 899px) {
  #login-cover { order: -2; }
  #login-panel { order: 0; }
}
