/* SECOND CHANCE — the working side of the same paper-and-clay identity. */
:root {
  color-scheme: light;
  --paper: #f7f3ec;
  --paper-2: #efe8dd;
  --surface: #fffcf7;
  --ink: #171311;
  --ink-2: #5a524b;
  --line: #e2dad0;
  --clay: #d2502a;
  --clay-ink: #9c3416;
  --sage: #3f5b4c;
  --sage-light: #e2e8dd;
  --forest: #1d3a2d;
  --forest-2: #29503e;
  --apricot: #f3b26a;
  --rail-width: 240px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-serif: "Iowan Old Style", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); scroll-padding-top: 24px; }
body { margin: 0; color: var(--ink); font: 15px/1.6 var(--font-sans); }
body:has(dialog[open]) { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { color: inherit; }
button { cursor: pointer; }
button, a { touch-action: manipulation; }
a { color: inherit; text-underline-offset: 4px; }
img { display: block; max-width: 100%; }
button, input, select, textarea, a { outline-offset: 4px; }
:focus-visible { outline: 2px solid var(--ink); box-shadow: 0 0 0 4px var(--paper); }
button:disabled { cursor: not-allowed; opacity: .5; }
::selection { background: #dfc5b5; color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip { position: fixed; z-index: 100; top: 10px; left: 12px; padding: 12px 20px; background: var(--ink); color: var(--paper); transform: translateY(-160%); }
.skip:focus { transform: translateY(0); }

/* One quiet rail, a wide workspace, and rules instead of a wall of cards. */
/* The studio rail is the dark side of the same doorway identity used on the public site. */
.rail { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column; width: var(--rail-width); padding: 32px 20px 24px; background: var(--forest); color: #eef2ec; overflow-y: auto; }
.rail :focus-visible { outline-color: var(--apricot); box-shadow: none; }
.brand { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 12px; width: fit-content; padding: 0 4px; text-decoration: none; }
.brand-mark { position: relative; width: 24px; height: 30px; border: 2px solid currentColor; border-radius: 13px 13px 3px 3px; }
.brand-mark::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--apricot); }
.brand-word { font-size: 22px; line-height: .92; font-weight: 850; letter-spacing: -.06em; }
.brand-sub { grid-column: 1 / -1; margin-top: 14px; color: #a9bbad; font-size: 10px; font-weight: 600; letter-spacing: .06em; }
.rail-caption { margin: 48px 12px 10px; color: #a9bbad; font-size: 10px; font-weight: 650; letter-spacing: .12em; }
.rail nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; width: 100%; padding: 12px 14px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: #d5dfd6; text-align: left; font-size: 14px; font-weight: 650; }
.nav-btn span { font-size: 15px; font-weight: 400; opacity: .6; }
.nav-btn.active { background: var(--apricot); color: var(--forest); }
.nav-btn.active span { opacity: 1; }
.preview-link { display: flex; align-items: center; justify-content: space-between; min-height: 48px; margin-top: 24px; padding: 0 6px 0 16px; border: 1px solid #ffffff38; border-radius: 999px; color: #fff; font-size: 13px; font-weight: 700; text-decoration: none; }
.preview-link span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #ffffff1a; }
.rail-bottom { margin-top: auto; padding-top: 48px; color: #c3d0c6; font-size: 11px; line-height: 1.7; }
.rail-bottom small { display: block; margin-top: 8px; color: #a9bbad; font-size: 10px; line-height: 1.8; }
.demo-dot { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--apricot); vertical-align: 1px; }
#workspace { min-width: 0; margin-left: var(--rail-width); padding: 0 clamp(24px, 3.4vw, 64px); }
.workspace-top { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 86px; border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: 11px; }
.workspace-top > span { letter-spacing: .045em; }
.workspace-top b { padding: 0 12px; color: var(--clay-ink); font-weight: 400; }
.workspace-top a { display: flex; align-items: center; min-height: 44px; text-decoration: none; }
.view { max-width: 1420px; margin-inline: auto; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; padding: 50px 0 35px; }
.eyebrow { margin: 0 0 16px; color: var(--clay-ink); font-size: 10px; font-weight: 650; letter-spacing: .16em; line-height: 1.5; }
h1 { margin: 0; font-size: clamp(30px, 3.35vw, 54px); line-height: 1.25; font-weight: 750; letter-spacing: -.065em; word-break: keep-all; text-wrap: balance; }
.page-heading h1 + p { max-width: 52ch; margin: 18px 0 0; color: var(--ink-2); font-size: 13px; word-break: keep-all; }
.page-heading > button { flex: 0 0 auto; margin-bottom: 4px; }
.primary, .secondary, .icon-btn, .edit-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; border: 1px solid transparent; border-radius: 999px; text-decoration: none; font-size: 13px; font-weight: 650; line-height: 1.4; }
.primary { padding: 13px 24px; background: var(--clay-ink); color: #fff; font-weight: 750; box-shadow: 0 12px 24px -14px #9c3416aa; }
.secondary { padding: 12px 22px; border-color: #bfb2a5; background: transparent; color: var(--ink); }
.icon-btn { width: 46px; flex: 0 0 46px; padding: 0; border-color: var(--line); background: transparent; font-size: 27px; font-weight: 400; }
.edit-btn { min-width: 76px; padding: 10px 16px; border-color: var(--forest); background: transparent; color: var(--forest); font-weight: 700; white-space: nowrap; }

/* A single ruled statistics band, with room for the numbers to breathe. */
.stats { display: flex; margin: 0 0 36px; padding: 26px 0 28px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.stats > div { display: flex; flex: 1 1 0; flex-direction: column; gap: 8px; min-width: 0; padding: 0 28px; border-left: 1px solid var(--line); }
.stats > div:first-child { padding-left: 0; border-left: 0; }
.stats > div:last-child { padding-right: 0; }
.stats span { color: var(--ink-2); font-size: 12px; }
.stats strong { font-size: clamp(32px, 3.2vw, 46px); line-height: 1.1; font-weight: 450; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.stats > div:nth-child(2) strong { color: var(--sage); }
.list-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
label { display: flex; flex-direction: column; gap: 8px; min-width: 0; color: var(--ink-2); font-size: 12px; font-weight: 600; line-height: 1.5; }
input:not([type="checkbox"]):not([type="hidden"]), select, textarea { display: block; min-width: 0; width: 100%; min-height: 46px; padding: 11px 12px; border: 1px solid #bfb2a5; border-radius: 3px; background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 400; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #74675d; opacity: 1; }
textarea { resize: vertical; min-height: 100px; }
select { padding-right: 28px; }
input:focus, textarea:focus, select:focus { border-color: var(--ink); }
.search-label { flex: 0 1 300px; }
.list-toolbar > label:not(.search-label) { flex: 0 0 156px; }
.list-toolbar > p { margin: 0 0 12px auto; color: var(--ink-2); font-size: 11px; }
.animal-table-wrap { width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 14px 14px; border-bottom: 1px solid #bfb2a5; color: var(--ink-2); font-size: 11px; font-weight: 500; text-align: left; white-space: nowrap; }
td { padding: 19px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; text-align: right; }
td small { display: block; margin-top: 3px; color: var(--ink-2); font-size: 11px; }
.table-animal { display: flex; align-items: center; gap: 16px; min-width: 150px; }
.table-animal img { flex: 0 0 64px; width: 64px; height: 76px; border-radius: 32px 32px 8px 8px; background: var(--paper-2); object-fit: cover; }
.table-animal strong { display: block; font-size: 19px; font-weight: 750; letter-spacing: -.045em; }
.table-animal small { letter-spacing: .02em; }
.status, .visibility { display: inline-flex; align-items: center; gap: 6px; min-height: 27px; padding: 4px 8px; border-radius: 3px; font-size: 11px; font-weight: 550; line-height: 1.5; white-space: nowrap; }
.status { background: #e3e9df; color: #315541; }
.status.adopted { background: #e9e4df; color: #5e5852; }
.visibility { padding-left: 0; }
.visibility::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.visibility.published { color: var(--sage); }
.visibility.draft { color: #805418; }
.visibility.hidden { color: #655c54; }
.date-cell { color: var(--ink-2); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { padding: 64px 20px !important; color: var(--ink-2); text-align: center !important; font-size: 13px; }
.admin-footer { max-width: 1420px; margin: 64px auto 0; padding: 22px 0 30px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 10px; line-height: 1.8; }

/* First-screen editing is a simple split between words and one large photo. */
.hero-editor { display: grid; grid-template-columns: minmax(250px, .8fr) minmax(280px, 1.2fr); align-items: start; gap: clamp(28px, 4vw, 64px); padding-top: 12px; }
.form-card { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.form-card > .primary { align-self: flex-start; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
#hero-status:empty { display: none; }
#hero-status.error, #editor-status.error { color: var(--clay-ink); font-weight: 650; }
.hero-preview { position: sticky; top: 24px; min-width: 0; margin: 0; }
.hero-preview img { width: 100%; height: min(52vw, 560px); min-height: 280px; background: var(--paper-2); object-fit: cover; }
.hero-preview figcaption { margin-top: 12px; color: var(--ink-2); font-size: 11px; }
.fine { margin: 0; color: var(--ink-2); font-size: 11px; font-weight: 400; line-height: 1.75; overflow-wrap: anywhere; }
.upload-box { gap: 8px; padding: 16px; border: 1px dashed #b7a899; border-radius: 4px; background: var(--paper); color: var(--ink); }
.upload-box > span { color: var(--ink-2); font-size: 10px; font-weight: 400; }
.upload-box:focus-within { border-color: var(--ink); }
.upload-box input[type="file"] { min-height: 44px; padding: 0; border: 0; background: transparent; font-size: 11px; overflow: hidden; }
input[type="file"]::file-selector-button { min-height: 44px; margin-right: 10px; padding: 10px 12px; border: 1px solid #bfb2a5; border-radius: 3px; background: var(--surface); color: var(--ink); font: 600 11px var(--font-sans); cursor: pointer; }
.history-list { margin: 8px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--ink); }
.history-list li { display: flex; align-items: flex-start; gap: 22px; padding: 24px 0; border-bottom: 1px solid var(--line); }
.history-list li > span { display: grid; flex: 0 0 30px; width: 30px; height: 30px; place-items: center; border: 1px solid #b7c2b4; border-radius: 50%; color: var(--sage); font-size: 12px; }
.history-list li > div { display: flex; flex: 1; align-items: baseline; justify-content: space-between; gap: 24px; min-width: 0; }
.history-list strong { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.history-list time { flex: 0 0 auto; color: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; }

/* Native dialog supplies modal semantics and escape handling; CSS makes it a drawer. */
:is(#animal-editor, #story-editor) { position: fixed; inset: 0 0 0 auto; width: min(860px, calc(100vw - 32px)); max-width: none; height: 100vh; height: 100dvh; max-height: none; margin: 0; padding: 0; overflow: hidden; border: 0; border-left: 1px solid var(--line); background: var(--paper); color: var(--ink); box-shadow: -20px 0 70px -30px rgb(23 19 17 / 28%); }
:is(#animal-editor, #story-editor)::backdrop { background: rgb(23 19 17 / 28%); }
:is(#animal-form, #story-form) { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; min-height: 0; }
.editor-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 28px 32px 24px; border-bottom: 1px solid var(--line); }
.editor-header .eyebrow { margin-bottom: 8px; font-size: 9px; }
.editor-header h2 { margin: 0; font-size: 30px; font-weight: 650; letter-spacing: -.055em; line-height: 1.2; overflow-wrap: anywhere; }
.editor-body { display: grid; grid-template-columns: minmax(180px, .7fr) minmax(0, 1.3fr); align-items: start; gap: 28px; min-height: 0; padding: 28px 32px 40px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.editor-photo { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.editor-photo > img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: var(--paper-2); border-radius: 100px 100px 4px 4px; }
.editor-photo .upload-box { padding: 12px; }
.editor-fields { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.checkbox-label { flex-direction: row; align-items: center; gap: 10px; min-height: 48px; padding: 12px; background: var(--paper-2); border-radius: 3px; color: var(--ink); cursor: pointer; }
.checkbox-label input { flex: 0 0 20px; width: 20px; height: 20px; margin: 0; accent-color: var(--sage); }
.editor-actions { display: flex; align-items: center; gap: 12px; padding: 20px 32px max(20px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
:is(#editor-status, #story-status) { flex: 1 1 auto; min-width: 0; color: var(--ink-2); font-size: 11px; line-height: 1.6; }
.editor-actions > button { flex: 0 0 auto; }

/* Shared hooks for the 1–6 image picker and its keyboard-operable order buttons. */
.gallery-picker { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding-top: 8px; }
.gallery-picker > p, .gallery-picker > small { margin: 0; color: var(--ink-2); font-size: 11px; line-height: 1.7; }
.gallery-thumbs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-width: 0; }
.photo-slot { position: relative; min-width: 0; margin: 0; padding: 0 0 10px; border-bottom: 1px solid var(--line); }
.photo-slot > img, .photo-slot > button > img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--paper-2); border-radius: 3px; }
.photo-slot > span, .photo-slot > figcaption { display: block; padding: 6px 0; color: var(--ink-2); font-size: 10px; }
.photo-slot button { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 8px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); color: var(--ink); font-size: 11px; line-height: 1.3; }
.photo-slot > div { display: flex; flex-wrap: wrap; gap: 4px; }
.photo-slot > label { margin-top: 8px; font-size: 10px; }
.photo-slot input { min-height: 44px; }
.photo-slot [aria-pressed="true"], .photo-slot.is-primary { border-color: var(--sage); }
.photo-slot [data-remove] { color: var(--clay-ink); }
.photo-slot [data-photo-action="remove"] { color: var(--clay-ink); }
.gallery-picker > .secondary { width: 100%; }

#toast { position: fixed; z-index: 100; right: 28px; bottom: max(24px, env(safe-area-inset-bottom)); width: max-content; max-width: min(440px, calc(100vw - 40px)); padding: 16px 20px; border: 1px solid #5a7162; border-radius: 4px; background: var(--sage); color: #fff; font-size: 13px; line-height: 1.6; opacity: 0; visibility: hidden; transform: translateY(10px); pointer-events: none; transition: opacity 160ms ease, transform 160ms ease, visibility 160ms; }
#toast.show { opacity: 1; visibility: visible; transform: translateY(0); }
#toast.error { background: var(--clay-ink); border-color: var(--clay-ink); }

@media (hover: hover) {
  .nav-btn:not(.active):hover, .preview-link:hover { background: #ffffff14; color: #fff; }
  .edit-btn:hover { background: var(--forest); border-color: var(--forest); color: #fff; }
  .guide-action:hover { background: var(--forest-2); }
  .primary:hover { background: #7d2b13; }
  .secondary:hover, .icon-btn:hover, .photo-slot button:hover { background: var(--paper-2); border-color: #9d8e80; }
  tbody tr:hover { background: #f0ebe2; }
  .workspace-top a:hover { text-decoration: underline; }
}

@media (max-width: 1100px) {
  #workspace { padding-inline: 28px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 24px; }
  .stats > div { padding-inline: 18px; }
  th, td { padding-inline: 9px; }
  .table-animal { gap: 10px; min-width: 132px; }
  .table-animal img { flex-basis: 48px; width: 48px; height: 58px; }
  .date-cell { white-space: normal; }
  .list-toolbar > p { flex-basis: 100%; margin: 0; }
}

@media (max-width: 820px) {
  .rail { position: relative; width: 100%; padding: 16px 24px 0; overflow: visible; }
  .brand-word { font-size: 18px; }
  .brand-mark { width: 20px; height: 26px; }
  .brand-sub { display: none; }
  .rail-caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; }
  .rail nav { flex-direction: row; gap: 6px; margin: 16px -24px 0; padding: 0 24px 14px; overflow-x: auto; scrollbar-width: none; }
  .nav-btn { justify-content: center; flex: 0 0 auto; width: auto; min-height: 44px; padding: 10px 16px; border-color: #ffffff2e; border-radius: 999px; font-size: 13px; }
  .nav-btn span { display: none; }
  .preview-link { position: absolute; top: 12px; right: 20px; min-height: 44px; margin: 0; padding: 0 5px 0 14px; gap: 8px; font-size: 12px; }
  .preview-link span { width: 32px; height: 32px; }
  .rail-bottom { display: none; }
  #workspace { margin-left: 0; padding-inline: 24px; }
  .workspace-top { min-height: 60px; font-size: 10px; }
  .page-heading { padding-top: 36px; }
  h1 { font-size: clamp(30px, 5.5vw, 44px); }
  .hero-editor { grid-template-columns: minmax(0, 1fr); }
  .hero-preview { position: static; }
  .hero-preview img { height: 440px; }
  .admin-footer { margin-top: 42px; }
}

@media (max-width: 600px) {
  html { scroll-padding-top: 12px; }
  .rail { padding-inline: 20px; }
  .preview-link { right: 20px; font-size: 11px; }
  #workspace { padding-inline: 20px; }
  .workspace-top { min-height: 55px; }
  .workspace-top b { padding-inline: 8px; }
  .workspace-top > a { font-size: 0; }
  .workspace-top > a::after { content: "사이트 ↗"; font-size: 10px; }
  .page-heading { gap: 24px; padding: 32px 0 28px; }
  h1 { font-size: clamp(27px, 7.7vw, 40px); line-height: 1.3; }
  .eyebrow { font-size: 9px; margin-bottom: 12px; }
  .page-heading h1 + p { margin-top: 14px; font-size: 12px; }
  .page-heading > button { width: 100%; margin: 0; min-height: 48px; }
  .stats { padding: 22px 0; margin-bottom: 28px; }
  .stats > div { gap: 10px; padding-inline: 10px; }
  .stats span { font-size: 10px; white-space: nowrap; letter-spacing: -.04em; }
  .stats strong { font-size: 32px; }
  .list-toolbar { gap: 12px; margin-bottom: 10px; }
  .search-label { flex: 1 1 0; }
  .list-toolbar > label:not(.search-label) { flex: 0 0 120px; }
  .list-toolbar > p { margin-top: 2px; font-size: 10px; }
  input:not([type="checkbox"]):not([type="hidden"]), textarea, select { font-size: 16px; }
  .animal-table-wrap { overflow: visible; }
  table { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  tbody { display: block; }
  tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 12px 18px; padding: 24px 0; border-bottom: 1px solid var(--line); }
  td { min-width: 0; padding: 0; border: 0; font-size: 12px; }
  td:first-child { grid-column: 1; grid-row: 1; }
  td:nth-child(2) { grid-column: 1; grid-row: 2; }
  td:nth-child(3) { grid-column: 2; grid-row: 2; }
  td:nth-child(4) { grid-column: 1; grid-row: 3; }
  td:nth-child(5) { grid-column: 2; grid-row: 3; }
  td:last-child:not([colspan]) { grid-column: 2; grid-row: 1; align-self: center; justify-self: end; }
  td:nth-child(2)::before, td:nth-child(3)::before, td:nth-child(4)::before, td:nth-child(5)::before { display: block; margin-bottom: 5px; color: var(--ink-2); font-size: 10px; font-weight: 400; }
  td:nth-child(2)::before { content: "기본정보"; }
  td:nth-child(3)::before { content: "입양 상태"; }
  td:nth-child(4)::before { content: "공개"; }
  td:nth-child(5)::before { content: "최근 수정"; }
  td[colspan] { grid-column: 1 / -1; }
  .table-animal { min-width: 0; gap: 12px; }
  .table-animal img { flex-basis: 48px; width: 48px; height: 58px; }
  .table-animal strong { font-size: 18px; overflow-wrap: anywhere; }
  .table-animal small { font-size: 10px; overflow-wrap: anywhere; }
  .date-cell { align-self: start; font-size: 11px; }
  .hero-editor { gap: 32px; }
  .hero-preview img { height: 340px; min-height: 0; }
  .form-card > .primary { align-self: stretch; min-height: 48px; }
  .hero-actions > button { flex: 1 1 auto; min-height: 48px; }
  .history-list li { gap: 14px; }
  .history-list li > div { flex-direction: column; gap: 6px; }
  .history-list strong { font-size: 13px; }
  :is(#animal-editor, #story-editor) { width: 100%; border-left: 0; }
  .editor-header { padding: 20px; }
  .editor-header h2 { font-size: 27px; }
  .editor-body { grid-template-columns: minmax(0, 1fr); gap: 28px; padding: 24px 20px 32px; scrollbar-gutter: auto; }
  .editor-photo > img { max-height: 260px; aspect-ratio: 3 / 2; border-radius: 4px; object-position: 50% 40%; }
  .editor-fields { gap: 20px; }
  .two-col { gap: 12px; }
  .editor-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px 20px max(16px, env(safe-area-inset-bottom)); }
  :is(#editor-status, #story-status) { grid-column: 1 / -1; font-size: 10px; }
  .editor-actions > button { min-height: 48px; }
  .gallery-thumbs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #toast { right: 20px; bottom: max(20px, env(safe-area-inset-bottom)); width: calc(100vw - 40px); font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
  #toast { transform: none; }
}

@media (forced-colors: active) {
  .primary, .nav-btn.active, .status, .visibility { border: 1px solid ButtonText; }
  :focus-visible { outline: 2px solid Highlight; box-shadow: none; }
  .demo-dot, .visibility::before { background: CanvasText; }
  #toast { border: 1px solid CanvasText; }
}

/* A small, repeatable workflow for volunteer operators. */
.operator-guide { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:24px; margin:0 0 34px; padding:22px 0; list-style:none; border-top:1px solid var(--line); }
.operator-guide li { display:flex; gap:12px; min-width:0; }
.operator-guide li > span { color:var(--clay-ink); font:italic 22px/1.2 var(--font-serif); }
.operator-guide strong { display:block; font-size:13px; font-weight:650; }
.operator-guide p { margin:5px 0 0; color:var(--ink-2); font-size:11px; word-break:keep-all; }
.record-section { display:flex; flex-direction:column; gap:20px; margin:2px 0; padding:20px 0; border:0; border-block:1px solid var(--line); }
.record-section legend { padding:0 12px 0 0; font-size:14px; font-weight:700; color:var(--ink); }
.translation-fields { display:block; border:1px solid var(--line); padding:0 14px 14px; border-radius:4px; }
.translation-fields:not([open]) { padding-bottom:0; }
.translation-fields summary, .animal-transitions summary { padding:14px 0; color:var(--ink-2); font-size:12px; font-weight:600; cursor:pointer; }
.translation-fields label + label { margin-top:16px; }
.animal-transitions { border-top:1px solid var(--line); }
#animal-change-dates { display:grid; gap:8px; margin:0 0 18px; }
#animal-change-dates > div { display:flex; justify-content:space-between; gap:16px; font-size:11px; }
#animal-change-dates dt { color:var(--ink-2); }
#animal-change-dates dd { margin:0; font-variant-numeric:tabular-nums; }
#animal-state-history { margin:0 0 12px; padding:0; list-style:none; }
#animal-state-history li { padding:10px 0; border-top:1px solid var(--line); font-size:11px; }
#animal-state-history time { display:block; margin-top:4px; color:var(--ink-2); }
.local-note { margin:24px 0 0; color:var(--ink-2); font-size:11px; line-height:1.8; }
.story-list { border-top:1px solid var(--ink); }
.story-row { display:grid; grid-template-columns:110px minmax(0,1fr) auto; align-items:center; gap:24px; padding:26px 0; border-bottom:1px solid var(--line); }
.story-row > img { width:110px; aspect-ratio:1; border-radius:3px; object-fit:cover; background:var(--paper-2); }
.story-category { color:var(--clay-ink); font-size:10px; font-weight:600; }
.story-row h2 { margin:5px 0 8px; font-size:20px; font-weight:650; letter-spacing:-.04em; word-break:keep-all; overflow-wrap:anywhere; }
.story-row p { max-width:70ch; margin:0; color:var(--ink-2); font-size:12px; overflow-wrap:anywhere; }
.story-row-meta { display:flex; flex-wrap:wrap; align-items:center; gap:12px; margin-top:12px; }
.story-row-meta time { color:var(--ink-2); font-size:10px; font-variant-numeric:tabular-nums; }
.story-editor-body { display:grid; grid-template-columns:minmax(160px,.65fr) minmax(0,1.35fr); align-items:start; gap:28px; min-height:0; padding:28px 32px 40px; overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable; }
.story-editor-photo { display:grid; gap:18px; min-width:0; }
#story-preview { width:100%; aspect-ratio:1; object-fit:cover; background:var(--paper-2); border-radius:3px; }
#story-status.error { color:var(--clay-ink); font-weight:650; }
@media(max-width:820px){ .operator-guide { gap:18px; } }
@media(max-width:600px){
 .operator-guide { grid-template-columns:1fr; gap:18px; padding-block:22px; }
 .operator-guide li { gap:16px; }
 .operator-guide li > span { min-width:24px; }
 .story-row { grid-template-columns:74px minmax(0,1fr); gap:16px; }
 .story-row > img { width:74px; align-self:start; }
 .story-row h2 { font-size:18px; line-height:1.4; }
 .story-row > button { grid-column:2; justify-self:start; }
 .story-row-meta { gap:6px 12px; }
 .story-editor-body { grid-template-columns:1fr; gap:28px; padding:24px 20px 32px; scrollbar-gutter:auto; }
 #story-preview { max-height:220px; aspect-ratio:3/2; }
 #animal-change-dates > div { flex-direction:column; gap:2px; }
}

/* First-run guide: three real actions, marked done as the operator completes them. */
.studio-guide { display:grid; grid-template-columns:minmax(170px,.45fr) minmax(0,2fr); gap:20px 32px; align-items:center; margin:0 0 34px; padding:20px; border:1px solid var(--line); border-radius:22px; background:var(--surface); }
.guide-head { padding-left:6px; }
.guide-head .eyebrow { margin-bottom:6px; }
.guide-head h2 { margin:0; font-size:21px; font-weight:750; line-height:1.3; letter-spacing:-.045em; word-break:keep-all; }
.guide-steps { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; margin:0; padding:0; list-style:none; }
.guide-steps li { display:grid; grid-template-columns:30px minmax(0,1fr); gap:10px 12px; align-items:start; min-width:0; padding:14px; border-radius:16px; background:var(--paper); }
.guide-no { display:grid; place-items:center; width:30px; height:30px; border:1px solid #bfb2a5; border-radius:50%; font-size:12px; font-weight:750; }
.guide-steps strong { display:block; font-size:14px; font-weight:750; }
.guide-steps p { margin:2px 0 0; color:var(--ink-2); font-size:11px; line-height:1.55; word-break:keep-all; }
.guide-action, .guide-state { grid-column:2; justify-self:start; }
.guide-action { display:inline-flex; align-items:center; min-height:44px; padding:0 18px; border:0; border-radius:999px; background:var(--forest); color:#fff; font-size:12px; font-weight:700; text-decoration:none; white-space:nowrap; }
.guide-state { display:inline-flex; align-items:center; min-height:44px; color:var(--ink-2); font-size:12px; font-weight:650; }
.guide-steps li.is-done .guide-no { border-color:var(--sage); background:var(--sage); color:#fff; }
.guide-steps li.is-done .guide-state { color:var(--sage); }
.guide-toggle { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:44px; padding:0 16px; border:1px solid #bfb2a5; border-radius:999px; background:transparent; color:var(--ink); font-size:12px; font-weight:700; white-space:nowrap; }
.guide-toggle::after { content:""; width:6px; height:6px; margin-top:-3px; border-right:1.5px solid currentColor; border-bottom:1.5px solid currentColor; transform:rotate(45deg); transition:transform 180ms ease, margin 180ms ease; }
.studio-guide.is-open .guide-toggle::after { margin-top:3px; transform:rotate(-135deg); }
#guide-progress { font-variant-numeric:tabular-nums; }
/* Open: heading and toggle on the left, the three steps on the right. */
.studio-guide.is-open { grid-template-areas:"head steps" "toggle steps"; align-items:start; }
.studio-guide.is-open .guide-head { grid-area:head; padding-top:6px; }
.studio-guide.is-open .guide-steps { grid-area:steps; }
.studio-guide.is-open .guide-toggle { grid-area:toggle; justify-self:start; }
.studio-guide.is-open .guide-steps li.is-current { box-shadow:inset 0 0 0 1.5px var(--forest); }
/* Collapsed (default): one working row — progress, the next step with its real action, and the toggle. */
.studio-guide:not(.is-open) { grid-template-columns:auto minmax(0,1fr) auto; grid-template-areas:"head steps toggle"; gap:12px 24px; margin-bottom:28px; padding:10px 10px 10px 22px; border-radius:999px; }
.studio-guide:not(.is-open) .guide-head { grid-area:head; padding-left:0; }
.studio-guide:not(.is-open) .guide-head .eyebrow { margin:0; white-space:nowrap; }
.studio-guide:not(.is-open) .guide-head h2 { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.studio-guide:not(.is-open) .guide-steps { grid-area:steps; display:block; }
.studio-guide:not(.is-open) .guide-steps li:not(.is-current) { display:none; }
.studio-guide:not(.is-open) .guide-steps li { grid-template-columns:30px minmax(0,1fr) auto; align-items:center; padding:0; background:transparent; }
.studio-guide:not(.is-open) .guide-steps p { display:none; }
.studio-guide:not(.is-open) :is(.guide-action, .guide-state) { grid-column:3; grid-row:1; }
.studio-guide:not(.is-open) .guide-toggle { grid-area:toggle; }

/* After every save: what changed, and one click to see it on the public site.
   It floats above the work instead of pushing the records down. */
.saved-banner { position:fixed; z-index:30; left:calc(var(--rail-width) + (100vw - var(--rail-width)) / 2); bottom:max(20px, env(safe-area-inset-bottom)); display:flex; align-items:center; gap:14px; width:min(680px, calc(100vw - var(--rail-width) - 48px)); margin:0; padding:8px 8px 8px 14px; border-radius:18px; background:var(--forest); color:#fff; box-shadow:0 22px 50px -18px #1d3a2dee; transform:translateX(-50%); animation:saved-in 220ms ease-out; }
@keyframes saved-in { from { opacity:0; translate:0 12px; } }
body:has(#saved-banner:not([hidden])) #workspace { padding-bottom:96px; }
body:has(#saved-banner:not([hidden])) #toast { bottom:calc(max(20px, env(safe-area-inset-bottom)) + 84px); }
.saved-check { display:grid; place-items:center; flex:none; width:30px; height:30px; border-radius:50%; background:var(--apricot); color:var(--forest); font-weight:800; }
.saved-banner p { flex:1; min-width:0; margin:0; font-size:13px; line-height:1.5; overflow-wrap:anywhere; }
.saved-banner a { display:inline-flex; align-items:center; flex:none; min-height:44px; padding:0 18px; border-radius:999px; background:#fff; color:var(--forest); font-size:12px; font-weight:750; text-decoration:none; }
.saved-banner button { flex:none; width:44px; height:44px; border:0; border-radius:50%; background:#ffffff14; color:#fff; font-size:22px; line-height:1; }
.saved-banner :focus-visible { outline-color:var(--apricot); box-shadow:none; }
@media(max-width:1100px){ .studio-guide.is-open { grid-template-columns:minmax(0,1fr) auto; grid-template-areas:"head toggle" "steps steps"; align-items:center; } }
@media(max-width:820px){ .saved-banner { left:50%; width:min(680px, calc(100vw - 40px)); } }
@media(max-width:700px){
 .guide-steps { grid-template-columns:minmax(0,1fr); } .guide-steps li { grid-template-columns:30px minmax(0,1fr) auto; align-items:center; } .guide-action, .guide-state { grid-column:3; grid-row:1; }
 /* Collapsed on a phone: progress and toggle on one line, the next step and its action below. */
 .studio-guide:not(.is-open) { grid-template-columns:minmax(0,1fr) auto; grid-template-areas:"head toggle" "steps steps"; align-items:center; gap:10px 12px; margin-bottom:20px; padding:10px 10px 14px 16px; border-radius:20px; }
}
@media(max-width:600px){
 .saved-banner { flex-wrap:wrap; } .saved-banner p { flex-basis:calc(100% - 100px); } .saved-banner a { order:3; flex:1 1 100%; justify-content:center; }
 body:has(#saved-banner:not([hidden])) #workspace { padding-bottom:150px; }
 body:has(#saved-banner:not([hidden])) #toast { bottom:calc(max(20px, env(safe-area-inset-bottom)) + 138px); }
 /* Tighter heading and stats so the first record shows on the first phone screen. */
 .page-heading { gap:18px; padding:24px 0 22px; }
 .stats { padding:16px 0; margin-bottom:20px; }
 .stats strong { font-size:28px; }
}

.row-actions { display:flex; flex-direction:column; align-items:flex-end; gap:6px; }
.row-preview { display:inline-flex; align-items:center; min-height:36px; color:var(--ink-2); font-size:11px; white-space:nowrap; text-underline-offset:4px; }
@media(max-width:600px){ .story-row > .row-actions { grid-column:2; justify-self:start; align-items:flex-start; } }
