/* ============================================================
   南女之路｜基礎：設計代幣、重置、版面外框
   色彩靈感：鳳凰花（臺南市花）的朱紅，搭配葉綠與暖色紙張底色
   ============================================================ */

:root {
  color-scheme: light;
  --font-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", "Source Han Serif TC", serif;

  --bg: #fbf6ef;
  --bg-2: #f4ecdf;
  --surface: #ffffff;
  --surface-2: #fffaf3;
  --ink: #2a2420;
  --ink-2: #5a4f46;
  --ink-3: #75685d;
  --line: #e7d9c5;
  --line-2: #f0e6d6;

  --brand: #c83b22;
  --brand-2: #e0553a;
  --brand-hover: #b0311a;
  --brand-ink: #ffffff;
  --brand-soft: #fde8e1;
  --brand-soft-ink: #8e2713;
  --leaf: #1f7a52;
  --leaf-soft: #def2e7;
  --gold: #8f5a00;
  --gold-soft: #fcefcc;
  --info: #25669f;
  --info-soft: #e0edf9;
  --danger: #b4281f;
  --danger-soft: #fde3e0;
  --focus: #2563eb;

  --shadow-1: 0 1px 2px rgba(80, 50, 20, .06), 0 2px 10px rgba(80, 50, 20, .06);
  --shadow-2: 0 4px 12px rgba(80, 50, 20, .10), 0 18px 40px rgba(80, 50, 20, .14);
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;

  --topbar-h: 56px;
  --tabbar-h: 62px;
  --sidebar-w: 256px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16110e;
  --bg-2: #211a15;
  --surface: #1f1814;
  --surface-2: #261e19;
  --ink: #f4ece4;
  --ink-2: #d2c4b7;
  --ink-3: #a29486;
  --line: #3a2e26;
  --line-2: #2d241e;

  --brand: #ff7b5c;
  --brand-2: #ff9a80;
  --brand-hover: #ff9279;
  --brand-ink: #2a0d05;
  --brand-soft: #3b1e15;
  --brand-soft-ink: #ffc4b3;
  --leaf: #5fd0a0;
  --leaf-soft: #16302a;
  --gold: #f2b84b;
  --gold-soft: #33260b;
  --info: #86b9ee;
  --info-soft: #14283e;
  --danger: #ff8d82;
  --danger-soft: #3d1a17;
  --focus: #8cc0ff;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 10px rgba(0, 0, 0, .3);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, .5), 0 18px 40px rgba(0, 0, 0, .5);
}

/* ---------- 重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font: 16px/1.75 var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
body.modal-open { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; letter-spacing: .01em; }
h1 { font-size: clamp(1.55rem, 1.25rem + 1.2vw, 2.05rem); font-weight: 800; }
h2 { font-size: 1.28rem; font-weight: 750; }
h3 { font-size: 1.06rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-hover); }
img, svg { max-width: 100%; }
button { font: inherit; color: inherit; }
ul, ol { margin: 0; padding-left: 1.3em; }
table { border-collapse: collapse; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--brand-soft); color: var(--ink); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); text-decoration: none; }
.skip-link:focus { top: 10px; }
[hidden] { display: none !important; }

/* ---------- 圖示 ---------- */
.ic { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.22em; }
.logo { width: 38px; height: 38px; flex: none; border-radius: 10px; }

/* ---------- 版面外框 ---------- */
.app { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.main { min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
#view { flex: 1; width: 100%; max-width: 1140px; margin: 0 auto; padding: 18px 16px 36px; outline: none; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) 12px 0 16px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line-2);
}
.top-actions { display: flex; align-items: center; gap: 6px; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-text { display: grid; line-height: 1.2; }
.brand-text b { font-size: 1.12rem; letter-spacing: .06em; }
.brand-text small { color: var(--ink-3); font-size: .78rem; }
.brand-mini b { font-size: 1.1rem; letter-spacing: .06em; }
.brand-mini .logo { width: 32px; height: 32px; border-radius: 9px; }

.cd-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border-radius: 999px; background: var(--brand-soft); color: var(--brand-soft-ink);
  font-size: .88rem; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.cd-pill:hover { color: var(--brand-soft-ink); filter: brightness(.97); }

.sidebar { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-3); text-decoration: none; font-size: .74rem; font-weight: 600; -webkit-tap-highlight-color: transparent;
}
.tab .ic { width: 1.5rem; height: 1.5rem; }
.tab.active { color: var(--brand); }
.tab.active .ic { stroke-width: 2.2; }

.site-foot { padding: 20px 16px 28px; max-width: 1140px; width: 100%; margin: 0 auto; color: var(--ink-3); font-size: .82rem; line-height: 1.7; display: grid; gap: 4px; }

.toasts {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 100;
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 12px; pointer-events: none;
}

@media (min-width: 960px) {
  .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .main { padding-bottom: 0; }
  .sidebar {
    display: flex; flex-direction: column; gap: 6px;
    position: sticky; top: 0; height: 100vh; height: 100dvh; padding: 22px 14px 16px;
    background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto;
  }
  .tabbar { display: none; }
  .brand-mini { display: none; }
  .topbar { justify-content: flex-end; border-bottom-color: transparent; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; position: static; padding-right: 24px; }
  #view { padding: 8px 32px 56px; }
  .site-foot { padding: 20px 32px 32px; }
  .toasts { bottom: 24px; }
  .side-nav { display: grid; gap: 2px; margin-top: 14px; }
  .side-group { margin: 14px 10px 4px; font-size: .74rem; font-weight: 700; letter-spacing: .12em; color: var(--ink-3); }
  .side-link {
    display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; border-radius: 12px;
    color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .95rem;
  }
  .side-link:hover { background: var(--bg-2); color: var(--ink); }
  .side-link.active { background: var(--brand-soft); color: var(--brand-soft-ink); }
  .side-foot { margin-top: auto; padding: 14px 10px 0; }
  .side-note { font-size: .78rem; color: var(--ink-3); line-height: 1.6; }
}

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

@media print {
  .sidebar, .topbar, .tabbar, .site-foot, .toasts, .no-print { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .app { display: block; }
  #view { max-width: none; padding: 0; }
  .card, .callout { box-shadow: none !important; break-inside: avoid; }
  a { color: inherit; }
}
