:root {
  --bg: #f7f5f1;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b675f;
  --border: #e2ddd3;
  --accent: #1b2a22;
  --accent-text: #ffffff;
  --ok: #2e7d4f;
  --error: #b3261e;
  --error-bg: #fbebea;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 17px; line-height: 1.45; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--accent); color: var(--accent-text);
}
.topbar .brand { color: inherit; text-decoration: none; font-weight: 600; }
.topbar form { margin: 0; }
button.link { background: none; border: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

.page { max-width: 720px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: 8px 0 12px; }
h2 { font-size: 1.15rem; margin: 28px 0 10px; }
.hint { color: var(--muted); margin: 0 0 16px; }

.stack { display: grid; gap: 14px; max-width: 360px; }
label { display: grid; gap: 4px; font-weight: 500; }
input[type=text], input:not([type]), input[type=password], select {
  font: inherit; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.primary, button.primary {
  display: inline-block; font: inherit; font-weight: 600; text-align: center;
  padding: 14px 20px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-text); cursor: pointer;
}
.notice { padding: 10px 12px; border-radius: 8px; }
.notice.error { background: var(--error-bg); color: var(--error); }

.tiles { display: grid; gap: 12px; }
.tile {
  display: grid; gap: 4px; padding: 18px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); color: inherit; text-decoration: none;
}
.tile span { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin: 0 0 14px; }
.card h2 { margin-top: 0; }
.card.muted { opacity: .6; }
code { font-size: .9em; background: var(--bg); padding: 1px 4px; border-radius: 4px; }

