:root {
  --navy: #1e3a63; --navy2: #22375c; --azure: #249cd8; --azure7: #146f9e;
  --ink: #223; --muted: #5b6b82; --line: #dbe3ec; --tint: #eef4f9; --bg: #f3f7fb;
  --white: #fff; --warn: #c4772f; --danger: #c4442f; --ok: #2f8f4e;
  --radius: 12px; --shadow: 0 10px 30px -14px rgba(30,58,99,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--navy); letter-spacing: -.01em; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--azure), var(--navy)); }
.brand-sub { font-weight: 700; color: var(--azure7); font-size: .8em; padding: 2px 7px; background: var(--tint); border-radius: 999px; }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--white); color: var(--navy); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; transition: .15s; }
.btn:hover { border-color: var(--azure); color: var(--azure7); }
.btn-primary { background: linear-gradient(135deg, var(--azure7), var(--navy)); color: #fff; border-color: transparent; }
.btn-primary:hover { color: #fff; filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { color: var(--danger); border-color: #f0cfc9; }
.btn-danger:hover { background: #fbeae6; color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: .85rem; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 92vw); background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card h1 { margin: 4px 0 2px; font-size: 1.4rem; color: var(--navy); }
.login-card label { display: grid; gap: 5px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.login-card input { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.login-card input:focus { outline: 2px solid var(--azure); border-color: var(--azure); }
.err { color: var(--danger); font-size: .85rem; min-height: 1em; margin: 0; }

/* topbar */
.topbar { display: flex; align-items: center; gap: 18px; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.tabs { display: flex; gap: 6px; }
.tab { border: none; background: transparent; padding: 8px 16px; border-radius: 9px; cursor: pointer; font-weight: 700; color: var(--muted); }
.tab.active { background: var(--tint); color: var(--navy); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill { font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.pill-warn { background: #fbe7d3; color: var(--warn); }

/* layout */
.layout { display: grid; grid-template-columns: 340px 1fr; gap: 0; height: calc(100vh - 61px); }
.list-pane { border-right: 1px solid var(--line); background: #fff; overflow-y: auto; }
.list-head { position: sticky; top: 0; background: #fff; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 800; color: var(--navy); }
.items { list-style: none; margin: 0; padding: 8px; display: grid; gap: 6px; }
.item { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; }
.item:hover { background: var(--bg); }
.item.active { background: var(--tint); border-color: #bfe0f2; }
.item-thumb { width: 46px; height: 34px; border-radius: 6px; object-fit: contain; background: var(--tint); flex: 0 0 auto; border: 1px solid var(--line); }
.item-body { min-width: 0; flex: 1; }
.item-title { font-weight: 700; font-size: .9rem; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-ord { display: flex; flex-direction: column; gap: 2px; }
.item-ord button { border: 1px solid var(--line); background: #fff; width: 22px; height: 18px; line-height: 1; border-radius: 5px; cursor: pointer; color: var(--muted); font-size: .7rem; padding: 0; }
.item-ord button:hover { color: var(--azure7); border-color: var(--azure); }

/* editor */
.editor { overflow-y: auto; padding: 24px 28px; }
.editor .empty { color: var(--muted); display: grid; place-items: center; height: 100%; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.field input[type=text], .field textarea, .field select { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%; background: #fff; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--azure); border-color: var(--azure); }
.field textarea { min-height: 74px; resize: vertical; }
.bl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bl .sub { position: relative; }
.bl .lang { position: absolute; top: -8px; left: 10px; background: #fff; padding: 0 5px; font-size: .65rem; font-weight: 800; color: var(--azure7); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.editor-head h2 { margin: 0; font-size: 1.15rem; color: var(--navy); }

/* image */
.img-field { display: flex; gap: 14px; align-items: flex-start; }
.img-preview { width: 150px; height: 100px; border: 1px solid var(--line); border-radius: 10px; object-fit: contain; background: var(--tint); flex: 0 0 auto; }
.img-controls { flex: 1; display: grid; gap: 8px; }

/* tech chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--tint); color: var(--navy); border-radius: 999px; padding: 4px 10px; font-size: .8rem; font-weight: 600; }
.chip button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0; }
.chips input { border: none; outline: none; flex: 1; min-width: 100px; padding: 4px; }

/* toast + overlay */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 60; font-weight: 600; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
.overlay { position: fixed; inset: 0; background: rgba(30,58,99,.55); backdrop-filter: blur(3px); display: grid; place-items: center; gap: 14px; z-index: 70; color: #fff; }
.overlay p { font-weight: 600; }
.spinner { width: 46px; height: 46px; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .list-pane { max-height: 40vh; border-right: none; border-bottom: 1px solid var(--line); }
  .bl, .row2 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}
