/* Adytum：胡桃木櫃、黃銅標籤框、牛皮紙卡片 */
:root {
  --walnut: #2e1d12;
  --walnut-2: #3a2517;
  --oak: #5b3b22;
  --oak-light: #7a5233;
  --paper: #efe4c8;
  --paper-2: #e4d5ae;
  --manila: #e6d6b0;
  --ink: #2b2017;
  --ink-soft: #5d4b39;
  --brass: #b38b45;
  --brass-light: #d9b56a;
  --glass: #3f6a57;
  --glass-light: #5f8c77;
  --wax: #7b2d26;
  --line: rgba(43, 32, 23, 0.22);
  --serif: 'Noto Serif TC', 'Songti TC', 'PMingLiU', serif;
  --fell: 'IM Fell English', 'Noto Serif TC', serif;
  --typed: 'Special Elite', 'Noto Serif TC', serif;
  --radius-card: 3px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--serif);
  color: var(--paper);
  background-color: var(--walnut);
  /* 木紋 */
  background-image:
    repeating-linear-gradient(92deg, rgba(0,0,0,.10) 0 2px, transparent 2px 9px, rgba(255,255,255,.025) 9px 10px, transparent 10px 23px),
    repeating-linear-gradient(88deg, rgba(0,0,0,.08) 0 1px, transparent 1px 41px),
    radial-gradient(ellipse at 30% 10%, rgba(122,82,51,.35), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(0,0,0,.45), transparent 60%);
  background-attachment: fixed;
  line-height: 1.75;
  font-size: 16px;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--brass-light); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 開書動畫 ---------- */
