:root {
  color-scheme: light;
  --ink: #20242b;
  --muted: #667085;
  --line: #d7dce3;
  --surface: #fff;
  --page: #f5f7f9;
  --accent: #176b5b;
  --accent-soft: #e8f3f0;
  --danger: #b42318;
  --danger-soft: #fff0ee;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Noto Sans SC", sans-serif; }
main { width: min(720px, 100%); margin: 0 auto; padding: 20px 16px 0; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
h1 { margin: 0; font-size: 24px; letter-spacing: 0; }
h2 { margin: 0 0 14px; font-size: 18px; letter-spacing: 0; }
.page-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 16px; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 7px; font-weight: 600; }
input, select, textarea, button { min-height: 48px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
input, select, textarea { width: 100%; padding: 10px 12px; background: #fff; }
button { padding: 9px 16px; background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 650; cursor: pointer; }
button.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
button.danger { background: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 3px solid #86b9ff; outline-offset: 2px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.segmented label { display: block; }
.segmented input { position: absolute; width: 1px; height: 1px; min-height: 0; margin: -1px; padding: 0; opacity: 0; overflow: hidden; pointer-events: none; }
.segmented span { display: grid; place-items: center; min-height: 48px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.segmented input:checked + span { color: #fff; background: var(--accent); border-color: var(--accent); }
.upload-workspace {
  display: grid;
  grid-template-areas:
    "editor"
    "preview"
    "fields"
    "submit"
    "pending";
  gap: 0;
}
.upload-editor { grid-area: editor; }
.upload-fields { grid-area: fields; }
.upload-aside { display: contents; }
.preview-panel { grid-area: preview; }
.pending-panel { grid-area: pending; }
.image-picker { position: relative; min-height: 92px; align-content: center; padding: 16px; border: 1px dashed #8d98a8; border-radius: 6px; background: #fafbfc; text-align: center; cursor: pointer; }
.image-picker span { color: var(--accent); }
.image-picker small { color: var(--muted); font-size: 13px; font-weight: 400; }
.image-picker input { position: absolute; width: 1px; height: 1px; min-height: 0; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.image-picker:focus-within { outline: 3px solid #86b9ff; outline-offset: 2px; }
.preview-stage { display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #eef1f4; }
.preview-stage p { max-width: 220px; margin: 0; color: var(--muted); text-align: center; }
.preview { width: 100%; height: 100%; max-height: 100%; object-fit: contain; background: #eef1f4; }
.submit-bar { grid-area: submit; display: grid; gap: 10px; position: sticky; bottom: 0; z-index: 5; margin: 0 -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgb(245 247 249 / .96); }
.submit-bar button { width: 100%; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2 { margin-bottom: 0; }
.count-badge { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700; }
.hidden { display: none !important; }
.status { min-height: 24px; color: var(--muted); }
.workflow-status { position: sticky; bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 6; margin: 10px 0 0; pointer-events: none; }
.workflow-status:not(:empty) { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: 0 5px 18px rgb(32 36 43 / .1); }
.error { color: var(--danger); }
.item { border-top: 1px solid var(--line); padding: 14px 0; }
.item:first-child { border-top: 0; }
.item p { margin: 6px 0; color: var(--muted); }
.item-rejected { margin: 8px 0; padding: 14px; border: 1px solid #f2b8b2; border-radius: 6px; background: var(--danger-soft); }
.item-rejected:first-child { border-top: 1px solid #f2b8b2; }
.item img { width: 100%; max-height: 360px; object-fit: contain; background: #eef1f4; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.manage-page .actions button, #rejected-dialog .actions button { flex: 1 1 180px; }
.empty-state { margin: 16px 0 4px; color: var(--muted); text-align: center; }
.tabs { display: flex; overflow-x: auto; gap: 6px; margin-bottom: 14px; }
.tabs button { white-space: nowrap; background: #fff; color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }
dialog { width: min(680px, calc(100% - 24px)); border: 0; border-radius: 8px; padding: 0; }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog .panel { margin: 0; }
.rejection-note { margin: 8px 0 0; padding: 10px 12px; border-radius: 6px; background: var(--danger-soft); color: var(--danger); }
.dialog-actions { position: sticky; bottom: 0; padding-top: 4px; background: var(--surface); }
progress { width: 100%; height: 12px; }
.note { color: var(--muted); font-size: 14px; }
@media (min-width: 640px) {
  main { padding-top: 32px; }
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .submit-bar { margin: 0; padding-right: 0; padding-left: 0; background: transparent; border-top: 0; }
}
@media (min-width: 900px) and (orientation: landscape) {
  main.manage-page { width: min(1180px, 100%); padding-right: 24px; padding-left: 24px; }
  .upload-workspace {
    grid-template-areas:
      "editor aside"
      "fields aside"
      "submit aside";
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.82fr);
    align-items: start;
    align-content: start;
    column-gap: 20px;
  }
  .upload-aside { display: grid; grid-area: aside; gap: 16px; position: sticky; top: 24px; }
  .upload-aside .panel { margin-bottom: 0; }
  .preview-panel, .pending-panel { grid-area: auto; }
  .pending-panel { max-height: 40vh; overflow: auto; overscroll-behavior: contain; }
  .submit-bar { position: static; margin-bottom: 16px; }
  .workflow-status { bottom: 20px; }
}
