:root {
  --ink: #0f1c3f;
  --slate: #475569;
  --border: #e2e8f5;
  --bg: #f4f6fc;
  --card: #fff;
  --violet: #1d4ed8;
  --amber: #f2a81d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--ink); background: var(--bg); min-height: 100vh; }
h1, h2, h3, strong { font-family: 'Outfit', sans-serif; }
.hidden { display: none !important; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: linear-gradient(135deg, #1e3a8a, #2563eb); }
.login-card { width: min(400px, 100%); background: #fff; border-radius: 20px; padding: 2rem; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.login-logo { width: 78px; height: 78px; margin: 0 auto 1rem; display: block; object-fit: contain; }
.login-card h1 { text-align: center; font-size: 1.4rem; }
.login-card > p { text-align: center; color: var(--slate); margin: .4rem 0 1.4rem; font-size: .92rem; }
.login-card label { display: flex; flex-direction: column; gap: .4rem; font-size: .85rem; font-weight: 600; margin-bottom: 1rem; }
.login-card input { padding: .75rem .9rem; border: 1.5px solid var(--border); border-radius: 10px; font: inherit; }
.login-card button { width: 100%; padding: .85rem; border: 0; border-radius: 10px; background: var(--amber); font: inherit; font-weight: 700; cursor: pointer; }
.error { color: #dc2626; font-size: .85rem; text-align: center; margin-top: .8rem; }

.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.4rem; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-left { display: flex; align-items: center; gap: .8rem; }
.topbar-left img { width: 42px; height: 42px; object-fit: contain; }
.topbar-left span { display: block; font-size: .78rem; color: var(--slate); }
.topbar-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.btn { border: 0; border-radius: 10px; padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; }
.btn-primary { background: var(--amber); color: #3b1d00; }
.btn-ghost { background: #eef2ff; color: var(--violet); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }

.layout { display: grid; grid-template-columns: 240px 1fr; flex: 1; min-height: 0; }
.layout.preview-on { grid-template-columns: 200px 1fr 42%; }
.preview-panel { background: #fff; border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.preview-panel.hidden { display: none; }
.preview-head { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .88rem; }
#previewFrame { flex: 1; width: 100%; border: 0; background: #fafaff; }
.images-manager { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; }
.img-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.img-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.img-card-meta { padding: .5rem .7rem; font-size: .78rem; }
.img-card-meta small { color: var(--slate); display: block; }
.img-card .btn { margin: 0 .7rem .7rem; width: calc(100% - 1.4rem); }
.field-check label { flex-direction: row !important; align-items: center; gap: .5rem; text-transform: none; font-size: .9rem !important; }
.field-check input { width: auto; }
.hint { display: block; font-size: .72rem; color: var(--slate); font-weight: 400; text-transform: none; letter-spacing: 0; margin-bottom: .25rem; }
@media (max-width: 1100px) { .layout.preview-on { grid-template-columns: 1fr; } .preview-panel { height: 50vh; } }
.sidebar { background: #fff; border-right: 1px solid var(--border); padding: 1rem .6rem; overflow-y: auto; }
.sidebar button { width: 100%; text-align: left; border: 0; background: transparent; padding: .65rem .85rem; border-radius: 10px; font: inherit; font-weight: 500; color: var(--slate); cursor: pointer; margin-bottom: .2rem; }
.sidebar button.active { background: #eef2ff; color: var(--violet); font-weight: 700; }

.editor { padding: 1.4rem; overflow-y: auto; }
.panel { display: none; max-width: 920px; }
.panel.active { display: block; }
.panel h2 { font-size: 1.35rem; margin-bottom: .3rem; }
.panel > .subtitle { color: var(--slate); margin-bottom: 1.2rem; font-size: .92rem; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1.2rem; margin-bottom: 1rem; }
.card h3 { font-size: 1rem; margin-bottom: .8rem; }

.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--slate); margin-bottom: .35rem; }
.field input, .field textarea, .field select { width: 100%; padding: .65rem .8rem; border: 1.5px solid var(--border); border-radius: 10px; font: inherit; }
.field textarea { min-height: 90px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 700px) { .field-row { grid-template-columns: 1fr; } .layout { grid-template-columns: 1fr; } .sidebar { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); } .sidebar button { white-space: nowrap; width: auto; } }

.list-item { border: 1px dashed var(--border); border-radius: 12px; padding: 1rem; margin-bottom: .8rem; background: #fafbff; }
.list-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .7rem; gap: .5rem; }
.list-item-head span { font-weight: 700; font-size: .88rem; }
.list-item-actions { display: flex; gap: .25rem; align-items: center; flex-shrink: 0; }
.list-item-actions .btn-sm { min-width: 2rem; padding: .35rem .45rem; }

.img-picker { display: flex; gap: .6rem; align-items: center; }
.img-picker img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: #eee; }
.img-picker input { flex: 1; }

.toast { position: fixed; bottom: 1.2rem; right: 1.2rem; background: var(--ink); color: #fff; padding: .75rem 1.1rem; border-radius: 10px; font-size: .9rem; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.toast.error { background: #dc2626; }

.modal { position: fixed; inset: 0; background: rgba(8,12,30,.6); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal-box { background: #fff; border-radius: 16px; width: min(720px, 100%); max-height: 85vh; overflow: hidden; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.modal-close { border: 0; background: none; font-size: 1.6rem; cursor: pointer; line-height: 1; }
.modal-upload { padding: .8rem 1.2rem; border-bottom: 1px solid var(--border); }
.modal-upload input[type=file] { display: none; }
.image-grid { padding: 1rem; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .7rem; }
.image-grid button { border: 2px solid transparent; border-radius: 10px; padding: 0; overflow: hidden; cursor: pointer; background: #eee; aspect-ratio: 4/3; }
.image-grid button:hover { border-color: var(--violet); }
.image-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }

.features-list input { margin-bottom: .4rem; }
