:root {
  color-scheme: light dark;
  --paper: #f4f6f1;
  --surface: #fff;
  --sunken: #eaeee6;
  --ink: #14201a;
  --ink-2: #566458;
  --ink-3: #7b8a7d;
  --line: #d3dbd0;
  --line-soft: #e3e9df;
  --accent: #2e6f4e;
  --accent-ink: #fff;
  --accent-dim: #e1ede4;
  --gold: #a97a05;
  --gold-dim: #f5ecd2;
  --danger: #a33b12;
  --danger-dim: #fbe9e2;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 32, 26, 0.06), 0 8px 24px -16px rgba(20, 32, 26, 0.35);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1613;
    --surface: #16201b;
    --sunken: #121a16;
    --ink: #e3eae2;
    --ink-2: #9fb0a2;
    --ink-3: #7c8d80;
    --line: #2a3830;
    --line-soft: #212e27;
    --accent: #6fc08d;
    --accent-ink: #0f1613;
    --accent-dim: #1a2c22;
    --gold: #ddb44a;
    --gold-dim: #2a2415;
    --danger: #e08256;
    --danger-dim: #2c1a13;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px -18px rgba(0, 0, 0, 0.8);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 60rem; margin: 0 auto; padding: 0 1rem 5rem; }

header.top {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
header.top .inner {
  max-width: 60rem; margin: 0 auto; padding: 0.8rem 1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
header.top h1 { font-size: 1.05rem; margin: 0; letter-spacing: -0.01em; }
header.top .who { margin-left: auto; font-size: 0.82rem; color: var(--ink-3); }
header.top nav { display: flex; gap: 0.4rem; }
header.top nav a {
  font-size: 0.82rem; text-decoration: none; color: var(--ink-2);
  padding: 0.3rem 0.6rem; border-radius: 999px; border: 1px solid transparent;
}
header.top nav a[aria-current="page"] { background: var(--accent-dim); color: var(--accent); border-color: var(--line-soft); }

h2 { font-size: 1.1rem; margin: 2rem 0 0.75rem; letter-spacing: -0.01em; }
h2:first-of-type { margin-top: 1.5rem; }
p.hint { color: var(--ink-3); font-size: 0.86rem; margin: 0.25rem 0 1rem; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem;
}

label.field { display: block; margin-bottom: 0.85rem; }
label.field > span {
  display: block; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--ink-3); margin-bottom: 0.3rem;
}
input[type="text"], input[type="email"], input[type="date"], select, textarea {
  width: 100%; padding: 0.55rem 0.65rem; font: inherit; font-size: 0.95rem;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 6px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 12rem; }

button {
  font: inherit; font-size: 0.92rem; font-weight: 500; cursor: pointer;
  padding: 0.55rem 1rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
button:hover:not(:disabled) { border-color: var(--ink-3); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { background: var(--danger-dim); border-color: var(--danger); color: var(--danger); }
button.small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.drop {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 2.5rem 1rem; text-align: center; background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-dim); }
.drop strong { display: block; font-size: 1rem; margin-bottom: 0.3rem; }
.drop span { color: var(--ink-3); font-size: 0.86rem; }

.queue { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.4rem; }
.queue li {
  display: grid; grid-template-columns: 3rem 1fr auto; gap: 0.75rem; align-items: center;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 6px; padding: 0.5rem;
}
.queue img { width: 3rem; height: 3rem; object-fit: cover; border-radius: 4px; background: var(--sunken); }
.queue .name { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .sub { font-size: 0.75rem; color: var(--ink-3); }
.queue .state { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.state.waiting { color: var(--ink-3); }
.state.working { color: var(--gold); }
.state.done { color: var(--accent); }
.state.failed, .state.duplicate { color: var(--danger); }

.grid { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); }
.tile {
  position: relative; background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 6px; overflow: hidden; cursor: pointer; padding: 0;
}
.tile img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--sunken); }
.tile figcaption { padding: 0.4rem 0.5rem; font-size: 0.72rem; color: var(--ink-3); text-align: left; }
.tile.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile .check {
  position: absolute; top: 0.4rem; left: 0.4rem; width: 1.3rem; height: 1.3rem;
  border-radius: 4px; background: rgba(255, 255, 255, 0.85); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 0.8rem; color: var(--accent);
}
.tile.selected .check { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th {
  text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--ink-3); font-weight: 500; padding: 0 0.75rem 0.4rem 0; border-bottom: 1px solid var(--line);
}
td { padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.scroll { overflow-x: auto; }

.note {
  border-left: 3px solid var(--gold); background: var(--gold-dim);
  padding: 0.7rem 0.9rem; border-radius: 0 6px 6px 0; font-size: 0.88rem; margin-bottom: 1rem;
}
.pill {
  display: inline-block; font-size: 0.7rem; padding: 0.12rem 0.45rem;
  border-radius: 999px; background: var(--sunken); color: var(--ink-2);
}
.pill.pending { background: var(--gold-dim); color: var(--gold); }
.pill.approved { background: var(--accent-dim); color: var(--accent); }
.pill.rejected, .pill.hidden { background: var(--danger-dim); color: var(--danger); }

.sticky-bar {
  position: sticky; bottom: 0; z-index: 10; margin-top: 1rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.6rem 0.8rem; box-shadow: var(--shadow);
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
}
.sticky-bar .count { font-size: 0.85rem; color: var(--ink-2); margin-right: auto; }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 0.6rem 1rem;
  border-radius: 999px; font-size: 0.88rem; box-shadow: var(--shadow); z-index: 100;
}
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  color: var(--ink); max-width: min(92vw, 46rem); padding: 0;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog .body { padding: 1rem; }
dialog img { display: block; max-width: 100%; max-height: 60vh; margin: 0 auto; border-radius: 6px; }
.empty { color: var(--ink-3); font-size: 0.9rem; padding: 2rem 0; text-align: center; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
