:root {
  --bg: #f6f3ef;
  --surface: #ffffff;
  --sunk: #ece7e1;
  --ink: #1d1b19;
  --muted: #6f6a64;
  --line: #ddd6ce;
  --accent: #8a3b12;
  --accent-ink: #ffffff;
  --ok: #2f6b3a;
  --ok-bg: #e3efe3;
  --bad: #9b2c2c;
  --bad-bg: #f5e1df;
  --run: #7a5b00;
  --run-bg: #f4ead0;
  --radius: 14px;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312;
    --surface: #1e1c1a;
    --sunk: #262321;
    --ink: #f2eee9;
    --muted: #a39d96;
    --line: #34302c;
    --accent: #e08a55;
    --accent-ink: #1a0f08;
    --ok: #8fd19a;
    --ok-bg: #1f3323;
    --bad: #f0a39b;
    --bad-bg: #3a2220;
    --run: #e6c56a;
    --run-bg: #3a3220;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) var(--gutter) 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 19px; letter-spacing: -0.01em; text-decoration: none; }
.top nav { display: flex; gap: 4px; }
.top nav a {
  text-decoration: none; padding: 7px 12px; border-radius: 999px; color: var(--muted); font-size: 15px;
}
.top nav a.on { background: var(--ink); color: var(--bg); }

main { padding: 14px var(--gutter) 40px; max-width: 900px; margin: 0 auto; }
h1 { font-size: 22px; line-height: 1.2; margin: 6px 0 4px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 22px 0 8px; font-weight: 600; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px;
  border-radius: 999px; background: var(--sunk); color: var(--muted);
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.run { background: var(--run-bg); color: var(--run); }

.card {
  display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-bottom: 10px;
}
.card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card .name { font-weight: 600; overflow-wrap: anywhere; }
.card .meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.strip img, .strip .ph { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; background: var(--sunk); display: block; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.tile { position: relative; display: block; border-radius: 10px; overflow: hidden; background: var(--sunk); text-decoration: none; }
.tile img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; }
.tile .status {
  width: 100%; aspect-ratio: 3 / 4; display: grid; place-items: center; text-align: center;
  padding: 12px; font-size: 13px; color: var(--muted);
}
.tile .badge { position: absolute; left: 6px; top: 6px; }
.tile .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font-size: 12px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.55)); overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

.run { margin-bottom: 18px; }
.run .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
details.prompt { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; font-size: 14px; }
details.prompt summary { cursor: pointer; color: var(--muted); }
details.prompt p { white-space: pre-wrap; margin: 8px 0 0; }

.viewer img { width: 100%; border-radius: var(--radius); display: block; background: var(--sunk); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 12px 14px; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer; min-height: 46px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.approve.on { background: var(--ok); color: var(--bg); border-color: var(--ok); }
.btn.reject.on { background: var(--bad); color: var(--bg); border-color: var(--bad); }
.btn:disabled { opacity: .55; }
.wide { grid-column: 1 / -1; }
textarea, input[type=search], input[type=text] {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px; font-size: 16px;
}
textarea { min-height: 84px; resize: vertical; }
dl.info { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; margin: 12px 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; overflow-wrap: anywhere; }
code.id { font: 600 14px ui-monospace, SFMono-Regular, Menlo, monospace; }

.list a.item {
  display: flex; justify-content: space-between; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); text-decoration: none;
}
.list a.item span:last-child { color: var(--muted); }

.drop {
  display: grid; place-items: center; text-align: center; gap: 6px; padding: 28px 16px; border: 2px dashed var(--line);
  border-radius: var(--radius); background: var(--surface); cursor: pointer;
}
.drop input { display: none; }
.uploads .card { display: flex; gap: 12px; align-items: center; }
.uploads img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--sunk); flex: none; }

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 18px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
