:root {
  --paper: #f4efe6;
  --card: #fffdf8;
  --ink: #2a2622;
  --muted: #7a7166;
  --line: #e3dbcd;
  --accent: #b5543c;
  --accent-ink: #fff;
  --ok: #3f6b4a;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c1a17; --card: #26231f; --ink: #efe8dc; --muted: #a59b8d;
    --line: #3a352f; --accent: #d9765c; --ok: #8fc29b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.45 var(--sans); }
body { padding: env(safe-area-inset-top) 16px calc(76px + env(safe-area-inset-bottom)); }
main { max-width: 520px; margin: 0 auto; }
[hidden] { display: none !important; }

.title { font: 600 26px/1.1 var(--serif); margin: 18px 0 4px; letter-spacing: .2px; }
.muted { color: var(--muted); font-size: 14px; }
.top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.login-card { margin-top: 18vh; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0; }
input, textarea {
  width: 100%; margin-top: 6px; padding: 12px; font: inherit; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { font: 19px/1.45 var(--serif); resize: vertical; }
#send-form input { margin-top: 10px; }

button { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.primary { display: block; width: 100%; margin-top: 14px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 13px; text-align: center; border-radius: 12px; }
.primary:disabled { opacity: .55; }
.link { border: 0; background: none; color: var(--muted); text-decoration: underline; }
.error { color: var(--accent); min-height: 1em; margin: 8px 0 0; font-size: 14px; }
.ok { color: var(--ok); min-height: 1em; margin: 8px 0 0; font-size: 14px; }
.count { text-align: right; color: var(--muted); font-size: 12px; margin-top: 4px; }

.seg { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; color: var(--muted); }
.seg button.on { background: var(--paper); color: var(--ink); font-weight: 600; }

.drop { display: grid; place-items: center; min-height: 180px; border: 1.5px dashed var(--line); border-radius: 12px; margin: 0; cursor: pointer; overflow: hidden; }
.drop img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }

.results { list-style: none; padding: 0; margin: 8px 0 0; }
.results li, .picked { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; cursor: pointer; }
.results li:hover { background: var(--paper); }
.results img, .picked img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; flex: none; }
.picked { background: var(--paper); margin-top: 10px; cursor: default; }
.t1 { font-weight: 600; font-size: 15px; } .t2 { color: var(--muted); font-size: 13px; }
.picked .x { margin-left: auto; border: 0; background: none; color: var(--muted); font-size: 20px; padding: 0 6px; }

.banner { background: var(--accent); color: var(--accent-ink); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; cursor: pointer; }

.history { list-style: none; padding: 0; margin: 0; }
.history li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; max-width: 88%; }
.history li.mine { margin-left: auto; background: var(--paper); }
.history li.unread { border-color: var(--accent); }
.history .meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.history .body { font: 18px/1.4 var(--serif); white-space: pre-wrap; overflow-wrap: anywhere; }
.history img.photo { width: 100%; border-radius: 10px; margin-top: 4px; }
.history .song { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; }
.history .song img { width: 56px; height: 56px; border-radius: 6px; }

.grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.grid li { position: relative; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; background: var(--line); }
.grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid button { position: absolute; top: 4px; right: 4px; padding: 2px 8px; font-size: 13px; background: rgba(0,0,0,.45); color: #fff; border: 0; }
.file-btn { cursor: pointer; }

.frames { display: grid; gap: 18px; }
.frames figure { margin: 0; }
.frame { background: #ede8de; padding: 18px; border-radius: 6px; box-shadow: 0 1px 0 var(--line), 0 6px 18px rgba(0,0,0,.08); }
.frame img { display: block; width: 100%; aspect-ratio: 4 / 3; background: #ddd; filter: sepia(.08); }
figcaption { color: var(--muted); font-size: 13px; margin-top: 8px; text-align: center; }
.row { display: flex; justify-content: space-between; align-items: center; margin: 18px 0; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px;
  background: var(--card); border-top: 1px solid var(--line); padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.tabs button { flex: 1; max-width: 130px; border: 0; background: none; color: var(--muted); position: relative; }
.tabs button.on { color: var(--accent); font-weight: 600; }
.dot { position: absolute; top: 6px; right: 18px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
