/* Carte 名片簿 — 設計系統：印泥朱紅 × 檔案紙 × 名帖 */

:root {
  --paper: #F7F4EE;        /* 檔案紙底 */
  --paper-2: #EFE9DE;      /* 次要面 */
  --card: #FFFDF8;         /* 卡片面 */
  --ink: #26201A;          /* 墨 */
  --ink-2: #7A6F62;        /* 淡墨 */
  --line: #E3DACA;         /* 細線 */
  --accent: #BE4433;       /* 印泥朱紅 */
  --accent-soft: rgba(190, 68, 51, .09);
  --accent-ink: #FFF9F2;
  --teal: #43594E;         /* 墨青（次要強調） */
  --shadow: 0 1px 2px rgba(38,32,26,.05), 0 6px 24px rgba(38,32,26,.07);
  --shadow-lift: 0 2px 6px rgba(38,32,26,.08), 0 14px 40px rgba(38,32,26,.14);
  --serif: "Noto Serif TC", "Songti TC", "STSong", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  --r: 14px;
  --r-lg: 20px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171411;
    --paper-2: #221E19;
    --card: #1F1B16;
    --ink: #EDE6DA;
    --ink-2: #9B9082;
    --line: #352E26;
    --accent: #D96A50;
    --accent-soft: rgba(217, 106, 80, .13);
    --accent-ink: #FFF6EF;
    --teal: #8FA89B;
    --shadow: 0 1px 2px rgba(0,0,0,.25), 0 6px 24px rgba(0,0,0,.3);
    --shadow-lift: 0 2px 6px rgba(0,0,0,.3), 0 14px 40px rgba(0,0,0,.45);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  min-height: 100%;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  /* 紙纖維質感：極淡的斜紋 */
  background-image: repeating-linear-gradient(115deg, transparent 0 5px, rgba(122,111,98,.022) 5px 6px);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

.safe-top { padding-top: max(10px, env(safe-area-inset-top)); }
.safe-bottom { padding-bottom: max(16px, env(safe-area-inset-bottom)); }

/* ---------- 品牌 ---------- */
.brand { display: flex; align-items: baseline; gap: 9px; }
.brand h1 { font-family: var(--serif); font-size: 24px; font-weight: 700; letter-spacing: .02em; }
.brand-sub { font-size: 12px; color: var(--ink-2); letter-spacing: .28em; }
.seal {
  align-self: center;
  display: grid; place-items: center;
  width: 30px; height: 30px;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--serif); font-size: 17px; font-weight: 700;
  border-radius: 7px;
  box-shadow: inset 0 0 0 1.5px rgba(255,249,242,.35), inset 0 0 0 3.5px var(--accent);
}
.brand-lg { gap: 14px; }
.brand-lg .seal { width: 54px; height: 54px; font-size: 30px; border-radius: 12px; }
.brand-lg h1 { font-size: 40px; }
.brand-text p { font-size: 12px; color: var(--ink-2); letter-spacing: .14em; margin-top: 2px; }

/* ---------- 登入 ---------- */
.login { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px; }
.login-card { width: min(360px, 100%); animation: rise .5s cubic-bezier(.2,.8,.25,1); }
.login-hint {
  margin: 26px 0 22px;
  font-family: var(--serif); font-size: 16px; color: var(--ink-2);
  border-left: 3px solid var(--accent); padding-left: 12px;
}
.login-card input {
  width: 100%; padding: 14px 16px; margin-bottom: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  font-size: 16px; outline: none; transition: border-color .18s, box-shadow .18s;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-err { margin-top: 12px; font-size: 13px; color: var(--accent); }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: var(--r);
  font-size: 15px; font-weight: 600;
  transition: transform .12s, opacity .18s, box-shadow .18s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); }
.btn-block { width: 100%; }
.textbtn { font-size: 14px; color: var(--ink-2); padding: 8px 10px; border-radius: 10px; }
.textbtn-primary { color: var(--accent); font-weight: 600; font-size: 15px; }
.iconbtn {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 12px; color: var(--ink-2); transition: background .15s, color .15s;
}
.iconbtn:active { background: var(--paper-2); color: var(--ink); }
.iconbtn svg { width: 21px; height: 21px; fill: currentColor; }
.iconbtn svg [fill="none"] { fill: none; }

