:root {
  --paper: #fbfaf8; --panel: #f1eee8; --deep: #e8e4dc; --ink: #141312; --slate: #57534c; --line: #d2ccc0; --white: #fffefc;
  --accent: #7a5c2e; --danger: #9a2b20; --ok: #2f5d3a; --ring: 0 0 0 3px rgba(122, 92, 46, 0.35);
  --sans: 'Montserrat', system-ui, sans-serif; --serif: 'Times New Roman', Times, serif; --side: 264px;
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--paper); color: var(--ink); font: 500 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; }
a { color: inherit; text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; }
h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 14px; font-weight: 700; }
:focus-visible { outline: none; box-shadow: var(--ring); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 8px 14px; background: var(--ink); color: var(--paper); transform: translateY(-200%); }
.skip:focus { transform: none; }
.boot { padding: 48px; color: var(--slate); }
.empty { padding: 20px; color: var(--slate); }
.intro { color: var(--slate); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border: 1px solid var(--line); background: var(--white); font-weight: 600; font-size: 13px; text-decoration: none; white-space: nowrap; transition: background 0.15s, border-color 0.15s; }
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: 0.45; }
.btn[aria-busy='true'] { opacity: 0.6; cursor: progress; }
.btn--primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn--primary:hover:not(:disabled) { background: #35322d; }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--quiet { background: transparent; border-color: transparent; }
.btn--quiet:hover:not(:disabled) { background: var(--panel); border-color: transparent; }
.btn--wide { width: 100%; }
.btn--left { margin-right: auto; }
.btn--add { width: 100%; border-style: dashed; background: transparent; margin-top: 12px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border: 0; background: transparent; color: var(--slate); }
.icon-btn:hover:not(:disabled) { background: var(--panel); color: var(--ink); }
.icon-btn:disabled { opacity: 0.25; }
.icon-btn[aria-pressed='true'] { background: var(--deep); color: var(--ink); }
.icon-btn--small { width: 26px; height: 26px; }
.link-btn { border: 0; background: none; padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; font-size: 13px; color: var(--slate); }
.link-btn:hover { color: var(--ink); }

/* shell */
#app { min-height: 100%; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column; width: var(--side); background: var(--panel); border-right: 1px solid var(--line); }
.sidebar__brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 20px 18px; text-decoration: none; }
.sidebar__brand img { display: block; width: 124px; height: auto; }
.sidebar__brand span { padding: 2px 8px; border: 1px solid var(--line); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--slate); }
.nav { flex: 1; overflow-y: auto; padding: 0 12px 16px; }
.nav__group { margin-top: 10px; }
.nav__group:first-child { margin-top: 0; }
.nav__group h2 { padding: 4px 10px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--slate); }
.nav__link { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 33px; padding: 5px 10px; border: 0; background: none; text-align: left; text-decoration: none; font-size: 13px; font-weight: 500; color: var(--slate); }
.nav__link:hover { background: var(--deep); color: var(--ink); }
.nav__link[aria-current='page'] { background: var(--ink); color: var(--paper); font-weight: 600; }
.nav__link svg { flex: none; }
.nav__link span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav__link strong, .nav__link small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__link small { font-size: 11.5px; }
.sidebar__foot { display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-top: 1px solid var(--line); }
.sidebar__foot .nav__link { flex: 1; min-width: 0; }
.topbar { display: none; }
.main { min-height: 100vh; margin-left: var(--side); outline: none; }
.main:focus-visible { box-shadow: none; }
.screen { max-width: 1120px; padding: 36px clamp(20px, 4vw, 48px) 80px; }
.screen-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px 24px; margin-bottom: 28px; }
.screen-head p { margin-top: 6px; color: var(--slate); max-width: 62ch; }
.sub { margin: 32px 0 12px; }
.bar { margin: 0 0 18px; max-width: 360px; }

