:root {
  --paper: #F7F2E8; --white: #FFFFFF; --ink: #2E211A; --ink-2: #4A3A2F; --muted: #6B5A4E;
  --line: #E7DCC8; --field: #D8CBB4; --rose: #A8124F; --rose-bg: #F7E3EA; --rose-ink: #8C0F42;
  --lagoon: #12606E; --lagoon-bg: #E3F0F2; --lagoon-ink: #0B4651; --saffron: #E0A526; --danger: #8E2A22;
  --radius: 14px;
  font-family: 'Nunito Sans', system-ui, sans-serif; color: var(--ink); background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.45; }
h1, h2, h3 { font-family: 'Baloo 2', system-ui, sans-serif; margin: 0; line-height: 1.1; }
h1 { font-size: 32px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
a { color: var(--lagoon); font-weight: 700; }
a:hover { color: var(--lagoon-ink); }
:focus-visible { outline: 3px solid var(--lagoon); outline-offset: 2px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; } .skip:focus { left: 12px; top: 12px; background: var(--white); padding: 8px 12px; z-index: 10; }
.loading { padding: 40px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .pad { padding: 16px; } .right { text-align: right; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.row.two > * { flex: 1 1 200px; }
.stack { display: flex; flex-direction: column; gap: 14px; } .stack.tight { gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.self-end { align-self: flex-end; min-height: 44px; }

/* layout */
.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 220px; max-width: 240px; background: var(--white); border-right: 1.5px solid var(--line); padding: 24px 14px; display: flex; flex-direction: column; gap: 4px; }
.brand { font-family: 'Baloo 2'; font-weight: 800; font-size: 24px; padding: 0 12px 16px; }
.side a { min-height: 44px; border-radius: 12px; display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--ink); font-weight: 600; text-decoration: none; }
.side a:hover { background: var(--paper); }
.side a.active { background: var(--rose-bg); color: var(--rose-ink); font-weight: 800; }
.count { background: var(--paper); border-radius: 10px; padding: 0 8px; font-size: 12px; }
.side-foot { margin-top: auto; padding: 12px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 36px 60px; display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 700px) { .side { max-width: none; flex-basis: 100%; } .main { padding: 20px 16px; } }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split > * { flex: 1 1 380px; min-width: 0; }
.split.narrow-left > :first-child { flex: 1 1 260px; max-width: 340px; }
.split.narrow-left > :last-child { flex: 999 1 420px; }

/* controls */
.btn { min-height: 44px; padding: 0 18px; border-radius: 14px; border: 1.5px solid var(--ink); background: var(--white); color: var(--ink); font: inherit; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--ink); color: #FBF6EC; }
.btn.primary:hover { background: #46352A; color: #FBF6EC; }
.btn.secondary:hover { background: var(--paper); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-outline { border-color: #E1B4AF; color: var(--danger); }
.btn.wide { width: 100%; }
.btn.small-btn { min-height: 40px; font-size: 14px; align-self: flex-start; }
.btn:disabled, .icon:disabled, .link:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; padding: 4px 0; font: inherit; font-weight: 800; color: var(--lagoon); cursor: pointer; min-height: 32px; }
.link.danger { color: var(--danger); }
.icon { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--field); background: var(--white); font-size: 16px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 42px; padding: 0 16px; border-radius: 21px; border: 1.5px solid var(--field); background: var(--white); font: inherit; font-weight: 800; color: var(--ink); cursor: pointer; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #FBF6EC; }
.chip.block { width: 100%; text-align: left; border-radius: 12px; }
.chip.block.on { background: var(--lagoon-bg); border-color: var(--lagoon); color: var(--lagoon-ink); }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; }
.field label, .field legend, .label { font-size: 14px; font-weight: 800; padding: 0; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--white); border: 1.5px solid var(--field); border-radius: 12px; }
input:not([type=checkbox]):not([type=radio]), select { min-height: 44px; padding: 0 12px; }
textarea { padding: 10px 12px; resize: vertical; }
input[type=search] { min-width: 240px; margin-left: auto; }
.check { display: flex; gap: 10px; align-items: center; min-height: 36px; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--lagoon); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 16px; }

/* surfaces */
.card { background: var(--white); border: 1.5px solid var(--line); border-radius: 18px; padding: 20px; }
.notice { background: #FFF8E6; border: 1.5px solid #E8C873; border-radius: 14px; padding: 12px 16px; font-size: 14px; }
.notice.error { background: #FBEAE8; border-color: #E1B4AF; color: var(--danger); font-weight: 700; }
.notice.warn { font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { background: var(--white); border: 1.5px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 800; }
.stat b { font-family: 'Baloo 2'; font-size: 32px; font-weight: 800; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th { text-align: left; font-size: 13px; color: var(--muted); padding: 12px 10px; }
td { padding: 10px; border-top: 1px solid #EFE6D6; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 18px; } th:last-child, td:last-child { padding-right: 18px; }
.cell-art { display: flex; gap: 12px; align-items: center; }
.empty-row { text-align: center; padding: 28px; color: var(--muted); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.pill.published { background: #E6F0DF; color: #2F5A1A; }
.pill.draft { background: #FCF0D2; color: #7A5600; }
.pill.unpublished { background: #F1E4DF; color: #6E3527; }
.pill.trashed { background: #EEE; color: #555; }

/* images */
.mini { width: 44px; height: 56px; object-fit: cover; border-radius: 8px; background: #EFE6D6; flex-shrink: 0; }
.thumb { width: 72px; height: 92px; object-fit: cover; border-radius: 10px; background: #EFE6D6; flex-shrink: 0; border: 1px solid #EFE6D6; }
.thumb.empty, .mini.empty { display: block; }
.thumb.fill { width: 100%; height: 150px; }
.thumb.contain { width: 100%; height: 100%; object-fit: contain; background: #fff; border: 0; }
.thumb.wide { width: 100%; height: 240px; }
.file-icon { display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--muted); }
.file-icon.big { width: 100%; height: 150px; }

/* upload slots */
.slot { display: flex; gap: 14px; align-items: flex-start; background: var(--white); border: 1.5px solid var(--line); border-radius: 16px; padding: 14px; }
.slot.has-error { border-color: #C9726B; }
.slot-body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.slot-title { font-weight: 800; }
.err { color: var(--danger); font-weight: 800; font-size: 14px; }
.ok { color: #2F5A1A; font-weight: 800; font-size: 13px; }
.bar { height: 8px; border-radius: 4px; background: #EFE6D6; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--lagoon); transition: width .2s; }
.foot { border-top: 1px solid #EFE6D6; padding-top: 12px; }

/* collections */
.list { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.list-row { display: flex; gap: 6px; align-items: center; border-radius: 12px; padding: 2px; }
.list-row.on { background: var(--lagoon-bg); }
.list-main { flex: 1; min-height: 48px; border: 0; background: none; text-align: left; font: inherit; font-weight: 800; display: flex; flex-direction: column; justify-content: center; padding: 0 10px; cursor: pointer; color: var(--ink); }
.page-order { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.page-order li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-order select { max-width: 170px; }

/* gallery */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.tile { background: var(--white); border: 1.5px solid var(--line); border-radius: 16px; padding: 8px; display: flex; flex-direction: column; gap: 6px; color: var(--ink); text-decoration: none; align-items: flex-start; }
.tile:hover { border-color: var(--lagoon); }
.tile-img { position: relative; width: 100%; }
.badge { position: absolute; left: 8px; top: 8px; background: var(--white); border-radius: 8px; padding: 2px 8px; font-size: 12px; font-weight: 800; }

/* trash */
.trash-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid #EFE6D6; }
.trash-row:last-child { border-bottom: 0; }

/* preview */
.device-wrap { display: flex; justify-content: center; }
.device { background: var(--ink); border-radius: 36px; padding: 12px; }
.device.phone { width: 330px; height: 680px; } .device.tablet { width: 560px; height: 720px; max-width: 100%; }
.device-screen { background: #FBF6EC; border-radius: 26px; height: 100%; overflow: hidden; padding: 22px 16px; display: flex; flex-direction: column; gap: 12px; }
.pv-title { font-family: 'Baloo 2'; font-weight: 800; font-size: 22px; } .pv-title.center { text-align: center; font-size: 18px; }
.pv-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); } .pv-grid.tablet { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pv-tile { position: relative; display: flex; flex-direction: column; gap: 4px; }
.pv-tile .thumb.fill { height: 128px; }
.pv-tile.current .thumb { outline: 3px solid var(--saffron); outline-offset: 2px; }
.pv-badge { position: absolute; left: 6px; top: 6px; background: #FCF0D2; color: #7A5600; border-radius: 8px; padding: 1px 6px; font-size: 11px; font-weight: 800; }
.pv-name { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-canvas { flex: 1; min-height: 0; background: #fff; border-radius: 16px; padding: 10px; display: flex; }
.pv-story { font-size: 14px; color: var(--ink-2); margin: 0; }

/* sign in */
.signin { display: flex; flex-wrap: wrap; min-height: 100vh; background: #F3ECDF; }
.signin-art { flex: 1 1 420px; min-height: 280px; background: radial-gradient(circle at 30% 30%, #E0A526 0 8%, transparent 9%), radial-gradient(circle at 70% 60%, #A8124F 0 10%, transparent 11%), radial-gradient(circle at 40% 80%, #12606E 0 12%, transparent 13%), #2E211A; }
.signin-panel { flex: 1 1 480px; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.signin-card { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 16px; }

/* toast & dialog */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: var(--ink); color: #FBF6EC; padding: 12px 18px; border-radius: 14px; font-weight: 700; max-width: min(560px, 92vw); transition: .2s; z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { background: var(--danger); }
dialog { border: 0; border-radius: 20px; padding: 0; max-width: 460px; width: calc(100% - 32px); color: var(--ink); }
dialog::backdrop { background: rgba(46, 33, 26, .45); }
.dialog-body { padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.dialog-body h2 { font-size: 24px; }
.dialog-text p { margin: 0 0 8px; }
body.busy { cursor: progress; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