/* ---------- 主畫面 ---------- */
#view-home { padding-bottom: 110px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 8px;
}
.topbar-actions { display: flex; gap: 2px; }
#btn-sync.spinning svg { animation: spin 1s linear infinite; }

.searchwrap { position: relative; padding: 6px 18px 2px; }
.search-ic {
  position: absolute; left: 32px; top: 50%; transform: translateY(-46%);
  width: 17px; height: 17px; color: var(--ink-2); pointer-events: none;
}
#search {
  width: 100%; padding: 11px 14px 11px 42px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  font-size: 16px; outline: none; appearance: none;
  transition: border-color .18s, box-shadow .18s;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#search::-webkit-search-cancel-button { -webkit-appearance: none; }

.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 18px 4px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px;
  font-size: 13px; color: var(--ink-2);
  background: var(--paper-2); border: 1px solid transparent;
  transition: all .16s;
}
.chip.on { background: var(--ink); color: var(--paper); font-weight: 600; }
.chip.chip-tag.on { background: var(--accent); color: var(--accent-ink); }
.chip-div { flex: none; width: 1px; margin: 6px 2px; background: var(--line); }

.meta-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px 6px;
}
.count { font-family: var(--mono); font-size: 12px; color: var(--ink-2); letter-spacing: .06em; }
.meta-tools { display: flex; align-items: center; gap: 6px; }
.viewtoggle { display: flex; background: var(--paper-2); border-radius: 10px; padding: 2px; }
.viewtoggle button { display: grid; place-items: center; width: 34px; height: 28px; border-radius: 8px; color: var(--ink-2); }
.viewtoggle button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.viewtoggle svg { width: 17px; height: 17px; }

/* ---------- 列表 ---------- */
.list { padding: 6px 18px; }
.row {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  padding: 12px 12px; margin-bottom: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  transition: transform .14s, box-shadow .2s;
  animation: rise .34s cubic-bezier(.2,.8,.25,1) backwards;
}
.row:active { transform: scale(.985); }
.thumb {
  flex: none; width: 66px; height: 42px; border-radius: 8px; overflow: hidden;
  background: var(--paper-2); border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--paper-2); }
