:root {
  /* Cream background and copper accent, taken from the logo. */
  --bg: #faf7f2;
  --surface: #fff;
  --text: #1f1b16;
  --muted: #6e665c;
  --border: #e4dccf;
  --accent: #c77d3a;
  --accent-tint: #f7ecdf;
  --accent-tint-strong: #f0dcc5;
  --accent-tint-border: #e8cdae;
  --neutral: #f2ede5;
  --neutral-strong: #e9e2d7;
  --danger: #a33a2c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); }

/* --- Frame: top bar, left sidebar, content --- */
:root { --topbar: 56px; --sidebar: 220px; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; text-decoration: none; }
.logo img { display: block; height: 40px; width: auto; }
.menu-button { display: none; }
.account { margin-left: auto; position: relative; }
.account-button {
  display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer;
}
.account-button:hover, .account-button[aria-expanded=true] { background: var(--accent-tint); color: var(--accent); }
.account-menu {
  position: absolute; right: 0; top: 46px; width: 230px; padding: 10px; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}
.account-menu .hint { margin: 6px 6px 0; font-size: .8rem; }
.account-name { margin: 0 6px 6px; font-weight: 600; }
.menu-item { padding: 6px; border-radius: 4px; }
.menu-item.disabled { color: var(--muted); }

.layout { display: flex; align-items: flex-start; }
.sidebar {
  position: sticky; top: var(--topbar); flex: 0 0 var(--sidebar); height: calc(100vh - var(--topbar)); overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; padding: 16px 12px; background: var(--bg); border-right: 1px solid var(--border);
}
.nav-heading { margin: 0 8px 4px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sidebar a { display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 18px; border-radius: 6px; color: var(--text); text-decoration: none; }
.sidebar a.nav-top { padding-left: 10px; font-weight: 600; margin-top: 10px; }
.sidebar a:hover { background: var(--neutral); }
.sidebar a[aria-current=page] { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.soon { margin-left: auto; padding: 0 6px; font-size: .7rem; font-weight: 600; border-radius: 999px; background: var(--neutral); color: var(--muted); }

main { flex: 1; min-width: 0; max-width: 1180px; padding: 24px 24px 64px; }

h1 { font-size: 1.5rem; margin: 0 0 16px; color: var(--accent); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.count { color: var(--muted); font-weight: 400; font-size: 1rem; }
.hint, .empty, small { color: var(--muted); }

.message { background: var(--accent-tint); border: 1px solid var(--accent-tint-border); padding: 8px 12px; border-radius: 6px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }

.form { max-width: 560px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field label.check { font-weight: 400; display: flex; align-items: center; gap: 8px; }
.field input:not([type=checkbox]), .field select, .field textarea {
  width: 100%; padding: 8px 10px; font: inherit;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
.field small { display: block; margin-top: 4px; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: 4px 0 0; }

.actions { display: flex; align-items: center; gap: 16px; }
.button {
  display: inline-block; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer;
  color: #fff; background: var(--accent); border: 0; border-radius: 6px; text-decoration: none;
}
.button.danger { background: var(--danger); }
.danger-zone { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--border); }

h2 { font-size: 1.15rem; margin: 0 0 8px; color: var(--accent); }
[hidden] { display: none !important; }
.message.error { background: #f8e9e6; border-color: #e6c3bc; }
.button.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--border); }

fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.parts { display: flex; flex-wrap: wrap; gap: 8px; }
.part { flex: 1 1 90px; }
.part label { font-weight: 400; font-size: .8rem; color: var(--muted); }
.part-currency { flex-basis: 200px; }
.part-unit { flex: 0 0 80px; }
.part-other { flex-basis: 100%; }

.thumb-cell { width: 64px; padding: 6px 0 6px 12px; }
.thumb-cell img { display: block; width: 52px; height: 52px; object-fit: cover; border-radius: 4px; }

.media-section { margin: 32px 0 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.rows { list-style: none; padding: 0; margin: 0 0 12px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 8px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.option-row .row-body { flex-direction: row; }
.row-options { display: flex; gap: 16px; }
.row-buttons { display: flex; gap: 4px; }
.row-buttons button {
  width: 32px; height: 32px; font: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.image-row img { display: block; width: 88px; height: 88px; object-fit: cover; border-radius: 4px; }
.field input[type=file] { padding: 6px; }
.video-row video { display: block; width: 176px; max-height: 132px; background: #000; border-radius: 4px; }
.button[disabled] { opacity: .6; cursor: progress; }
.part-wide { flex: 2 1 220px; }
.part-date { flex: 0 1 180px; }
.parts .field { margin-bottom: 12px; }
.history { margin-top: 16px; }
td.wrap { white-space: normal; }
td .count { font-size: .85rem; margin-left: 4px; }
.total { margin: 0; font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.filter select, .filter input {
  padding: 7px 10px; font: inherit; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
.filter-searchinput { flex: 1 1 240px; }
.filter-searchinput input { width: 100%; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
th a.sort { color: inherit; text-decoration: none; }
th a.sort:hover { color: var(--text); }
.head-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: flex-end; }

.steps { display: flex; gap: 20px; list-style: none; padding: 0; margin: 0 0 16px; color: var(--muted); }
.steps a { color: inherit; }
.steps [aria-current] { color: var(--text); font-weight: 600; }
.problems { padding-left: 28px; list-style: disc; }
.mapping td { vertical-align: top; }
.samples span:not(.count) {
  display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin: 0 6px 2px 0; padding: 0 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  font-size: .85rem; vertical-align: bottom;
}
.target select, .new-field input { width: 100%; min-width: 220px; padding: 6px 8px; font: inherit;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.new-field { display: flex; gap: 6px; margin-top: 6px; }
.new-field select { min-width: 0; width: auto; }
.empty-columns { margin: 12px 0; }
.push-right { margin-left: auto; }
.summary { padding-left: 20px; }
.review-form { margin-top: 24px; }
td.clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
progress { width: 100%; max-width: 560px; height: 12px; }

/* --- Piece editor --- */
.editbar {
  position: sticky; top: var(--topbar); z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin: -24px -24px 0; padding: 14px 24px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.editbar h1 { margin: 0; font-size: 1.3rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editbar-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

/* Folder-style tabs: the open tab joins the panel below it. */
.tabs { display: flex; gap: 4px; margin-top: 20px; padding: 0 8px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  display: block; padding: 10px 18px; margin-bottom: -1px; white-space: nowrap; text-decoration: none;
  color: var(--muted); background: var(--neutral); border: 1px solid var(--border); border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text); background: var(--neutral-strong); }
.tab.active { color: var(--text); font-weight: 600; background: var(--surface); border-bottom-color: var(--surface); }
.tab-error {
  display: inline-block; width: 18px; height: 18px; margin-left: 4px; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: .75rem; line-height: 18px; text-align: center; font-weight: 600;
}
.tab-panel {
  padding: 24px; background: var(--surface); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 8px 8px;
}
.tab-panel .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .tab-panel .field select, .tab-panel .field textarea { background: #fff; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 24px; }
.field-grid .wide { grid-column: 1 / -1; }
.subsection { margin-top: 16px; padding-top: 20px; border-top: 1px solid var(--border); }
h3 { font-size: 1.05rem; margin: 24px 0 10px; }
.subsection h3 { margin-top: 0; }

/* Images tab: thumbnails in a grid */
.image-grid { list-style: none; padding: 0; margin: 0 0 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.image-card { display: flex; flex-direction: column; gap: 8px; padding: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.image-card img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; }
.image-card input[type=text] { width: 100%; padding: 6px 8px; font: inherit; font-size: .9rem; border: 1px solid var(--border); border-radius: 6px; }
.card-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .85rem; }
.star { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.star input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star span::before { content: '\2606'; font-size: 1.15rem; color: var(--muted); }
.star input:checked + span::before { content: '\2605'; color: #c58b00; }
.star input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.video-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.video-row .row-body { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.video-row input[type=text] { width: 100%; padding: 6px 8px; font: inherit; border: 1px solid var(--border); border-radius: 6px; }

@media (max-width: 600px) {
  .editbar { flex-wrap: wrap; }
  .editbar-actions { width: 100%; justify-content: flex-end; }
  .tab-panel { padding: 16px; }
  .image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

/* --- Pieces gallery --- */
.gallery { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 20px; }
.piece-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.piece-thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 1; padding: 0; border: 0; overflow: hidden;
  cursor: zoom-in; background: var(--neutral); border-bottom: 1px solid var(--border);
}
/* Positioned so a tall image can't stretch the square; the whole artwork shows, never cropped. */
.piece-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.piece-thumb:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.piece-thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); cursor: default; }
.piece-meta { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; font-size: .9rem; }
.piece-title { font-size: 1rem; font-weight: 600; text-decoration: none; margin-bottom: 2px; }
.piece-title:hover { text-decoration: underline; }
.piece-status { color: var(--text); }
.muted { color: var(--muted); }
.pill { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .8rem; }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 16px; }
.filter-tag {
  display: inline-flex; gap: 6px; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .9rem;
  background: var(--accent-tint); border: 1px solid var(--accent-tint-border); color: var(--accent); text-decoration: none;
}
.filter-tag:hover { background: var(--accent-tint-strong); }
@media (max-width: 600px) {
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .piece-meta { padding: 8px; font-size: .85rem; }
}

/* --- Slide-out panel --- */
.panel-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(20, 20, 18, .35); }
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(380px, 100vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -8px 0 32px rgba(0, 0, 0, .15);
}
.side-panel-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.side-panel-head h2 { margin: 0; }
.side-panel-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.side-panel-body select, .side-panel-body input {
  width: 100%; padding: 8px 10px; font: inherit; border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
.side-panel-body .field { margin-bottom: 12px; }
.side-panel-foot { display: flex; flex-direction: column; gap: 6px; padding: 14px 20px; border-top: 1px solid var(--border); font-size: .9rem; }
.icon-button { width: 36px; height: 36px; font-size: 22px; line-height: 1; cursor: pointer; background: none; border: 1px solid var(--border); border-radius: 6px; }

/* --- Image viewer over the list --- */
.viewer {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(20, 20, 18, .6); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.viewer figure { margin: 0; display: flex; flex-direction: column; align-items: center; max-width: 88vw; }
.viewer img { max-width: min(88vw, 1600px); max-height: 80vh; object-fit: contain; border-radius: 4px; box-shadow: 0 12px 48px rgba(0, 0, 0, .45); }
.viewer figcaption { margin-top: 14px; text-align: center; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.viewer figcaption strong { display: block; font-size: 1.15rem; }
.viewer figcaption a { color: #fff; }
.viewer button {
  position: absolute; border: 0; cursor: pointer; color: #fff; background: rgba(0, 0, 0, .4);
  width: 52px; height: 52px; border-radius: 50%; font-size: 30px; line-height: 1;
}
.viewer button:hover, .viewer button:focus-visible { background: rgba(0, 0, 0, .7); }
.viewer .viewer-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.viewer .viewer-next { right: 16px; top: 50%; transform: translateY(-50%); }
.viewer .viewer-close { top: 16px; right: 16px; width: 44px; height: 44px; font-size: 26px; }
.viewer .viewer-count { position: absolute; top: 28px; left: 24px; color: #fff; font-size: .9rem; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
body.no-scroll { overflow: hidden; }

/* --- Batch C --- */
.page-head { flex-wrap: wrap; }
.field-group { margin-bottom: 28px; }
.field-group h2 { margin-bottom: 4px; }
.field-rows { list-style: none; padding: 0; margin: 8px 0 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.field-rows li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.field-rows li:last-child { border-bottom: 0; }
.field-rows li:target { background: var(--accent-tint); }
.field-rows .move { margin-left: auto; display: flex; gap: 6px; }
.small-button { font: inherit; font-size: .85rem; padding: 4px 10px; cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.small-button:disabled { opacity: .4; cursor: default; }
.data-grid, .summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 20px; }
.data-card, .summary-card { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.plain-list { list-style: none; padding: 0; margin: 16px 0 0; }
.plain-list li { margin-bottom: 6px; }
table.compact th, table.compact td { padding: 4px 12px 4px 0; border: 0; font-size: .95rem; text-transform: none; letter-spacing: 0; color: var(--text); }
table.compact th { font-weight: 600; }
@media (max-width: 600px) {
  .page-head { margin-bottom: 14px; }
  .page-head h1 { margin-bottom: 0; }
}
.backup-state { font-weight: 600; margin: 0 0 8px; }
.backup-state.good { color: var(--accent); }
.backup-state.bad { color: var(--danger); }
code { font-size: .9em; background: var(--bg); padding: 1px 4px; border-radius: 4px; }

/* --- Read/Edit switch --- */
.mode-switch { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 600; }
.mode-track {
  position: relative; width: 44px; height: 24px; border-radius: 999px; background: #d6cdbf; transition: background .15s;
}
.mode-knob {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: left .15s;
}
.mode-switch[aria-checked=true] .mode-track { background: var(--accent); }
.mode-switch[aria-checked=true] .mode-knob { left: 23px; }
.mode-switch:focus-visible .mode-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Overview with thumbnail --- */
.overview-layout { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 24px; align-items: start; }
.overview-thumb { margin: 0; aspect-ratio: 1; background: var(--neutral); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; position: relative; }
.overview-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.overview-thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .9rem; }
@media (max-width: 700px) {
  .overview-layout { grid-template-columns: 1fr; }
  .overview-thumb { width: 160px; grid-row: 1; }
}

/* --- Read mode --- */
.read-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px 24px; margin: 0; }
.read-fields .wide { grid-column: 1 / -1; }
.read-fields dt { color: var(--muted); font-size: .85rem; margin-bottom: 2px; }
.read-fields dd { margin: 0; overflow-wrap: anywhere; }
.unset { color: var(--muted); font-style: italic; }
.card-caption { margin: 0; font-size: .9rem; }
.primary-mark { color: #c58b00; }
.video-read { margin: 0 0 16px; max-width: 640px; }
.video-read video { width: 100%; border-radius: 6px; background: #000; }
.video-read figcaption { color: var(--muted); font-size: .9rem; }
.history-list { padding-left: 18px; }

/* --- Image cards: thumbnail opens the viewer --- */
.viewer-thumb { position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 4px; overflow: hidden; }
.viewer-thumb:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.position {
  position: absolute; top: 6px; left: 6px; min-width: 24px; padding: 1px 6px; border-radius: 999px;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: .8rem; text-align: center;
}
.order-buttons { margin-left: auto; display: flex; gap: 4px; }
.order-buttons .small-button { padding: 2px 10px; }
.viewer[data-single] .viewer-prev, .viewer[data-single] .viewer-next { display: none; }
.viewer-link { display: block; margin-top: 4px; }

/* Narrow screens: the sidebar slides in from the left behind the menu button. */
@media (max-width: 800px) {
  .menu-button {
    display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; font-size: 20px;
    background: none; border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
  }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar); bottom: 0; z-index: 25; height: auto; width: 240px;
    transform: translateX(-100%); transition: transform .2s;
  }
  .sidebar.open { transform: none; box-shadow: 4px 0 24px rgba(0, 0, 0, .12); }
  main { padding: 20px 16px 64px; }
  .editbar { margin: -20px -16px 0; padding: 12px 16px; }
}

/* --- Round: quick sort, collections, numbering --- */
.quick-sort { display: flex; align-items: center; gap: 6px; margin: -4px 0 16px; flex-wrap: wrap; }
.sort-chip { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-size: .9rem; }
.sort-chip:hover { background: var(--neutral); }
.sort-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.check-list { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 8px; }
.numbering { padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.crumb { margin: 0 0 4px; font-size: .9rem; }

.collection-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.collection-card { display: flex; flex-direction: column; gap: 4px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.collection-link { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--accent); }
.collection-link:hover strong { text-decoration: underline; }
.collection-thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--neutral); }
.collection-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty { display: flex; align-items: center; justify-content: center; background: var(--neutral); color: var(--muted); font-size: .85rem; }
.thumb-empty.wide { grid-column: 1 / -1; grid-row: 1 / 3; }
.clamp { margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.collection-text { max-width: 760px; }
.collection-notes { margin-bottom: 20px; color: var(--muted); }

.collection-fields { max-width: 720px; margin: 20px 0; }
.collection-fields .field input, .collection-fields .field textarea { width: 100%; }
.picker { padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.picker-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.picker-head h2 { margin: 0; }
.picker-head input[type=search] { flex: 1 1 220px; padding: 8px 10px; font: inherit; border: 1px solid var(--border); border-radius: 6px; }
.picker-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; max-height: 60vh; overflow-y: auto; }
.picker-list label { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 6px; cursor: pointer; }
.picker-list label:hover { background: var(--neutral); }
.picker-list label:has(input:checked) { background: var(--accent-tint); }
.picker-list img, .picker-list .thumb-empty { width: 44px; height: 44px; flex: 0 0 44px; object-fit: cover; border-radius: 4px; }
/* Same height with or without the buttons, so the Read/Edit switch never moves. */
.editbar-actions { min-height: 42px; }
@media (max-width: 600px) {
  /* Narrow screens: the switch is pinned top-right of the bar; the buttons wrap below the title. */
  .editbar { position: sticky; }
  .editbar h1 { padding-right: 90px; }
  .editbar .mode-switch { position: absolute; right: 16px; top: 16px; }
  .editbar-actions { flex-wrap: wrap; }
  .editbar-actions:not(:has(.button)) { min-height: 0; }
}

/* --- Accounts: sign-in, profile, admin --- */
.auth-card { max-width: 440px; margin: 48px auto; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.auth-card .field input:not([type=checkbox]) { width: 100%; }
.auth-card .button { width: 100%; }
.account-name small { display: block; font-weight: 400; }
.account-menu form { margin: 0; }
.account-menu a.menu-item, .account-menu button.menu-item { display: block; width: 100%; color: var(--text); text-decoration: none; text-align: left; font: inherit; background: none; border: 0; cursor: pointer; }
.account-menu .menu-item:hover { background: var(--neutral); }
.static-value { margin: 0; padding: 8px 0 0; }
.state { padding: 1px 8px; border-radius: 999px; font-size: .85rem; font-weight: 600; background: var(--neutral); color: var(--muted); }
.state-active { background: var(--accent-tint); color: var(--accent); }
.state-disabled { background: #f8e9e6; color: var(--danger); }
.danger-zone h2 { color: var(--danger); }

/* --- Profile --- */
.profile-form { max-width: 820px; display: flex; flex-direction: column; gap: 20px; }
.profile-form .field input:not([type=checkbox]):not([type=file]), .profile-form .field select, .profile-form .field textarea { background: #fff; }
.profile-head { display: flex; gap: 20px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.avatar-large { width: 112px; height: 112px; border-radius: 50%; overflow: hidden; flex: 0 0 112px; display: flex; align-items: center; justify-content: center; background: var(--accent-tint); color: var(--accent); font-size: 2.6rem; font-weight: 600; border: 1px solid var(--border); }
.avatar-large img { width: 100%; height: 100%; object-fit: cover; }
.profile-head-fields { flex: 1 1 240px; }
.profile-head-fields .field { margin-bottom: 8px; }
.slug-input { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 6px; background: #fff; overflow: hidden; }
.slug-input span { display: flex; align-items: center; padding: 0 4px 0 10px; color: var(--muted); background: var(--neutral); white-space: nowrap; }
.field .slug-input input { border: 0; border-radius: 0; min-width: 0; }
.account-avatar { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.account-button:has(.account-avatar) { padding: 0; overflow: hidden; }

/* --- Public portfolio --- */
.portfolio-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin: 20px 0; }
.portfolio-settings .check { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.public-badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--accent-tint); color: var(--accent); }
.owner-bar { padding: 8px 16px; text-align: center; font-size: .9rem; background: var(--accent-tint); border-bottom: 1px solid var(--accent-tint-border); }
.public-header { max-width: 1180px; margin: 0 auto; padding: 28px 24px 8px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.public-artist { display: flex; align-items: center; gap: 16px; text-decoration: none; color: var(--text); }
.public-artist > span { display: flex; flex-direction: column; }
.public-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.public-name { font-size: 1.7rem; font-weight: 600; color: var(--accent); line-height: 1.2; }
.public-location { color: var(--muted); }
.public-links { display: flex; gap: 18px; }
.public-main { max-width: 1180px; margin: 0 auto; padding: 16px 24px 48px; }
.public-about { max-width: 760px; margin-bottom: 28px; }
.public-about .statement { font-size: 1.08rem; }
.public-about summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.public-gallery .piece-thumb { display: block; }
.sold-tag { display: inline-block; align-self: flex-start; margin: 0; padding: 0 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #f8e9e6; color: var(--danger); }
.public-piece { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr); gap: 32px; align-items: start; }
.public-images { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.public-images .viewer-thumb { padding: 0; border: 0; background: var(--neutral); cursor: zoom-in; border-radius: 6px; overflow: hidden; aspect-ratio: 1; }
.public-images .viewer-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.public-images .lead { grid-column: 1 / -1; aspect-ratio: auto; background: none; }
.public-images .lead img { height: auto; max-height: 75vh; object-fit: contain; }
.public-info h1 { font-size: 1.8rem; margin-bottom: 8px; }
.public-price { font-size: 1.2rem; font-weight: 600; margin: 0 0 12px; }
.public-details { margin: 16px 0; }
.public-details div { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.public-details div.long { grid-template-columns: 1fr; gap: 4px; }
.public-details dt { color: var(--muted); }
.public-details dd { margin: 0; }
.public-info video { width: 100%; border-radius: 6px; background: #000; margin-top: 12px; }
.public-nav { display: flex; justify-content: space-between; margin-top: 20px; }
.public-footer { text-align: center; padding: 24px; color: var(--muted); font-size: .85rem; }
@media (max-width: 760px) {
  .public-piece { grid-template-columns: 1fr; }
  .public-header, .public-main { padding-left: 16px; padding-right: 16px; }
  .public-name { font-size: 1.35rem; }
}
.piece-meta .public-badge { align-self: flex-start; }
/* The save bar normally tucks up under the top bar; after a message it sits below it instead. */
main:has(> .message) .editbar { margin-top: 0; }

/* --- Private Rooms --- */
.share-link { display: flex; gap: 8px; margin: 8px 0 16px; }
.share-link input { flex: 1; min-width: 0; padding: 8px 10px; font: inherit; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.inline-actions { margin: 16px 0 0; }
.visitor-list li { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.visitor-list li:last-child { border-bottom: 0; }
.visitor-list form { margin: 0; }
.room-kicker { margin: 0 0 4px; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.room-leave { margin-top: 32px; text-align: center; }
.room-pieces a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.state-open { background: var(--accent-tint); color: var(--accent); }
.state-closed, .state-expired { background: #f8e9e6; color: var(--danger); }
.public-main .auth-card .button { width: 100%; }
.invite-form { margin-bottom: 20px; }
.invite-row { display: grid; grid-template-columns: 2fr 3fr; gap: 8px; margin-bottom: 8px; }
.invite-row input { min-width: 0; padding: 8px 10px; font: inherit; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.visitor-actions { display: flex; gap: 6px; flex-wrap: wrap; }
table.compact td, table.compact th { white-space: normal; }

/* --- Profile links --- */
.link-rows { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.link-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.link-row select, .link-row input { padding: 8px 10px; font: inherit; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.link-row select { flex: 0 0 150px; }
.link-value { flex: 1 1 260px; display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 6px; background: #fff; overflow: hidden; min-width: 0; }
.link-value input { flex: 1; min-width: 0; border: 0; border-radius: 0; }
.link-before, .link-after { display: flex; align-items: center; padding: 0 2px 0 10px; color: var(--muted); background: var(--neutral); white-space: nowrap; font-size: .9rem; }
.link-before:empty, .link-after:empty { display: none; }
.link-after { padding: 0 10px 0 2px; }
.link-label { flex: 0 1 170px; min-width: 0; }
.icon { display: block; flex: 0 0 auto; }
.public-links { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.public-links a { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; color: var(--text); background: var(--surface); border: 1px solid var(--border); }
.public-links a:hover { color: var(--accent); border-color: var(--accent); }
.public-nav-tabs { display: flex; gap: 22px; max-width: 1180px; margin: 0 auto; padding: 0 24px; border-bottom: 1px solid var(--border); }
.public-nav-tabs a { padding: 10px 0; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.public-nav-tabs a[aria-current=page] { color: var(--accent); border-bottom-color: var(--accent); }
.about-page { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; align-items: start; max-width: 980px; }
.about-page .avatar-large { width: 220px; height: 220px; flex-basis: 220px; font-size: 5rem; }
.about-page h2 { margin-top: 0; }
.about-section + .about-section { margin-top: 28px; }
.about-links { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.about-links a { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.about-links a:hover span { color: var(--accent); text-decoration: underline; }
@media (max-width: 760px) {
  .about-page { grid-template-columns: 1fr; gap: 20px; }
  .about-page .avatar-large { width: 140px; height: 140px; flex-basis: 140px; }
  .public-nav-tabs { padding: 0 16px; }
}
/* Line the tab underline up with the content edges. */
.public-nav-tabs { max-width: none; padding: 0; margin: 0 max(24px, calc((100% - 1132px) / 2)); }
@media (max-width: 760px) { .public-nav-tabs { margin: 0 16px; padding: 0; } }
.public-sort { margin: 18px 0 18px; }
.chip-gap { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }
.button.inquiry { margin-top: 4px; }
.inquiry-field { margin-top: 14px; }
.inquiry-field input { background: #fff; }

/* --- Select mode and bulk edit --- */
.select-bar { position: sticky; top: calc(var(--topbar) + 8px); z-index: 15; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; padding: 10px 14px; background: var(--accent-tint); border: 1px solid var(--accent-tint-border); border-radius: 8px; }
.select-bar-end { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.select-bar .button:disabled { opacity: .5; cursor: default; }
.piece-card { position: relative; }
.select-box { position: absolute; top: 8px; left: 8px; z-index: 2; display: flex; padding: 6px; background: rgba(255, 255, 255, .92); border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); cursor: pointer; }
.select-box input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.gallery.selecting .piece-thumb { cursor: pointer; }
.piece-card.selected { outline: 3px solid var(--accent); outline-offset: -1px; }
.bulk-thumbs { list-style: none; padding: 0; margin: 20px 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.bulk-thumbs li, .bulk-thumbs img, .bulk-thumbs .thumb-empty { width: 56px; height: 56px; border-radius: 4px; object-fit: cover; font-size: .6rem; text-align: center; }
.bulk-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; align-items: start; padding: 16px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.bulk-row.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.bulk-row h3 { margin: 0 0 8px; font-size: 1rem; }
.bulk-change { font-weight: 600; padding-top: 4px; }
.bulk-fields .field { margin-bottom: 0; }
.bulk-fields .field input:not([type=checkbox]), .bulk-fields .field select, .bulk-fields .field textarea { background: #fff; }
/* Previous / next in the piece title bar */
.editbar-title { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pager { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.pager a { text-decoration: none; font-weight: 600; }
.pager .count { font-size: .85rem; }
@media (max-width: 600px) {
  .bulk-row { grid-template-columns: 1fr; }
  .select-bar-end { margin-left: 0; width: 100%; justify-content: space-between; }
}

/* Plans: the plan card on the profile and the plan choices */
.plan-card { margin-bottom: 20px; }
.plan-card .page-head h2 { margin: 0; }
.plan-card table { width: auto; }
.current-plan { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.plan-price { font-weight: 600; margin: 0 0 8px; }
.billing-link { margin-top: 16px; }
.auth-switch { margin: 20px 0 0; text-align: center; color: var(--muted, #6b645c); }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.site-footer { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--muted, #6b645c); }
.site-footer a { color: inherit; }
.legal { max-width: 720px; }
.legal h2 { margin-top: 28px; }
.draft-banner { background: #fff4d6; border: 1px solid #e8d08a; padding: 10px 14px; border-radius: 6px; }
.checkout-embed { max-width: 1000px; min-height: 300px; margin-top: 16px; }
.receipts { margin-top: 20px; }
.receipts table { width: 100%; }
.switch-card { max-width: 640px; }
.switch-card form { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