#book-intro {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at center, #3d2717 0%, #170e08 75%);
  perspective: 1800px;
  cursor: pointer;
  transition: opacity .7s ease .1s;
}
#book-intro[hidden] { display: none; }
#book-intro.done { opacity: 0; pointer-events: none; }
.book { position: relative; width: min(340px, 72vw); aspect-ratio: 3 / 4; transform-style: preserve-3d; }
.book-page {
  position: absolute; inset: 4px 4px 4px 0;
  background: linear-gradient(90deg, #d9c9a3 0%, var(--paper) 8%, var(--paper) 100%);
  border-radius: 0 4px 4px 0;
  color: var(--ink);
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
  padding: 2rem;
  box-shadow: inset 6px 0 14px rgba(0,0,0,.18);
}
.book-page .ex-libris { font-family: var(--fell); font-size: 1.05rem; color: var(--ink-soft); font-style: italic; }
.book-page .owner { font-size: 1.6rem; margin: .4rem 0 0; letter-spacing: .08em; }
.book-page .rule { width: 60%; height: 1px; background: var(--line); margin: 1rem 0; }
.book-page small { color: var(--ink-soft); }
.book-cover {
  position: absolute; inset: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 1.6s cubic-bezier(.6,.05,.25,1);
}
.book-cover .front, .book-cover .back {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: 2px 6px 6px 2px;
}
.book-cover .front {
  background:
    radial-gradient(ellipse at 40% 30%, rgba(255,255,255,.06), transparent 60%),
    repeating-linear-gradient(45deg, rgba(0,0,0,.06) 0 2px, transparent 2px 5px),
    #4a1f1a;
  border-left: 14px solid #33140f;
  box-shadow: 0 30px 60px rgba(0,0,0,.6), inset 0 0 0 1px rgba(217,181,106,.25);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem;
  color: var(--brass-light);
}
.book-cover .front .frame {
  position: absolute; inset: 18px 18px 18px 14px; border: 1px solid rgba(217,181,106,.55);
  outline: 1px solid rgba(217,181,106,.25); outline-offset: 5px;
}
.book-cover .front h1 { font-family: var(--fell); font-weight: 400; font-size: 2.8rem; letter-spacing: .08em; margin: 0; line-height: 1.1; }
.book-cover .front .gloss { font-size: .95rem; letter-spacing: .35em; padding-left: .35em; opacity: .85; }
.book-cover .front .sigil { width: 70px; height: 70px; opacity: .9; }
.book-cover .back { background: #3a1813; transform: rotateY(180deg); }
#book-intro.open .book-cover { transform: rotateY(-165deg); }
.book-hint { position: absolute; bottom: 2rem; width: 100%; text-align: center; color: rgba(239,228,200,.5); font-size: .85rem; }

/* ---------- 版面 ---------- */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.cabinet {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 1.25rem 1rem;
  background: linear-gradient(90deg, rgba(0,0,0,.35), rgba(0,0,0,.15));
  border-right: 6px solid #1e130b;
  box-shadow: inset -2px 0 0 rgba(255,255,255,.04);
  display: flex; flex-direction: column; gap: .7rem;
}
.cabinet-title { text-align: center; padding: .4rem 0 .8rem; }
.cabinet-title a { text-decoration: none; }
.cabinet-title .name { display: block; font-family: var(--fell); font-size: 2rem; line-height: 1.2; letter-spacing: .06em; color: var(--brass-light); }
.cabinet-title .gloss { display: block; color: rgba(239,228,200,.55); font-size: .8rem; letter-spacing: .3em; padding-left: .3em; }
.sheet h1.site-name { font-family: var(--fell); font-weight: 400; font-size: 2.6rem; letter-spacing: .06em; }

.drawer {
  position: relative; display: block; text-decoration: none;
  height: 74px;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.09) 0 1px, transparent 1px 13px, rgba(255,255,255,.03) 13px 14px, transparent 14px 31px),
    linear-gradient(180deg, var(--oak-light), var(--oak) 55%, #4a2f1b);
  border: 1px solid #22150c;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.08), inset 0 -3px 0 rgba(0,0,0,.25), 0 2px 0 #1a1009;
  border-radius: 2px;
  transition: transform .18s ease;
}
.drawer:hover { transform: translateX(4px); }
.drawer[aria-current="page"] { transform: translateX(10px); box-shadow: inset 0 2px 0 rgba(255,255,255,.08), 0 2px 0 #1a1009, -10px 0 0 #1a1009; }
/* 黃銅標籤框 */
.drawer .plate {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  width: 72%; height: 34px;
  background: linear-gradient(180deg, var(--brass-light), var(--brass) 60%, #8a6a32);
  border-radius: 2px; padding: 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.drawer .plate span {
  display: flex; align-items: center; justify-content: center; height: 100%;
  background: var(--manila); color: var(--ink);
  font-size: .95rem; letter-spacing: .12em;
  box-shadow: inset 0 0 4px rgba(0,0,0,.25);
}
.drawer .knob {
  position: absolute; left: 50%; bottom: 7px; transform: translateX(-50%);
  width: 22px; height: 9px; border-radius: 0 0 11px 11px;
  background: linear-gradient(180deg, var(--brass-light), #7c5c2a);
  box-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.cabinet-foot { margin-top: auto; font-size: .85rem; color: rgba(239,228,200,.6); display: flex; flex-direction: column; gap: .3rem; padding-top: 1rem; }
.cabinet-foot button { background: none; border: 0; padding: 0; text-align: left; color: rgba(239,228,200,.6); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

main { padding: 2rem clamp(1rem, 4vw, 3rem) 4rem; min-width: 0; }

/* 紙張 */
.sheet {
  max-width: 920px; margin: 0 auto;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(255,255,255,.35), transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(120,90,40,.18), transparent 55%),
    var(--paper);
  color: var(--ink);
  padding: clamp(1.25rem, 4vw, 2.75rem);
  border-radius: var(--radius-card);
  box-shadow: 0 18px 40px rgba(0,0,0,.45), 0 2px 0 rgba(0,0,0,.2);
  position: relative;
}
.sheet h1 { font-size: 1.75rem; font-weight: 600; margin: 0 0 .25rem; letter-spacing: .06em; line-height: 1.3; }
.sheet .sub { color: var(--ink-soft); margin: 0 0 1.75rem; }
.sheet h2 { font-size: 1.2rem; font-weight: 600; margin: 2rem 0 .75rem; letter-spacing: .05em; }
.sheet h3 { font-size: 1.05rem; margin: 1.25rem 0 .4rem; }
.sheet p { max-width: 38em; }
.latin { font-family: var(--fell); font-style: italic; }

/* 索引卡 */
.index-card {
  background: #f6eedb;
  border-radius: var(--radius-card);
  box-shadow: 0 1px 0 rgba(0,0,0,.08), 0 6px 14px rgba(60,40,20,.14);
  padding: 1rem 1.15rem;
  position: relative;
  background-image: linear-gradient(transparent 2.7rem, rgba(170,60,50,.35) 2.7rem, rgba(170,60,50,.35) calc(2.7rem + 1px), transparent calc(2.7rem + 1px)),
    repeating-linear-gradient(transparent 0 1.6rem, rgba(60,100,140,.13) 1.6rem calc(1.6rem + 1px));
  background-position: 0 0, 0 2.9rem;
}
.index-card .card-head { font-family: var(--typed); font-size: .9rem; color: var(--ink-soft); height: 1.7rem; line-height: 1.7rem; overflow: hidden; margin-bottom: .6rem; }
.today .card-head { grid-column: 1 / -1; margin-bottom: 0; }

/* 標本標籤 */
.file-pick { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.file-pick input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-pick .name { color: var(--ink-soft); font-size: .9rem; }
.specimen-tag {
  display: inline-block; font-family: var(--typed); font-size: .8rem; color: var(--ink);
  background: var(--manila); border: 1px solid rgba(43,32,23,.35); padding: 0 .5rem; border-radius: 2px;
  line-height: 1.6;
}

/* 按鈕與表單 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1.1rem; border-radius: 2px; cursor: pointer;
  border: 1px solid var(--ink); background: transparent; color: var(--ink);
  text-decoration: none; font-size: .95rem; letter-spacing: .05em;
}
.btn:hover { background: rgba(43,32,23,.06); }
.btn.primary { background: var(--glass); border-color: #2c4c3e; color: #f3ead2; }
.btn.primary:hover { background: #355c4b; }
.btn.danger { border-color: var(--wax); color: var(--wax); }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

label.field { display: block; margin-bottom: 1rem; }
label.field > span { display: block; font-size: .9rem; color: var(--ink-soft); margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=date], textarea, select {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 2px;
  background: rgba(255,255,255,.55); color: var(--ink);
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.7; }
input:focus, textarea:focus, select:focus { border-color: var(--glass); outline: none; box-shadow: 0 0 0 2px rgba(63,106,87,.2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }

.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: 2px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: .4rem .9rem; cursor: pointer; color: var(--ink); }
.seg button + button { border-left: 1px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.muted { color: var(--ink-soft); }
.empty { padding: 2rem; text-align: center; color: var(--ink-soft); border: 1px dashed var(--line); border-radius: 2px; }
.error-text { color: var(--wax); }

/* ---------- 首頁：今日卡 ---------- */
.today { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: center; }
.today .moon-wrap { text-align: center; }
.today .moon-wrap small { display: block; color: var(--ink-soft); }
.today dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .2rem 1rem; }
.today dt { color: var(--ink-soft); font-size: .9rem; }
.today dd { margin: 0; }
.today .date-line { font-size: 1.35rem; letter-spacing: .05em; margin-bottom: .5rem; }

.home-drawers { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.home-drawers .drawer { height: 84px; }
.home-drawers .drawer .plate { top: 16px; }
.home-drawers .soon { opacity: .55; pointer-events: none; }
.home-drawers .soon .plate span::after { content: '（下一批）'; font-size: .7rem; letter-spacing: 0; margin-left: .2rem; }

/* ---------- 夥伴 ---------- */
.companion-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1.25rem; }
.companion-card { text-decoration: none; color: inherit; display: block; }
.companion-card .photo {
  aspect-ratio: 4/3; background: var(--paper-2); display: grid; place-items: center; overflow: hidden;
  border: 6px solid #fbf6e9; box-shadow: 0 2px 6px rgba(0,0,0,.2); transform: rotate(-1deg);
  font-size: 2.4rem; color: var(--ink-soft);
}
.companion-card:nth-child(even) .photo { transform: rotate(1.2deg); }
.companion-card .photo img { width: 100%; height: 100%; object-fit: cover; }
.companion-card .name { font-size: 1.15rem; margin: .7rem 0 .1rem; }
.companion-card .meta { font-size: .85rem; color: var(--ink-soft); }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }

.profile-head { display: grid; grid-template-columns: 220px 1fr; gap: 1.75rem; align-items: start; }
.profile-head .photo { border: 8px solid #fbf6e9; box-shadow: 0 3px 10px rgba(0,0,0,.25); background: var(--paper-2); aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; font-size: 3rem; color: var(--ink-soft); }
.profile-head .photo img { width: 100%; height: 100%; object-fit: cover; }
.profile-fields { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; margin: .75rem 0; }
.profile-fields dt { color: var(--ink-soft); font-size: .9rem; }
.profile-fields dd { margin: 0; }
.prose { white-space: pre-wrap; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 2rem 0 1.25rem; flex-wrap: wrap; }
.tabs button {
  border: 1px solid var(--line); border-bottom: 0; background: var(--paper-2); padding: .4rem 1rem; cursor: pointer;
  border-radius: 3px 3px 0 0; margin-bottom: -1px; color: var(--ink-soft);
}
.tabs button[aria-selected="true"] { background: #f6eedb; color: var(--ink); border-color: var(--line); }

.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 6.2rem; top: 0; bottom: 0; width: 1px; background: var(--line); }
.timeline li { display: grid; grid-template-columns: 5.6rem 1fr; gap: 1.6rem; margin-bottom: 1.25rem; position: relative; }
.timeline li::before { content: ''; position: absolute; left: calc(6.2rem - 4px); top: .6rem; width: 9px; height: 9px; border-radius: 50%; background: var(--glass); }
.timeline .when { font-family: var(--typed); font-size: .85rem; color: var(--ink-soft); padding-top: .2rem; text-align: right; }
.timeline .what h4 { margin: 0 0 .2rem; font-size: 1rem; }
.timeline .what img { max-width: 260px; margin-top: .5rem; border: 5px solid #fbf6e9; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.kind-encounter { --k: var(--brass); } .kind-event { --k: var(--wax); } .kind-daily { --k: var(--glass); }
.kind-observation { --k: #4f5f86; } .kind-dream { --k: #6b4f86; }
.timeline li[class^="kind-"]::before { background: var(--k); }
.kind-chip { display: inline-block; font-size: .78rem; padding: 0 .45rem; border-radius: 2px; color: #f6eedb; background: var(--k, var(--glass)); margin-right: .4rem; vertical-align: 1px; }

/* ---------- 占卜 ---------- */
.spread-table {
  margin-top: 1.5rem; padding: 1.5rem 1rem; border-radius: 3px;
  background:
    radial-gradient(ellipse at center, rgba(255,255,255,.06), transparent 70%),
    repeating-linear-gradient(45deg, rgba(0,0,0,.05) 0 2px, transparent 2px 4px),
    #2f4a3f; /* 綠絨布 */
  box-shadow: inset 0 0 40px rgba(0,0,0,.45);
  display: flex; flex-wrap: wrap; gap: 1.25rem; justify-content: center;
}
.slot { width: 118px; text-align: center; color: #e9dfc4; font-size: .85rem; }
.slot .pos { min-height: 2.4em; line-height: 1.3; margin-bottom: .4rem; }
.tcard { width: 118px; height: 196px; perspective: 900px; cursor: pointer; background: none; border: 0; padding: 0; }
.tcard-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.4,.1,.2,1); }
.tcard.flipped .tcard-inner { transform: rotateY(180deg); }
.tcard-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 6px; box-shadow: 0 4px 10px rgba(0,0,0,.45); }
.tcard-back {
  background:
    radial-gradient(circle at center, transparent 22px, rgba(217,181,106,.6) 23px, transparent 24px),
    repeating-linear-gradient(45deg, rgba(217,181,106,.18) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(-45deg, rgba(217,181,106,.18) 0 1px, transparent 1px 9px),
    #4a1f1a;
  border: 5px solid #f2e7cc;
}
.tcard-front {
  transform: rotateY(180deg);
  background: #f6eedb; color: var(--ink);
  border: 1px solid #c9b88f;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: .55rem .4rem;
}
.tcard-front .numeral { font-family: var(--fell); font-size: 1.05rem; }
.tcard-front .glyph { font-size: 2.6rem; line-height: 1; color: var(--glass); }
.tcard-front .zh { font-size: .95rem; letter-spacing: .05em; }
.tcard-front .en { font-family: var(--fell); font-style: italic; font-size: .72rem; color: var(--ink-soft); line-height: 1.2; }
.tcard.reversed .tcard-front > * { transform: rotate(180deg); }
.tcard.reversed .tcard-front { flex-direction: column-reverse; }
.rune-stone .tcard-face { border-radius: 40% 44% 42% 46% / 46% 40% 48% 42%; }
.rune-stone { width: 96px; height: 110px; }
.rune-stone .tcard-back { background: radial-gradient(ellipse at 35% 30%, #8d8a83, #5d5a54 70%); border: 0; }
.rune-stone .tcard-front { background: radial-gradient(ellipse at 35% 30%, #a9a59c, #6f6b63 70%); border: 0; justify-content: center; }
.rune-stone .tcard-front .glyph { color: #3a1612; font-size: 3.2rem; text-shadow: 0 1px 0 rgba(255,255,255,.25); }
.slot.rune { width: 110px; }
.slot .rev-label { color: #e8c37b; margin-top: .35rem; min-height: 1.4em; }

.reading-list { list-style: none; padding: 0; margin: 0; }
.reading-list li { padding: .9rem 0; border-bottom: 1px solid var(--line); }
.reading-list .cards-line { font-size: .92rem; }
.interpretation { white-space: pre-wrap; background: rgba(255,255,255,.45); border-left: 3px solid var(--glass); padding: 1rem 1.2rem; margin-top: 1rem; }
.interpretation.easton { border-left-color: var(--wax); }
.interpretation .by { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: .4rem; }

/* ---------- 月曆 ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; gap: 1rem; flex-wrap: wrap; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-grid .dow { text-align: center; font-size: .85rem; color: var(--ink-soft); padding: .3rem 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(0,0,0,.03); }
.cal-cell { min-height: 92px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .3rem .35rem; font-size: .8rem; position: relative; }
.cal-cell.out { background: rgba(0,0,0,.04); color: rgba(43,32,23,.4); }
.cal-cell.is-today { background: rgba(63,106,87,.12); }
.cal-cell .d { font-family: var(--fell); font-size: 1rem; }
.cal-cell .ev { display: block; line-height: 1.35; margin-top: .15rem; }
.cal-cell .ev.sabbat { color: var(--wax); }
.cal-cell svg { position: absolute; top: .35rem; right: .35rem; }
.day-detail { margin-top: 1rem; }
.upcoming { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.upcoming .count { font-family: var(--fell); font-size: 2rem; line-height: 1; }

/* ---------- 顧問室 ---------- */
.advisor { display: grid; grid-template-rows: auto 1fr auto; height: calc(100vh - 6rem); max-height: 900px; }
.advisor-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.advisor-head .who { display: flex; gap: .9rem; align-items: center; }
.advisor-head .portrait {
  width: 64px; height: 64px; border-radius: 50%; padding: 0; flex: none; cursor: zoom-in; overflow: hidden;
  border: 2px solid var(--brass); background: #2b2017; box-shadow: 0 0 0 3px rgba(179,139,69,.18);
}
.advisor-head .portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait-full { width: 100%; border-radius: 2px; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.chat { overflow-y: auto; padding: 1.25rem .25rem; display: flex; flex-direction: column; gap: .9rem; }
.msg { max-width: 82%; padding: .7rem 1rem; white-space: pre-wrap; line-height: 1.7; position: relative; }
.msg.user { align-self: flex-end; background: #dfe7dc; border-radius: 10px 10px 2px 10px; }
.msg.assistant {
  align-self: flex-start; background: #f8f1e0; border: 1px solid #d8c8a2; border-radius: 2px;
  font-family: var(--serif);
  box-shadow: 2px 3px 0 rgba(60,40,20,.08);
}
.msg .mode { position: absolute; top: -.75rem; left: .6rem; font-size: .7rem; background: var(--paper); padding: 0 .3rem; color: var(--ink-soft); }
.msg.pending { color: var(--ink-soft); font-style: italic; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: .6rem; border-top: 1px solid var(--line); padding-top: .9rem; }
.chat-form textarea { min-height: 3rem; max-height: 10rem; }

/* ---------- 彈窗與提示 ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,12,6,.7); z-index: 60; display: grid; place-items: center; padding: 1rem; }
.modal { background: var(--paper); color: var(--ink); width: min(560px, 100%); max-height: 90vh; overflow-y: auto; border-radius: 3px; padding: 1.5rem; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal h2 { margin-top: 0; }

.safety-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(15,22,19,.88); display: grid; place-items: center; padding: 1rem; }
.safety {
  width: min(460px, 100%); background: #f3f1ea; color: #1f2522; border-radius: 14px; padding: 1.75rem 1.5rem;
  font-family: system-ui, -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif; line-height: 1.6;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.safety .big { font-size: 1.6rem; font-weight: 700; margin: 0 0 .3rem; }
.safety p { margin: .3rem 0 .9rem; }
.safety ul { padding-left: 1.1rem; margin: .4rem 0 1rem; }
.safety li { margin: .25rem 0; }
.safety a { color: #1d5b46; font-weight: 600; }
.safety .actions { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.safety button { padding: .7rem; border-radius: 10px; border: 0; cursor: pointer; font-size: 1rem; }
.safety .ok { background: #1d5b46; color: #fff; }
.safety .fine { background: transparent; color: #4b5753; text-decoration: underline; }

.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: .6rem 1.2rem; border-radius: 2px; z-index: 70; box-shadow: 0 6px 18px rgba(0,0,0,.4); }

/* ---------- 登入 ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-wrap .sheet { width: min(440px, 100%); }

/* ---------- 手機 ---------- */
.mobile-bar, .tabbar { display: none; }
@media (max-width: 820px) {
  :root { --bar-h: 52px; --tab-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px); }
  body { font-size: 16px; }
  .shell { grid-template-columns: 1fr; }
  .cabinet { display: none; }

  /* 上方：只有名字和設定 */
  .mobile-bar {
    display: flex; position: sticky; top: 0; z-index: 20; align-items: center; justify-content: space-between;
    height: calc(var(--bar-h) + var(--safe-t)); padding: var(--safe-t) 1rem 0;
    background: rgba(30,19,11,.96); border-bottom: 2px solid #1a1009;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  }
  .mobile-bar .name { text-decoration: none; color: var(--brass-light); font-family: var(--fell); font-size: 1.45rem; letter-spacing: .06em; }
  .mobile-bar .gear { color: rgba(239,228,200,.75); display: grid; place-items: center; width: 44px; height: 44px; margin-right: -10px; }

  /* 下方：抽屜分頁列 */
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background:
      repeating-linear-gradient(90deg, rgba(0,0,0,.09) 0 1px, transparent 1px 13px, rgba(255,255,255,.03) 13px 14px, transparent 14px 31px),
      linear-gradient(180deg, var(--oak), #3d2716);
    border-top: 2px solid var(--brass);
    box-shadow: 0 -6px 18px rgba(0,0,0,.45);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; color: rgba(239,228,200,.62); font-size: .72rem; letter-spacing: .08em;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar a .lb { padding: 0 .45rem; border-radius: 2px; line-height: 1.5; }
  .tabbar a[aria-current="page"] { color: var(--brass-light); }
  .tabbar a[aria-current="page"] .lb { background: var(--manila); color: var(--ink); box-shadow: 0 0 0 2px var(--brass); }
  body.typing .tabbar { display: none; }

  main { padding: .75rem .6rem calc(var(--tab-h) + var(--safe-b) + 1.25rem); }
  .sheet { padding: 1.25rem 1rem 1.5rem; border-radius: 3px; }
  .sheet h1 { font-size: 1.5rem; }
  .sheet .sub { margin-bottom: 1.25rem; font-size: .95rem; }
  .sheet h2 { margin-top: 1.5rem; }

  /* 手指好按 */
  .btn { min-height: 44px; }
  .btn.small { min-height: 38px; padding: .35rem .8rem; }
  .seg button { min-height: 40px; }
  input[type=text], input[type=password], input[type=date], textarea, select { font-size: 16px; min-height: 44px; }

  /* 首頁 */
  .today { grid-template-columns: 84px 1fr; gap: .9rem; text-align: left; align-items: start; }
  .today .moon-wrap svg { width: 84px; height: 84px; }
  .today .date-line { font-size: 1.05rem; margin-bottom: .3rem; }
  .today dl { grid-template-columns: 1fr; gap: 0; font-size: .92rem; }
  .today dt { font-size: .78rem; margin-top: .35rem; }
  .home-drawers { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .home-drawers .drawer { height: 62px; }
  .home-drawers .drawer .plate { top: 10px; width: 86%; height: 30px; }
  .home-drawers .drawer .plate span { font-size: .85rem; letter-spacing: .05em; }
  .home-drawers .drawer:hover { transform: none; }

  /* 夥伴 */
  .companion-grid { grid-template-columns: 1fr 1fr; gap: .9rem; }
  .companion-card .photo { border-width: 4px; font-size: 1.8rem; }
  .companion-card .name { font-size: 1rem; margin-top: .5rem; }
  .companion-card .meta { font-size: .78rem; }
  .profile-head { grid-template-columns: 1fr; gap: 1rem; }
  .profile-head .photo { width: 140px; border-width: 5px; font-size: 2rem; transform: rotate(-1.5deg); }
  .tabs { margin-top: 1.5rem; }
  .tabs button { flex: 1; min-height: 44px; }
  .timeline::before { left: .3rem; }
  .timeline li { grid-template-columns: 1fr; gap: .1rem; padding-left: 1.3rem; }
  .timeline li::before { left: 0; }
  .timeline .when { text-align: left; }
  .timeline .what img { max-width: 100%; }

  /* 占卜：一排三張 */
  .spread-table { gap: .9rem .5rem; padding: 1rem .4rem; margin-left: -.4rem; margin-right: -.4rem; }
  .slot { width: calc((100% - 1rem) / 3); max-width: 96px; font-size: .78rem; }
  .spread-table.many .slot { width: calc((100% - 1.5rem) / 4); max-width: 80px; font-size: .7rem; }
  .spread-table.many .tcard-front .en, .spread-table.many .tcard-front .numeral { display: none; }
  .spread-table.many .tcard-front { justify-content: center; gap: .4rem; }
  .spread-table.many .tcard-front .glyph { font-size: 1.4rem; }
  .spread-table.many .tcard-front .zh { font-size: .72rem; line-height: 1.25; }
  .slot .pos { min-height: 2.6em; display: flex; align-items: flex-end; justify-content: center; }
  .tcard { width: 100%; height: auto; aspect-ratio: 3 / 5; }
  .tcard-front { padding: .4rem .25rem; }
  .tcard-front .glyph { font-size: 1.8rem; }
  .tcard-front .zh { font-size: .82rem; }
  .tcard-front .en { font-size: .62rem; }
  .rune-stone { aspect-ratio: 7 / 8; max-width: 88px; margin: 0 auto; }
  .slot.rune { width: calc((100% - 1rem) / 3); }

  /* 月曆：點日期看細節 */
  .cal-cell { min-height: 54px; font-size: .68rem; padding: .2rem; cursor: pointer; }
  .cal-cell .ev { display: none; }
  .cal-cell.has-sabbat::after { content: ''; position: absolute; left: .3rem; bottom: .3rem; width: 6px; height: 6px; border-radius: 50%; background: var(--wax); }
  .cal-cell.has-sign::before { content: ''; position: absolute; left: .75rem; bottom: .3rem; width: 6px; height: 6px; border-radius: 50%; background: var(--glass); }
  .cal-cell svg { width: 13px; height: 13px; top: .25rem; right: .2rem; }
  .cal-cell .d { font-size: .95rem; }
  .upcoming { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .upcoming .count { font-size: 1.6rem; }
  .upcoming .index-card { padding: .8rem .85rem; }

  /* 顧問室：整個畫面都是聊天室 */
  body[data-route="advisor"] main { padding: 0; }
  body[data-route="advisor"] .advisor {
    border-radius: 0; box-shadow: none; max-height: none; padding: .6rem .8rem 0;
    height: calc(100dvh - var(--bar-h) - var(--safe-t) - var(--tab-h) - var(--safe-b));
  }
  body.typing[data-route="advisor"] .advisor { height: calc(100dvh - var(--bar-h) - var(--safe-t)); }
  .advisor-head { padding-bottom: .6rem; gap: .5rem; flex-wrap: nowrap; }
  .advisor-head .portrait { width: 50px; height: 50px; }
  .advisor-head .who > div > div:first-child { font-size: 1rem !important; }
  .advisor-head .who > div > div:last-child { display: none; }
  .advisor-head .btn-row { flex-wrap: nowrap; gap: .4rem; }
  .advisor-head .seg button { padding: .3rem .65rem; font-size: .9rem; }
  .advisor-head .clear { width: 40px; padding: 0; }
  .chat { padding: 1rem 0 .75rem; }
  .msg { max-width: 90%; font-size: .97rem; }
  .chat-form { padding: .6rem 0 calc(.6rem + var(--safe-b)); grid-template-columns: 1fr 64px; }
  body:not(.typing) .chat-form { padding-bottom: .6rem; }
  .chat-form textarea { min-height: 46px; height: 46px; max-height: 8rem; padding: .6rem .7rem; }
  .chat-form .btn { align-self: end; height: 46px; min-height: 46px; padding: 0; white-space: nowrap; }

  /* 彈窗改成從下方拉起的抽屜 */
  .modal-backdrop { place-items: end stretch; padding: 0; }
  .modal { width: 100%; max-height: 92dvh; border-radius: 12px 12px 0 0; padding: 1.25rem 1rem calc(1.25rem + var(--safe-b)); }
  .modal::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: -.5rem auto .9rem; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .toast { bottom: calc(var(--tab-h) + var(--safe-b) + 1rem); }
  .safety { border-radius: 16px; }
}
@media (max-width: 360px) {
  .companion-grid { grid-template-columns: 1fr; }
  .upcoming { grid-template-columns: 1fr; }
}
@media (hover: none) { .drawer:hover { transform: none; } }


/* ===================== 第二批 ===================== */
.small { font-size: .85rem; }
.ok { color: #2f6a4f; }
.more-link { display: inline-block; margin-top: .4rem; font-size: .9rem; color: var(--glass); }
a.index-card { display: block; text-decoration: none; color: inherit; }
.notice { background: #f3e2c2; border: 1px solid #c9a35c; border-left: 4px solid var(--wax); padding: .8rem 1rem; margin-bottom: 1.25rem; border-radius: 2px; }
.notice a { margin-left: .4rem; font-weight: 600; color: var(--wax); }

/* 抽屜櫃變多了：桌機抽屜縮小一點 */
.cabinet .drawer { height: 56px; flex: none; }
.cabinet .drawer .plate { top: 8px; height: 30px; }
.cabinet .drawer .knob { bottom: 5px; height: 7px; width: 18px; }
.cabinet { gap: .5rem; }
.home-drawers.in-sheet { grid-template-columns: 1fr 1fr; margin-top: .5rem; }
.home-drawers.in-sheet .drawer { height: 62px; }
.home-drawers.in-sheet .drawer .plate { top: 10px; width: 86%; height: 30px; }

/* 今日頁 */
.daily-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin-top: 1rem; }
.daily-grid .index-card { min-height: 9rem; }
.fact { margin: 0; line-height: 1.7; }
.kind-tag { display: inline-block; font-size: .72rem; padding: 0 .4rem; margin-right: .4rem; border-radius: 2px; color: #f6eedb; background: var(--glass); vertical-align: 1px; letter-spacing: .05em; }
.kind-tag.k-迷思 { background: var(--wax); } .kind-tag.k-傳統 { background: #6b4f86; } .kind-tag.k-天文 { background: #4f5f86; } .kind-tag.k-安全 { background: #8a6a32; }
.gem { display: inline-block; width: 34px; height: 34px; flex: none; border-radius: 45% 55% 50% 50% / 55% 45% 55% 45%;
  background: radial-gradient(circle at 32% 28%, rgba(255,255,255,.85) 0 8%, transparent 22%), radial-gradient(circle at 60% 70%, rgba(0,0,0,.28), transparent 60%), var(--gem, #999);
  box-shadow: inset 0 -3px 6px rgba(0,0,0,.25), 0 2px 4px rgba(0,0,0,.25); }
.gem.big { width: 64px; height: 64px; }
.gem-row { display: flex; gap: .9rem; align-items: center; }
.big-name { font-size: 1.25rem; }
.reminder-strip { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.reminder-chip { text-decoration: none; color: var(--ink); background: #f6eedb; border: 1px dashed var(--brass); padding: .35rem .7rem; border-radius: 2px; font-size: .92rem; }

/* 晶片選擇 */
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0 .8rem; }
.chip { border: 1px solid var(--line); background: rgba(255,255,255,.5); color: var(--ink); padding: .3rem .8rem; border-radius: 999px; cursor: pointer; font-size: .92rem; min-height: 36px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.sys-note { margin: 0 0 .9rem; }
.switch-row { display: flex; gap: .55rem; align-items: center; margin: .4rem 0; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; flex: none; accent-color: var(--glass); }
.switch-row.small { font-size: .88rem; }

/* 占卜：各種外觀 */
.tcard.look-len .tcard-front { justify-content: space-between; padding: .5rem .3rem; }
.tcard.look-len .len-name { font-size: 1.05rem; }
.tcard.look-len .inset { font-family: var(--fell); font-size: 1.05rem; color: var(--wax); }
.tcard.look-len .tcard-back { background:
    repeating-linear-gradient(0deg, rgba(217,181,106,.22) 0 1px, transparent 1px 10px),
    repeating-linear-gradient(90deg, rgba(217,181,106,.22) 0 1px, transparent 1px 10px), #24423a; }
.spread-table.look-die .slot, .spread-table.look-gem .slot, .spread-table.look-coin .slot { width: 110px; }
.tcard.look-die { width: 96px; height: 96px; margin: 0 auto; }
.tcard.look-die .tcard-face { border-radius: 18px; }
.tcard.look-die .tcard-back { background: radial-gradient(circle at 30% 25%, #8a3b33, #4a1f1a 75%); border: 0; }
.tcard.look-die .tcard-front { background: radial-gradient(circle at 30% 25%, #fbf3df, #e4d3a9 80%); border: 0; justify-content: center; }
.tcard.look-die .glyph { font-size: 2.6rem; color: var(--ink); }
.tcard.look-die .tcard-inner { transition-duration: .9s; }
.tcard.look-die.flipped .tcard-inner { transform: rotateY(540deg) rotateX(0); }
.tcard.look-gem { width: 96px; height: 96px; margin: 0 auto; }
.tcard.look-gem .tcard-face { border-radius: 50%; box-shadow: none; }
.tcard.look-gem .tcard-back { background: radial-gradient(circle at 35% 30%, #a08463, #6b5338 70%); border: 0;
  box-shadow: inset 0 -6px 10px rgba(0,0,0,.35), 0 4px 8px rgba(0,0,0,.4); }
.tcard.look-gem .tcard-back::after { content: ''; position: absolute; inset: 30% 30% auto auto; width: 30%; height: 12%; border-top: 2px solid rgba(255,255,255,.25); border-radius: 50%; }
.tcard.look-gem .tcard-front { background: transparent; border: 0; justify-content: center; box-shadow: none; }
.tcard.look-gem .gem.big { width: 78px; height: 78px; }
.tcard.look-coin { width: 104px; height: 104px; margin: 0 auto; }
.tcard.look-coin .tcard-face { border-radius: 50%; }
.tcard.look-coin .tcard-back, .tcard.look-coin .tcard-front {
  background: radial-gradient(circle at 35% 30%, #f3d991, #b38b45 60%, #7c5c2a); border: 3px solid #8a6a32; box-shadow: inset 0 0 0 5px rgba(255,255,255,.18), 0 4px 10px rgba(0,0,0,.45); }
.tcard.look-coin .tcard-back::after { content: '?'; position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--fell); font-size: 2.6rem; color: rgba(60,40,10,.55); }
.tcard.look-coin .tcard-front { justify-content: center; }
.tcard.look-coin .glyph { font-size: 2.4rem; color: #3b2a10; font-weight: 600; }
.tcard.look-coin .tcard-inner { transition: transform 1.4s cubic-bezier(.2,.7,.2,1); }
.tcard.look-coin.flipped .tcard-inner { transform: rotateY(1980deg); }
.coin-summary { font-size: 1.15rem; background: #f6eedb; border-left: 3px solid var(--brass); padding: .7rem 1rem; }
.spread-table.grid { display: grid; gap: .5rem; justify-items: center; }
.spread-table.grid-3 { grid-template-columns: repeat(3, minmax(0, 118px)); justify-content: center; }
.spread-table.grid-9 { grid-template-columns: repeat(9, minmax(0, 1fr)); }
.spread-table.grid-9 .slot { width: 100%; }
.spread-table.grid-9 .tcard { width: 100%; height: auto; aspect-ratio: 3 / 4.4; }
.spread-table.grid-9 .tcard-front { padding: .2rem; }
.spread-table.grid-9 .tcard-front .numeral { font-size: .75rem; }
.spread-table.grid-9 .tcard-front .len-name { font-size: .72rem; }
.spread-table.grid-9 .tcard-front .inset { font-size: .7rem; }
.spread-table.grid-9 .rev-label { font-size: .65rem; min-height: 0; margin-top: .1rem; }
.spread-table.grid-3 .slot .pos { font-size: .75rem; }
.rune-editor { display: grid; gap: .6rem; }
.rune-row { display: grid; grid-template-columns: 54px 1fr auto; gap: .5rem; align-items: start; padding: .6rem; background: rgba(255,255,255,.4); border: 1px solid var(--line); }
.rune-row .glyph-in { text-align: center; font-size: 1.4rem; padding: .4rem 0; }
.rune-fields { display: grid; gap: .35rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; }
.inline-form > input, .inline-form > select { flex: 1; }

/* 字卡聊天室 */
.cards-head { flex-wrap: wrap; }
.cards-head .chips { margin: 0; flex: 1; min-width: 0; }
.chat-intro { text-align: center; max-width: none; font-size: .9rem; }
.msg.cards-msg { align-self: flex-start; background: none; padding: 0; max-width: 100%; }
.msg.cards-msg .who { display: block; font-size: .78rem; color: var(--ink-soft); margin: 0 0 .25rem .2rem; }
.word-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.word-card { display: inline-flex; align-items: center; justify-content: center; min-width: 4.2rem; min-height: 5.2rem; padding: .5rem .7rem;
  background: var(--manila); border: 1px solid #b9a273; border-radius: 4px; font-size: 1.35rem; letter-spacing: .08em;
  box-shadow: 0 1px 0 rgba(0,0,0,.08), 0 4px 10px rgba(60,40,20,.18), inset 0 0 0 4px #efe2bf; color: var(--ink); }
.word-card.fresh { animation: deal .5s cubic-bezier(.2,.8,.3,1) both; animation-delay: calc(var(--i) * .18s); }
@keyframes deal { from { opacity: 0; transform: translateY(-14px) rotate(-6deg) scale(.9); } to { opacity: 1; transform: none; } }
.card-form { grid-template-columns: 1fr auto auto; align-items: end; }
.card-form .draw { min-width: 5.5rem; }
.card-form > .muted { grid-column: 1 / -1; }
.deck-picks .switch-row { align-items: flex-start; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.deck-picks .switch-row .btn { margin-left: auto; }

/* 影子書 */
.day-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.day-title { display: flex; align-items: center; gap: .4rem; white-space: nowrap; }
.day-nav .btn { white-space: nowrap; padding-left: .6rem; padding-right: .6rem; }
.prompt-line { display: flex; gap: .6rem; align-items: center; justify-content: space-between; background: #f6eedb; border-left: 3px solid #6b4f86; padding: .5rem .8rem; margin-bottom: .6rem; }
.journal-body { min-height: 12rem; background: repeating-linear-gradient(transparent 0 1.7rem, rgba(60,100,140,.12) 1.7rem calc(1.7rem + 1px)), #fbf6e9; line-height: 1.7rem; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .2rem; }
.checklist label { display: flex; gap: .6rem; align-items: center; padding: .35rem 0; cursor: pointer; }
.checklist input { width: 20px; height: 20px; accent-color: var(--glass); }
.checklist input:checked + span { text-decoration: line-through; color: var(--ink-soft); }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--paper) 30%); padding: .8rem 0 .2rem; margin-top: 1rem; }
.mood-tag { display: inline-block; margin-left: .4rem; font-size: .8rem; padding: 0 .45rem; background: #e6dcef; border-radius: 999px; }
.log-link { text-decoration: none; color: inherit; display: block; }
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .9rem; }
.note-card { text-align: left; cursor: pointer; border: 0; font: inherit; color: inherit; }
.note-card p { margin: .3rem 0; }
.link-row { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit; }
.count-pill { display: inline-block; min-width: 3.5rem; text-align: center; margin-right: .6rem; padding: .1rem .5rem; border-radius: 2px; background: var(--ink); color: var(--paper); font-size: .85rem; }
.cal-cell .ev.reminder { color: #6b4f86; }
.reflect { margin: .5rem 0 0; font-size: .95rem; }

/* 圖鑑 */
.filter-bar { margin: 1.25rem 0 .5rem; }
.filter-bar input[type=search] { max-width: 280px; }
.specimen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; }
.specimen-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .25rem; padding: .9rem .5rem; text-decoration: none; color: inherit;
  background: #f6eedb; border: 1px solid #d8c8a2; border-radius: 2px; box-shadow: 0 2px 6px rgba(60,40,20,.12); position: relative; }
.specimen-card::before { content: ''; position: absolute; top: 6px; left: 50%; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; border: 1px solid #b9a273; background: var(--paper); }
.specimen-card .gem { margin-top: .6rem; }
.specimen-card.danger { background: #efe0d6; border-color: #c49a8c; }
.herb-mark { font-size: 1.8rem; color: var(--glass); line-height: 1; margin-top: .5rem; }
.herb-mark.big { font-size: 2.8rem; margin: 0; }
.herb-mark.danger { color: var(--wax); }
.specimen-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.specimen-head h1 { margin: 0; }
.label-card { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; background: var(--manila); border: 1px solid #b9a273; padding: .8rem 1rem; margin: 0 0 1rem; font-size: .95rem;
  box-shadow: inset 0 0 0 4px #efe2bf; }
.label-card dt { color: var(--ink-soft); }
.label-card dd { margin: 0; }
.safety-note { background: #f3e2c2; border-left: 3px solid #8a6a32; padding: .6rem .9rem; }
.danger-note { background: #f1d3cc; border-left: 4px solid var(--wax); padding: .6rem .9rem; font-weight: 600; color: #6a1f18; }
.danger-note.soft { background: #f3e2c2; color: var(--ink); border-left-color: #8a6a32; }
.today-specimen { margin-bottom: 1rem; }
.recommend summary { cursor: pointer; font-weight: 600; padding: .2rem 0; }
.recommend textarea { margin-top: .4rem; }
.safety-box { margin-top: 1.5rem; }
.safety-box summary { cursor: pointer; font-weight: 600; }
.basic-item h3 { display: flex; gap: .6rem; align-items: center; }
.step { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--glass); color: var(--paper); font-size: .85rem; flex: none; }

/* 學習室 */
.tabs.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tabs.scroll::-webkit-scrollbar { display: none; }
.tabs.scroll button { flex: none; }
.lesson { background: #f6eedb; border: 1px solid #d8c8a2; padding: 1rem 1.15rem; margin-bottom: 1rem; }
.lesson h2 { margin-top: 0; }
.combo-list { padding-left: 1.1rem; margin: .3rem 0 .6rem; }
.browser-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.browser-head .chips { margin: .3rem 0; }
.study-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; }
.study-card { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; aspect-ratio: 3 / 4;
  background: #f6eedb; border: 1px solid #c9b88f; border-radius: 5px; cursor: pointer; padding: .3rem; color: var(--ink); font: inherit; }
.study-card.learned { background: #e3ead9; border-color: #8fae94; }
.sc-glyph { font-size: 1.3rem; color: var(--glass); font-family: var(--fell); }
.sc-name { font-size: .85rem; line-height: 1.3; text-align: center; }
.sc-mark { position: absolute; top: .2rem; right: .3rem; font-size: .75rem; color: var(--brass); }
.astro-table table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.astro-table td { border-bottom: 1px solid var(--line); padding: .35rem .4rem; vertical-align: top; }
.astro-table td:first-child { width: 2.2rem; text-align: center; font-size: 1.15rem; color: var(--glass); }
.fact-list { list-style: none; padding: 0; margin: 0; }
.fact-list li { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; padding: .7rem 0; border-bottom: 1px solid var(--line); align-items: start; }
.star { background: none; border: 0; font-size: 1.2rem; color: #cdbf9e; cursor: pointer; min-width: 36px; min-height: 36px; }
.star.on { color: var(--brass); }
.progress-row { display: grid; grid-template-columns: 5.5rem 1fr 3.5rem; gap: .7rem; align-items: center; margin: .5rem 0; }
.bar { height: 10px; background: rgba(43,32,23,.1); border-radius: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--glass); }
.practice-head { display: flex; align-items: baseline; justify-content: space-between; }
.streak { font-family: var(--fell); color: var(--wax); font-size: 1.1rem; }
.practice-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; width: 140px; aspect-ratio: 3 / 5; margin: .5rem auto 1rem;
  background: #f6eedb; border: 1px solid #c9b88f; border-radius: 8px; box-shadow: 0 6px 16px rgba(0,0,0,.2); text-align: center; padding: .6rem; }
.practice-card.reversed .pc-glyph { transform: rotate(180deg); }
.pc-glyph { font-size: 2.4rem; color: var(--glass); font-family: var(--fell); }
.practice-card.sys-rune { border-radius: 40% 44% 42% 46% / 46% 40% 48% 42%; background: radial-gradient(ellipse at 35% 30%, #a9a59c, #6f6b63 70%); color: #f6eedb; aspect-ratio: 1; width: 130px; }
.practice-card.sys-rune .pc-glyph { color: #3a1612; }
.practice-card.sys-rune .latin { color: #efe4c8; }
.past-practice { margin-top: 1.5rem; }
.past-practice summary { cursor: pointer; }

/* 設定 */
.settings-section { border-top: 1px solid var(--line); padding-top: .4rem; margin-top: 1.4rem; }
.settings-section.owner { background: #f3e9d2; border: 1px solid #c9a35c; padding: .2rem 1rem 1rem; }
.status { padding: .5rem .8rem; border-radius: 2px; margin: .8rem 0 0; }
.status.ok { background: #e1ecdf; color: #2f5a3f; }
.status.warn { background: #f3e2c2; color: #6a4a15; }
.radio-group { border: 0; padding: 0; margin: .6rem 0; display: grid; gap: .5rem; }
.radio-group label { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .8rem; border: 1px solid var(--line); background: rgba(255,255,255,.4); cursor: pointer; }
.radio-group label span { display: flex; flex-direction: column; }
.radio-group input { margin-top: .3rem; accent-color: var(--glass); width: 18px; height: 18px; }
.radio-group[disabled] { opacity: .5; }
.own-box { margin-top: .6rem; padding-left: .8rem; border-left: 2px solid var(--glass); }
.api-form { margin-top: .5rem; }
.api-result { margin-top: .7rem; font-size: .92rem; }
.model-pills { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; max-height: 9rem; overflow-y: auto; }
.pill { border: 1px solid var(--line); background: #fbf6e9; border-radius: 999px; padding: .15rem .6rem; font-size: .8rem; cursor: pointer; font-family: ui-monospace, Menlo, monospace; color: var(--ink); }
.member-list, .edit-list { list-style: none; padding: 0; margin: .4rem 0; }
.member-list li { padding: .3rem 0; border-bottom: 1px solid var(--line); }
.edit-list li { display: flex; justify-content: space-between; align-items: center; padding: .25rem 0; border-bottom: 1px solid var(--line); }
input[type=url], input[type=search] { width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 2px; background: rgba(255,255,255,.55); color: var(--ink); }

/* 底部分頁的「抽屜」按鈕 */
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: none; border: 0; cursor: pointer;
  color: rgba(239,228,200,.62); font-size: .72rem; letter-spacing: .08em; -webkit-tap-highlight-color: transparent; font-family: inherit; }
.tabbar button .lb { padding: 0 .45rem; border-radius: 2px; line-height: 1.5; max-width: 4.6em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tabbar button[aria-current="page"] { color: var(--brass-light); }
.tabbar button[aria-current="page"] .lb { background: var(--manila); color: var(--ink); box-shadow: 0 0 0 2px var(--brass); }

@media (max-width: 820px) {
  .daily-grid { grid-template-columns: 1fr; gap: .7rem; }
  .daily-grid .index-card { min-height: 0; }
  .spread-table.grid-9 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .spread-table.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .spread-table.grid-3 .slot { width: 100%; max-width: none; }
  .spread-table.look-die .slot, .spread-table.look-gem .slot, .spread-table.look-coin .slot { width: calc((100% - 1rem) / 3); }
  .tcard.look-die, .tcard.look-gem, .tcard.look-coin { width: 84px; height: 84px; aspect-ratio: auto; }
  .tcard.look-gem .gem.big { width: 66px; height: 66px; }
  .spread-table.look-coin:has(.slot:only-child) .slot { width: 60%; }
  .card-form { grid-template-columns: 5.5rem 1fr; }
  .card-form textarea { grid-column: 1 / -1; }
  .card-form .btn { height: 46px; }
  .card-form .draw { min-width: 0; }
  body[data-route="cards"] main { padding: 0; }
  body[data-route="cards"] .advisor { border-radius: 0; box-shadow: none; max-height: none; padding: .6rem .8rem 0;
    height: calc(100dvh - var(--bar-h) - var(--safe-t) - var(--tab-h) - var(--safe-b)); }
  body.typing[data-route="cards"] .advisor { height: calc(100dvh - var(--bar-h) - var(--safe-t)); }
  .cards-head .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .cards-head { gap: .4rem; }
  .specimen-grid { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
  .specimen-card { padding: .7rem .3rem; }
  .specimen-card .latin { display: none; }
  .study-grid { grid-template-columns: repeat(4, 1fr); }
  .note-grid { grid-template-columns: 1fr; }
  .prompt-line { flex-direction: column; align-items: flex-start; }
  .rune-row { grid-template-columns: 46px 1fr; }
  .rune-row > .btn { grid-column: 1 / -1; justify-self: end; }
  .progress-row { grid-template-columns: 4.5rem 1fr 3rem; }
  .settings-section.owner { margin-left: -.4rem; margin-right: -.4rem; }
}

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

/* 防止任何子元素把整個版面撐寬 */
.stage { min-width: 0; }
.sheet { min-width: 0; overflow-wrap: anywhere; }
.tabs.scroll { max-width: 100%; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain[disabled] { opacity: .5; }
