:root {
  --bg: #f2f2f2;
  --panel: #ffffff;
  --ink: #191919;
  --muted: #6a6a6a;
  --line: #d9d9d9;
  --accent: #0d97a6;
  --accent-strong: #0b7f8c;
  --danger: #a62929;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
  --radius: 22px;
  --font-heading: "Shell", "Avenir Next", "Helvetica Neue", sans-serif;
  --font-body: "Avenir Next", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: linear-gradient(180deg, #ededed 0%, #f7f7f7 100%); color: var(--ink); font-family: var(--font-body); }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
dialog { color: inherit; }

a { color: inherit; }

.app-shell, .admin-shell { width: min(1200px, calc(100vw - 40px)); margin: 0 auto; padding: 32px 0 60px; }
.gallery-body.is-compact .app-shell { width: min(1280px, calc(100vw - 24px)); padding-top: 18px; }
.gallery-body.is-compact .hero { margin-bottom: 18px; }
.gallery-body.is-compact .hero-copy { max-width: none; font-size: 0.98rem; }
.hero { display: grid; gap: 24px; align-items: end; grid-template-columns: 1.5fr 1fr; margin-bottom: 28px; }
.hero h1 { margin: 0; font: 400 clamp(2.4rem, 4vw, 4.5rem)/0.95 var(--font-heading); letter-spacing: -0.04em; }
.hero-copy { max-width: 56ch; color: var(--muted); font-size: 1.05rem; line-height: 1.6; }
.eyebrow { margin: 0 0 10px; color: var(--accent); font-size: 0.82rem; letter-spacing: 0.16em; text-transform: uppercase; }
.hero-controls { display: grid; gap: 12px; }
.admin-toolbar { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.hero-controls input, .hero-controls select, .editor-form input, .editor-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,0.9); padding: 14px 16px; }
.admin-status { margin: 0 0 20px; padding: 14px 16px; border-radius: 16px; background: rgba(255,255,255,0.95); box-shadow: var(--shadow); }
.admin-status[data-tone="warn"] { border-left: 4px solid #c88a12; }
.admin-status[data-tone="success"] { border-left: 4px solid #1d8c53; }
.admin-status[data-tone="error"] { border-left: 4px solid #a62929; }
.admin-status[data-tone="info"] { border-left: 4px solid var(--accent); }
.family-chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.family-chip, .ghost-button, .danger-button, .editor-form button, .color-card-button { border: 0; }
.family-chip, .ghost-button, .editor-form button, .danger-button { border-radius: 999px; padding: 10px 16px; background: var(--panel); box-shadow: var(--shadow); cursor: pointer; }
.family-chip.is-active, .editor-form button { background: var(--accent); color: white; }
.ghost-button { background: white; color: var(--ink); }
.danger-button { background: var(--danger); color: white; }
.gallery-grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.empty-state { margin: 6px 0 0; color: var(--muted); }
.color-card { min-height: 100%; }
.color-card-button { width: 100%; display: block; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; text-align: left; padding: 0; }
.image-frame { aspect-ratio: 4 / 3; background: linear-gradient(180deg, #d9d9d9 0%, #efefef 72%, #f7f7f7 100%); border-bottom: 1px solid var(--line); }
.card-image { width: 100%; height: 100%; object-fit: cover; }
.card-copy { padding: 18px 18px 20px; }
.card-family { margin: 0 0 8px; color: var(--accent); font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; }
.card-title { margin: 0 0 10px; font: 600 1.35rem/1.15 var(--font-heading); }
.card-description { margin: 0; color: var(--muted); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.color-dialog { width: min(1100px, calc(100vw - 28px)); border: 0; border-radius: 28px; padding: 0; box-shadow: 0 32px 90px rgba(0,0,0,0.22); }
.color-dialog::backdrop { background: rgba(11, 11, 11, 0.5); backdrop-filter: blur(8px); }
.color-dialog[open] { display: block; }
.color-dialog > * { padding: 24px 24px 0; }
.dialog-header { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.dialog-header h2 { margin: 0; font: 500 clamp(1.8rem, 3vw, 3rem)/1 var(--font-heading); }
.dialog-description { color: var(--muted); line-height: 1.7; }
.dialog-images { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); padding-bottom: 24px; }
.dialog-image-card { margin: 0; background: #f8f8f8; border-radius: 18px; overflow: hidden; border: 1px solid #ececec; }
.dialog-image-button { display: block; width: 100%; padding: 0; background: linear-gradient(180deg, #eeeeee 0%, #f7f7f7 100%); cursor: zoom-in; }
.dialog-image { aspect-ratio: 1 / 1; width: 100%; object-fit: contain; background: #efefef; padding: 10px; }
.dialog-caption { padding: 12px 14px 14px; color: var(--muted); font-size: 0.95rem; line-height: 1.45; }
.dialog-expanded { position: sticky; bottom: 0; z-index: 3; margin: 0 24px 24px; padding: 56px 24px 24px; border-radius: 22px; background: rgba(255,255,255,0.98); box-shadow: 0 28px 70px rgba(0,0,0,0.18); }
.dialog-expanded-close { position: absolute; top: 14px; right: 14px; width: 42px; height: 42px; border-radius: 999px; border: 1px solid var(--line); background: white; box-shadow: var(--shadow); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.dialog-expanded-image { width: 100%; max-height: min(70vh, 780px); object-fit: contain; background: linear-gradient(180deg, #ededed 0%, #f7f7f7 100%); border-radius: 18px; }
.dialog-expanded-caption { margin: 14px 0 0; color: var(--muted); line-height: 1.6; }

.admin-layout { display: grid; gap: 20px; grid-template-columns: 1.1fr 1fr; }
.panel { background: rgba(255,255,255,0.96); border-radius: 24px; box-shadow: var(--shadow); padding: 20px; }
.span-2 { grid-column: 1 / -1; }
.panel-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 18px; }
.panel-header h2 { margin: 0; font-size: 1.25rem; }
.panel-search { width: min(240px, 100%); border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; background: white; }
.panel-note { margin: 0 0 16px; color: var(--muted); line-height: 1.5; }
.editor-form { display: grid; gap: 14px; }
.editor-form label { display: grid; gap: 8px; color: var(--muted); font-size: 0.95rem; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.upload-form { margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.inline-form button { height: fit-content; }
.admin-color-list, .admin-image-list { display: grid; gap: 10px; }
.admin-item { border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; background: #fafafa; display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.admin-item.is-active, .admin-color-item.is-active { border-color: var(--accent); background: rgba(13, 151, 166, 0.08); }
.admin-item button { padding: 8px 12px; border-radius: 999px; background: white; box-shadow: none; border: 1px solid var(--line); cursor: pointer; }
.admin-item-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.admin-item-copy h3 { margin: 0 0 4px; font-size: 1rem; }
.admin-item-copy p { margin: 0; color: var(--muted); font-size: 0.92rem; }

@media (max-width: 900px) {
  .hero, .admin-layout, .inline-form { grid-template-columns: 1fr; }
  .admin-toolbar { justify-content: flex-start; }
}

.admin-shell-v2 { width: min(1440px, calc(100vw - 32px)); }
.admin-hero-v2 { grid-template-columns: 1.4fr 1fr; align-items: center; }
.admin-workspace { display: grid; grid-template-columns: minmax(320px, 520px) minmax(420px, 1fr); gap: 22px; align-items: start; }
.board-panel, .detail-panel { min-height: 70vh; }
.family-board-grid { display: grid; gap: 18px; }
.family-board { border: 1px solid var(--line); border-radius: 22px; padding: 16px; background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,247,247,0.96)); }
.family-board-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.family-board-header h3 { margin: 0; font: 600 1.1rem/1.1 var(--font-heading); }
.family-board-list { display: grid; gap: 12px; min-height: 32px; }
.family-board-list.drop-end { padding-bottom: 16px; border-bottom: 3px solid var(--accent); }
.admin-color-card { display: grid; grid-template-columns: 1fr auto; gap: 10px; border: 1px solid var(--line); border-radius: 18px; padding: 10px; background: white; box-shadow: var(--shadow); }
.admin-color-card.is-selected { border-color: var(--accent); box-shadow: 0 18px 50px rgba(13, 151, 166, 0.18); }
.admin-color-card.is-hidden { opacity: 0.62; }
.admin-color-card.drop-before { box-shadow: inset 0 4px 0 var(--accent), var(--shadow); }
.admin-color-card.drop-after { box-shadow: inset 0 -4px 0 var(--accent), var(--shadow); }
.admin-color-card-button { display: grid; grid-template-columns: 88px 1fr; gap: 12px; align-items: center; padding: 0; background: transparent; border: 0; text-align: left; cursor: pointer; }
.admin-color-card-thumb { aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; background: linear-gradient(180deg, #e2e2e2, #f4f4f4); }
.admin-color-card-image { width: 100%; height: 100%; object-fit: cover; }
.admin-color-card-copy { min-width: 0; }
.admin-color-card-title { margin: 0 0 6px; font-size: 1rem; }
.admin-color-card-meta { margin: 0; color: var(--muted); font-size: 0.9rem; }
.admin-color-card-actions { display: grid; gap: 8px; align-content: start; }
.drag-pill { display: inline-flex; justify-content: center; padding: 8px 10px; border-radius: 999px; background: #eff6f7; color: var(--accent-strong); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; }
.detail-panel { position: static; align-self: start; }
.empty-detail { display: grid; place-items: center; min-height: 60vh; text-align: center; color: var(--muted); }
.empty-detail h2 { margin: 0 0 10px; color: var(--ink); }
.detail-header { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; margin-bottom: 22px; }
.detail-cover { border-radius: 24px; overflow: hidden; background: linear-gradient(180deg, #d9d9d9, #f4f4f4); aspect-ratio: 1 / 1; }
.detail-cover img { width: 100%; height: 100%; object-fit: contain; }
.detail-meta { display: grid; gap: 12px; }
.detail-meta h2 { margin: 0; font: 500 clamp(1.9rem, 2vw, 2.7rem)/0.98 var(--font-heading); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-card-form { margin-bottom: 22px; }
.admin-toggle { display: inline-flex; gap: 10px; align-items: center; color: var(--muted); font-size: 0.95rem; }
.admin-toggle input { width: auto; margin: 0; }
.admin-toggle-inline { padding-top: 8px; }
.advanced-panel { border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; background: rgba(247,247,247,0.92); }
.advanced-panel summary { cursor: pointer; font-weight: 600; }
.advanced-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-top: 12px; }
.image-manager { border-top: 1px solid var(--line); padding-top: 18px; }
.image-manager-header { align-items: start; }
.image-dropzone { border: 2px dashed #b9d8dd; border-radius: 22px; background: linear-gradient(180deg, rgba(13,151,166,0.06), rgba(255,255,255,0.96)); padding: 26px 20px; text-align: center; cursor: pointer; margin-bottom: 18px; }
.image-dropzone strong { display: block; margin-bottom: 6px; font-size: 1.05rem; }
.image-dropzone p { margin: 0; color: var(--muted); }
.image-dropzone.is-over { border-color: var(--accent); background: linear-gradient(180deg, rgba(13,151,166,0.12), rgba(255,255,255,0.98)); }
.image-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.image-grid.drop-end { padding-bottom: 16px; border-bottom: 3px solid var(--accent); }
.hidden-image-grid { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.image-tile { border: 1px solid var(--line); border-radius: 18px; background: white; overflow: hidden; box-shadow: var(--shadow); }
.image-tile.is-selected { border-color: var(--accent); box-shadow: 0 18px 46px rgba(13, 151, 166, 0.16); }
.image-tile.is-hidden { opacity: 0.6; }
.image-tile.drop-before { box-shadow: inset 0 4px 0 var(--accent), var(--shadow); }
.image-tile.drop-after { box-shadow: inset 0 -4px 0 var(--accent), var(--shadow); }
.image-tile-button { width: 100%; padding: 0; border: 0; background: linear-gradient(180deg, #ececec, #f8f8f8); cursor: pointer; }
.image-tile-image { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; padding: 8px; }
.image-tile-copy { padding: 10px 12px 12px; }
.image-tile-caption { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.4; min-height: 2.4em; }
.image-inspector { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 18px; }
.image-inspector-layout { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: start; }
.image-inspector-preview { border-radius: 20px; overflow: hidden; background: linear-gradient(180deg, #ececec, #f7f7f7); }
.image-inspector-preview img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; }

@media (max-width: 1100px) {
  .admin-workspace { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
}

@media (max-width: 700px) {
  .admin-hero-v2, .detail-header, .image-inspector-layout, .admin-color-card-button { grid-template-columns: 1fr; }
  .admin-toolbar { justify-content: flex-start; }
}
