:root {
  --bg: #f7f3ee;
  --card: #ffffff;
  --text: #2b2521;
  --muted: #7a6f66;
  --accent: #9c6b4e;
  --accent-ink: #ffffff;
  --line: #e8e0d7;
  --ok: #3f7d4f;
  --err: #b3412f;
  --radius: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }

.hero { text-align: center; padding: 8px 0 16px; }
.cover { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); display: block; margin-bottom: 16px; }
h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: 2rem; line-height: 1.2; margin: 8px 0 4px; }
.welcome { color: var(--muted); margin: 0 auto; max-width: 30em; }

.banner { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-align: center; }
.banner.test { background: #fff6d6; border-color: #eed98a; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 12px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%; font-size: 16px; /* 16px stops iOS zooming on focus */
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--text);
}

.big-button {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 64px; padding: 16px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 14px; font-size: 1.15rem; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.big-button:active { filter: brightness(.92); }
.big-icon { font-size: 1.5rem; line-height: 1; }
.hint { font-size: .85rem; color: var(--muted); text-align: center; margin: 10px 0 0; }

.summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 16px; font-size: .95rem; }
.retry { font: inherit; font-size: .9rem; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--err); color: var(--err); background: #fff; }

.queue { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.item { display: grid; grid-template-columns: 48px 1fr; gap: 10px; align-items: center; }
.item-thumb { width: 48px; height: 48px; border-radius: 8px; background: var(--line) center / cover no-repeat; }
.item-body { min-width: 0; }
.item-name { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-status { font-size: .8rem; color: var(--muted); }
.item.done .item-status { color: var(--ok); }
.item.failed .item-status { color: var(--err); }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 4px 0 2px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.item.done .bar > i { background: var(--ok); }
.item.failed .bar > i { background: var(--err); }

.feed-section h2 { font-family: Georgia, serif; font-weight: 500; text-align: center; margin: 28px 0 12px; }
.feed { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tile { position: relative; aspect-ratio: 1; padding: 0; border: 0; background: var(--line); border-radius: 6px; overflow: hidden; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }

.viewer { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
.viewer::backdrop { background: rgba(0, 0, 0, .9); }
.viewer[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.viewer-media { width: 100%; display: flex; justify-content: center; }
.viewer-media img, .viewer-media video { max-width: 100vw; max-height: 80vh; object-fit: contain; }
.viewer-guest { color: #eee; margin: 8px 0 0; min-height: 1.5em; }
.viewer-close {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 12px; z-index: 1;
  width: 44px; height: 44px; border-radius: 22px; border: 0; background: rgba(255, 255, 255, .15); color: #fff; font-size: 20px;
}

.admin-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.admin-row input, .admin-row select, .admin-row button { font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); }
.admin-row button { background: var(--accent); color: #fff; border: 0; }
.tile .del { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 16px; border: 0; background: rgba(179, 65, 47, .9); color: #fff; font-size: 16px; }
