:root {
  --paper: #f3ede2; --card: #fbf8f2; --ink: #2a221c; --ink-2: #5e5246; --line: #d8ccb8;
  --accent: #8a4b2a; --accent-2: #a85d36; --accent-ink: #fffaf3; --gold: #c08a3e;
  --ok: #3f7a3d; --bad: #b23b22; --stage: #1d1814;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif SC", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1d1915; --card: #2a241e; --ink: #f4ecdf; --ink-2: #c4b6a3; --line: #4a3f34;
    --accent: #d08a5c; --accent-2: #e2a074; --accent-ink: #1d1915; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1d1915; --card: #2a241e; --ink: #f4ecdf; --ink-2: #c4b6a3; --line: #4a3f34;
  --accent: #d08a5c; --accent-2: #e2a074; --accent-ink: #1d1915; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; overflow-x: hidden; }
body { background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 22px; line-height: 1.5;
  min-height: 100dvh; -webkit-tap-highlight-color: transparent; padding-bottom: env(safe-area-inset-bottom); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.top { padding: calc(18px + env(safe-area-inset-top)) 16px 6px; text-align: center; }
.top h1 { font-family: var(--serif); font-size: 40px; margin: 0; letter-spacing: .12em; }
.top p { margin: 2px 0 0; color: var(--ink-2); font-size: 20px; }
main { max-width: 640px; margin: 0 auto; padding: 0 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 22px; margin-top: 18px; }
.notice .big { font-size: 26px; margin: 0 0 8px; font-weight: 600; }
.notice .small { font-size: 18px; color: var(--ink-2); margin: 0; }

#actions { margin-top: 18px; display: grid; gap: 14px; }
.shoot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 200px; border-radius: 28px; background: var(--accent); color: var(--accent-ink);
  font-size: 40px; font-weight: 800; letter-spacing: .1em; user-select: none;
  box-shadow: 0 2px 4px rgba(60,40,20,.15), 0 10px 28px rgba(60,40,20,.18); transition: transform .1s;
}
.shoot:active { transform: scale(.98); background: var(--accent-2); }
.album {
  display: flex; align-items: center; justify-content: center; min-height: 76px; border-radius: 22px;
  border: 2px solid var(--line); background: var(--card); font-size: 26px; font-weight: 700; user-select: none;
}
.album:active { background: var(--paper); }
.hint { margin: 2px 4px 0; color: var(--ink-2); font-size: 19px; text-align: center; }

#gallerySec h2 { font-family: var(--serif); font-size: 28px; margin: 30px 0 12px; }
.empty { color: var(--ink-2); font-size: 20px; }
.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.gallery li {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column;
}
.gallery .ph { position: relative; aspect-ratio: 4 / 3; background: #d9cfbf; display: block; width: 100%; border: 0; padding: 0; }
.gallery .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .st { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; font-size: 21px; font-weight: 700; padding: 6px; }
.st.busy { color: var(--ink-2); }
.st.ok { color: var(--ok); }
.st.bad { color: var(--bad); }
.st .dot { width: 14px; height: 14px; border-radius: 50%; border: 3px solid currentColor; border-top-color: transparent; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.gallery .retryBtn { margin: 0 10px 10px; min-height: 52px; border-radius: 14px; border: 0; background: var(--bad); color: #fff; font-size: 22px; font-weight: 700; }

.foot { text-align: center; padding: 36px 16px 28px; }
.foot a { color: var(--ink-2); font-size: 15px; }

.viewer { position: fixed; inset: 0; z-index: 50; background: var(--stage); color: #fff; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.vbar { display: flex; justify-content: flex-end; padding: 10px 12px 0; }
.close { min-height: 56px; min-width: 96px; border-radius: 16px; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 22px; font-weight: 700; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px; }
.tabs button { min-height: 60px; border-radius: 16px; border: 2px solid rgba(255,255,255,.25); background: transparent; color: #fff; font-size: 23px; font-weight: 700; }
.tabs button[aria-selected="true"] { background: #fff; color: #2a221c; border-color: #fff; }
.vimg { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 6px 12px; }
.vimg img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.vstate { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-size: 24px; text-align: center; padding: 20px; }
.vnote { margin: 0; padding: 4px 16px; font-size: 16px; color: #e8d9c4; text-align: center; min-height: 1.5em; }
.vactions { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 12px 14px; align-items: center; }
.save { min-height: 72px; border-radius: 20px; border: 0; background: var(--gold); color: #1d1408; font-size: 28px; font-weight: 800; }
.save:disabled { opacity: .45; }
.retry { min-height: 72px; border-radius: 20px; border: 0; background: var(--bad); color: #fff; font-size: 24px; font-weight: 700; padding: 0 20px; }
.orig { background: none; border: 0; color: #cdbfae; font-size: 17px; text-decoration: underline; padding: 10px 6px; min-height: 44px; }

.toast { position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  max-width: calc(100% - 32px); background: rgba(30,22,16,.94); color: #fff; padding: 14px 20px; border-radius: 16px; font-size: 20px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.ailine { text-align: center; font-size: 17px; color: var(--ink-2); padding: 0 8px 10px; margin-top: -6px; }
.tips h2 { font-family: var(--serif); font-size: 24px; margin: 0 0 8px; }
.tips ul { margin: 0; padding-left: 1.1em; }
.tips li { margin: 4px 0; font-size: 20px; }
.tips b { color: var(--accent); }
