:root {
  color-scheme: light;
  --paper: #faf6ef;
  --surface: #fffdf9;
  --white: #fff;
  --ink: #2d221d;
  --muted: #66564c;
  --line: #ded2c5;
  --control-border: #9e8d7e;
  --accent: #883d30;
  --accent-deep: #6a2b20;
  --accent-soft: #f5e6df;
  --green: #30583c;
  --green-soft: #e9f2e8;
  --shadow: 0 10px 30px rgb(54 36 24 / 6%);
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
[hidden] { display: none !important; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
h1:focus, .form-error:focus, main:focus { outline: none; }
h1, h2, h3, p, ul, ol, dl { margin: 0; }
h1, .wordmark, .preview h3 { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; }
h1 { font-size: clamp(2.4rem, 4.5vw, 3.5rem); line-height: 1.08; letter-spacing: -.038em; overflow-wrap: anywhere; }
h2 { font-size: 1.18rem; font-weight: 680; line-height: 1.25; overflow-wrap: anywhere; }
p, label, summary, dd, small { overflow-wrap: anywhere; }
small { line-height: 1.45; color: var(--muted); }
summary { cursor: pointer; color: var(--accent-deep); padding-block: .5rem; }
.muted { color: var(--muted); }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.skip { position: absolute; z-index: 8; left: 1rem; top: .7rem; background: var(--white); padding: .6rem 1rem; transform: translateY(-180%); }
.skip:focus { transform: none; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner, #navigation { width: min(100% - 2rem, 70rem); margin-inline: auto; }
.top-inner { min-height: 4.4rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.wordmark { display: inline-flex; gap: .22em; align-items: center; font-size: 1.6rem; white-space: nowrap; letter-spacing: -.035em; }
.beads { width: .6em; height: .29em; display: inline-flex; justify-content: space-between; }
.beads::before, .beads::after { content: ""; border-radius: 100%; width: .26em; height: .26em; background: #a4513f; }
.beads::after { background: #52685a; }
#account { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.account-email { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#account .button { white-space: nowrap; }
#navigation { display: flex; gap: .35rem; align-items: stretch; }
.button.nav-link { min-width: 6.5rem; padding: .65rem .9rem; border: 0; border-radius: 0; border-bottom: 3px solid transparent; }
.button.nav-link[aria-current="page"] { color: var(--accent-deep); border-bottom-color: var(--accent); }

main { width: min(100% - 2rem, 70rem); margin-inline: auto; padding-block: clamp(1.6rem, 4vw, 3rem) 4rem; }
.loading { padding: 1rem 0; color: var(--muted); }
.notice, .form-error { border: 1px solid; border-radius: 8px; padding: .65rem .9rem; }
.notice { color: var(--green); background: var(--green-soft); border-color: #a6b8a5; margin-bottom: 1rem; }
.form-error { color: var(--accent-deep); background: var(--accent-soft); border-color: #bb8171; margin-block: .3rem; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.2rem; margin-bottom: 1.55rem; }
.page-heading p { color: var(--muted); margin-top: .45rem; max-width: 45rem; }
.page-heading .button { align-self: center; flex: 0 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.empty { padding: clamp(1.1rem, 3vw, 2.3rem); border: 1px dashed var(--control-border); border-radius: 12px; background: var(--surface); }
.empty p { color: var(--muted); margin-top: .4rem; }
.empty .button { margin-top: .85rem; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: .58rem .94rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  transition: background-color .16s ease, border-color .16s ease;
}
.button.primary, .button.danger { background: var(--accent); color: var(--white); }
.button.primary:hover:not(:disabled), .button.danger:hover:not(:disabled) { background: var(--accent-deep); }
.button.secondary { background: var(--white); border-color: var(--control-border); }
.button.secondary:hover:not(:disabled), .button.quiet:hover:not(:disabled), .button.nav-link:hover { background: var(--accent-soft); }
.button.quiet, .button.nav-link { background: transparent; color: var(--accent-deep); }
.button.danger-outline { background: transparent; border-color: var(--accent); color: var(--accent-deep); }
.button.danger-outline:hover { background: var(--accent-soft); }
.button-row { display: flex; flex-wrap: wrap; gap: .65rem; }

.auth-card { width: min(100%, 31rem); margin: clamp(0rem, 5vh, 3rem) auto 0; padding: clamp(1.15rem, 4vw, 2rem); }
.auth-card h1 { font-size: clamp(2rem, 5vw, 2.85rem); }
.eyebrow { color: var(--accent-deep); font-size: .88rem; font-weight: 650; margin-bottom: .4rem; }
.auth-description { color: var(--muted); margin-block: .75rem 1.2rem; }
.form-stack { display: grid; gap: .7rem; }
.form-stack .quiet { justify-self: center; }
.code-input { font-variant-numeric: tabular-nums; letter-spacing: .14em; }
.mfa-qr { margin: .25rem auto; background: var(--white); padding: .45rem; object-fit: contain; border: 1px solid var(--line); border-radius: 9px; }
.setup-key { margin-block: .6rem 1rem; }
.setup-key input { font-family: ui-monospace, monospace; }
.setup-key small[role="status"] { display: block; }

.field { display: grid; gap: .28rem; min-width: 0; }
.field label { font-weight: 650; }
.field :is(input, select, textarea) { padding: .56rem .68rem; }
input:not([type="checkbox"]), select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--control-border);
  border-radius: 7px;
  background: var(--white);
}
input::placeholder { opacity: 1; color: var(--muted); }
input[type="file"] { font-size: .9rem; }
input[type="file"]::file-selector-button { min-height: 36px; font: inherit; margin-right: .55rem; cursor: pointer; }
textarea { min-height: 6.4rem; resize: vertical; }
.filters, .field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.filters { grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); }
.result-count { font-size: .9rem; color: var(--muted); margin-block: .8rem; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.7rem), 1fr)); gap: 1rem; padding: 0; list-style: none; }
.item-card { overflow: hidden; display: flex; flex-direction: column; }
.photo-frame { display: grid; align-items: center; justify-items: center; min-width: 0; aspect-ratio: 1; overflow: hidden; background: #f0e8df; color: var(--muted); }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.photo-fallback { font-size: .8rem; padding: .25rem; text-align: center; }
.card-image { aspect-ratio: 16 / 9; }
.item-body { flex: 1; min-width: 0; padding: .85rem; display: flex; flex-direction: column; gap: .45rem; }
.item-body .button { align-self: flex-start; margin-top: auto; }
.badges { display: flex; flex-wrap: wrap; gap: .35rem; }
.badge { font-size: .77rem; font-weight: 650; padding: .11rem .51rem; border-radius: 999px; background: #eee7dc; color: #57443a; }
.badge.published { background: var(--green-soft); color: var(--green); }
.badge.sample { background: var(--accent-soft); color: var(--accent-deep); }
.item-meta { display: flex; flex-wrap: wrap; gap: .25rem .75rem; justify-content: space-between; align-items: baseline; margin-block: .25rem; }
.item-meta s, .preview-prices s { color: var(--muted); font-size: .9rem; margin-left: .5rem; }
.quantity { color: var(--green); font-size: .9rem; font-weight: 650; }
.quantity.sold-out { color: var(--accent-deep); }

.editor { max-width: 53rem; }
.back { margin: -.25rem 0 .5rem -.65rem; }
.editor-form { padding: 0 clamp(.95rem, 3vw, 1.65rem); }
.form-section { display: grid; gap: .85rem; padding-block: 1.25rem; border-bottom: 1px solid var(--line); }
.form-actions { display: grid; justify-items: start; gap: .7rem; padding-block: 1.15rem; }
.form-actions .form-error { width: 100%; }
.check { display: flex; align-items: center; align-self: center; min-height: 44px; gap: .5rem; font-weight: 650; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.inline-stock { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.photo-editor > p, .photo-help { margin-top: -.35rem; }
.photo-list { display: grid; gap: .65rem; list-style: none; padding: 0; }
.photo-list:empty { display: none; }
.photo-row { display: grid; align-items: start; grid-template-columns: 5.3rem minmax(0, 1fr); gap: .7rem; border: 1px solid var(--line); border-radius: 8px; padding: .6rem; }
.photo-row .photo-frame { border-radius: 5px; }
.photo-detail { display: grid; gap: .3rem; }
.photo-detail .field { font-size: .9rem; }
.photo-controls { display: flex; flex-wrap: wrap; gap: .2rem; }
.photo-controls .button { min-width: 44px; padding-inline: .56rem; }
.file-name { overflow-wrap: anywhere; }
.photo-count { font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.delete-panel, .stock-panel { margin-top: 1rem; padding: 1rem; }
.delete-panel p, .stock-panel h2 { margin-bottom: .55rem; }
.delete-panel h2 { margin-bottom: .25rem; }
.stock-list { list-style: none; padding: 0; }
.stock-list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; border-top: 1px solid var(--line); padding-block: .65rem; }
.stock-list li > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.stock-list p { color: var(--muted); }
.stock-total { flex-shrink: 0; display: grid; justify-items: end; }
.delta { font-variant-numeric: tabular-nums; }

.modal { width: min(100% - 1.4rem, 47rem); max-height: min(85vh, 48rem); padding: clamp(.95rem, 3vw, 1.5rem); border: 1px solid var(--control-border); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.modal::backdrop { background: rgb(36 26 19 / 62%); }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin: -.4rem -.25rem .6rem 0; }
.modal > p { margin-block: .55rem .95rem; }
.preview { display: grid; gap: 1.1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.preview-main { border-radius: 7px; }
.preview-thumbs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .35rem; margin-top: .4rem; }
.preview h3 { font-size: 2rem; line-height: 1.12; overflow-wrap: anywhere; }
.preview-prices { margin: .4rem 0 .7rem; }
.preview dl { margin-top: .85rem; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .25rem .65rem; }
.preview dt { font-weight: 650; }
.preview dd { margin: 0; }

@media (max-width: 620px) {
  .account-email { display: none; }
  .top-inner { min-height: 3.7rem; }
  #navigation { gap: 0; }
  .button.nav-link { min-width: 0; flex: 1; padding-inline: .4rem; }
  .page-heading { display: grid; gap: .8rem; }
  .page-heading .button { justify-self: start; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .field:first-child { grid-column: 1 / -1; }
  .field-grid { grid-template-columns: 1fr; }
  .catalog-grid { gap: .8rem; }
  .item-card { flex-direction: row; }
  .card-image { flex: 0 0 29%; aspect-ratio: auto; min-height: 7rem; }
  .item-body { padding: .75rem; }
  .preview { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