/* Review */
.crumbs { margin: 0 0 4px; }
.crumbs a, .pager a { color: var(--accent); }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.item-head h1 { margin-bottom: 4px; }
.pager { display: flex; gap: 14px; padding-top: 12px; white-space: nowrap; }
.status { display: inline-block; font-size: .85rem; padding: 2px 10px; border-radius: 999px; background: var(--border); }
.status.s-redrafted { background: #fdf0c8; }
.status.s-needs_changes { background: var(--error-bg); color: var(--error); }
.status.s-approved { background: #e1f1e7; color: var(--ok); }
.hero { display: block; margin: 12px 0; }
.hero img { width: 100%; max-height: 70vh; object-fit: contain; background: var(--surface); border-radius: 12px; border: 1px solid var(--border); }

.photo-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-grid li { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px; }
.photo-grid li.is-main { border: 2px solid var(--accent); }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
.tag-main { position: absolute; top: 10px; left: 10px; background: var(--accent); color: var(--accent-text); font-size: .75rem; padding: 2px 8px; border-radius: 999px; }
.needs-new { color: var(--error); font-size: .85rem; margin: 6px 0 0; }
.photo-options summary, .removed summary { cursor: pointer; font-size: .9rem; color: var(--accent); padding: 6px 0 0; }
.photo-options form, .removed form { margin: 8px 0 0; display: grid; gap: 6px; }
.photo-options button, .removed button, .actions form button:not(.primary):not(.btn-ok) {
  font: inherit; font-size: .9rem; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); cursor: pointer;
}
.removed { margin-top: 12px; }

.photo-rows { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.photo-row {
  display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: start;
  background: var(--surface); border: 1px solid var(--border); border-left-width: 5px; border-radius: 10px; padding: 8px;
}
.photo-row.is-confirmed { border-left-color: var(--ok); }
.photo-row.is-main { box-shadow: inset 0 0 0 1px var(--accent); }
.photo-row .thumb img { width: 112px; height: 112px; object-fit: cover; border-radius: 6px; display: block; }
.photo-row .tag-main { position: static; }
.photo-status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 2px 0 8px; min-height: 1.4em; }
.photo-buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.photo-buttons form { margin: 0; }
.photo-buttons button, .photo-buttons summary {
  font: inherit; font-size: .95rem; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); cursor: pointer; list-style: none; display: inline-block;
}
.photo-buttons summary::-webkit-details-marker { display: none; }
.photo-buttons .btn-ok { font-weight: 600; background: #e1f1e7; color: var(--ok); border-color: #b9dcc6; }
.photo-buttons .btn-quiet { color: var(--error); }
.photo-buttons details[open] { flex-basis: 100%; order: 10; }
.photo-buttons details[open] summary { background: var(--accent); color: var(--accent-text); }
.photo-buttons details form { display: grid; gap: 6px; margin-top: 8px; }
@media (max-width: 420px) {
  .photo-row { grid-template-columns: 84px 1fr; }
  .photo-row .thumb img { width: 84px; height: 84px; }
}
textarea { font: inherit; padding: 10px; border: 1px solid var(--border); border-radius: 8px; width: 100%; }
input[type=file] { font-size: .85rem; max-width: 100%; }

.field { background: var(--surface); border: 1px solid var(--border); border-left-width: 5px; border-radius: 10px; padding: 12px 14px; margin: 0 0 10px; scroll-margin-top: 12px; }
.field.r-ok { border-left-color: var(--ok); }
.field.r-not_ok { border-left-color: var(--error); }
.field.updated { background: #fffbea; }
.field header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field h3 { margin: 0; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.field .value { margin: 6px 0 10px; font-size: 1.05rem; }
.field .note { margin: 0 0 10px; color: var(--error); }
.field-photo { width: 120px; aspect-ratio: 1; object-fit: cover; border-radius: 8px; margin: 8px 0 4px; display: block; }
.mark { font-size: .85rem; font-weight: 600; }
.mark.ok { color: var(--ok); }
.mark.bad { color: var(--error); }
.badge { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #fdf0c8; color: #6b5400; }
.badge.muted { background: var(--border); color: var(--muted); }
.choices { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.choices form { margin: 0; }
.choices details[open] { flex-basis: 100%; }
.choices details form { display: grid; gap: 8px; margin-top: 8px; }
.btn-ok, .btn-bad {
  font: inherit; font-weight: 600; padding: 10px 22px; border-radius: 10px; cursor: pointer; display: inline-block; list-style: none;
}
.btn-ok { background: #e1f1e7; color: var(--ok); border: 1px solid #b9dcc6; }
.btn-bad { background: var(--error-bg); color: var(--error); border: 1px solid #f0c4c1; }
summary.btn-bad::-webkit-details-marker { display: none; }
.actions { margin: 20px 0 40px; display: grid; gap: 10px; }
.actions form { margin: 0; }
.wide { width: 100%; }
button:disabled { opacity: .45; cursor: not-allowed; }

.item-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.item-list a {
  display: grid; grid-template-columns: 56px auto 1fr auto; align-items: center; gap: 10px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: inherit; text-decoration: none;
}
.item-list img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }
.item-list .num { font-weight: 700; font-variant-numeric: tabular-nums; }
.item-list .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.notice.ok { background: #e1f1e7; color: var(--ok); }
.wide-form { max-width: none; }
.notes { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.notes li { background: var(--surface); border: 1px solid var(--border); border-left-width: 5px; border-radius: 10px; padding: 12px 14px; }
.notes li.new { border-left-color: var(--accent); }
.notes li.done { opacity: .65; }
.notes p { margin: 0 0 8px; }
.notes .meta { font-size: .85rem; color: var(--muted); }
.notes .reply { background: var(--bg); padding: 8px 10px; border-radius: 8px; }
.notes .reply.new { background: #fdf0c8; }
.note-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.note-actions details { flex: 1 1 260px; }
.note-actions summary { cursor: pointer; color: var(--accent); padding: 8px 0; }
.note-actions button:not(.primary) { font: inherit; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; }

.list-rows { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 4px; }
.list-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 8px 10px; border-radius: 8px; background: var(--bg); }
.list-row.retired { opacity: .55; }
.list-name { font-weight: 600; }
.list-meta { color: var(--muted); font-size: .85rem; }
.list-desc { flex-basis: 100%; color: var(--muted); font-size: .85rem; }
.list-edit { margin-left: auto; }
.list-edit summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.list-edit[open] { flex-basis: 100%; display: grid; gap: 8px; padding-top: 8px; }
.sizes { padding: 0 0 8px 24px; }
.sizes .list-row { background: var(--surface); border: 1px solid var(--border); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.inline-form input { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; flex: 1 1 160px; min-width: 0; }
.inline-form button, .list-edit button { font: inherit; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.add-form { margin-top: 8px; }

.picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.picker .primary { width: 100%; }
.picker input:focus-visible + .primary { outline: 3px solid #8fb39d; outline-offset: 2px; }

.summary { font-weight: 600; margin: 16px 0 8px; }
.queue { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.queue li {
  display: grid; grid-template-columns: 48px 1fr; grid-template-areas: "img name" "img state";
  column-gap: 10px; align-items: center; padding: 8px; background: var(--surface); border-radius: 8px; border: 1px solid var(--border);
}
.queue li img { grid-area: img; width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.queue .name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .state { grid-area: state; color: var(--muted); font-size: .9rem; }
.queue .state.ok { color: var(--ok); }
.queue .state.error { color: var(--error); }

.thumbs { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
