/* 济新阁 admin — mobile first */
:root {
  --wine: #7a1f2b; --wine-d: #5c1520; --gold: #b8892f; --gold-l: #f3e6c8;
  --paper: #f7f1e6; --card: #fffdf8; --ink: #2a1d17; --muted: #7a6d63; --line: #e6dccb;
  --ok: #2f7a4a; --warn: #a86a12; --err: #b3261e; --info: #2d5f8a;
  --r: 14px; --tab-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.admin { margin: 0; font: 16px/1.55 var(--font); color: var(--ink); background: var(--paper); padding-bottom: calc(var(--tab-h) + var(--safe-b) + 8px); }
a { color: var(--wine); }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
small, .small { font-size: .85rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85rem; margin: .25rem 0; }
.center { text-align: center; }
code { background: var(--gold-l); padding: 0 .3em; border-radius: 4px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top, 0px));
  background: var(--wine); color: #fff; }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; }
.seal { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 2px solid var(--gold); color: var(--gold-l); border-radius: 6px; font-weight: 700; font-size: 1rem; background: var(--wine-d); }
.seal.lg { width: 64px; height: 64px; font-size: 2rem; border-radius: 12px; }
.topnav { display: none; gap: .25rem; }
.topnav a { color: #f5dfe2; text-decoration: none; padding: .4rem .7rem; border-radius: 8px; }
.topnav a.on, .topnav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.who { margin-left: auto; display: flex; gap: .75rem; font-size: .9rem; }
.who a { color: var(--gold-l); }
.who span { display: none; }

/* bottom tab bar (phones) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -2px 12px rgba(42,29,23,.06); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .72rem; color: var(--muted); text-decoration: none; }
.tabbar a i { font-style: normal; font-size: 1.3rem; line-height: 1; }
.tabbar a.on { color: var(--wine); font-weight: 600; }
.tabbar a.cam { color: #fff; }
.tabbar a.cam i { display: grid; place-items: center; width: 52px; height: 52px; margin-top: -22px; border-radius: 50%; background: var(--wine); color: #fff; font-size: 1.5rem; box-shadow: 0 4px 12px rgba(122,31,43,.35); border: 3px solid var(--card); }
.tabbar a.cam { color: var(--wine); font-weight: 600; }

.wrap { max-width: 860px; margin: 0 auto; padding: 1rem; }
.page-title { font-size: 1.4rem; margin: .25rem 0 1rem; }
.page-title small { display: block; font-size: .85rem; font-weight: 400; color: var(--muted); margin-top: .2rem; }
.section-title { font-size: 1.05rem; margin: 1.5rem 0 .5rem; display: flex; align-items: center; gap: .5rem; }
.count { background: var(--wine); color: #fff; border-radius: 99px; font-size: .75rem; padding: 0 .55rem; }
.back { display: inline-block; text-decoration: none; padding: .5rem 0; font-size: .95rem; }
.row { display: flex; align-items: center; gap: .5rem; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: .9rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 1.25rem; }
.grid2.tight { margin-top: 0; }
@media (max-width: 420px) { .grid2.tight { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; margin: 0 0 1rem; }
details.card > summary { cursor: pointer; list-style: none; min-height: 32px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary { margin-bottom: 1rem; }

/* forms */
.field { display: block; }
.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=url], input[type=password], input[type=search], input[type=date], input[type=datetime-local], input:not([type]), select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */ color: var(--ink);
  padding: .7rem .8rem; min-height: 48px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