.thumb-mono {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--serif); font-size: 19px; font-weight: 700; color: var(--teal);
}
.thumb-mono.is-store { color: var(--accent); }
.row-main { flex: 1; min-width: 0; }
.row-name { font-family: var(--serif); font-size: 16.5px; font-weight: 700; letter-spacing: .01em; }
.row-sub {
  margin-top: 2px; font-size: 12.5px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-tags { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.minitag {
  font-size: 10.5px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); letter-spacing: .04em;
}
.row-chev { flex: none; color: var(--line); }

/* ---------- 卡片牆 ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 6px 18px; }
.gcard {
  position: relative; aspect-ratio: 8 / 5;
  border-radius: 12px; overflow: hidden; text-align: left;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform .14s;
  animation: rise .34s cubic-bezier(.2,.8,.25,1) backwards;
}
.gcard:active { transform: scale(.97); }
.gcard img { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--paper-2); }
.gcard-name {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 10px 7px; font-size: 12px; font-weight: 600; color: #fff;
  background: linear-gradient(transparent, rgba(20,15,10,.72));
}
/* 無照片：排版名片面 */
.gface { width: 100%; height: 100%; padding: 12px 14px; display: flex; flex-direction: column; justify-content: space-between; }
.gface-name { font-family: var(--serif); font-size: 17px; font-weight: 700; }
.gface-title { font-size: 10.5px; color: var(--ink-2); margin-top: 3px; }
.gface-co { font-size: 10.5px; color: var(--teal); letter-spacing: .05em; align-self: flex-end; }
.gface-rule { width: 22px; height: 2.5px; background: var(--accent); border-radius: 2px; }

/* ---------- 空狀態 ---------- */
.empty { text-align: center; padding: 72px 30px; animation: rise .4s cubic-bezier(.2,.8,.25,1); }
.empty .seal { width: 56px; height: 56px; font-size: 30px; border-radius: 13px; margin: 0 auto 18px; opacity: .92; }
.empty h3 { font-family: var(--serif); font-size: 19px; margin-bottom: 8px; }
.empty p { font-size: 13.5px; color: var(--ink-2); line-height: 1.7; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 20px; bottom: max(24px, calc(env(safe-area-inset-bottom) + 14px));
  width: 58px; height: 58px; border-radius: 19px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: var(--shadow-lift);
  transition: transform .14s;
  z-index: 40;
}
.fab:active { transform: scale(.92); }
.fab svg { width: 24px; height: 24px; }

/* ---------- 底部抽屜 ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(23,18,13,.42); animation: fade .2s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--paper); border-radius: 22px 22px 0 0;
  padding: 10px 18px 16px;
  box-shadow: var(--shadow-lift);
  animation: slideup .3s cubic-bezier(.2,.8,.25,1);
}
.sheet-grip { width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 14px; }
.sheet-opt {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px 12px; border-radius: var(--r-lg);
  transition: background .15s;
}
.sheet-opt:active { background: var(--paper-2); }
.opt-ic {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 13px; background: var(--accent-soft); color: var(--accent); font-size: 20px;
}
.opt-ic svg { width: 23px; height: 23px; }
.opt-tx b { display: block; font-size: 15.5px; }
.opt-tx small { color: var(--ink-2); font-size: 12.5px; }
.menu-stat { padding: 6px 12px 14px; font-family: var(--serif); font-size: 15px; color: var(--ink-2); }
.menu-stat b { color: var(--accent); font-size: 22px; font-family: var(--mono); margin: 0 3px; }
.menu-ver { text-align: center; font-size: 11px; color: var(--ink-2); padding: 12px 0 2px; opacity: .7; }

/* ---------- 覆蓋視圖 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--paper);
  background-image: repeating-linear-gradient(115deg, transparent 0 5px, rgba(122,111,98,.022) 5px 6px);
  overflow-y: auto;
  animation: slidein .28s cubic-bezier(.2,.8,.25,1);
}
.ovbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-left: 12px; padding-right: 12px; padding-bottom: 8px;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.ovbar h2 { font-family: var(--serif); font-size: 17px; }
.ovbar-spacer { width: 38px; }

/* ---------- 掃描：相機取景 ---------- */
.scan { background: #0D0B09; background-image: none; }
.scan .scan-crop { display: none; }
.scan[data-mode="crop"] .scan-cam { display: none; }
.scan[data-mode="crop"] .scan-crop { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.scan-cam { position: relative; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.scan-stage { position: absolute; inset: 0; overflow: hidden; }
#scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-guide {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%);
  width: min(88vw, 540px); aspect-ratio: 8 / 5;
  border-radius: 14px;
  box-shadow: 0 0 0 200vmax rgba(10, 8, 6, .56);
  pointer-events: none;
}
.scan-guide .gc {
  position: absolute; width: 26px; height: 26px;
  border: 3px solid #FFF6EF; border-radius: 2px;
}
.gc-tl { left: -2px; top: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.gc-tr { right: -2px; top: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
.gc-br { right: -2px; bottom: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.gc-bl { left: -2px; bottom: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; }
.scan-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .1s; }
.scan-flash.on { opacity: .85; }
.scan-detect { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.scan-detect polygon {
  fill: rgba(255, 246, 239, .10);
  stroke: rgba(255, 246, 239, .9); stroke-width: 2.5; stroke-linejoin: round;
  stroke-dasharray: 10 7;
}
.scan-detect polygon.locked {
  fill: rgba(217, 106, 80, .16);
  stroke: #E8785F; stroke-dasharray: none; stroke-width: 3;
}
.scan-status {
  position: absolute; left: 50%; top: max(64px, calc(env(safe-area-inset-top) + 54px));
  transform: translateX(-50%);
  padding: 7px 16px; border-radius: 999px;
  background: rgba(13, 11, 9, .62); color: #FFF6EF;
  font-size: 12.5px; letter-spacing: .1em; white-space: nowrap;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

.scan-top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding-left: 14px; padding-right: 14px;
}
.scan-btn { color: #FFF6EF; background: rgba(255, 246, 239, .14); border-radius: 999px; }
.scan-btn.torch-on { background: #FFF6EF; color: #1a1512; }
.scan-side {
  font-family: var(--serif); font-size: 15px; font-weight: 700; color: #FFF6EF;
  letter-spacing: .3em; padding-left: .3em;
  background: rgba(255, 246, 239, .14); padding: 6px 16px; border-radius: 999px;
}
.scan-hint {
  position: relative; z-index: 2; margin-top: auto;
  text-align: center; font-size: 12.5px; color: rgba(255, 246, 239, .82); letter-spacing: .08em;
}
.scan-hint-tap { margin-top: 6px; color: #E8785F; font-weight: 600; }
.scan-foot {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 18px 30px;
}
.scan-side-act {
  font-size: 14px; color: #FFF6EF; opacity: .9; padding: 10px;
  justify-self: start;
}
#scan-skip { justify-self: end; }
.scan-shutter {
  width: 72px; height: 72px; border-radius: 50%;
  background: #FFF6EF;
  box-shadow: 0 0 0 4px rgba(255, 246, 239, .001), 0 0 0 3px #0D0B09 inset, 0 0 0 0 transparent;
  border: 5px solid rgba(255, 246, 239, .4);
  background-clip: padding-box;
  transition: transform .1s;
}
.scan-shutter:active { transform: scale(.9); }

/* ---------- 掃描：邊角微調 ---------- */
.scan-crop .ovbar { background: transparent; border-bottom: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
.scan-crop .ovbar h2 { color: #FFF6EF; font-size: 15px; letter-spacing: .1em; }
.crop-stage { position: relative; flex: 1; margin: 8px 16px; overflow: hidden; }
#crop-canvas { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 6px; }
.crop-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.crop-lines polygon { fill: rgba(217, 106, 80, .14); stroke: #E8785F; stroke-width: 2; }
.crop-h {
  position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  touch-action: none; cursor: grab;
}
.crop-h::after {
  content: ""; position: absolute; inset: 10px;
  border-radius: 50%; background: rgba(255, 246, 239, .95);
  border: 3px solid #E8785F; box-shadow: 0 1px 6px rgba(0,0,0,.4);
}
.crop-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px;
}
.crop-foot .textbtn { color: rgba(255, 246, 239, .85); font-size: 15px; }
.crop-foot .btn { min-width: 150px; }

/* ---------- 拍攝確認 ---------- */
.capture-body { padding: 22px 20px; display: grid; gap: 18px; }
.shot-label { font-size: 13px; color: var(--ink-2); margin-bottom: 8px; letter-spacing: .08em; }
.shot-label small { opacity: .75; }
.shot-frame {
  aspect-ratio: 8 / 5; border-radius: var(--r-lg); overflow: hidden;
  display: grid; place-items: center;
  background: var(--card); border: 1.5px dashed var(--line);
  transition: border-color .2s;
}
.shot-frame:active { border-color: var(--accent); }
.shot-frame.filled { border-style: solid; border-color: var(--line); box-shadow: var(--shadow); }
.shot-frame img { width: 100%; height: 100%; object-fit: contain; background: var(--paper-2); }
.shot-empty { font-size: 13.5px; color: var(--ink-2); }
.capture-foot { padding: 8px 20px; display: grid; gap: 6px; justify-items: center; }
.capture-foot .btn { max-width: 480px; }

/* ---------- 表單 ---------- */
.form-body { padding: 18px 20px 60px; max-width: 560px; margin: 0 auto; }
.fsec { margin-bottom: 26px; }
.fsec-t {
  font-family: var(--serif); font-size: 13.5px; color: var(--ink-2);
  letter-spacing: .16em; margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
}
.fsec-t::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; letter-spacing: .05em; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  font-size: 16px; outline: none; appearance: none;
  transition: border-color .18s, box-shadow .18s;
}
.field textarea { min-height: 74px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input[type="tel"], .field input[type="email"], .field input[type="url"] { font-family: var(--mono); font-size: 15px; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; background: var(--paper-2); border-radius: var(--r); padding: 3px; }
.seg button {
  flex: 1; padding: 9px 4px; border-radius: 11px; font-size: 13.5px; color: var(--ink-2);
  transition: all .15s;
}
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.tagpick { display: flex; flex-wrap: wrap; gap: 8px; }
.tagpick .chip { background: var(--card); border: 1px solid var(--line); }
.tagpick .chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip-add { border-style: dashed !important; color: var(--accent) !important; }
.form-photos { display: flex; gap: 10px; margin-bottom: 4px; }
.fphoto {
  flex: 1; aspect-ratio: 8 / 5; border-radius: 12px; overflow: hidden; position: relative;
  background: var(--paper-2); border: 1px dashed var(--line);
  display: grid; place-items: center; font-size: 12px; color: var(--ink-2);
}
.fphoto img { width: 100%; height: 100%; object-fit: contain; background: var(--paper-2); }
.fphoto span { position: absolute; }
.fphoto .fphoto-hint { bottom: 6px; right: 8px; font-size: 10px; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.subcard { background: var(--paper-2); border-radius: var(--r); padding: 12px; margin-top: 8px; }

/* ---------- 詳細頁 ---------- */
.detail-body { padding: 20px 20px 70px; max-width: 560px; margin: 0 auto; }
.flip { perspective: 1200px; margin-bottom: 8px; }
.flip-inner {
  position: relative; aspect-ratio: 8 / 5;
  transform-style: preserve-3d; transition: transform .6s cubic-bezier(.3,.7,.3,1);
}
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: var(--r-lg); overflow: hidden;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-lift);
}
.flip-face img { width: 100%; height: 100%; object-fit: contain; background: var(--paper-2); }
.flip.is-portrait { max-width: min(62vw, 300px); margin-left: auto; margin-right: auto; }
.flip-back { transform: rotateY(180deg); }
.flip-hint { text-align: center; font-size: 11px; color: var(--ink-2); margin: 10px 0 4px; letter-spacing: .1em; }
.dface { width: 100%; height: 100%; padding: 20px 22px; display: flex; flex-direction: column; justify-content: space-between; }
.dface-name { font-family: var(--serif); font-size: 26px; font-weight: 700; }
.dface-title { font-size: 13px; color: var(--ink-2); margin-top: 5px; }
.dface-co { font-size: 13px; color: var(--teal); align-self: flex-end; letter-spacing: .06em; }
.dface-rule { width: 30px; height: 3px; background: var(--accent); border-radius: 2px; }

.dhead { margin: 18px 2px 6px; }
.dhead h2 { font-family: var(--serif); font-size: 26px; }
.dhead p { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.dhead .minitag { font-size: 11.5px; }
.dtags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.dsec { margin-top: 20px; }
.dsec-t {
  font-family: var(--serif); font-size: 13px; color: var(--ink-2);
  letter-spacing: .16em; margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px;
}
.dsec-t::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.drow {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  padding: 13px 14px; margin-bottom: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  transition: transform .12s;
}
.drow:active { transform: scale(.985); }
.drow-ic { flex: none; width: 20px; height: 20px; color: var(--teal); }
.drow-ic svg { width: 100%; height: 100%; }
.drow-main { flex: 1; min-width: 0; }
.drow-label { font-size: 10.5px; color: var(--ink-2); letter-spacing: .1em; }
.drow-val { font-size: 15px; margin-top: 1px; word-break: break-all; }
.drow-val.mono { font-family: var(--mono); font-size: 14.5px; letter-spacing: .02em; }
.drow-act { flex: none; font-size: 11px; color: var(--accent); letter-spacing: .06em; }
.dnote {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; font-size: 14px; line-height: 1.75; white-space: pre-wrap;
}
.darchive {
  display: block; margin: 34px auto 0; padding: 10px 20px;
  font-size: 13.5px; color: var(--accent); opacity: .85;
}

/* ---------- OCR loading ---------- */
.ocr-loading {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-content: center; gap: 16px; justify-items: center;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.ocr-seal {
  display: grid; place-items: center; width: 64px; height: 64px;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--serif); font-size: 34px; font-weight: 700; border-radius: 15px;
  box-shadow: inset 0 0 0 2px rgba(255,249,242,.35), inset 0 0 0 5px var(--accent);
  animation: stamp 1.15s ease-in-out infinite;
}
.ocr-loading p { font-family: var(--serif); font-size: 15px; color: var(--ink-2); letter-spacing: .2em; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(96px, calc(env(safe-area-inset-bottom) + 86px));
  transform: translateX(-50%);
  padding: 11px 20px; border-radius: 999px;
  background: var(--ink); color: var(--paper);
  font-size: 13.5px; z-index: 90;
  box-shadow: var(--shadow-lift);
  animation: rise .3s cubic-bezier(.2,.8,.25,1);
  max-width: 88vw; text-align: center;
}
.toast.err { background: var(--accent); color: var(--accent-ink); }

/* ---------- 動畫 ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(40px); opacity: .4; } }
@keyframes slidein { from { transform: translateX(6%); opacity: .5; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes stamp {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(.88) rotate(-3deg); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 桌機微調 */
@media (min-width: 640px) {
  #view-home { max-width: 640px; margin: 0 auto; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .fab { right: calc(50vw - 320px + 20px); }
}
