/* 沿用 render.py 報告的配色，讓網頁和 PDF 是同一套視覺語言 */
:root {
  --ink: #2a2417;
  --muted: #6b6350;
  --faint: #9a9179;
  --placeholder: #c2baa4;
  --gold: #a9822a;
  --jade: #2f8a6b;
  --warn: #c15a34;
  --line: #e5ddca;
  --panel: #faf7ef;
  --bg: #fffdf8;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  line-height: 1.7;
  font-size: 15px;
}

a { color: var(--gold); }

.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px 64px; }

/* ---------- 頁首 ---------- */
header.top {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  margin-bottom: 24px;
}
header.top .inner {
  max-width: 780px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
}
header.top h1 { font-size: 19px; margin: 0; letter-spacing: .02em; }
header.top h1 a {
  color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
  /* Playfair Display 沒有中文字形，瀏覽器會自動把「命星閣」那幾個字回退到後面的
     中文字型，只有英文的 MingStar 會吃到 Playfair 的華麗襯線效果，不用特別拆字串處理。 */
  font-family: "Playfair Display", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  font-weight: 700;
}
/* 徽章圖裡黃道帶＋小字縮小後會糊成一團，所以頁首只取正中央那顆星做成獨立小圖示，
   當作原本 🔮 emoji 的替代，跟文字標題並排。 */
header.top h1 a .brand-icon { height: 26px; width: auto; display: block; }
header.top nav { margin-left: auto; display: flex; gap: 14px; font-size: 13px; }
header.top nav a { color: var(--muted); text-decoration: none; }
header.top nav a:hover { color: var(--gold); }

/* 前台（排盤／塔羅）：做成一個分段切換器（segmented control）——外層一條淺色軌道，
   目前頁面那一段浮成白色小卡。置中在頁首中間，跟後台那個純文字、靠右的 nav
   （看前台／登出）分開處理，不要互相影響。 */
body.site header.top .inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
body.site header.top h1 { grid-column: 1; justify-self: start; }
body.site header.top nav.site-nav {
  grid-column: 2; justify-self: center; margin-left: 0;
  display: inline-flex; gap: 3px;
  padding: 3px;
  background: #efe7d2;
  border: 1px solid var(--line);
  border-radius: 999px;
}
header.top nav.site-nav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 15px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; line-height: 1;
  color: var(--muted); border: 0;
  transition: color .15s ease, background .15s ease, box-shadow .15s ease;
}
header.top nav.site-nav a:hover { color: var(--gold); }
header.top nav.site-nav a.is-active {
  color: var(--gold); font-weight: 600;
  background: #fff;
  box-shadow: 0 1px 2px rgba(42, 36, 23, .10), 0 0 0 1px rgba(169, 130, 42, .18);
}
header.top nav.site-nav a.is-active:hover { color: var(--gold); }
header.top nav.site-nav svg {
  width: 15px; height: 15px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- 區塊 ---------- */
.card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}
.card h2 { font-size: 16px; margin: 0 0 12px; }
.card h2 .sub { font-size: 12px; color: var(--faint); font-weight: 400; margin-left: 8px; }

.intro { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

/* ---------- 首頁頭像 ---------- */
/* 頭像置中在表單「上方」，不是塞在角落當 logo——要看起來像一個正在等你的人，
   不是網站標題列的一部分。 */
.hero {
  display: flex; align-items: stretch; gap: 40px;
  margin-bottom: 18px;
}
.hero picture { flex: none; }
/* 圖檔本身已經是去背圓形＋金框的老師照，直接顯示整張即可。 */
.hero-avatar { width: 160px; height: 160px; display: block; border-radius: 50%; object-fit: cover; }
.hero-body { flex: 1; min-width: 0; display: flex; }

@media (max-width: 560px) {
  .hero { flex-direction: column; align-items: center; text-align: center; gap: 12px; }
  .hero-avatar { width: 120px; height: 120px; }
}

/* 老師的開場白：講話泡泡感，跟一般 .notice 分開，字級大一點、行距鬆一點。
   拉伸到跟頭像等高、內容垂直置中，讓左右兩塊在視覺上對齊成一個區塊。 */
.greeting {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
}
.greeting p { margin: 0; font-size: 14.5px; color: var(--ink); line-height: 1.8; }
.greeting .greet-hi { font-weight: 600; }
.greeting .greet-pitch { margin-top: 8px; color: var(--muted); }

/* ---------- 分步表單 ---------- */
.step-lead { color: var(--muted); font-size: 13px; margin: -4px 0 16px; }
.card .step h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }

