:root {
  --bg: #fff;
  --panel: #fffdf9;
  --panel-soft: #f0eee8;
  --ink: #201f1d;
  --muted: #77736a;
  --line: #e2ded5;
  --accent: #9b6a45;
  --accent-ink: #fffaf2;
  --danger: #a74436;
  color-scheme: light;
  font-family: NeueHaasGrotesk, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background-color: var(--bg); background-image: radial-gradient(rgba(29, 29, 29, .07) 1px, transparent 1px), radial-gradient(rgba(29, 29, 29, .06) 1px, transparent 1px); background-size: 22px 22px; background-attachment: fixed; color: var(--ink); font-size: 16px; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, .button { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 9px 14px; cursor: pointer; text-decoration: none; transition: border-color .15s, background .15s, transform .15s; }
button:hover, .button:hover { border-color: #c9c0b2; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, textarea, select { width: 100%; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 14px; padding: 11px 12px; min-height: 42px; }
textarea { line-height: 1.5; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
label, .field > label, .field > span { display: grid; gap: 8px; color: var(--muted); font-size: 13px; letter-spacing: .01em; }
small { color: var(--muted); line-height: 1.35; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(34px, 5vw, 58px); line-height: .95; letter-spacing: -.055em; font-weight: 620; }
h2 { font-size: 21px; letter-spacing: -.02em; margin-bottom: 18px; }
h3 { font-size: 15px; margin-bottom: 12px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-form { position: relative; width: min(280px, 100%); }
.login-form input, .login-form button { width: 100%; min-height: 44px; }
.login-form button { position: absolute; top: calc(100% + 10px); left: 0; animation: login-reveal .18s ease-out; }
.login-form .error { position: absolute; top: calc(100% + 64px); left: 0; right: 0; margin: 0; text-align: center; font-size: 14px; }
@keyframes login-reveal { from { opacity: 0; transform: translateY(-4px); } }
.login-form button, .save-button { background: var(--ink); border-color: var(--ink); color: white; }
.error { color: var(--danger); }
.loading { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 292px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: rgba(255, 253, 249, .72); backdrop-filter: blur(18px); padding: 22px 16px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 24px; font-weight: 610; letter-spacing: -.02em; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.nav { display: grid; gap: 7px; min-height: 0; }
.nav button, .side-bottom button, .side-bottom a { display: flex; align-items: center; width: 100%; gap: 10px; border: 0; background: transparent; border-radius: 14px; padding: 10px; text-align: left; color: var(--muted); text-decoration: none; }
.nav button:hover, .side-bottom button:hover, .side-bottom a:hover, .nav .active, .side-bottom .active { background: var(--panel-soft); color: var(--ink); }
.nav-label { margin: 18px 10px 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .09em; }
.project-nav { overflow: auto; display: grid; gap: 4px; padding-right: 2px; max-height: calc(100vh - 310px); }
.project-pill .mini { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 10px; }
.project-pill span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-pill.is-muted { opacity: .48; }
.new-project { margin-top: 8px; }
.side-bottom { margin-top: auto; display: grid; gap: 4px; border-top: 1px solid var(--line); padding-top: 14px; }
.main { min-width: 0; padding: 34px clamp(28px, 5vw, 72px) 80px; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: flex-end; align-items: center; gap: 14px; width: fit-content; margin: 0 0 10px auto; padding: 6px 6px 6px 16px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .86); backdrop-filter: blur(14px); }
.save-state { color: var(--muted); font-size: 14px; }
.save-state::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #b8b0a4; margin-right: 8px; }
.save-state.dirty::before { background: var(--accent); }
.editor { max-width: 1180px; margin: 0 auto; }
.editor.narrow { max-width: 940px; }
.title-row { display: flex; justify-content: flex-end; }
.card, .subcard { background: var(--panel); border: 1px solid var(--line); border-radius: 26px; padding: 24px; margin: 18px 0; box-shadow: 0 12px 40px rgba(45, 37, 25, .035); }
.subcard { margin: 0; border-radius: 20px; background: #fbfaf6; }
.grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 16px; align-items: start; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-all { grid-column: 1 / -1; }
.stack { display: grid; gap: 16px; }
.field { display: grid; gap: 8px; min-width: 0; }
.field + .field { margin-top: 0; }
.section-head, .mini-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.section-head h2, .section-head p, .mini-head h3 { margin-bottom: 0; }
.section-head p { color: var(--muted); }
.inline-row { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: end; }
.link-row { grid-template-columns: minmax(160px, 1fr) minmax(240px, 2fr) auto; margin-bottom: 12px; }
.row-button { align-self: end; }
.work-row { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.grow { flex: 1; }
.handle { color: var(--muted); cursor: grab; padding-top: 34px; user-select: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button, .ghost { padding: 8px 11px; background: transparent; }
.danger { color: var(--danger); border-color: #e5c6bf; }
.danger-zone { display: flex; justify-content: flex-end; margin-top: 28px; }
.inline-toggles { display: flex; gap: 22px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.toggle input { width: 18px; min-height: 18px; accent-color: var(--accent); }
.media-row { display: grid; grid-template-columns: 86px 1fr; gap: 14px; align-items: stretch; }
.mini { width: 72px; height: 72px; object-fit: cover; border-radius: 16px; background: var(--panel-soft); border: 1px solid var(--line); }
.mini.empty { display: block; }
.media-controls { display: grid; gap: 8px; }
.drop { display: grid; place-items: center; min-height: 44px; border: 1px dashed #cbc4b8; border-radius: 14px; color: var(--muted); background: #fbfaf7; cursor: pointer; }
.drop input { display: none; }
.notice { color: var(--accent); }
.add-menu { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.add-menu button { padding: 8px 10px; }
.block-card { border-top: 1px solid var(--line); padding: 13px 0; }
.block-summary { width: 100%; border: 0; border-radius: 18px; background: transparent; display: grid; grid-template-columns: 24px 58px 1fr 24px; align-items: center; gap: 14px; padding: 8px; text-align: left; }
.block-summary:hover { background: var(--panel-soft); }
.block-summary .mini { width: 58px; height: 46px; border-radius: 12px; }
.block-copy { display: grid; gap: 4px; min-width: 0; }
.block-copy strong { text-transform: capitalize; }
.block-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--muted); justify-self: center; }
.block-body { padding: 16px 8px 8px 96px; }
.backup-list { display: grid; gap: 10px; }
.backup-row { display: flex; justify-content: space-between; gap: 14px; align-items: center; border-top: 1px solid var(--line); padding: 14px 0 4px; }
.backup-row div { display: grid; gap: 4px; }
.muted { color: var(--muted); }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 420px; background: var(--ink); color: white; border-radius: 18px; padding: 14px 16px; box-shadow: 0 20px 60px rgba(0,0,0,.22); z-index: 20; }
.toast.is-error { background: var(--danger); }
.secondary { background: transparent; color: var(--ink); }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .project-nav { max-height: none; }
  .grid, .grid.two, .grid.three, .grid.four, .link-row { grid-template-columns: 1fr; }
  .block-body { padding-left: 8px; }
  .topbar { top: 0; }
}

.work-row .grid.four { grid-template-columns: 1fr 1fr 1fr minmax(240px, 1.6fr); }
.work-row .media-row { grid-template-columns: 58px minmax(150px, 1fr); }
.work-row .mini { width: 54px; height: 54px; border-radius: 14px; }
.work-row .drop { min-height: 36px; font-size: 12px; }
.lock { font-size: 13px; filter: grayscale(1); opacity: .75; }

/* Polish pass */
html, body, #root { height: 100%; }
.app-shell { height: 100vh; min-height: 0; overflow: hidden; }
.sidebar { position: sticky; align-self: stretch; min-height: 100vh; height: 100vh; background: rgba(255, 253, 249, .9); }
.main { height: 100vh; overflow-y: auto; }

.toast { left: 50%; right: auto; bottom: 22px; transform: translateX(-50%); }

.blocks-card .section-head { align-items: flex-start; }
.add-block { position: relative; display: inline-flex; justify-content: flex-end; }
.add-block.align-start { justify-content: flex-start; }
.add-block-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 10; min-width: 210px; display: grid; gap: 2px; padding: 7px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 44px rgba(45, 37, 25, .13); }
.add-block.align-start .add-block-menu { left: 0; right: auto; }
.add-block-menu button { justify-content: flex-start; width: 100%; border: 0; border-radius: 10px; background: transparent; text-align: left; padding: 9px 10px; }
.add-block-menu button:hover, .add-block-menu button:focus-visible { background: var(--panel-soft); }
.block-list { border-top: 1px solid var(--line); }
.block-card { position: relative; border-top: 0; border-bottom: 1px solid var(--line); padding: 6px 0; }
.block-card.drop-target::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 2px; border-radius: 999px; background: var(--accent); }
.block-summary { width: 100%; border: 0; border-radius: 16px; background: transparent; display: grid; grid-template-columns: 22px 56px minmax(0, 1fr) auto 22px; align-items: center; gap: 12px; padding: 7px 8px; text-align: left; cursor: pointer; }
.block-summary:hover, .block-summary:focus-visible, .block-card:focus-within .block-summary { background: var(--panel-soft); }
.block-summary .handle { padding-top: 0; text-align: center; font-size: 14px; opacity: .55; }
.block-summary .mini { width: 56px; height: 44px; border-radius: 12px; }
.block-actions { display: flex; gap: 4px; opacity: 0; transform: translateX(4px); transition: opacity .15s, transform .15s; }
.block-card:hover .block-actions, .block-card:focus-within .block-actions { opacity: 1; transform: translateX(0); }
.block-actions button { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border-radius: 999px; background: rgba(255,255,255,.72); }
.block-actions .danger { color: var(--danger); }
.block-body { padding: 16px 8px 16px 98px; }
.block-list-footer { display: flex; justify-content: flex-start; padding-top: 18px; }

@media (max-width: 980px) {
  .app-shell { height: auto; overflow: visible; }
  .sidebar { min-height: 0; height: auto; }
  .main { height: auto; overflow: visible; }
  .block-summary { grid-template-columns: 18px 48px minmax(0, 1fr) 22px; }
  .block-actions { grid-column: 3 / -1; opacity: 1; transform: none; justify-content: flex-start; }
}
.block-actions { opacity: .42; transform: none; }
.block-card:hover .block-actions, .block-card:focus-within .block-actions { opacity: 1; }
.block-actions button { color: var(--ink); border-color: var(--line); }
.block-actions button.danger { color: var(--danger); }
