:root {
  --ink: #2b1209;
  --ink-soft: #704936;
  --cream: #fbf7f1;
  --cream-deep: #f1e5d5;
  --paper: #fffdf9;
  --gold: #c9963a;
  --gold-deep: #9c691a;
  --gold-wash: rgba(201, 150, 58, 0.13);
  --line: rgba(87, 47, 22, 0.16);
  --danger: #aa3d37;
  --success: #2d7653;
  --shadow: 0 18px 50px rgba(56, 27, 10, 0.10);
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-display: 'Prata', Georgia, serif;
}

* { box-sizing: border-box; }
html { background: var(--cream); }
body { min-width: 320px; margin: 0; color: var(--ink); background: var(--cream); font-family: var(--font-body); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.65; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); transition: border-color .18s ease, box-shadow .18s ease; }
input, select { min-height: 44px; padding: 0.65rem 0.75rem; }
textarea { min-height: 112px; padding: 0.7rem 0.75rem; line-height: 1.55; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-wash); }
a { color: inherit; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 2rem; background: radial-gradient(circle at 16% 12%, rgba(224, 183, 92, .26), transparent 35%), linear-gradient(135deg, #2e1409, #5a2a14); }
.login-panel { width: min(100%, 490px); padding: clamp(2rem, 7vw, 3.35rem); border: 1px solid rgba(232, 200, 130, .42); border-radius: 24px; color: var(--cream); background: rgba(58, 27, 12, .87); box-shadow: 0 35px 70px rgba(0, 0, 0, .35); }
.login-brand { display: inline-flex; margin-bottom: 2rem; }
.login-brand img { width: 106px; height: auto; object-fit: contain; }
.eyebrow { margin: 0 0 .6rem; color: var(--gold); font-size: .69rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.login-panel h1, .workspace-header h1 { margin: 0; font-family: var(--font-display); font-weight: 400; }
.login-panel h1 { font-size: clamp(2.05rem, 6vw, 2.65rem); }
.login-copy { margin: 1rem 0 1.8rem; color: rgba(251, 247, 241, .77); line-height: 1.65; }
.login-panel label { display: block; margin: 1rem 0 .45rem; color: rgba(251, 247, 241, .86); font-size: .83rem; font-weight: 600; }
.login-panel input { border-color: rgba(232, 200, 130, .25); color: var(--cream); background: rgba(10, 4, 2, .35); }
.login-panel input:focus { border-color: var(--gold); }
.form-error { margin: 1rem 0 0; color: #ffc3b8; font-size: .9rem; line-height: 1.5; }
.login-footnote { margin: 1.7rem 0 0; color: rgba(251, 247, 241, .53); font-size: .77rem; text-align: center; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: .55rem; min-height: 43px; padding: .65rem 1rem; border: 1px solid transparent; border-radius: 10px; font-size: .88rem; font-weight: 700; text-decoration: none; transition: transform .18s ease, background-color .18s ease, border-color .18s ease, color .18s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { border-color: var(--gold-deep); color: #241005; background: linear-gradient(135deg, #e5bd6a, #bb7e24); box-shadow: 0 7px 18px rgba(156, 105, 26, .19); }
.button-primary:hover:not(:disabled) { background: linear-gradient(135deg, #f0ce81, #c68a30); }
.button-ghost { border-color: var(--line); color: var(--ink); background: transparent; }
.button-ghost:hover { border-color: rgba(156, 105, 26, .5); background: var(--gold-wash); }
.button-danger { border-color: rgba(170, 61, 55, .32); color: var(--danger); background: #fff8f7; }
.button-danger:hover { border-color: var(--danger); background: #fff0ed; }
.button-small { min-height: 36px; padding: .45rem .68rem; border-radius: 8px; font-size: .78rem; }
.button-full { width: 100%; margin-top: 1.45rem; }

.studio-view { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.45rem 1rem; color: var(--cream); background: linear-gradient(175deg, #35170a, #5a2a14 62%, #2f1308); }
.sidebar-brand { display: flex; align-items: center; gap: .8rem; padding: 0 .55rem 1.6rem; border-bottom: 1px solid rgba(232, 200, 130, .17); font-family: var(--font-display); font-size: .95rem; }
.sidebar-brand img { width: 39px; height: 39px; object-fit: contain; }
.studio-nav { display: grid; gap: .35rem; padding-top: 1.4rem; }
.nav-item { display: flex; align-items: center; gap: .8rem; width: 100%; padding: .75rem .8rem; border: 1px solid transparent; border-radius: 10px; color: rgba(251, 247, 241, .68); background: transparent; font-size: .88rem; text-align: left; }
.nav-item i { width: 1.2rem; color: rgba(232, 200, 130, .68); text-align: center; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .075); }
.nav-item.is-active { border-color: rgba(232, 200, 130, .28); color: #fff4dd; background: rgba(201, 150, 58, .18); }
.nav-item.is-active i { color: #f1ca76; }
.sidebar-footer { display: grid; gap: .25rem; margin-top: auto; padding: 1.25rem .3rem 0; border-top: 1px solid rgba(232, 200, 130, .17); }
.quiet-link, .quiet-button { display: flex; align-items: center; gap: .65rem; padding: .55rem; border: 0; color: rgba(251, 247, 241, .66); background: transparent; font-size: .78rem; text-align: left; text-decoration: none; }
.quiet-link:hover, .quiet-button:hover { color: #fff; }

.workspace { min-width: 0; padding: clamp(1.3rem, 4vw, 3.4rem); }
.workspace-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; max-width: 1120px; margin: 0 auto 2rem; }
.workspace-header h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .65rem; }
.status-banner { max-width: 1120px; margin: 0 auto 1.4rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 11px; font-size: .88rem; line-height: 1.5; }
.status-banner.success { border-color: rgba(45, 118, 83, .28); color: #1b5a3a; background: #edf8f1; }
.status-banner.error { border-color: rgba(170, 61, 55, .27); color: #82312c; background: #fff1ef; }
.status-banner.info { border-color: rgba(156, 105, 26, .25); color: #6b4610; background: #fff9e8; }
.editor-root { max-width: 1120px; margin: 0 auto; }
.editor-layout { display: grid; gap: 1.35rem; }
.editor-card { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: 0 8px 25px rgba(60, 30, 12, .045); }
.editor-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.35rem; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, rgba(201, 150, 58, .065), rgba(255, 255, 255, 0)); }
.editor-card-heading h2 { margin: 0; color: var(--ink); font-family: var(--font-display); font-size: 1.18rem; font-weight: 400; }
.editor-card-heading p { max-width: 650px; margin: .35rem 0 0; color: var(--ink-soft); font-size: .84rem; line-height: 1.55; }
.editor-card-body { padding: 1.35rem; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.15rem; }
.field-grid.single { grid-template-columns: 1fr; }
.field { min-width: 0; }
.field.span-all { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: .42rem; color: #5a3827; font-size: .79rem; font-weight: 700; }
.field-help { margin: .4rem 0 0; color: #8a6b5a; font-size: .74rem; line-height: 1.45; }
.field-checkbox { display: flex; align-items: center; gap: .55rem; min-height: 44px; color: #5a3827; font-size: .85rem; font-weight: 600; }
.field-checkbox input { width: 1rem; min-height: auto; height: 1rem; accent-color: var(--gold-deep); }
.section-note { margin: 0; color: var(--ink-soft); font-size: .88rem; line-height: 1.65; }
.split-preview { display: grid; grid-template-columns: minmax(0, 1fr) 165px; gap: 1.1rem; align-items: end; }
.image-preview { overflow: hidden; min-height: 118px; border: 1px solid var(--line); border-radius: 12px; background: var(--cream-deep); }
.image-preview img { width: 100%; height: 155px; display: block; object-fit: cover; }
.upload-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .65rem; }
.upload-row input[type='file'] { display: none; }
.upload-label { cursor: pointer; }
.repeater-list { display: grid; gap: 1rem; }
.repeater-card { position: relative; border: 1px solid var(--line); border-radius: 13px; background: #fffefa; }
.repeater-card.is-inactive { opacity: .63; background: #fbf8f5; }
.repeater-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.repeater-head strong { font-size: .85rem; }
.repeater-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }
.repeater-body { padding: 1rem; }
.repeater-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; margin-top: 1.1rem; }
.gallery-card { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 1rem; align-items: start; }
.gallery-card .image-preview { min-height: 130px; }
.gallery-card .image-preview img { height: 130px; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; }
.content-meta { color: #8a6b5a; font-size: .75rem; }
.loading-state { display: flex; align-items: center; gap: .7rem; padding: 2.5rem; border: 1px dashed var(--line); border-radius: 14px; color: var(--ink-soft); background: rgba(255, 255, 255, .45); }
.empty-state { padding: 2.2rem; border: 1px dashed var(--line); border-radius: 12px; color: var(--ink-soft); text-align: center; }
.empty-state p { margin: 0 0 1rem; line-height: 1.55; }

@media (max-width: 820px) {
  .studio-view { display: block; }
  .sidebar { position: static; height: auto; padding: .85rem 1rem; }
  .sidebar-brand { padding: 0 .35rem .75rem; }
  .studio-nav { display: flex; overflow-x: auto; gap: .45rem; padding: .8rem 0 .15rem; }
  .nav-item { flex: 0 0 auto; width: auto; padding: .62rem .72rem; white-space: nowrap; }
  .sidebar-footer { display: none; }
  .workspace { padding: 1.3rem 1rem 2rem; }
  .workspace-header { align-items: flex-start; margin-bottom: 1.4rem; }
  .header-actions { gap: .45rem; }
  .header-actions .button { min-height: 39px; padding: .55rem .7rem; }
  .field-grid { grid-template-columns: 1fr; }
  .split-preview, .gallery-card { grid-template-columns: 1fr; }
  .image-preview { max-width: 270px; }
}

@media (max-width: 520px) {
  .login-view { padding: 1rem; }
  .login-panel { padding: 2rem 1.45rem; border-radius: 17px; }
  .workspace-header { display: grid; grid-template-columns: 1fr; }
  .header-actions { justify-content: flex-start; }
  .header-actions .button span { display: none; }
  .editor-card-heading, .editor-card-body { padding: 1rem; }
  .repeater-head { align-items: flex-start; flex-direction: column; }
  .repeater-actions { justify-content: flex-start; }
  .button-small { font-size: .72rem; }
}