.adv { margin-top: 14px; }
.adv summary {
  cursor: pointer; font-size: 12.5px; color: var(--muted); user-select: none;
}
.adv summary:hover { color: var(--gold); }
.adv[open] summary { margin-bottom: 4px; }

.concern-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: 14px; cursor: pointer;
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.chip:hover { border-color: var(--gold); color: var(--gold); }
.chip.on { border-color: var(--gold); background: var(--gold); color: #fff; }

/* ---------- 表單 ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.field .hint { font-size: 11px; color: var(--faint); }

input[type=text], input[type=number], input[type=password], select, textarea {
  font: inherit; font-size: 15px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(169, 130, 42, .12);
}
textarea { line-height: 1.6; resize: vertical; }

/* 沒設這個的話瀏覽器預設的 placeholder 顏色偏深，跟真的輸入值很像分不清楚 */
::placeholder { color: var(--placeholder); opacity: 1; }

.btn {
  font: inherit; font-size: 15px; font-weight: 600;
  padding: 10px 20px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--gold); background: var(--gold); color: #fff;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.ghost { background: #fff; color: var(--gold); }
.btn.small { font-size: 13px; padding: 6px 12px; font-weight: 500; }
.btn.danger { border-color: var(--warn); background: #fff; color: var(--warn); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* 對話串與「再問一題」輸入列之間的分隔 */
.ask-sep {
  margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--faint);
}

/* ---------- 額度 / 標籤 ---------- */
.quota { font-size: 12.5px; color: var(--muted); }
.quota b { color: var(--ink); }
.pill {
  display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}
.pill.ok { color: var(--jade); border-color: #bfe0d3; background: #f2faf7; }
.pill.warn { color: var(--warn); border-color: #f0cbbc; background: #fdf4f0; }
.pill.gold { color: var(--gold); border-color: #e8d6a8; background: #fdf9ef; }

.notice {
  border: 1px solid var(--line); background: var(--panel);
  border-radius: var(--radius); padding: 12px 14px; font-size: 13.5px;
  color: var(--muted); margin-bottom: 18px;
}
.notice.err { border-color: #f0cbbc; background: #fdf4f0; color: var(--warn); }
.notice.ok { border-color: #bfe0d3; background: #f2faf7; color: var(--jade); }

/* ---------- 報告 ---------- */
.report-frame {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; min-height: 400px;
}

/* ---------- 問答 ---------- */
.msg { margin-bottom: 14px; }
.msg .who { font-size: 11.5px; color: var(--faint); margin-bottom: 3px; }
.msg .body { white-space: pre-wrap; }
.msg.user .body {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 13px; display: inline-block;
  max-width: 100%;
}
.msg.assistant .body { padding: 2px 0; }
.msg.assistant { border-left: 3px solid var(--line); padding-left: 13px; }

.feedback { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.fb-label { font-size: 11.5px; color: var(--faint); margin-right: 2px; }
.fb-btn {
  font-size: 14px; line-height: 1; padding: 3px 7px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; opacity: .55;
}
.fb-btn:hover { opacity: .85; }
.fb-btn.on { opacity: 1; border-color: var(--gold); background: #fdf9ef; }
.fb-more {
  font-size: 11.5px; color: var(--faint); background: none; border: none;
  cursor: pointer; text-decoration: underline; padding: 2px 4px;
}
.fb-more:hover { color: var(--muted); }
/* 留言欄與「送出」預設收起，按讚或點「留言」後才出現 */
.fb-comment, .fb-send { display: none; }
.feedback.open .fb-comment, .feedback.open .fb-send { display: block; }
.feedback.open .fb-more { display: none; }
.fb-comment {
  font-size: 12.5px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px;
  min-width: 160px; flex: 1;
}
.fb-saved { color: var(--jade); font-size: 12px; }

.rating-stars { display: flex; gap: 4px; }
.star-btn {
  font-size: 30px; line-height: 1; padding: 0 2px; background: none; border: none;
  cursor: pointer; color: var(--line); transition: color .12s, transform .12s;
}
.star-btn:hover { transform: scale(1.12); }
.star-btn.on { color: var(--gold); }

.thinking { color: var(--faint); font-size: 13.5px; }
.thinking::after {
  content: "…"; animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots { 0% { opacity: .3 } 50% { opacity: 1 } 100% { opacity: .3 } }

/* ---------- 列表 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
td.mono, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
tr:hover td { background: #fffdf6; }
.tablewrap { overflow-x: auto; }

.list-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--line); font-size: 14px;
}
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow .sub { font-size: 12px; color: var(--faint); }

footer.foot {
  max-width: 780px; margin: 40px auto 0; padding: 16px;
  border-top: 1px solid var(--line); color: var(--faint); font-size: 12px;
}

/* ---------- 後台 ---------- */
body.admin { background: #f7f6f2; font-size: 14px; }
body.admin .wrap { max-width: 1100px; }
body.admin header.top .inner { max-width: 1100px; }
body.admin footer.foot { max-width: 1100px; }
.adminnav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; }
.adminnav a {
  font-size: 13px; padding: 6px 12px; border-radius: 999px;
  text-decoration: none; color: var(--muted); border: 1px solid transparent;
}
.adminnav a:hover { background: #fff; border-color: var(--line); }
.adminnav a.on { background: var(--gold); color: #fff; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .n { font-size: 26px; font-weight: 600; line-height: 1.2; }
.stat .k { font-size: 12px; color: var(--muted); }

.setrow {
  display: grid; grid-template-columns: 1fr 200px; gap: 14px;
  padding: 11px 0; border-bottom: 1px solid var(--line); align-items: center;
}
.setrow:last-of-type { border-bottom: none; }
.setrow .k { font-size: 13.5px; }
.setrow .k code { font-size: 11.5px; color: var(--faint); display: block; }
.setrow.wide { grid-template-columns: 1fr; }

@media (max-width: 600px) {
  /* .grid.three 放的是年/月/日、時/分/性別這種短欄位，手機上維持三欄比較好讀，
     不然年月日會被拆成「年 月」+「日」兩行。只有一般的兩欄 .grid 需要收成單欄。 */
  .grid { grid-template-columns: 1fr; }
  .grid.three { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .grid.three .hint { display: none; }
  .setrow { grid-template-columns: 1fr; gap: 6px; }
  header.top nav:not(.site-nav) { width: 100%; margin-left: 0; }
  /* 桌面版靠 grid-column:1/2 把 h1 和 nav 分左右兩欄置中；欄位定義收成單欄後，
     這兩個 grid-column 指定沒有跟著收掉的話，瀏覽器會自動生出一個隱性欄位讓
     nav 繼續跟 h1 並排，而不是我們要的上下堆疊，所以這裡要一起收成同一欄。 */
  body.site header.top .inner { grid-template-columns: 1fr; justify-items: center; gap: 8px; }
  body.site header.top h1 { grid-column: 1; justify-self: center; }
  body.site header.top nav.site-nav { grid-column: 1; justify-self: center; }
}
