:root { --ink: #1E1A17; --cream: #F5EFE4; --card: #FFFDF9; --line: #DDD2C0; --muted: #5E544A; --wine: #7A2632; --wine-d: #63202A; --ok: #2F4A35; }
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; background: var(--cream); color: var(--ink); }
a { color: var(--wine); }
h1 { font-size: 26px; margin: 0; line-height: 1.2; }
h2 { font-size: 17px; margin: 0 0 14px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.muted { color: var(--muted); } .small, small { font-size: 13px; }
:focus-visible { outline: 3px solid #C9A15A; outline-offset: 2px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 24px; background: var(--ink); color: var(--cream); }
.top a { color: #E6DCCB; text-decoration: none; }
.brand { font-weight: 700; font-size: 16px; color: var(--cream) !important; }
.top nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.top nav a, .top .linkbtn { padding: 6px 10px; border-radius: 8px; color: #E6DCCB; }
.top nav a.on, .top nav a:hover, .top .linkbtn:hover { background: #3A322B; color: #fff; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 20px 24px 80px; }
.crumbs { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.titlebar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 18px; }
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; }
.flash.ok { background: #E3EDE2; color: var(--ok); }
.flash.err, .err { background: #F6E1E3; color: #7A2632; padding: 10px 14px; border-radius: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--wine); background: var(--wine); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--wine-d); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: #F1EADF; }
.btn.danger { background: #fff; color: #9B1C1C; border-color: #E5B8B8; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--wine); cursor: pointer; }
.linkbtn.danger { color: #9B1C1C; font-size: 13px; }
.inline { display: inline; margin: 0; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: #F1EADF; }
.icon-btn.danger { color: #9B1C1C; }

label, .field { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; color: var(--ink); }
.field { margin-bottom: 14px; }
.field.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-top: -2px; }
input[type=text], input:not([type]), input[type=password], textarea, select { width: 100%; font: inherit; font-weight: 400; font-size: 15px; padding: 8px 10px; border: 1px solid #CFC3AF; border-radius: 7px; background: #fff; color: var(--ink); }
textarea { resize: vertical; line-height: 1.45; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.narrow { max-width: 420px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid2.tight .field { margin-bottom: 10px; }
.span2 { grid-column: 1 / -1; }
.row-end { display: flex; justify-content: flex-end; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Lists */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px 8px; border-bottom: 1px solid #EEE6D8; vertical-align: middle; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: #EEE6D8; }
.pill.pub { background: #E3EDE2; color: var(--ok); }
.slide-list { list-style: none; margin: 0 0 16px; padding: 0; }
.slide-list li { display: grid; grid-template-columns: 34px 1fr auto; grid-template-areas: "n t b" "n l b"; align-items: center; gap: 0 12px; padding: 10px 6px; border-bottom: 1px solid #EEE6D8; }
.slide-list li:target { background: #FBF3E3; }
.slide-list .snum { grid-area: n; font-weight: 700; color: var(--muted); text-align: center; }
.slide-list .stitle { grid-area: t; font-weight: 600; text-decoration: none; color: var(--ink); }
.slide-list .slayout { grid-area: l; font-size: 12px; color: var(--muted); }
.slide-list .sbtns { grid-area: b; display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.slide-list li.is-hidden .stitle { color: #9A8F84; text-decoration: line-through; }
.add-slide { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.add-slide label { min-width: 280px; flex: 1; }
.danger-zone { display: flex; gap: 10px; flex-wrap: wrap; background: transparent; border-style: dashed; }

/* Editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 24px; align-items: start; }
.editor-form { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.preview { position: sticky; top: 16px; }
.frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #0F0E0D; border: 1px solid var(--line); }
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.savebar { position: sticky; bottom: 0; display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 0 4px; background: linear-gradient(to top, var(--card) 70%, rgba(255,253,249,0)); }

fieldset.repeat { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 14px; margin: 0 0 16px; }
fieldset.repeat legend { font-weight: 700; font-size: 13px; padding: 0 6px; }
.rrow { border: 1px solid #EAE1D2; background: #FBF8F2; border-radius: 8px; padding: 10px 12px 2px; margin-bottom: 10px; }
.rrow-tools { display: flex; gap: 4px; align-items: center; margin-bottom: 8px; }
.rrow-tools .rnum { font-weight: 700; font-size: 12px; color: var(--muted); margin-right: auto; }
.rrow-tools button { width: 28px; height: 26px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; }
.rrow-tools button[data-del] { color: #9B1C1C; }
.rrow-fields .field { margin-bottom: 10px; }
[data-add]:disabled { opacity: .5; cursor: not-allowed; }

.imgf { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-weight: 400; }
.imgf-thumb { width: 120px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #eee; }
.imgf-btns { display: flex; gap: 6px; }

/* Picker */
.picker { position: fixed; inset: 0; z-index: 100; background: rgba(20,17,15,.55); display: flex; align-items: center; justify-content: center; padding: 24px; }
.picker[hidden] { display: none; }
.picker-box { background: var(--card); border-radius: 14px; width: min(980px, 100%); max-height: 86vh; display: flex; flex-direction: column; padding: 16px 18px; }
.picker-head { display: flex; align-items: center; gap: 10px; }
.picker-head strong { margin-right: auto; font-size: 16px; }
.picker-head label { flex-direction: row; color: #fff; }
.picker-grid { overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding: 4px; }
.pick-item { padding: 0; border: 2px solid transparent; border-radius: 8px; background: #EEE6D8; cursor: pointer; aspect-ratio: 4 / 3; overflow: hidden; }
.pick-item:hover, .pick-item:focus-visible { border-color: var(--wine); }
.pick-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.media-grid figure { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.media-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #EEE6D8; }
.media-grid figcaption { font-size: 12px; padding: 6px 10px 0; word-break: break-all; color: var(--muted); }
.media-grid form { padding: 2px 10px 8px; }
.media-grid label.btn, .actions label.btn { flex-direction: row; color: #fff; }

/* Auth */
body.auth { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; }
.auth-box { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.auth-box h1 { margin-bottom: 6px; }
.checks-list { list-style: none; padding: 0; margin: 12px 0 18px; }
.checks-list .pass { color: var(--ok); } .checks-list .fail { color: #9B1C1C; font-weight: 600; }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; }
  .preview { position: static; order: -1; }
  .grid2 { grid-template-columns: 1fr; }
  .slide-list li { grid-template-columns: 28px 1fr; grid-template-areas: "n t" "n l" "b b"; }
  .slide-list .sbtns { justify-content: flex-start; margin-top: 8px; }
  table.list thead { display: none; }
  table.list tr { display: grid; grid-template-columns: 1fr auto; padding: 8px 0; border-bottom: 1px solid #EEE6D8; }
  table.list td { border: 0; padding: 4px 8px; }
}
