:root {
  --bg: #fdfaf6;
  --fg: #2b2622;
  --muted: #7a7068;
  --accent: #c2603a;
  --border: #e6ddd3;
  --error-bg: #fbe9e4;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1a18;
    --fg: #eee7e0;
    --muted: #a59a90;
    --accent: #e98a62;
    --border: #3a342f;
    --error-bg: #4a2a20;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
header { padding: 16px; border-bottom: 1px solid var(--border); }
.brand { color: var(--accent); font-weight: 700; text-decoration: none; font-size: 1.2rem; }
main { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; }
a { color: var(--accent); }

form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
label { display: grid; gap: 4px; font-weight: 600; }
input, textarea, button { font: inherit; }
input, textarea { font-weight: 400; }
input[type=email], input[type=text], textarea {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  width: 100%;
}
button {
  justify-self: start;
  padding: 10px 20px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.req { color: var(--accent); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.error { background: var(--error-bg); padding: 10px 12px; border-radius: 6px; }

.who { color: var(--muted); font-size: 0.9rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.status { font-size: 0.85rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); }
.photo { max-width: 100%; border-radius: 8px; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
dt { color: var(--muted); }
dd { margin: 0; }
.notes { white-space: pre-wrap; }

/* --- admin --- */
:root { --ok: #2f7d4f; --warn: #b5462a; --muted-bg: rgba(127,127,127,0.08); }
@media (prefers-color-scheme: dark) { :root { --ok: #6cc28f; --warn: #f08a6c; } }

main:has(.adminnav) { max-width: 960px; }
.adminnav { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.adminnav .who { margin-left: auto; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.saved { background: var(--muted-bg); padding: 10px 12px; border-radius: 6px; color: var(--ok); }
h1 .status { vertical-align: middle; font-size: 0.9rem; }
.status-accepted { border-color: var(--ok); color: var(--ok); }
.status-declined { color: var(--muted); }
.status-completed { background: var(--muted-bg); }
.status-pending { border-color: var(--accent); color: var(--accent); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); text-transform: capitalize; border-bottom: 2px solid transparent; }
.tabs a[aria-current] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.count { font-size: 0.8rem; background: var(--muted-bg); border-radius: 999px; padding: 0 7px; }

.queue { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.card { display: flex; gap: 12px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: inherit; }
.card:hover { border-color: var(--accent); }
.card img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; flex: none; }
.card-body { display: grid; gap: 2px; align-content: center; min-width: 0; }
.card-body .muted { font-size: 0.9rem; overflow-wrap: anywhere; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 0.8rem; padding: 1px 8px; border-radius: 999px; background: var(--muted-bg); }
.chip.ok { color: var(--ok); }
.chip.late { color: var(--warn); font-weight: 600; }

.review-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 700px) { .review-grid { grid-template-columns: 1fr; } }
.photo-panel { margin: 0; }
.photo-panel figcaption { font-size: 0.9rem; margin-top: 6px; }
dd { overflow-wrap: anywhere; }
form.review { margin: 24px 0; padding: 16px; border: 1px solid var(--border); border-radius: 8px; }
form.review h2 { margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
legend { font-weight: 600; margin-bottom: 4px; }
label.inline { display: flex; gap: 8px; align-items: center; font-weight: 400; }
label.cap { text-transform: capitalize; }
label .muted { font-weight: 400; }
input[type=date] { padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: inherit; justify-self: start; }
.timeline { list-style: none; padding: 0; display: grid; gap: 10px; }
.timeline li { display: grid; gap: 2px; padding-left: 12px; border-left: 2px solid var(--border); }
.timeline .muted { font-size: 0.85rem; }
.timeline .ev-note { border-left-color: var(--accent); }
.timeline .ev-note .ev-text { white-space: pre-wrap; }
.timeline .ev-change .ev-text { color: var(--muted); }

.monthnav { display: flex; gap: 16px; align-items: baseline; margin-bottom: 12px; }
.calendar { table-layout: fixed; width: 100%; }
.calendar th { font-size: 0.8rem; color: var(--muted); padding: 4px; }
.calendar td { vertical-align: top; height: 88px; padding: 4px; border: 1px solid var(--border); }
.calendar td.out { background: var(--muted-bg); color: var(--muted); }
.calendar td.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.daynum { display: block; font-size: 0.8rem; }
.calendar .ev { display: block; font-size: 0.8rem; margin-top: 2px; padding: 1px 4px; border-radius: 4px; background: var(--muted-bg);
  border-left: 3px solid currentColor; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) {
  .calendar td { height: 52px; padding: 2px; }
  .calendar .ev { font-size: 0; width: 8px; height: 8px; padding: 0; border: 0; border-radius: 50%; background: currentColor; display: inline-block; margin-right: 2px; }
}

/* --- messages --- */
.thread { list-style: none; padding: 0; display: grid; gap: 10px; margin: 0 0 16px; }
.msg { display: grid; gap: 4px; padding: 10px 12px; border-radius: 10px; max-width: 85%; border: 1px solid var(--border); }
.msg .muted { font-size: 0.8rem; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-admin { justify-self: start; background: var(--muted-bg); }
.msg-requester { justify-self: end; border-color: var(--accent); }
.emails { margin: 0 0 16px; }
.emails ul { margin: 6px 0; padding-left: 20px; }
form.message { display: grid; gap: 8px; }
.hint { font-size: 0.85rem; margin: 0; }
code.link { overflow-wrap: anywhere; user-select: all; }
.mine { display: flex; gap: 12px; align-items: center; }
.mine img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }

/* --- admin-entered commissions --- */
.nophoto { width: 72px; height: 72px; flex: none; border-radius: 6px; background: var(--muted-bg);
  display: grid; place-items: center; font-size: 0.75rem; color: var(--muted); text-align: center; }
.nophoto-panel { border: 1px dashed var(--border); border-radius: 8px; display: grid; place-items: center; min-height: 160px; }

/* --- edit details --- */
.with-action { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.with-action .action { font-size: 0.9rem; font-weight: 400; }
.photo-edit { display: flex; gap: 12px; align-items: center; }
.photo-edit img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; flex: none; }
.photo-edit label { flex: 1; min-width: 0; }

/* --- roles / kept photos --- */
.hidden-card { border-style: dashed; color: var(--muted); }
.previous { margin-top: 10px; font-size: 0.9rem; }
.previous ul { list-style: none; padding: 0; display: grid; gap: 8px; margin: 8px 0 0; }
.previous li { display: flex; gap: 10px; align-items: center; }
.previous img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }

/* --- photo editor --- */
.editor { margin: 16px 0; }
.editor img, .editor canvas { display: block; max-width: 100%; border-radius: 8px; }
.editor canvas { touch-action: none; cursor: crosshair; background: var(--muted-bg); }
[hidden] { display: none !important; }
.tool-row { display: flex; gap: 8px; flex-wrap: wrap; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.crop-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.crop-fields label { font-weight: 400; }
.crop-fields input { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: inherit; }
select { font: inherit; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: inherit; justify-self: start; }
@media (max-width: 480px) { .crop-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* --- requester page --- */
.welcome { background: var(--muted-bg); border: 1px solid var(--accent); border-radius: 8px; padding: 4px 16px; margin-bottom: 16px; }
.status-card { margin-bottom: 16px; }
.status-card .status { margin-right: 6px; }

/* --- pickup spots --- */
a.button { display: inline-block; padding: 10px 20px; border-radius: 6px; font-weight: 600; text-decoration: none; }
a.button.secondary { border: 1px solid var(--accent); color: var(--accent); }
.spot-map { display: block; margin: 8px 0; }
.pickup-card { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; padding: 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; }
.pickup-card img { width: 100%; max-width: 320px; border-radius: 6px; }
.pickup-card > div { flex: 1; min-width: 200px; }
.pickup-card p { margin: 4px 0; }
.requester-pickup h2 { margin-top: 0; }
.pickup-form { display: grid; gap: 12px; }
input[type=datetime-local] { padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: inherit; justify-self: start; font: inherit; }
.ev-pickup { border-left-color: var(--ok); }
.maplinks a { white-space: nowrap; }

/* --- finished portrait --- */
figure.finished { margin: 0 0 12px; }
figure.finished img { max-width: 100%; max-height: 480px; }
.finished-reveal { margin-bottom: 16px; }
.finished-reveal img { display: block; max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