/* overview */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tiles--small { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.tile { display: grid; gap: 3px; padding: 18px; border: 1px solid var(--line); background: var(--white); text-decoration: none; transition: border-color 0.15s; }
.tile:hover { border-color: var(--ink); }
.tile svg { margin-bottom: 8px; color: var(--slate); }
.tile strong { font-weight: 700; }
.tile span { font-size: 12.5px; color: var(--slate); }
.tile .tile__draft { color: var(--accent); font-weight: 600; }
.columns { display: grid; gap: 16px; margin-top: 32px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); align-items: start; }
.card { padding: 24px; border: 1px solid var(--line); background: var(--white); }
.card > h2 { margin-bottom: 6px; }
.card .intro { margin-bottom: 16px; }
.card--note { margin-top: 24px; background: var(--panel); }
.steps { display: grid; gap: 12px; margin-top: 10px; padding-left: 20px; color: var(--slate); }
.steps strong { color: var(--ink); }
.feed { list-style: none; padding: 0; }
.feed li { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 13px; }
.feed li:first-child { border-top: 0; }
.feed time { flex: none; color: var(--slate); font-size: 12px; }
.feed--card { border: 1px solid var(--line); background: var(--white); margin-bottom: 16px; }
.feed--card li { padding: 13px 18px; }
.roles { display: grid; gap: 8px; margin-top: 8px; }
.roles div { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.roles dt { width: 120px; font-weight: 700; }
.roles dd { color: var(--slate); }

/* fields */
.form { display: grid; gap: 18px; }
.field { min-width: 0; border: 0; padding: 0; }
.field + .field, .card .field + .btn, .field-group .field + .field { margin-top: 16px; }
.form .field + .field { margin-top: 0; }
.field__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; margin-bottom: 4px; }
.field__top label, .field__name, .choice legend { font-size: 12.5px; font-weight: 600; color: var(--slate); }
.field__req { font-weight: 500; font-size: 11.5px; }
.field__hint { margin-top: 5px; font-size: 12px; color: var(--slate); overflow-wrap: anywhere; }
.field__error { margin-top: 5px; font-size: 13px; font-weight: 600; color: var(--danger); }
.field-group { padding: 14px; border: 1px solid var(--line); background: var(--paper); }
.input { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid #a49c8d; background: var(--white); border-radius: 0; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: var(--ring); }
.input[readonly] { background: var(--panel); color: var(--slate); }
.input--grow { display: block; resize: none; overflow: hidden; line-height: 1.5; }
.rich { border: 1px solid #a49c8d; background: var(--white); }
.rich:focus-within { border-color: var(--ink); box-shadow: var(--ring); }
.rich__tools { display: flex; border-bottom: 1px solid var(--line); background: var(--panel); }
.rich__area { border: 0; min-height: 92px; max-height: 420px; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: none; }
.rich__area:focus { box-shadow: none; }
.rich__area a { color: var(--accent); }
.choice { border: 0; }
.choice__row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.choice__item { display: flex; align-items: flex-start; gap: 8px; padding: 9px 13px; border: 1px solid var(--line); background: var(--white); cursor: pointer; }
.choice__item:has(:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice__item:has(:focus-visible) { box-shadow: var(--ring); }
.choice__item input { margin-top: 3px; accent-color: var(--ink); }
.choice__item small { display: block; font-size: 12px; color: var(--slate); }
.choice:disabled { opacity: 0.6; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { position: relative; flex: none; width: 38px; height: 22px; background: #8b8477; border-radius: 22px; transition: background 0.15s; }
.switch__track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .switch__track { background: var(--ok); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--ring); }
.switch input:disabled + .switch__track { opacity: 0.5; }
.switch--small { font-size: 12px; width: 94px; color: var(--slate); }
.picture-row { display: flex; gap: 14px; align-items: center; }
.picture { display: grid; place-items: center; flex: none; width: 112px; height: 84px; border: 1px solid var(--line); background: repeating-conic-gradient(#efebe3 0 25%, #fffefc 0 50%) 0 0 / 16px 16px; overflow: hidden; font-size: 11.5px; color: var(--slate); }
.picture img { width: 100%; height: 100%; object-fit: contain; }
.picture-row__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.items { display: grid; gap: 6px; }
.item { border: 1px solid var(--line); background: var(--white); }
.item__head { display: flex; align-items: center; }
.item__name { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 40px; padding: 6px 12px; border: 0; background: none; text-align: left; font-weight: 600; font-size: 13px; }
.item__body { padding: 4px 14px 16px; border-top: 1px solid var(--line); }

/* collections */
.group + .group { margin-top: 30px; }
.group h2 { display: flex; gap: 10px; align-items: baseline; margin-bottom: 10px; }
.group h2 span { font-size: 12px; color: var(--slate); font-weight: 600; }
.rows { border: 1px solid var(--line); background: var(--white); }
.row { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--white); }
.row:first-child { border-top: 0; }
.row:hover { background: var(--paper); }
.row.is-dragging, .section.is-dragging, .item.is-dragging { opacity: 0.5; }
.row__drag { color: #a49c8d; cursor: grab; display: grid; }
.row__pic { display: grid; place-items: center; flex: none; width: 52px; height: 52px; border: 1px solid var(--line); background: var(--panel); color: var(--slate); overflow: hidden; font-weight: 700; }
.row__pic img { width: 100%; height: 100%; object-fit: contain; }
.row__pic--round { border-radius: 50%; width: 42px; height: 42px; }
.row__main { flex: 1; min-width: 0; padding: 6px 0; border: 0; background: none; text-align: left; }
.row__main strong, .row__main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__main strong { font-weight: 600; }
.row__main span { font-size: 12.5px; color: var(--slate); }
.row__main em { margin-left: 8px; padding: 1px 7px; background: var(--deep); font-style: normal; font-size: 11px; }
.row.is-hidden .row__main strong, .row.is-hidden .row__pic { opacity: 0.6; }
.row__tools { display: flex; flex: none; }
.row__meta { display: grid; justify-items: end; gap: 3px; flex: none; font-size: 12px; color: var(--slate); }
.tag { padding: 2px 9px; border: 1px solid var(--line); background: var(--paper); font-size: 11.5px; font-weight: 600; color: var(--ink); }
.tag--admin { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* media */
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 18px; padding: 26px 20px; border: 1.5px dashed #a49c8d; background: var(--panel); text-align: center; cursor: pointer; }
.drop:hover, .drop.is-over { border-color: var(--ink); background: var(--deep); }
.drop:focus-within { box-shadow: var(--ring); }
.drop span { font-size: 12.5px; color: var(--slate); }
.drop.is-busy { opacity: 0.5; pointer-events: none; }
.media-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); margin-top: 14px; }
.media-grid--big { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.media-grid .empty { grid-column: 1 / -1; }
.media-tile { aspect-ratio: 1; padding: 6px; border: 1px solid var(--line); background: var(--panel); overflow: hidden; }
.media-tile:hover, .media-tile.is-current { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.media-tile img, .media-card__pic img { width: 100%; height: 100%; object-fit: contain; }
.media-card { border: 1px solid var(--line); background: var(--white); }
.media-card__pic { display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--panel); overflow: hidden; font-weight: 700; color: var(--slate); }
.media-card figcaption { padding: 10px 12px 0; font-size: 12px; }
.media-card figcaption strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-card figcaption span { color: var(--slate); }
.media-card__tools { display: flex; padding: 2px 6px 6px; }

/* dialogs */
.dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); margin: auto; padding: 0; border: 1px solid var(--ink); background: var(--paper); color: inherit; }
.dialog[open] { display: flex; flex-direction: column; }
.dialog--wide { width: min(880px, calc(100vw - 32px)); }
.dialog--side { width: min(600px, 100vw); height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; border-width: 0 0 0 1px; }
.dialog::backdrop { background: rgba(20, 19, 18, 0.5); }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.dialog__head h2 { overflow-wrap: anywhere; }
.dialog__body { flex: 1; overflow-y: auto; padding: 24px; }
.dialog__text { overflow-wrap: anywhere; }
.dialog__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--panel); }
.dialog__foot:empty { display: none; }
.secret { display: grid; gap: 10px; justify-items: start; margin: 14px 0 8px; padding: 14px; border: 1px solid var(--line); background: var(--white); }
.secret code { white-space: pre-wrap; overflow-wrap: anywhere; font: 500 13px/1.6 ui-monospace, Consolas, monospace; }
.reset { display: grid; gap: 28px; }
.reset section { display: grid; gap: 10px; justify-items: start; }
.reset section .field { width: 100%; }
.reset p { color: var(--slate); }
.block-picker { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.block-card { display: grid; gap: 3px; padding: 18px; border: 1px solid var(--line); background: var(--white); text-align: left; }
.block-card:hover { border-color: var(--ink); }
.block-card span { font-size: 12.5px; color: var(--slate); }
.plain-list { list-style: none; padding: 0; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.plain-list li:first-child { border-top: 0; }
.plain-list span { display: block; font-size: 12.5px; color: var(--slate); }
.plain-list .btn span { color: inherit; font-size: inherit; }

#toasts { position: fixed; z-index: 90; right: 20px; bottom: 20px; display: grid; gap: 8px; justify-items: end; pointer-events: none; }
.toast { max-width: 380px; padding: 12px 18px; background: var(--ink); color: var(--paper); font-weight: 600; font-size: 13px; }
.toast--error { background: var(--danger); color: #fff; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; background: none; font-size: 13px; font-weight: 600; color: var(--slate); }
.tab:hover { color: var(--ink); }
.tab[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--ink); }

/* page editor */
.screen--editor { max-width: none; padding: 0; }
.editor { display: grid; grid-template-columns: minmax(360px, 440px) 1fr; height: 100vh; height: 100dvh; }
.editor__side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--paper); }
.editor__head { padding: 22px 22px 14px; }
.editor__title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.editor__title h1 { font-size: 22px; }
.editor__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.editor__head .editor__actions { margin-top: 12px; }
.editor__body { flex: 1; overflow-y: auto; padding: 16px 22px 40px; }
.editor .tabs { padding: 0 18px; }
.status { font-size: 12.5px; font-weight: 600; color: var(--ok); }
.screen-head .status { color: var(--ok); }
.status--draft, .screen-head .status--draft { color: var(--accent); }
.status--error, .screen-head .status--error { color: var(--danger); }
.section { margin-bottom: 8px; border: 1px solid var(--line); background: var(--white); }
.section.is-open { border-color: var(--ink); }
.section__head { display: flex; align-items: center; padding-right: 4px; }
.section__name { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 46px; padding: 8px 14px; border: 0; background: none; text-align: left; font-weight: 600; font-size: 13.5px; }
.section__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section__name em { flex: none; padding: 1px 7px; background: var(--deep); font-style: normal; font-size: 11px; font-weight: 600; }
.section.is-hidden .section__name span { opacity: 0.55; }
.section .icon-btn { width: 32px; }
.section__body { padding: 6px 14px 18px; border-top: 1px solid var(--line); }
.section__body > * + * { margin-top: 16px; }
.list-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); background: var(--panel); text-decoration: none; }
.list-link:hover { border-color: var(--ink); }
.list-link small { display: block; color: var(--slate); }
.preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--deep); }
.preview__bar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel); font-size: 12.5px; color: var(--slate); }
.preview__bar > span { flex: 1; min-width: 0; }
.preview__tools { display: flex; }
.preview__shell { flex: 1; min-height: 0; margin: 14px; overflow: hidden; }
.preview__frame { display: block; width: 100%; height: 100%; margin: 0 auto; border: 1px solid var(--line); background: #fff; transform-origin: 0 0; }
.google { margin: 14px 0 6px; padding: 16px; border: 1px solid var(--line); background: #fff; font-family: Arial, sans-serif; }
.google span { font-size: 12px; color: #4d5156; }
.google strong { display: block; margin: 4px 0; font-size: 18px; font-weight: 400; line-height: 1.3; color: #1a0dab; }
.google p { font-size: 13px; line-height: 1.5; color: #4d5156; }

/* sign in */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: linear-gradient(160deg, var(--panel), var(--paper)); }
.auth__box { width: min(420px, 100%); padding: 40px; border: 1px solid var(--line); background: var(--white); }
.auth__box > img { display: block; margin-bottom: 28px; }
.auth__box h1 { margin-bottom: 8px; }
.auth__box .form { margin-top: 22px; }
.auth__box > .btn, .auth__box > .link-btn { margin-top: 18px; }
.auth__foot { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--slate); }

@media (max-width: 1080px) {
  .editor { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; }
  .editor__side { border-right: 0; }
  .editor__body { overflow: visible; }
  .preview { height: 80vh; border-top: 1px solid var(--line); }
}
@media (max-width: 820px) {
  .topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
  .sidebar { transform: translateX(-100%); visibility: hidden; transition: transform 0.2s, visibility 0.2s; box-shadow: 0 0 40px rgba(0, 0, 0, 0.2); }
  .nav-open .sidebar { transform: none; visibility: visible; }
  .sidebar__brand { padding-top: 64px; }
  .menu-toggle { position: relative; z-index: 30; }
  .nav-open .topbar { z-index: 25; background: none; border-color: transparent; }
  .main { margin-left: 0; }
  .screen { padding-top: 24px; }
  .screen--editor { padding: 0; }
  .row { flex-wrap: wrap; }
  .row__main { flex-basis: calc(100% - 120px); }
  .row__tools { margin-left: auto; }
  .row__meta { justify-items: start; }
  .preview__bar > span { display: none; }
  .preview__bar { justify-content: space-between; }
  .icon-btn { width: 40px; height: 40px; }
  .nav__link { min-height: 42px; font-size: 14px; }
  .auth__box { padding: 28px 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