textarea.short { min-height: 80px; }
textarea.long { min-height: 220px; }
textarea.verse { min-height: 150px; font-size: 1.25rem; line-height: 1.9; letter-spacing: .08em; font-family: "Songti SC", "Noto Serif SC", "STSong", serif; }
input[readonly], textarea[readonly] { background: #f3eee5; }
.check { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: 0 0 22px; margin-top: .1rem; accent-color: var(--wine); }
.check.big { background: var(--gold-l); border-radius: 10px; padding: .75rem; font-size: .92rem; }
.verse-preview { background: #f3eee5; border-radius: 10px; padding: .8rem; font-size: 1.15rem; line-height: 1.9; font-family: "Songti SC", "Noto Serif SC", serif; }
.cover-preview { max-height: 180px; border-radius: 10px; margin-bottom: .5rem; }
.filters { display: flex; gap: .5rem; margin-bottom: .75rem; }
.filters select { width: auto; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1rem; font: inherit; font-weight: 600;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-primary { background: var(--wine); border-color: var(--wine); color: #fff; }
.btn-primary:hover { background: var(--wine-d); }
.btn-ghost { background: transparent; border-color: var(--wine); color: var(--wine); }
.btn-link { background: none; border: 0; color: var(--wine); text-decoration: underline; }
.btn-sm { min-height: 36px; padding: .3rem .7rem; font-size: .85rem; }
.btn-lg { min-height: 54px; font-size: 1.05rem; }
.btn-xl { min-height: 64px; font-size: 1.15rem; border-radius: 14px; }
.btn-block { display: flex; width: 100%; }
.btn.danger, .danger { color: var(--err); border-color: #ebc3bf; }
.btn.busy { opacity: .8; }
.btn.busy::before { content: ""; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.btn.on { background: var(--gold-l); border-color: var(--gold); }
.grow { flex: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
.cam-ico { font-size: 1.4em; line-height: 1; }
.actions { display: flex; gap: .5rem; }
.actions.sticky { position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + 6px); z-index: 20; background: linear-gradient(to top, var(--card) 70%, transparent); padding-top: .75rem; margin-top: 1rem; }
.inline { display: inline-flex; gap: .25rem; }
.danger-zone { margin: 2rem 0 1rem; text-align: center; }

/* badges & notices */
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; background: #eee; color: var(--muted); white-space: nowrap; vertical-align: middle; }
.badge.ok { background: #e2f1e7; color: var(--ok); }
.badge.warn { background: #fbefd9; color: var(--warn); }
.badge.err { background: #f8e1df; color: var(--err); }
.badge.info { background: #e1ecf6; color: var(--info); }
.badges { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; margin-top: .25rem; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #ccc; }
.dot.proofread { background: var(--ok); } .dot.auto { background: var(--warn); } .dot.stale, .dot.error { background: var(--err); } .dot.missing { background: #d6cfc4; }
.notice { padding: .8rem 1rem; border-radius: 10px; margin: 0 0 1rem; background: #e1ecf6; color: var(--info); font-size: .95rem; }
.notice.ok { background: #e2f1e7; color: var(--ok); }
.notice.warn { background: #fbefd9; color: #7a4d0c; }
.notice.err { background: #f8e1df; color: var(--err); }
.ai-notes div { margin-top: .3rem; font-size: .92rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 0; }

/* lists */
.list { list-style: none; margin: 0 0 1rem; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.list-item { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; min-height: 60px; color: inherit; text-decoration: none; }
.list-item > img, .noimg { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: 0 0 56px; background: var(--gold-l); }
.list-item.today { background: #fff6e3; }
.list-item.past { opacity: .65; }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.li-main small { color: var(--muted); }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .9rem; }
.chev { color: var(--muted); font-size: 1.4rem; }
.datebox { display: flex; flex-direction: column; align-items: center; width: 48px; flex: 0 0 48px; background: var(--gold-l); border-radius: 10px; padding: .25rem 0; }
.datebox b { font-size: 1.25rem; line-height: 1.1; color: var(--wine); }
.datebox small { font-size: .7rem; color: var(--muted); }
.menu .list-item { min-height: 56px; }

.segmented { display: flex; background: #ece3d3; border-radius: 12px; padding: 4px; margin-bottom: 1rem; overflow-x: auto; }
.segmented a { flex: 1; text-align: center; padding: .55rem .5rem; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; font-size: .92rem; }
.segmented a.on { background: var(--card); color: var(--wine); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.pager { display: flex; align-items: center; justify-content: center; gap: 1.25rem; margin: 1rem 0; }
.pager a { padding: .5rem .9rem; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; background: var(--card); }

.tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; text-decoration: none; color: inherit; }
.tile b { display: block; color: var(--wine); }
.tile small { color: var(--muted); }

/* dashboard session card */
.session-card { border-color: var(--gold); background: linear-gradient(160deg, #fffdf8, #fbf1db); }
.session-card.today { border-width: 2px; }
.session-when { margin-bottom: 1rem; position: relative; }
.big-date { font-size: 1.6rem; font-weight: 700; }
.big-date small { font-size: 1rem; font-weight: 400; color: var(--muted); }
.lunar { color: var(--muted); }
.lunar b { color: var(--wine); }
.tag { position: absolute; top: 0; right: 0; font-size: .75rem; font-weight: 700; padding: .2rem .6rem; border-radius: 99px; background: var(--gold-l); color: var(--warn); }
.tag.live { background: var(--wine); color: #fff; }
.thumbs { display: flex; gap: .5rem; overflow-x: auto; margin-top: 1rem; }
.thumb { position: relative; flex: 0 0 84px; }
.thumb img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; }
.thumb .badge { position: absolute; left: 4px; bottom: 4px; }

/* upload screen */
.capture { display: grid; gap: .6rem; }
.previews { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.previews li { display: flex; align-items: center; gap: .75rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .5rem; }
.previews img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.previews .pg { flex: 1; font-weight: 600; }
.pv-tools { display: flex; gap: .3rem; }
.progress { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.progress .bar { height: 10px; border-radius: 99px; background: #ece3d3; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--wine), var(--gold)); transition: width .4s; }
.progress .status { margin: .6rem 0 0; font-weight: 600; }

/* 乩文 edit: photo pane */
.photo-pane { background: #1d1612; color: #f3e6c8; border-radius: var(--r); padding: .6rem; margin-bottom: 1rem; }
.photo-tools { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; font-size: .9rem; }
.photo-tools .btn { background: #3a2d26; color: #fff; border-color: #4d3d33; }
.photo-tools .btn.on { background: var(--gold); color: #1d1612; }
.photo-scroll { --zoom: 1; max-height: 55vh; overflow: auto; border-radius: 10px; background: #000; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; }
.photo-scroll img { width: calc(100% * var(--zoom)); max-width: none; }
.photo-scroll img + img { margin-top: 4px; }
.photo-manage { margin-top: .5rem; }
.photo-manage summary { cursor: pointer; padding: .4rem 0; font-size: .9rem; }
.photo-manage .list { color: var(--ink); }
body.compare .photo-pane { position: sticky; top: 52px; z-index: 25; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
body.compare .photo-scroll { max-height: 38vh; }
body.compare .photo-manage { display: none; }
.ai-rerun { margin-bottom: 1rem; }

/* language tabs */
.langtabs { display: flex; gap: 4px; position: sticky; top: 52px; z-index: 15; background: var(--paper); padding: .5rem 0; margin-bottom: .25rem; overflow-x: auto; }
body.compare .langtabs { position: static; }
.langtabs a { flex: 1; min-width: 56px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .45rem .3rem; border-radius: 10px; background: #ece3d3; color: var(--muted); text-decoration: none; font-weight: 700; font-size: .9rem; }
.langtabs a small { font-size: .65rem; font-weight: 400; }
.langtabs a.on { background: var(--wine); color: #fff; }
.langtabs a.disabled { pointer-events: none; opacity: .4; }

/* login / install */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 1.5rem; }
.auth-brand { text-align: center; margin-bottom: 1.25rem; }
.auth-brand .seal { margin: 0 auto .75rem; }
.auth-brand p { color: var(--muted); margin: 0; }

/* desktop */
@media (min-width: 900px) {
  body.admin { padding-bottom: 0; }
  .tabbar { display: none; }
  .topnav { display: flex; }
  .who span { display: inline; }
  .actions.sticky { bottom: 0; }
  .wrap { padding: 1.5rem; }
  .langtabs, body.compare .photo-pane { top: 56px; }
}
