/* ==========================================================================
   命理天涯 · Bazi Forum — Unified Design System
   theme.css  (single source of truth for every page)

   Sections
     01 Tokens          07 Badges / chips
     02 Reset & base    08 Tables
     03 Typography      09 Tabs
     04 Layout          10 Thread list
     05 Top nav         11 Discussion
     06 Buttons         12 Hero / stats
                        13 Modal
                        14 Empty / loading
                        15 Auth pages
                        16 Footer
                        17 Utilities
                        18 Responsive
   ========================================================================== */


/* ── 01 Tokens ─────────────────────────────────────────────────────────── */
:root{
  /* surfaces */
  --bg:            #0a0d13;
  --bg-elev:       #0e121b;
  --surface:       #141926;
  --surface-2:     #1a2030;
  --surface-3:     #212838;
  --inset:         #0c1017;

  /* lines */
  --line:          #232b3d;
  --line-soft:     rgba(255,255,255,.06);
  --line-strong:   #313b52;

  /* text */
  --text:          #e8edf5;
  --text-2:        #b9c3d4;
  --text-3:        #8b95a9;
  --muted:         #7d879c;

  /* accents */
  --gold:          #c9a961;
  --gold-bright:   #e6cc85;
  --gold-dim:      rgba(201,169,97,.14);
  --gold-line:     rgba(201,169,97,.32);
  --blue:          #4a7ddb;
  --blue-bright:   #6a9aef;
  --blue-dim:      rgba(74,125,219,.14);
  --green:         #3fb27f;
  --red:           #e0605a;
  --amber:         #d99a3c;

  /* legacy aliases (kept so existing markup keeps working) */
  --card:          var(--surface);
  --chip:          var(--surface-2);
  --ok:            var(--blue);
  --accent:        var(--blue);
  --warn:          var(--amber);
  --hot:           var(--red);

  /* radius */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* shadow */
  --sh-1: 0 1px 2px rgba(0,0,0,.32);
  --sh-2: 0 4px 14px rgba(0,0,0,.30);
  --sh-3: 0 14px 40px rgba(0,0,0,.42);
  --sh-4: 0 28px 70px rgba(0,0,0,.55);
  --glow-blue: 0 0 0 3px rgba(74,125,219,.16);
  --glow-gold: 0 0 0 3px rgba(201,169,97,.16);

  /* layout */
  --wrap:    1180px;
  --wrap-sm:  940px;
  --wrap-narrow: 440px;

  /* type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, "Noto Sans CJK SC", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC",
                Georgia, "Times New Roman", serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}


/* ── 02 Reset & base ───────────────────────────────────────────────────── */
*,*::before,*::after{ box-sizing:border-box; }

html{ -webkit-text-size-adjust:100%; }

html,body{
  margin:0; padding:0;
  min-height:100%;
}

body{
  display:flex;
  flex-direction:column;
  min-height:100vh;
  background:var(--bg);
  background-image:
    radial-gradient(1100px 560px at 12% -6%,  rgba(74,125,219,.13), transparent 62%),
    radial-gradient(900px 520px at 100% 102%, rgba(201,169,97,.09), transparent 62%);
  background-attachment:fixed;
  color:var(--text);
  font-family:var(--font);
  font-size:16px;
  line-height:1.65;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  text-rendering:optimizeLegibility;
}

a{ color:inherit; text-decoration:none; }
a:hover{ color:var(--blue-bright); }

img,svg{ max-width:100%; display:block; }

::selection{ background:rgba(201,169,97,.28); color:#fff; }

/* scrollbar */
*{ scrollbar-width:thin; scrollbar-color:#2a3346 transparent; }
::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-track{ background:transparent; }
::-webkit-scrollbar-thumb{ background:#252e42; border-radius:8px; border:2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover{ background:#33405a; }

:focus-visible{
  outline:2px solid var(--blue-bright);
  outline-offset:2px;
  border-radius:4px;
}


/* ── 03 Typography ─────────────────────────────────────────────────────── */
h1,h2,h3,h4{ margin:0; font-weight:600; line-height:1.32; letter-spacing:-.01em; }
h1{ font-size:1.06rem; }
h2{ font-size:1.12rem; }
h3{ font-size:1rem; }
p{ margin:0 0 .8em; }
p:last-child{ margin-bottom:0; }

strong,b{ font-weight:650; color:#fff; }

code,kbd,pre{ font-family:var(--font-mono); font-size:.875em; }
code{
  background:var(--inset); border:1px solid var(--line);
  padding:.12em .42em; border-radius:var(--r-xs); color:var(--gold-bright);
}
pre{
  background:var(--inset); border:1px solid var(--line);
  border-radius:var(--r-sm); padding:14px 16px; overflow:auto;
  color:var(--text-2); line-height:1.6;
}

/* section eyebrow */
.eyebrow{
  font-size:.7rem; font-weight:600; letter-spacing:.14em;
  text-transform:uppercase; color:var(--gold);
}


/* ── 04 Layout ─────────────────────────────────────────────────────────── */
.wrap{
  width:100%;
  max-width:var(--wrap);
  margin:0 auto;
  padding:28px 22px 8px;
}
.wrap.narrow{ max-width:var(--wrap-sm); }

.grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:18px;
}

/* card = generic surface panel */
.card{
  background:linear-gradient(180deg, var(--surface), var(--bg-elev));
  border:1px solid var(--line);
  border-radius:var(--r-lg);
  padding:20px 22px;
  box-shadow:var(--sh-2);
  position:relative;
}
.card > h2{
  margin:0 0 14px;
  padding-bottom:11px;
  border-bottom:1px solid var(--line);
  font-size:1.02rem;
  font-weight:600;
  letter-spacing:.01em;
  display:flex; align-items:center; gap:8px;
}
.card > h2::before{
  content:""; width:3px; height:15px; border-radius:2px;
  background:linear-gradient(180deg, var(--gold-bright), var(--gold));
  flex:0 0 auto;
}

/* stacking of result sections */
.wrap > .card{ margin-bottom:18px; }

/* row helper */
.row{ margin:0; color:var(--text-2); }

/* generic vertical rhythm for stacked panels */
.stack{ display:flex; flex-direction:column; gap:14px; }


/* ── 05 Top nav ────────────────────────────────────────────────────────── */
.topnav{
  position:sticky; top:0; z-index:60;
  display:flex; align-items:center; gap:20px;
  padding:12px 26px;
  background:rgba(11,14,20,.82);
  backdrop-filter:saturate(150%) blur(14px);
  -webkit-backdrop-filter:saturate(150%) blur(14px);
  border-bottom:1px solid var(--line);
}

.brand{ display:flex; align-items:center; gap:12px; flex:0 0 auto; }
.brand .logo{
  width:42px; height:42px; flex:0 0 auto;
  border-radius:11px;
  background:linear-gradient(140deg, #2c5aa8 0%, #1d3f7d 45%, #8a6f2e 100%);
  display:flex; align-items:center; justify-content:center;
  font-family:var(--font-serif);
  font-size:21px; font-weight:700; color:#fff;
  box-shadow:0 4px 16px rgba(44,90,168,.34), inset 0 1px 0 rgba(255,255,255,.22);
  letter-spacing:0;
}
.brand .name{ min-width:0; }
.brand h1{
  font-size:1.02rem; font-weight:650; letter-spacing:.01em;
  white-space:nowrap;
}
.brand .tag{
  font-size:.72rem; color:var(--muted); margin-top:2px;
  letter-spacing:.03em; white-space:nowrap;
}

.nav-links{ display:flex; gap:4px; margin-left:auto; }
.nav-links a{
  padding:8px 15px; border-radius:var(--r-sm);
  font-size:.875rem; font-weight:500; color:var(--text-3);
  transition:background .16s, color .16s;
  white-space:nowrap;
}
.nav-links a:hover{ background:var(--surface-2); color:var(--text); }
.nav-links a.active{
  background:var(--gold-dim);
  color:var(--gold-bright);
  box-shadow:inset 0 0 0 1px var(--gold-line);
}

/* user capsule slot (auth-client.js) */
#user-nav{ display:flex; align-items:center; gap:8px; flex:0 0 auto; }

.user-chip{
  position:relative; display:inline-flex; align-items:center; gap:9px;
  padding:5px 13px 5px 5px;
  background:var(--surface-2);
  border:1px solid var(--line);
  border-radius:var(--r-pill);
  cursor:pointer; font-size:.85rem; color:var(--text);
  transition:background .16s, border-color .16s;
  user-select:none;
}
.user-chip:hover{ background:var(--surface-3); border-color:var(--line-strong); }
.user-chip .avatar{
  width:29px; height:29px; flex:0 0 auto; border-radius:50%;
  background:linear-gradient(140deg, var(--blue), var(--gold));
  display:flex; align-items:center; justify-content:center;
  font-size:.72rem; font-weight:700; color:#fff;
}
.user-chip .email{
  max-width:170px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  color:var(--text-2);
}
.user-chip .caret{ color:var(--muted); font-size:.62rem; }

.user-menu{
  display:none; position:absolute; right:0; top:calc(100% + 9px);
  min-width:186px; padding:6px;
  background:var(--surface); border:1px solid var(--line-strong);
  border-radius:var(--r-md);
  box-shadow:var(--sh-3);
  z-index:70;
}
.user-menu a,
.user-menu button{
  display:block; width:100%; text-align:left;
  padding:9px 13px; border:none; background:transparent;
  color:var(--text-2); font-size:.86rem; font-family:inherit;
  border-radius:var(--r-xs); cursor:pointer;
  transition:background .14s, color .14s;
}
.user-menu a:hover,
.user-menu button:hover{ background:var(--surface-2); color:var(--text); }
.user-menu button{ color:#f09a95; }

/* nav auth buttons */
.auth-btn{
  display:inline-flex; align-items:center; gap:6px;
  padding:7px 16px; border-radius:var(--r-sm);
  font-size:.86rem; font-weight:550;
  border:1px solid var(--line);
  transition:background .16s, border-color .16s, filter .16s;
  white-space:nowrap;
}
.auth-btn.ghost{ background:transparent; color:var(--text-2); }
.auth-btn.ghost:hover{ background:var(--surface-2); color:var(--text); }
.auth-btn.primary{
  background:linear-gradient(140deg, var(--blue), #3a68bb);
  color:#fff; border-color:transparent;
  box-shadow:0 2px 10px rgba(74,125,219,.28);
}
.auth-btn.primary:hover{ filter:brightness(1.08); }


/* ── 06 Buttons ────────────────────────────────────────────────────────── */
button{ font-family:inherit; }

.btn,
button.primary,
button:not([class]){
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  padding:10px 20px;
  background:var(--surface-2);
  color:var(--text);
  border:1px solid var(--line-strong);
  border-radius:var(--r-sm);
  font-size:.9rem; font-weight:550;
  cursor:pointer;
  transition:background .16s, border-color .16s, filter .16s, transform .08s;
  white-space:nowrap;
}
.btn:hover,
button.primary:hover,
button:not([class]):hover{ background:var(--surface-3); border-color:#3b4762; }
.btn:active,
button:not([class]):active{ transform:translateY(1px); }

/* primary action */
.btn.primary,
button.primary{
  background:linear-gradient(140deg, var(--blue), #3a68bb);
  border-color:transparent; color:#fff;
  box-shadow:0 3px 14px rgba(74,125,219,.28);
}
.btn.primary:hover,
button.primary:hover{ filter:brightness(1.09); background:linear-gradient(140deg, var(--blue), #3a68bb); }

/* gold accent button */
.btn.gold{
  background:linear-gradient(140deg, var(--gold), #a8873f);
  border-color:transparent; color:#1a1408; font-weight:650;
  box-shadow:0 3px 14px rgba(201,169,97,.26);
}
.btn.gold:hover{ filter:brightness(1.07); }

/* ghost */
.btn.ghost{ background:transparent; border-color:var(--line); color:var(--text-2); }
.btn.ghost:hover{ background:var(--surface-2); color:var(--text); }

.btn:disabled,
button:disabled{ opacity:.5; cursor:not-allowed; filter:none; transform:none; }

.btn-sm{ padding:7px 14px; font-size:.82rem; }
.btn-lg{ padding:12px 26px; font-size:.95rem; }

/* button group */
.btns{ display:flex; gap:10px; margin-top:16px; flex-wrap:wrap; }


/* ── 07 Badges / chips ─────────────────────────────────────────────────── */
.badge,
.type-badge,
.disc-badge{
  display:inline-flex; align-items:center; gap:5px;
  padding:3px 9px;
  background:var(--surface-2);
  border:1px solid var(--line-strong);
  border-radius:var(--r-xs);
  font-size:.7rem; font-weight:600;
  letter-spacing:.05em;
  color:var(--text-3);
  vertical-align:middle;
  white-space:nowrap;
}

/* thread type variants */
.type-badge{ margin-right:7px; }
.type-badge.chart{
  background:var(--blue-dim); color:#93b4f5; border-color:rgba(74,125,219,.38);
}
.type-badge.topic{
  background:var(--gold-dim); color:var(--gold-bright); border-color:var(--gold-line);
}
.type-badge.phd17{
  background:linear-gradient(140deg, rgba(201,169,97,.20), rgba(74,125,219,.16));
  color:var(--gold-bright);
  border-color:var(--gold-line);
}

.badge.hot{
  background:rgba(224,96,90,.15);
  border-color:rgba(224,96,90,.42);
  color:#f2938e;
}

/* small round counter */
.count-pill{
  display:inline-flex; align-items:center; justify-content:center;
  min-width:22px; padding:1px 7px;
  background:var(--surface-3); border-radius:var(--r-pill);
  font-size:.7rem; font-weight:600; color:var(--text-3);
}


/* ── 08 Forms ──────────────────────────────────────────────────────────── */
label{
  display:inline-flex; align-items:center; gap:8px;
  margin:0 12px 12px 0;
  color:var(--text-2);
  font-size:.875rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="time"],
input[type="search"],
select,
textarea{
  background:var(--inset);
  border:1px solid var(--line);
  color:var(--text);
  border-radius:var(--r-sm);
  padding:9px 12px;
  font-size:.9rem;
  font-family:inherit;
  line-height:1.5;
  transition:border-color .16s, box-shadow .16s, background .16s;
}
select{
  min-width:112px;
  appearance:none; -webkit-appearance:none;
  padding-right:32px;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%237d879c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat:no-repeat;
  background-position:right 11px center;
}
input::placeholder,
textarea::placeholder{ color:#5d6779; }

input:focus,
select:focus,
textarea:focus{
  outline:none;
  border-color:var(--blue);
  box-shadow:var(--glow-blue);
  background:#0a0e15;
}
textarea{ resize:vertical; min-height:96px; line-height:1.65; }

/* error box */
#error-box{
  display:none;
  margin-top:14px;
  padding:12px 15px;
  background:rgba(224,96,90,.09);
  border:1px solid rgba(224,96,90,.34);
  border-radius:var(--r-sm);
  color:#f3b4b0;
  font-size:.85rem;
  white-space:pre-wrap;
  line-height:1.6;
}

/* field wrapper (modal / auth) */
.field{ margin-bottom:15px; }
.field > label{
  display:block; margin:0 0 7px;
  font-size:.8rem; font-weight:550; color:var(--text-3);
  letter-spacing:.02em;
}
.field input,
.field textarea,
.field select{ width:100%; }
.field-hint{ font-size:.76rem; color:var(--muted); margin-top:6px; line-height:1.55; }
.field-hint a{ color:var(--blue-bright); }
.field-hint a:hover{ text-decoration:underline; }

/* input with leading icon */
.input-wrap{ position:relative; }
.input-wrap .icon{
  position:absolute; left:13px; top:50%; transform:translateY(-50%);
  color:var(--muted); font-size:.9rem; pointer-events:none; line-height:1;
}
.input-wrap input{ padding-left:40px; }


/* ── 09 Tabs ───────────────────────────────────────────────────────────── */
.tabs{
  display:inline-flex; gap:3px; padding:4px;
  background:var(--inset);
  border:1px solid var(--line);
  border-radius:var(--r-md);
}
.tab{
  padding:7px 15px; border-radius:var(--r-xs);
  font-size:.82rem; font-weight:500;
  color:var(--text-3); cursor:pointer;
  transition:background .15s, color .15s;
  user-select:none; white-space:nowrap;
}
.tab:hover{ color:var(--text); background:var(--surface-2); }
.tab.active{
  background:linear-gradient(140deg, var(--blue), #3a68bb);
  color:#fff; font-weight:550;
  box-shadow:0 2px 9px rgba(74,125,219,.26);
}

/* category tabs (forum) */
.cat-tabs{ display:flex; gap:10px; margin-bottom:18px; flex-wrap:wrap; }
.cat-tab{
  flex:1 1 190px;
  display:flex; align-items:center; justify-content:center; gap:9px;
  padding:13px 18px;
  background:linear-gradient(180deg, var(--surface), var(--bg-elev));
  border:1px solid var(--line);
  border-radius:var(--r-md);
  font-size:.86rem; font-weight:500; color:var(--text-3);
  cursor:pointer; user-select:none;
  transition:background .18s, border-color .18s, color .18s, transform .1s;
}
.cat-tab:hover{ background:var(--surface-2); color:var(--text); border-color:var(--line-strong); }
.cat-tab:active{ transform:translateY(1px); }
.cat-tab.active{
  background:linear-gradient(140deg, rgba(74,125,219,.16), rgba(201,169,97,.11));
  border-color:var(--gold-line);
  color:var(--text);
  box-shadow:inset 0 0 0 1px rgba(201,169,97,.10), var(--sh-2);
}
.cat-tab .badge{
  background:var(--surface-3); border-color:transparent; color:var(--muted);
  padding:1px 8px; border-radius:var(--r-pill); font-size:.7rem;
}
.cat-tab.active .badge{
  background:linear-gradient(140deg, var(--gold), #a8873f);
  color:#1a1408;
}


/* ── 10 Thread list ────────────────────────────────────────────────────── */
.thread-list{ display:flex; flex-direction:column; gap:11px; }

.thread-card{
  display:grid;
  grid-template-columns:1fr auto;
  gap:10px 20px;
  align-items:start;
  padding:16px 20px;
  background:linear-gradient(180deg, var(--surface), var(--bg-elev));
  border:1px solid var(--line);
  border-left:2px solid transparent;
  border-radius:var(--r-md);
  transition:border-color .18s, background .18s, transform .1s, box-shadow .18s;
}
.thread-card:hover{
  border-color:var(--line-strong);
  border-left-color:var(--gold);
  background:linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow:var(--sh-2);
}
.thread-card:active{ transform:translateY(1px); }

/* 錨點帖：永久金色左邊條 + 微金底，一眼認得出 */
.thread-card.pinned{
  border-left-color:var(--gold);
  background:
    linear-gradient(90deg, rgba(201,169,97,.055), transparent 42%),
    linear-gradient(180deg, var(--surface), var(--bg-elev));
}
.thread-card.pinned:hover{
  border-left-color:var(--gold-bright);
  background:
    linear-gradient(90deg, rgba(201,169,97,.085), transparent 46%),
    linear-gradient(180deg, var(--surface-2), var(--surface));
}

.thread-key{
  font-family:var(--font-serif);
  font-size:1.08rem; font-weight:600;
  color:var(--gold-bright);
  letter-spacing:.07em;
  word-break:break-all;
  line-height:1.45;
}
.thread-title{
  font-size:.99rem; font-weight:550;
  color:var(--text); line-height:1.5;
}

.thread-meta{
  display:flex; flex-wrap:wrap; gap:16px;
  margin-top:7px;
  font-size:.75rem; color:var(--muted);
}
.thread-meta span{ display:inline-flex; align-items:center; gap:5px; }

.thread-preview{
  margin-top:10px;
  font-size:.85rem; color:var(--text-3); line-height:1.62;
  overflow:hidden;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical;
}
.thread-preview .by{ color:var(--blue-bright); font-weight:600; margin-right:5px; }

.thread-stats{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:3px; min-width:86px; padding:9px 12px;
  background:var(--inset);
  border:1px solid var(--line);
  border-radius:var(--r-sm);
}
.thread-stats .num{
  font-size:1.22rem; font-weight:700; line-height:1;
  color:var(--text); font-variant-numeric:tabular-nums;
}
.thread-stats .lbl{ font-size:.68rem; color:var(--muted); letter-spacing:.04em; }


/* ── 11 Discussion (comments) ──────────────────────────────────────────── */
.disc-header{
  display:flex; align-items:center; justify-content:space-between;
  flex-wrap:wrap; gap:10px; margin-bottom:16px;
  padding-bottom:12px; border-bottom:1px solid var(--line);
}
.disc-header h2{ font-size:1.02rem; }
.disc-badge{
  color:var(--gold-bright);
  background:var(--gold-dim);
  border-color:var(--gold-line);
  letter-spacing:.06em;
  font-family:var(--font-serif);
}

.disc-list{ display:flex; flex-direction:column; gap:12px; }

.disc-item{
  padding:15px 17px;
  background:var(--inset);
  border:1px solid var(--line);
  border-radius:var(--r-md);
  transition:border-color .16s;
}
.disc-item:hover{ border-color:var(--line-strong); }

.disc-item .disc-meta{
  display:flex; align-items:center; gap:11px; flex-wrap:wrap;
  margin-bottom:9px;
}
.disc-item .disc-name{
  font-size:.85rem; font-weight:650; color:var(--blue-bright);
}
.disc-item .disc-time{ font-size:.72rem; color:var(--muted); }
.disc-item .disc-body{
  font-size:.92rem; line-height:1.72; color:var(--text-2);
  white-space:pre-wrap; word-break:break-word;
}
.disc-item .disc-actions{ margin-top:12px; display:flex; gap:10px; }
.disc-item .disc-actions button{
  display:inline-flex; align-items:center; gap:5px;
  padding:5px 13px;
  background:var(--surface-2);
  border:1px solid var(--line);
  border-radius:var(--r-pill);
  color:var(--text-3);
  font-size:.76rem; font-family:inherit;
  cursor:pointer;
  transition:background .15s, color .15s, border-color .15s;
}
.disc-item .disc-actions button:hover{
  background:var(--surface-3); color:var(--text); border-color:var(--line-strong);
}
.disc-item .disc-actions .disc-like:hover{ color:#f2938e; border-color:rgba(224,96,90,.42); }
.disc-item .disc-actions .disc-delete:hover{ color:#f2938e; border-color:rgba(224,96,90,.42); }

.disc-empty{
  padding:34px 16px; text-align:center;
  color:var(--muted); font-size:.87rem;
  background:var(--inset);
  border:1px dashed var(--line);
  border-radius:var(--r-md);
}

.disc-form{
  display:flex; flex-direction:column; gap:11px;
  margin-top:20px; padding-top:18px;
  border-top:1px solid var(--line);
}
.disc-form input,
.disc-form textarea{ width:100%; }
.disc-form .row{ display:flex; gap:12px; align-items:center; }
.disc-form .disc-name{ flex:0 0 240px; }
.disc-form .disc-submit{
  align-self:flex-start;
  background:linear-gradient(140deg, var(--blue), #3a68bb);
  border-color:transparent; color:#fff;
  box-shadow:0 3px 14px rgba(74,125,219,.26);
}
.disc-form .disc-submit:hover{ filter:brightness(1.09); }
.disc-form .disc-submit:disabled{ opacity:.55; cursor:not-allowed; }
.form-tip{ font-size:.75rem; color:var(--muted); }
/* 未設顯示名時嘅提示（見 auth-client.js renderUserNav / discussion.js） */
.nav-warn{ color:#e8c65a; margin-left:4px; font-size:.72rem; }
.form-tip.needs-nick strong{ color:#e8c65a; }


/* ── 12 Hero / stats ───────────────────────────────────────────────────── */
.hero{
  position:relative;
  display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between;
  gap:22px;
  padding:26px 30px;
  margin-bottom:20px;
  background:
    linear-gradient(140deg, rgba(74,125,219,.15), rgba(201,169,97,.10)),
    linear-gradient(180deg, var(--surface), var(--bg-elev));
  border:1px solid var(--line);
  border-radius:var(--r-lg);
  overflow:hidden;
  box-shadow:var(--sh-2);
}
.hero::after{
  content:""; position:absolute; inset:0; pointer-events:none;
  background:radial-gradient(560px 200px at 92% 0%, rgba(201,169,97,.14), transparent 70%);
}
.hero > *{ position:relative; z-index:1; }
.hero h2{ font-size:1.42rem; font-weight:650; margin-bottom:7px; letter-spacing:-.015em; }
.hero p{ margin:0; color:var(--text-3); font-size:.87rem; }

.hero .stats{ display:flex; gap:34px; }
.stat-num{
  font-size:1.6rem; font-weight:700; line-height:1.1; color:#fff;
  font-variant-numeric:tabular-nums;
}
.stat-lbl{
  font-size:.72rem; color:var(--muted); margin-top:3px; letter-spacing:.05em;
}

/* inline stat row (thread page) */
.thread-stats-row{ display:flex; flex-wrap:wrap; gap:30px; margin-top:16px; }
.thread-stats-row .item{ font-size:.78rem; color:var(--muted); }
.thread-stats-row .item strong{
  display:inline; margin-right:5px;
  font-size:1.02rem; color:var(--text); font-variant-numeric:tabular-nums;
}


/* ── 13 Toolbar + Modal ────────────────────────────────────────────────── */
.toolbar{
  display:flex; align-items:center; gap:13px; flex-wrap:wrap;
  padding:13px 17px;
  margin-bottom:18px;
  background:linear-gradient(180deg, var(--surface), var(--bg-elev));
  border:1px solid var(--line);
  border-radius:var(--r-md);
  box-shadow:var(--sh-1);
}

.search{ position:relative; flex:1 1 250px; min-width:200px; }
.search input{
  width:100%; padding-left:38px;
  background:var(--inset);
}
.search::before{
  content:"🔍";
  position:absolute; left:13px; top:50%; transform:translateY(-50%);
  font-size:.82rem; opacity:.55; pointer-events:none; line-height:1;
}

/* modal */
.modal-mask{
  position:fixed; inset:0; z-index:120;
  display:none; align-items:flex-start; justify-content:center;
  padding:48px 18px;
  background:rgba(4,6,10,.72);
  backdrop-filter:blur(5px);
  -webkit-backdrop-filter:blur(5px);
  overflow-y:auto;
}
.modal-mask.show{ display:flex; }

.modal{
  width:100%; max-width:580px;
  background:linear-gradient(180deg, var(--surface), var(--bg-elev));
  border:1px solid var(--line-strong);
  border-radius:var(--r-lg);
  box-shadow:var(--sh-4);
  animation:modal-in .2s cubic-bezier(.2,.8,.3,1);
  overflow:hidden;
}
@keyframes modal-in{
  from{ opacity:0; transform:translateY(-14px) scale(.985); }
  to  { opacity:1; transform:none; }
}

.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:17px 23px;
  border-bottom:1px solid var(--line);
  background:rgba(255,255,255,.015);
}
.modal-head h2{ font-size:1.02rem; }
.modal-close{
  padding:0 6px; background:none; border:none;
  color:var(--muted); font-size:1.42rem; line-height:1;
  cursor:pointer; border-radius:var(--r-xs);
  transition:color .15s, background .15s;
}
.modal-close:hover{ color:var(--text); background:var(--surface-2); }

.modal-body{ padding:21px 23px; }

.modal-tabs{
  display:flex; gap:5px; padding:4px; margin-bottom:18px;
  background:var(--inset); border:1px solid var(--line);
  border-radius:var(--r-md);
}
.modal-tab{
  flex:1; padding:9px; text-align:center;
  border-radius:var(--r-xs);
  font-size:.83rem; font-weight:500; color:var(--text-3);
  cursor:pointer; user-select:none;
  transition:background .15s, color .15s;
}
.modal-tab:hover{ color:var(--text); background:var(--surface-2); }
.modal-tab.active{
  background:linear-gradient(140deg, var(--blue), #3a68bb);
  color:#fff; box-shadow:0 2px 9px rgba(74,125,219,.24);
}

.modal-actions{
  display:flex; gap:11px; justify-content:flex-end;
  padding:16px 23px;
  border-top:1px solid var(--line);
  background:rgba(255,255,255,.012);
}


/* ── 14 Empty / loading ────────────────────────────────────────────────── */
.empty,.loading{
  padding:56px 26px; text-align:center;
  background:linear-gradient(180deg, var(--surface), var(--bg-elev));
  border:1px solid var(--line);
  border-radius:var(--r-lg);
  color:var(--muted); font-size:.88rem;
}
.empty h3{
  margin:0 0 9px; color:var(--text);
  font-size:1.06rem; font-weight:600;
}
.empty p{ margin:0; }
.loading{ color:var(--text-3); }
.loading::before{
  content:""; display:block;
  width:22px; height:22px; margin:0 auto 14px;
  border:2px solid var(--line-strong);
  border-top-color:var(--gold);
  border-radius:50%;
  animation:spin .7s linear infinite;
}
@keyframes spin{ to{ transform:rotate(360deg); } }


/* ── 15 Auth pages ─────────────────────────────────────────────────────── */
.stage{
  flex:1;
  display:flex; align-items:center; justify-content:center;
  padding:32px 18px 60px;
}

.auth-card{
  width:100%; max-width:var(--wrap-narrow);
  padding:38px 36px 32px;
  background:linear-gradient(180deg, rgba(20,25,38,.94), rgba(14,18,27,.96));
  border:1px solid var(--line-strong);
  border-radius:var(--r-xl);
  box-shadow:var(--sh-4);
  position:relative;
  overflow:hidden;
}
.auth-card::before{
  content:""; position:absolute; inset:0; pointer-events:none;
  background:
    radial-gradient(420px 180px at 100% 0%, rgba(201,169,97,.14), transparent 68%),
    radial-gradient(420px 200px at 0% 100%, rgba(74,125,219,.14), transparent 68%);
}
.auth-card > *{ position:relative; z-index:1; }

.auth-card h2{ font-size:1.42rem; font-weight:650; margin-bottom:8px; letter-spacing:-.015em; }
.auth-card .lead{ color:var(--text-3); font-size:.86rem; margin-bottom:26px; line-height:1.65; }

.auth-card .form-row{ margin-bottom:17px; }
.auth-card .form-row > label{
  display:block; margin:0 0 7px;
  font-size:.8rem; font-weight:550; color:var(--text-3);
}
.auth-card input{ width:100%; }

.btn-primary{
  display:inline-flex; align-items:center; justify-content:center; gap:9px;
  width:100%; padding:13px 22px;
  background:linear-gradient(140deg, var(--blue), #3a68bb);
  border:none; border-radius:var(--r-sm);
  color:#fff; font-size:.94rem; font-weight:600; font-family:inherit;
  cursor:pointer;
  box-shadow:0 4px 16px rgba(74,125,219,.30);
  transition:filter .16s, transform .08s, box-shadow .16s;
}
.btn-primary:hover{ filter:brightness(1.08); box-shadow:0 6px 22px rgba(74,125,219,.40); }
.btn-primary:active{ transform:translateY(1px); }
.btn-primary:disabled{ opacity:.55; cursor:not-allowed; filter:none; transform:none; }

.divider{
  display:flex; align-items:center; gap:14px;
  margin:24px 0 16px;
  color:var(--muted); font-size:.75rem; letter-spacing:.04em;
}
.divider::before,.divider::after{
  content:""; flex:1; height:1px; background:var(--line);
}

.swap{ margin:0; text-align:center; color:var(--text-3); font-size:.86rem; }
.swap a{ color:var(--blue-bright); font-weight:550; }
.swap a:hover{ text-decoration:underline; }

.alert{
  padding:12px 15px; margin-bottom:17px;
  border-radius:var(--r-sm);
  font-size:.84rem; line-height:1.6;
}
.alert.error{
  background:rgba(224,96,90,.10); border:1px solid rgba(224,96,90,.36); color:#f3b4b0;
}
.alert.success{
  background:rgba(63,178,127,.10); border:1px solid rgba(63,178,127,.36); color:#8ddcb4;
}
.alert.info{
  background:var(--blue-dim); border:1px solid rgba(74,125,219,.36); color:#a6c2f7;
}

.dev-link{
  margin-top:18px; padding:13px 15px;
  background:var(--inset);
  border:1px dashed var(--line-strong);
  border-radius:var(--r-sm);
  font-size:.78rem; color:var(--gold-bright);
  word-break:break-all; line-height:1.6;
}
.dev-link .label{
  display:block; margin-bottom:6px;
  font-size:.7rem; color:var(--muted); letter-spacing:.03em;
}
.dev-link a{ color:var(--gold-bright); text-decoration:underline; }

.features{ display:grid; grid-template-columns:repeat(3,1fr); gap:11px; margin-top:24px; }
.feature{
  padding:12px 8px; text-align:center;
  background:var(--inset);
  border:1px solid var(--line);
  border-radius:var(--r-sm);
}
.feature .icon{ font-size:1.15rem; margin-bottom:5px; }
.feature .lbl{ font-size:.7rem; color:var(--muted); }


/* ── 16 Footer ─────────────────────────────────────────────────────────── */
footer{
  margin-top:44px; padding:26px 20px 30px;
  border-top:1px solid var(--line);
  text-align:center;
  color:var(--muted); font-size:.78rem; letter-spacing:.02em;
}


/* ── 17 Page-specific ──────────────────────────────────────────────────── */

/* thread hero (thread.html) */
.thread-header{
  position:relative;
  padding:24px 28px;
  margin-bottom:20px;
  background:
    linear-gradient(140deg, rgba(201,169,97,.10), rgba(74,125,219,.10)),
    linear-gradient(180deg, var(--surface), var(--bg-elev));
  border:1px solid var(--line);
  border-radius:var(--r-lg);
  box-shadow:var(--sh-2);
  overflow:hidden;
}
.thread-header::after{
  content:""; position:absolute; inset:0; pointer-events:none;
  background:radial-gradient(520px 190px at 0% 0%, rgba(201,169,97,.13), transparent 70%);
}
.thread-header > *{ position:relative; z-index:1; }

.breadcrumb{ font-size:.76rem; color:var(--muted); margin-bottom:11px; letter-spacing:.02em; }
.breadcrumb a{ color:var(--text-3); }
.breadcrumb a:hover{ color:var(--blue-bright); }

.thread-header .thread-key{
  font-family:var(--font-serif);
  font-size:1.5rem; font-weight:700;
  color:var(--gold-bright);
  letter-spacing:.09em; line-height:1.36;
  margin:6px 0 6px;
  word-break:break-all;
}
.thread-subtitle{ color:var(--muted); font-size:.79rem; }

/* ── 命盤卡（由簽名還原，顯示於論壇命盤帖）────────────────────────── */
.chart-card{
  padding:20px 22px;
  margin-bottom:20px;
  background:
    linear-gradient(180deg, rgba(201,169,97,.05), transparent 40%),
    linear-gradient(180deg, var(--surface), var(--bg-elev));
  border:1px solid var(--line);
  border-left:3px solid var(--gold);
  border-radius:var(--r-lg);
  box-shadow:var(--sh-2);
}
.chart-card-head{
  display:flex; align-items:baseline; justify-content:space-between;
  gap:14px; flex-wrap:wrap;
  padding-bottom:13px; margin-bottom:18px;
  border-bottom:1px solid var(--line);
}
.chart-card-head h3{
  margin:0; font-size:1rem; font-weight:600;
  display:flex; align-items:center; gap:8px;
}
.chart-card-head h3::before{
  content:""; width:3px; height:15px; border-radius:2px;
  background:linear-gradient(180deg, var(--gold-bright), var(--gold));
}
.chart-card-sig{
  font-family:var(--font-serif);
  font-size:.82rem; color:var(--muted);
  letter-spacing:.06em; word-break:break-all;
}

/* 四柱 */
.pillars{ display:grid; grid-template-columns:repeat(4,1fr); gap:12px; }
.pillar{
  padding:14px 8px;
  text-align:center;
  background:var(--inset);
  border:1px solid var(--line);
  border-radius:var(--r-md);
}
.pillar-label{
  font-size:.7rem; color:var(--muted);
  letter-spacing:.1em; margin-bottom:10px;
}
.pillar-glyphs{ display:flex; flex-direction:column; gap:6px; }
.pillar-char{
  display:flex; flex-direction:column; align-items:center; gap:2px;
  font-family:var(--font-serif);
  font-size:1.6rem; font-weight:600; line-height:1.1;
  color:var(--text);
}
.pillar-char i{
  font-family:var(--font); font-style:normal;
  font-size:.6rem; font-weight:500; letter-spacing:.04em;
  opacity:.75;
}
.pillar-char.el-wood  { color:#5cc894; }
.pillar-char.el-fire  { color:#ee7a72; }
.pillar-char.el-earth { color:#dfa94f; }
.pillar-char.el-metal { color:#d9c47c; }
.pillar-char.el-water { color:#6a9aef; }
.pillar-zodiac{ margin-top:9px; font-size:.66rem; color:var(--muted); }

/* 命宮／身宮／胎元／胎息 */
.chart-chips{
  display:grid; grid-template-columns:repeat(4,1fr); gap:10px;
  margin-top:16px;
}
.chart-chip{
  display:flex; align-items:center; justify-content:space-between;
  gap:8px; padding:9px 13px;
  background:var(--inset);
  border:1px solid var(--line);
  border-radius:var(--r-sm);
}
.chart-chip-label{ font-size:.72rem; color:var(--muted); }
.chart-chip-value{
  font-family:var(--font-serif);
  font-size:1rem; font-weight:600; color:var(--gold-bright);
  letter-spacing:.06em;
}

/* 五行分佈 */
.el-distribution{ margin-top:16px; }
.el-dist-title{
  font-size:.72rem; color:var(--muted);
  letter-spacing:.08em; margin-bottom:8px;
}
.el-bars{ display:flex; gap:8px; }
.el-bar{
  flex:1; display:flex; align-items:center; justify-content:center; gap:6px;
  padding:7px 4px;
  border-radius:var(--r-xs);
  font-size:.76rem; font-weight:600;
  background:var(--surface-2);
  border:1px solid var(--line);
}
.el-bar .el-count{ font-variant-numeric:tabular-nums; opacity:.85; }
.el-bar.el-wood  { color:#5cc894; border-color:rgba(92,200,148,.32); }
.el-bar.el-fire  { color:#ee7a72; border-color:rgba(238,122,114,.32); }
.el-bar.el-earth { color:#dfa94f; border-color:rgba(223,169,79,.32); }
.el-bar.el-metal { color:#d9c47c; border-color:rgba(217,196,124,.32); }
.el-bar.el-water { color:#6a9aef; border-color:rgba(106,154,239,.32); }
.el-bar .el-name{ opacity:.9; }

.el-missing{ margin-top:9px; font-size:.75rem; color:var(--amber); }
.el-missing.el-complete{ color:var(--green); }

.chart-card-note{
  margin:16px 0 0; padding-top:13px;
  border-top:1px solid var(--line);
  font-size:.75rem; color:var(--muted); line-height:1.65;
}
.chart-card-note strong{ color:var(--text-3); font-weight:600; }

/* bazi result table (index.html) */
#result-table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  margin-top:10px;
  border:1px solid var(--line);
  border-radius:var(--r-md);
  overflow:hidden;
}
#result-table th,
#result-table td{
  padding:13px 10px;
  text-align:center;
  border-bottom:1px solid var(--line);
  border-right:1px solid var(--line);
}
#result-table th:last-child,
#result-table td:last-child{ border-right:none; }
#result-table tbody tr:last-child td{ border-bottom:none; }

#result-table th{
  background:var(--inset);
  color:var(--text-3);
  font-size:.76rem; font-weight:600;
  letter-spacing:.06em;
}
#result-table td{
  background:rgba(255,255,255,.012);
  font-family:var(--font-serif);
  font-size:1.16rem; font-weight:600;
  color:var(--text);
  letter-spacing:.06em;
  transition:background .15s;
}
#result-table td:hover{ background:rgba(201,169,97,.07); }
/* the four pillars get the gold treatment (cols 6-9 of 9) */
#result-table td:nth-child(n+6){
  color:var(--gold-bright);
  background:rgba(201,169,97,.045);
}

/* rule notes */
.line{ margin:6px 0; color:var(--text-2); font-size:.87rem; line-height:1.7; }
.card .line strong{ color:var(--gold-bright); font-weight:600; }

/* luck phases */
.luck-item{
  padding:12px 15px; margin:9px 0;
  background:var(--inset);
  border:1px solid var(--line);
  border-radius:var(--r-sm);
  transition:border-color .15s;
}
.luck-item:hover{ border-color:var(--line-strong); }
.luck-item .title{
  font-weight:600; color:var(--gold-bright);
  font-size:.92rem; font-family:var(--font-serif); letter-spacing:.05em;
}
.luck-item .range{ font-size:.78rem; color:var(--text-3); margin-top:3px; }

.title{ font-weight:600; }
.note{ margin-top:9px; color:var(--muted); font-size:.79rem; line-height:1.6; }

/* hidden data-bridge anchors (script.js writes here) */
#extra,#pillars{ display:none; }
#pillars .badge{
  display:block; background:transparent; border:none; padding:0;
  color:inherit; font-size:inherit;
}
#pillars .kv{ display:flex; gap:8px; }

/* ── 18 Utilities ──────────────────────────────────────────────────────── */
.mt-0{margin-top:0}   .mt-1{margin-top:8px}  .mt-2{margin-top:16px} .mt-3{margin-top:24px}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}
.text-muted{color:var(--muted)}
.text-gold{color:var(--gold-bright)}
.text-center{text-align:center}
.hidden{display:none !important}
.nowrap{white-space:nowrap}


/* ── 19 Responsive ─────────────────────────────────────────────────────── */
@media (max-width:980px){
  .grid{ grid-template-columns:1fr; }
  .wrap{ padding:22px 16px 8px; }
}

@media (max-width:760px){
  body{ font-size:15.5px; }

  .topnav{
    flex-wrap:wrap; gap:12px;
    padding:11px 15px;
  }
  .brand .tag{ display:none; }
  .nav-links{ margin-left:auto; order:2; }
  .nav-links a{ padding:7px 12px; font-size:.82rem; }
  #user-nav{ order:3; width:100%; justify-content:flex-end; }
  .user-chip .email{ max-width:104px; }

  .wrap{ padding:18px 13px 8px; }
  .card{ padding:17px 16px; border-radius:var(--r-md); }

  .hero{ padding:20px 18px; gap:18px; border-radius:var(--r-md); }
  .hero h2{ font-size:1.2rem; }
  .hero .stats{ gap:24px; }
  .stat-num{ font-size:1.35rem; }

  .cat-tabs{ gap:8px; }
  .cat-tab{ flex:1 1 100%; padding:11px 14px; }

  .toolbar{ padding:11px 13px; gap:10px; }
  .tabs{ width:100%; }
  .tab{ flex:1; text-align:center; padding:7px 8px; }

  .thread-card{ grid-template-columns:1fr; padding:14px 15px; }
  .thread-stats{ flex-direction:row; gap:16px; justify-content:flex-start; min-width:0; }
  .thread-key{ font-size:1rem; }

  #result-table th,
  #result-table td{ padding:9px 3px; font-size:.86rem; }
  #result-table th{ font-size:.66rem; }

  .thread-header{ padding:19px 18px; border-radius:var(--r-md); }
  .thread-header .thread-key{ font-size:1.14rem; }

  /* 命盤卡：窄屏改成 2 欄 */
  .chart-card{ padding:16px 15px; border-radius:var(--r-md); }
  .pillars{ grid-template-columns:repeat(2,1fr); gap:9px; }
  .pillar{ padding:11px 6px; }
  .pillar-char{ font-size:1.34rem; }
  .chart-chips{ grid-template-columns:repeat(2,1fr); gap:8px; }
  .chart-chip{ padding:8px 11px; }
  .chart-chip-value{ font-size:.9rem; }
  .el-bars{ flex-wrap:wrap; }
  .el-bar{ flex:1 1 28%; }

  .disc-form .row{ flex-direction:column; align-items:stretch; }
  .disc-form .disc-name{ flex:1; }

  .modal-mask{ padding:20px 12px; }
  .auth-card{ padding:28px 21px 24px; border-radius:var(--r-lg); }
  .features{ gap:8px; }
  .feature .lbl{ font-size:.64rem; }

  footer{ margin-top:30px; padding:20px 14px 24px; }
}

@media (max-width:420px){
  .brand .logo{ width:38px; height:38px; font-size:19px; }
  .brand h1{ font-size:.92rem; }
  .hero .stats{ gap:18px; }
  .thread-meta{ gap:11px; }
}
