:root {
  --cream: #f7f3ed;
  --surface: #ffffff;
  --surface-2: #f6f0e9;
  --surface-3: #efe7e0;
  --line: #ece2e4;
  --line-2: #ddd0d4;
  --ink: #2c2530;
  --ink-2: #574d5e;
  --ink-3: #726879;
  --faint: #877c8f;
  --plum: #4a3652;
  --plum-deep: #382742;
  --plum-soft: #f1eaf3;
  --taupe: #8a7059;
  --taupe-soft: #f3ece4;
  --gold: #b6975f;
  --danger: #a8483f;
  --radius: 4px;
  --radius-lg: 5px;
  --radius-sm: 3px;
  --shadow-sm: 0 1px 2px rgba(44,37,48,.05);
  --shadow: 0 2px 10px rgba(44,37,48,.05), 0 10px 30px rgba(74,54,82,.05);
  /* Admin panel uses a single typeface: Montserrat (per brand direction). */
  --font: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "Montserrat", ui-monospace, "Segoe UI", Roboto, sans-serif;
  /* legacy aliases */
  --bg: var(--cream); --text: var(--ink); --text-muted: var(--ink-3); --text-faint: var(--faint);
  --border: var(--line); --border-strong: var(--line-2);
  --accent: var(--plum); --accent-ink: var(--plum); --on-accent: #fff; --accent-soft: var(--plum-soft);
  --green: var(--plum); --blue: var(--taupe); --red: var(--danger);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overscroll-behavior: none; }
body {
  background: var(--cream); color: var(--ink); font-family: var(--font);
  font-size: 12.5px; line-height: 1.55; letter-spacing: -0.005em; -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
.nav, .sidebar { overscroll-behavior: contain; }
a { color: inherit; text-decoration: none; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.muted { color: var(--ink-3); }
.green, .blue { color: var(--ink); }
.center { text-align: center; } .right { margin-left: auto; } .r { text-align: right; } .small { font-size: .87em; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.scrim { display: none; }
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 16px 18px 13px; border-bottom: 1px solid var(--line); }
.brand-logo { height: 60px; width: auto; max-width: 100%; display: block; }
.nav { padding: 6px 9px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); font-weight: 600; padding: 11px 11px 5px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 11px; border-radius: var(--radius);
  color: var(--ink-2); font-size: 12px; font-weight: 500; margin: 1px 0; transition: background .12s, color .12s, box-shadow .12s;
}
.nav-item svg { width: 15px; height: 15px; stroke: currentColor; opacity: .7; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--plum-soft); color: var(--plum); box-shadow: inset 3px 0 0 var(--plum); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.sidebar-foot { padding: 10px; border-top: 1px solid var(--line); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.user-avatar { width: 34px; height: 34px; border-radius: var(--radius); background: var(--plum); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12.5px; flex-shrink: 0; }
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 12px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; margin-top: 1px; font-weight: 600; }
.user-logout { background: none; border: none; color: var(--ink-3); cursor: pointer; padding: 4px; display: inline-flex; }
.user-logout:hover { color: var(--plum); }
.user-logout svg { width: 16px; height: 16px; stroke: currentColor; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mobile-bar { display: none; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.crumbs { font-size: 11px; letter-spacing: .04em; color: var(--faint); font-weight: 500; text-transform: uppercase; }
.crumbs strong { font-family: var(--serif); color: var(--ink); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: 16px; }
.crumbs .sep { margin: 0 8px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.btn-logout { background: var(--surface); border: 1px solid var(--line-2); color: var(--ink); padding: 7px 15px; border-radius: var(--radius); font-size: 12px; font-weight: 500; font-family: var(--font); cursor: pointer; transition: all .12s; }
.btn-logout:hover { background: var(--plum); color: #fff; border-color: var(--plum); }
.hamburger { background: none; border: none; padding: 6px; cursor: pointer; color: var(--ink); display: inline-flex; }
.hamburger svg { width: 22px; height: 22px; stroke: currentColor; }
.content { padding: 14px 18px 44px; max-width: 1500px; width: 100%; }

.flash { background: var(--plum-soft); border: 1px solid rgba(74,54,82,.18); color: var(--plum); padding: 9px 13px; border-radius: var(--radius); margin-bottom: 12px; font-size: 12px; font-weight: 500; }
.flash.err { background: #f8ecea; border-color: rgba(168,72,63,.24); color: var(--danger); }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 9px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-sm); }
.card-label { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.card-label svg { width: 13px; height: 13px; stroke: currentColor; opacity: .8; }
.card-value { font-family: var(--mono); font-size: 16.5px; font-weight: 500; line-height: 1; letter-spacing: -.02em; color: var(--ink); }
.card-value.small { font-size: 14.5px; }
.card-value .unit { font-family: var(--font); font-size: 11px; color: var(--faint); font-weight: 500; }
.card-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-top: 7px; }
.mini-bar { height: 3px; background: var(--surface-3); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.mini-bar > span { display: block; height: 100%; background: var(--plum); width: 0; transition: width .3s ease; }
.spark { margin-top: 8px; } .spark canvas { width: 100%; height: 22px; display: block; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.panel-h { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 600; margin-bottom: 12px; }
.panel-h.flush { margin-bottom: 4px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chart-wrap canvas { width: 100%; height: 240px; display: block; }
.chart-wrap.sm canvas { width: 100%; height: 142px; display: block; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); font-weight: 600; padding: 7px 10px; border-bottom: 1px solid var(--line); }
thead th.r { text-align: right; }
tbody td { padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 12px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
.proc td, .hist td, .coll td { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-family: var(--mono); font-size: 10.5px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink-2); padding: 2px 8px; border-radius: var(--radius-sm); }
.tag.blue { color: var(--plum); background: var(--plum-soft); border-color: rgba(74,54,82,.2); }
.msg { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }

/* ---------- Glance (legacy) ---------- */
.glance { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.glance > div { display: flex; flex-direction: column; gap: 6px; }
.g-lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); font-weight: 600; }
.g-val { font-family: var(--mono); font-size: 15px; } .g-link { margin-left: auto; color: var(--plum); font-size: 12px; font-weight: 600; }

/* ---------- VPS tabs ---------- */
.vps-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.vps-tabs a { display: flex; align-items: center; gap: 7px; padding: 10px 1px 14px; color: var(--ink-3); font-size: 12.5px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .12s; }
.vps-tabs a svg { width: 15px; height: 15px; stroke: currentColor; }
.vps-tabs a:hover { color: var(--ink); }
.vps-tabs a.on { color: var(--plum); border-bottom-color: var(--plum); font-weight: 600; }

/* ---------- Live head ---------- */
.live-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; flex-wrap: wrap; gap: 10px; }
.live-status { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--plum); box-shadow: 0 0 0 0 rgba(74,54,82,.4); animation: pulse 1.7s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(74,54,82,.35)} 70%{box-shadow:0 0 0 6px rgba(74,54,82,0)} 100%{box-shadow:0 0 0 0 rgba(74,54,82,0)} }
.live-label { letter-spacing: .12em; font-weight: 700; text-transform: uppercase; color: var(--plum); font-size: 10.5px; }
.refresh { display: flex; align-items: center; gap: 5px; font-size: 10.5px; letter-spacing: .08em; color: var(--faint); font-weight: 600; text-transform: uppercase; }
.refresh button, .ranges button, .ghost { background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-3); padding: 5px 12px; border-radius: var(--radius); font-size: 11px; font-weight: 500; cursor: pointer; font-family: var(--mono); transition: all .12s; }
.refresh button.on, .ranges button.on { background: var(--plum); color: #fff; border-color: var(--plum); }
.refresh button:hover, .ranges button:hover, .ghost:hover { border-color: var(--plum); color: var(--plum); }
.refresh button.on:hover, .ranges button.on:hover { color: #fff; }
.range-bar { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; flex-wrap: wrap; }
.ranges { display: flex; gap: 6px; }

/* ---------- Security / internals ---------- */
.test-email { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.mongo-status { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.mongo-status .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; margin-left: 8px; }
.mongo-status .lbl:first-child { margin-left: 0; }
.badge { font-family: var(--mono); font-size: 10.5px; font-weight: 500; padding: 3px 9px; border-radius: var(--radius-sm); }
.badge.ok { color: #fff; background: var(--plum); border: 1px solid var(--plum); }
.badge.bad, .badge.off { color: var(--ink-3); background: var(--surface-2); border: 1px solid var(--line-2); }

/* ---------- Buttons / forms ---------- */
.btn-primary { background: var(--plum); color: #fff; border: 1px solid var(--plum); border-radius: var(--radius); padding: 10px 18px; font-size: 12px; font-weight: 600; cursor: pointer; width: 100%; font-family: var(--font); box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s; }
.btn-primary:hover { background: var(--plum-deep); border-color: var(--plum-deep); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.test-email .btn-primary, .btn-primary.sm { width: auto; }
.btn-primary.sm { padding: 9px 16px; font-size: 12px; }
.btn-danger { background: var(--surface); color: var(--danger); border: 1px solid rgba(168,72,63,.35); border-radius: var(--radius); padding: 9px 16px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: var(--font); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ---------- Auth ---------- */
.auth-body { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; background: var(--cream); }
.auth-card { width: 100%; max-width: 392px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 34px 32px; box-shadow: var(--shadow); }
.auth-brand { text-align: left; }
.auth-brand .brand-logo { height: 48px; }
.auth-brand > span { display: none; }
.auth-kicker { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--taupe); font-weight: 600; margin: 16px 0 22px; }
.auth-title { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 6px; color: var(--ink); }
.auth-sub { color: var(--ink-3); font-size: 12.5px; margin: 0 0 22px; line-height: 1.5; }
.auth-form { display: flex; flex-direction: column; gap: 7px; }
.auth-form label { font-size: 11px; color: var(--ink-2); font-weight: 500; margin-top: 8px; text-transform: uppercase; letter-spacing: .05em; }
.auth-form input { background: var(--surface); border: 1px solid var(--line-2); color: var(--ink); padding: 11px 13px; border-radius: var(--radius); font-size: 12.5px; font-family: var(--font); transition: border-color .12s, box-shadow .12s; }
.auth-form input:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 3px var(--plum-soft); }
.auth-form .btn-primary { margin-top: 18px; padding: 12px; }
.otp-input { font-family: var(--mono); font-size: 16px; letter-spacing: .32em; text-align: center; }
.auth-error { background: #f8ecea; border: 1px solid rgba(168,72,63,.28); color: var(--danger); padding: 10px 14px; border-radius: var(--radius); font-size: 12px; font-weight: 500; margin-bottom: 18px; }
.resend { margin-top: 16px; text-align: center; }
.link-btn { background: none; border: none; color: var(--plum); font-size: 12px; font-weight: 500; cursor: pointer; font-family: var(--font); }
.link-btn:hover { text-decoration: underline; }
.auth-foot { color: var(--faint); font-size: 11px; margin-top: 22px; text-transform: uppercase; letter-spacing: .09em; }

/* ---------- Settings ---------- */
.settings { max-width: 560px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; color: var(--ink-2); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.field input, .select, .textarea { background: var(--surface); border: 1px solid var(--line-2); color: var(--ink); padding: 10px 12px; border-radius: var(--radius); font-size: 12.5px; font-family: var(--font); transition: border-color .12s, box-shadow .12s; }
.field input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 3px var(--plum-soft); }
.field input:disabled { background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; }
.textarea { resize: vertical; } .select { cursor: pointer; }
.form-actions { margin-top: 4px; }
.settings-note { font-size: 12px; color: var(--ink-3); margin: 0 0 15px; } .settings-note.flush { margin: 0; }
.hint { font-size: 11px; color: var(--faint); } .inline-link { color: var(--plum); font-weight: 500; text-decoration: underline; }

/* ---------- Key-value + edit disclosure ---------- */
.kv { display: flex; flex-direction: column; gap: 10px; margin: 0 0 4px; }
.kv > div { display: flex; gap: 14px; align-items: baseline; }
.kv dt { width: 84px; flex-shrink: 0; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 600; margin: 0; }
.kv dd { margin: 0; font-size: 12.5px; color: var(--ink); } .kv dd.mono { font-family: var(--mono); font-size: 12px; }
.edit-block { border-top: 1px solid var(--line); margin-top: 15px; padding-top: 15px; }
.edit-summary { display: inline-block; cursor: pointer; list-style: none; font-size: 12px; font-weight: 600; color: var(--plum); padding: 8px 15px; border: 1px solid var(--line-2); border-radius: var(--radius); user-select: none; transition: all .12s; }
.edit-summary::-webkit-details-marker { display: none; } .edit-summary::marker { content: ""; }
.edit-summary:hover { background: var(--plum); color: #fff; border-color: var(--plum); }
details[open] > .edit-summary { background: var(--plum-soft); border-color: var(--plum-soft); margin-bottom: 15px; }
.edit-block .form { margin-top: 0; }

/* ---------- Users ---------- */
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.inline-form { flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap; }
.u-name { font-weight: 600; color: var(--ink); } .u-email { font-size: 11px; margin-top: 1px; font-family: var(--mono); color: var(--ink-3); }
.you { font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: #fff; background: var(--plum); padding: 1px 6px; border-radius: 3px; }
.link-manage { color: var(--plum); font-weight: 600; } .link-manage:hover { text-decoration: underline; }
.role-badge { display: inline-block; font-family: var(--mono); font-size: 10.5px; font-weight: 500; padding: 2px 9px; border-radius: var(--radius-sm); text-transform: capitalize; }
.role-badge.owner { color: #fff; background: var(--plum); border: 1px solid var(--plum); }
.role-badge.admin { color: var(--plum); background: var(--plum-soft); border: 1px solid rgba(74,54,82,.24); }
.role-badge.developer { color: var(--taupe); background: var(--taupe-soft); border: 1px solid rgba(138,112,89,.22); }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--ink-3); font-size: 12px; font-weight: 500; } .back-link:hover { color: var(--plum); }
.danger-zone { border-color: rgba(168,72,63,.28); }

/* ---------- Blog (monochrome-free, brand) ---------- */
.blog-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-tabs a { padding: 7px 12px; border-radius: var(--radius); font-size: 12px; font-weight: 500; color: var(--ink-3); }
.filter-tabs a:hover { background: var(--surface-2); color: var(--ink); }
.filter-tabs a.on { background: var(--plum); color: #fff; }
.filter-tabs .cnt { font-family: var(--mono); font-size: 10.5px; opacity: .7; margin-left: 3px; }
.blog-head-right { display: flex; align-items: center; gap: 10px; }
.search input { background: var(--surface); border: 1px solid var(--line-2); color: var(--ink); padding: 8px 12px; border-radius: var(--radius); font-size: 12px; font-family: var(--font); width: 220px; }
.search input:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 3px var(--plum-soft); }
.post-title { font-weight: 600; color: var(--ink); } .post-title:hover { color: var(--plum); }
.post-sub { font-size: 11px; margin-top: 2px; font-family: var(--mono); color: var(--ink-3); }
.status-badge { display: inline-block; font-family: var(--mono); font-size: 10.5px; font-weight: 500; padding: 2px 9px; border-radius: var(--radius-sm); text-transform: capitalize; }
.status-badge.published { color: #fff; background: var(--plum); border: 1px solid var(--plum); }
.status-badge.draft { color: var(--ink-3); background: var(--surface-2); border: 1px solid var(--line-2); }
.status-badge.scheduled { color: var(--taupe); background: var(--taupe-soft); border: 1px solid rgba(138,112,89,.3); }
.actions-cell { white-space: nowrap; } .actions-cell .link-manage { margin-right: 4px; }
.rowbtn { background: none; border: none; color: var(--ink-3); font-size: 11.5px; font-weight: 500; cursor: pointer; font-family: var(--font); padding: 0; margin-left: 12px; }
.rowbtn:hover { color: var(--plum); text-decoration: underline; } .rowbtn.danger:hover { color: var(--danger); }
.inline { display: inline; } .pager { display: flex; align-items: center; gap: 14px; margin-top: 16px; } .empty { padding: 32px 0; }
.save-status { font-size: 11.5px; color: var(--ink-3); } .save-status.ok { color: var(--plum); font-weight: 600; } .save-status.err { color: var(--danger); }
.be-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.be-head-left { display: flex; align-items: center; gap: 14px; }
.be-back { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--ink-2); flex-shrink: 0; }
.be-back svg { width: 17px; height: 17px; stroke: currentColor; }
.be-back:hover { background: var(--plum); color: #fff; border-color: var(--plum); }
.be-title { font-family: var(--serif); font-size: 18px; font-weight: 600; margin: 0; color: var(--ink); line-height: 1.1; }
.be-subtitle { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.be-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.be-head-actions svg { width: 15px; height: 15px; stroke: currentColor; }
.btn-secondary { background: var(--surface); border: 1px solid var(--line-2); color: var(--ink); padding: 9px 15px; border-radius: var(--radius); font-size: 12px; font-weight: 600; cursor: pointer; font-family: var(--font); display: inline-flex; align-items: center; gap: 7px; }
.btn-secondary:hover { border-color: var(--plum); color: var(--plum); }
.be-head-actions .btn-primary.sm { display: inline-flex; align-items: center; gap: 7px; }
.be-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.be-main { min-width: 0; }
.be-title-input { width: 100%; border: none; outline: none; background: transparent; font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); margin-bottom: 14px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.be-title-input::placeholder { color: var(--faint); }
.be-editor-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.be-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 16px; } .be-side .panel { margin-bottom: 0; }
.meta-line { font-size: 11px; margin-top: 10px; font-family: var(--mono); color: var(--ink-3); }

/* Quill -> Tara brand */
.ql-toolbar.ql-snow { border: none; border-bottom: 1px solid var(--line); background: var(--surface-2); padding: 9px 10px; font-family: var(--font); }
.ql-container.ql-snow { border: none; font-family: var(--font); font-size: 13px; }
.ql-editor { min-height: 440px; line-height: 1.75; color: var(--ink); padding: 24px 26px; }
.ql-editor.ql-blank::before { color: var(--faint); font-style: normal; left: 26px; right: 26px; }
.ql-editor h2 { font-family: var(--serif); font-weight: 600; font-size: 18px; margin: 18px 0 8px; }
.ql-editor h3 { font-family: var(--serif); font-weight: 600; font-size: 16px; margin: 16px 0 6px; }
.ql-editor h4 { font-weight: 600; font-size: 13.5px; margin: 14px 0 4px; }
.ql-editor blockquote { border-left: 3px solid var(--plum); color: var(--ink-2); padding-left: 16px; margin: 12px 0; }
.ql-editor a { color: var(--plum); }
.ql-editor pre.ql-syntax { background: var(--ink); color: #f3eef5; border-radius: var(--radius); padding: 14px 16px; }
.ql-editor img { border-radius: var(--radius); max-width: 100%; }
.ql-snow .ql-stroke { stroke: var(--ink-2); }
.ql-snow .ql-fill { fill: var(--ink-2); }
.ql-snow .ql-picker { color: var(--ink-2); }
.ql-snow.ql-toolbar button:hover .ql-stroke, .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--plum); }
.ql-snow.ql-toolbar button:hover .ql-fill, .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--plum); }
.ql-snow.ql-toolbar button:hover, .ql-snow.ql-toolbar button.ql-active, .ql-snow .ql-picker-label:hover, .ql-snow .ql-picker-item:hover, .ql-snow .ql-picker-label.ql-active { color: var(--plum); }
.ql-snow .ql-picker-label:hover .ql-stroke, .ql-snow .ql-picker-label.ql-active .ql-stroke { stroke: var(--plum); }
.ql-snow .ql-picker-options { border-radius: var(--radius); border-color: var(--line-2); box-shadow: var(--shadow); }
.ql-snow .ql-tooltip { border-radius: var(--radius); border-color: var(--line-2); box-shadow: var(--shadow); color: var(--ink); }
.ql-snow .ql-tooltip input[type=text] { border-radius: var(--radius-sm); border-color: var(--line-2); }
.ql-snow a { color: var(--plum); }

/* Advanced editor — headings, blocks, sticky toolbar, slash menu */
.be-editor-card { overflow: visible; }
.ql-toolbar.ql-snow { position: sticky; top: 0; z-index: 6; border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); display: flex; flex-wrap: wrap; align-items: center; column-gap: 2px; row-gap: 6px; padding: 8px 12px; }
.ql-snow .ql-formats { margin: 0 9px 0 0 !important; display: inline-flex; align-items: center; height: 27px; }
.ql-snow.ql-toolbar button { width: 27px; height: 27px; display: inline-flex; align-items: center; justify-content: center; padding: 4px; }
.ql-snow .ql-picker { height: 27px; display: inline-flex; align-items: center; }
.ql-snow .ql-picker-label { display: flex; align-items: center; }
.ql-editor h1 { font-family: var(--serif); font-weight: 700; font-size: 20px; margin: 20px 0 10px; line-height: 1.15; }
.ql-editor h5 { font-weight: 700; font-size: 12.5px; margin: 12px 0 4px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.ql-editor h6 { font-weight: 600; font-size: 12px; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.ql-editor hr { border: none; border-top: 2px solid var(--line-2); margin: 22px 0; }
.ql-editor pre.ql-syntax { position: relative; font-family: var(--mono); font-size: 12px; line-height: 1.6; overflow-x: auto; }
.ql-editor .ql-code-block-container { position: relative !important; background: var(--ink); color: #f3eef5; border-radius: var(--radius); padding: 32px 16px 14px !important; margin: 12px 0; font-family: var(--mono); font-size: 12px; line-height: 1.6; overflow-x: auto; }
.ql-editor .ql-code-block-container .ql-ui { position: absolute !important; top: 7px !important; right: 8px !important; left: auto !important; z-index: 2; font-family: var(--font); font-size: 10.5px; background: rgba(255,255,255,.14); color: #efe9f2; border: 1px solid rgba(255,255,255,.22); border-radius: var(--radius-sm); padding: 1px 6px; cursor: pointer; }

/* Callouts (icons are inline SVG data-URIs so they never depend on an emoji font) */
.ql-editor .callout { position: relative; border-radius: var(--radius); padding: 12px 14px 12px 42px; margin: 12px 0; border: 1px solid; font-size: 12.5px; }
.ql-editor .callout::before { content: ""; position: absolute; left: 13px; top: 12px; width: 18px; height: 18px; background-repeat: no-repeat; background-position: center; background-size: contain; }
.callout-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.callout-info::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e40af' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cline x1='12' y1='11' x2='12' y2='16'/%3E%3Ccircle cx='12' cy='7.5' r='1.1' fill='%231e40af' stroke='none'/%3E%3C/svg%3E"); }
.callout-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.callout-warning::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2392400e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3L22 20H2Z'/%3E%3Cline x1='12' y1='10' x2='12' y2='14'/%3E%3Ccircle cx='12' cy='17' r='1' fill='%2392400e' stroke='none'/%3E%3C/svg%3E"); }
.callout-tip { background: #f5f3ff; border-color: #ddd6fe; color: #5b21b6; }
.callout-tip::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%235b21b6'%3E%3Cpath d='M12 2l2.2 7.2L21 12l-6.8 2.8L12 22l-2.2-7.2L3 12l6.8-2.8z'/%3E%3C/svg%3E"); }
.callout-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.callout-success::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23166534' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpolyline points='8 12 11 15 16 9'/%3E%3C/svg%3E"); }

/* Tables */
.ql-editor table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 12.5px; }
.ql-editor td, .ql-editor th { border: 1px solid var(--line-2); padding: 7px 10px; min-width: 40px; }
.ql-editor th { background: var(--surface-2); font-weight: 600; }

/* Slash-command menu */
.slash-menu { position: absolute; z-index: 300; min-width: 224px; max-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 5px; }
.slash-item { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: var(--radius-sm); font-size: 12px; color: var(--ink); cursor: pointer; }
.slash-item.on { background: var(--plum-soft); color: var(--plum); }
.slash-ico { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 11.5px; font-family: var(--mono); flex-shrink: 0; }
.slash-item.on .slash-ico { background: #fff; }

/* Image / video resize + align overlay */
.ql-editor iframe.ql-video { max-width: 100%; display: block; }
/* disable iframe interaction inside the EDITOR only (so clicks select for resize); preview/public stay interactive */
.ql-container .ql-editor iframe { pointer-events: none; }
.rz-overlay { position: absolute; box-sizing: border-box; border: 1.5px solid var(--plum); z-index: 20; pointer-events: none; }
.rz-h { position: absolute; width: 11px; height: 11px; background: #fff; border: 1.5px solid var(--plum); border-radius: 2px; pointer-events: auto; }
.rz-nw { top: -6px; left: -6px; cursor: nwse-resize; } .rz-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.rz-sw { bottom: -6px; left: -6px; cursor: nesw-resize; } .rz-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.rz-bar { position: absolute; top: -37px; left: 50%; transform: translateX(-50%); display: flex; gap: 1px; background: var(--plum); border-radius: var(--radius-sm); padding: 3px; pointer-events: auto; box-shadow: var(--shadow-sm); }
.rz-bar button { background: none; border: none; color: #fff; cursor: pointer; padding: 3px 7px; border-radius: 2px; display: inline-flex; }
.rz-bar button svg { width: 15px; height: 15px; display: block; }
.rz-bar button:hover { background: rgba(255,255,255,.22); }
.rz-overlay.rz-below .rz-bar { top: auto; bottom: -37px; }

/* Editor header icon buttons */
.btn-icon { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--ink-2); cursor: pointer; }
.btn-icon svg { width: 16px; height: 16px; stroke: currentColor; }
.btn-icon:hover { border-color: var(--plum); color: var(--plum); }

/* Live preview overlay */
.prev-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(44,37,48,.5); backdrop-filter: blur(2px); overflow-y: auto; padding: 30px 16px; }
.prev-doc { position: relative; max-width: 760px; margin: 0 auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 40px 48px 56px; }
.prev-close { position: absolute; top: 14px; right: 16px; background: none; border: none; font-size: 17px; line-height: 1; color: var(--faint); cursor: pointer; }
.prev-close:hover { color: var(--ink); }
.prev-cover { width: 100%; border-radius: var(--radius); margin-bottom: 22px; display: block; }
.prev-title { font-family: var(--serif); font-size: 22px; font-weight: 700; line-height: 1.12; margin: 0 0 18px; color: var(--ink); }
.prev-body { min-height: 0; padding: 0; font-size: 13.5px; }
@media (max-width: 640px) { .prev-doc { padding: 28px 20px 40px; } .prev-title { font-size: 19px; } }

/* Focus / distraction-free mode */
body.blog-focus .sidebar, body.blog-focus .topbar, body.blog-focus .mobile-bar, body.blog-focus .be-head, body.blog-focus .be-side { display: none !important; }
body.blog-focus .be-grid { grid-template-columns: 1fr; }
body.blog-focus .be-main, body.blog-focus .content { max-width: 800px; margin: 0 auto; }
body.blog-focus .content { padding-top: 28px; }
.focus-exit { position: fixed; top: 16px; right: 18px; z-index: 210; background: var(--plum); color: #fff; border: none; border-radius: var(--radius); padding: 8px 14px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: var(--font); box-shadow: var(--shadow-sm); }
.focus-exit:hover { background: var(--plum-deep); }

/* Table of contents panel */
.toc-panel { position: absolute; z-index: 300; min-width: 230px; max-width: 320px; max-height: 60vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; }
.toc-head { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 600; padding: 6px 8px 8px; }
.toc-item { display: block; padding: 6px 9px; border-radius: var(--radius-sm); font-size: 12px; color: var(--ink-2); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-item:hover { background: var(--plum-soft); color: var(--plum); }
.toc-item.toc-h3 { padding-left: 20px; font-size: 12px; color: var(--ink-3); }
.toc-empty { padding: 8px 9px 12px; font-size: 11.5px; color: var(--faint); white-space: normal; }

/* SEO previews, chips, slug status, featured, revision history */
.slug-status { display: block; font-size: 11px; margin-top: 4px; font-family: var(--mono); }
.slug-status.ok { color: #166534; } .slug-status.warn { color: var(--taupe); }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); cursor: pointer; margin-top: 6px; }
.check-row input { width: 15px; height: 15px; accent-color: var(--plum); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--plum-soft); color: var(--plum); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 11.5px; font-weight: 500; }
.chip button { background: none; border: none; color: var(--plum); cursor: pointer; font-size: 13px; line-height: 1; width: 17px; height: 17px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.chip button:hover { background: rgba(74,54,82,.15); }
.seo-label { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); font-weight: 600; margin: 12px 0 6px; }
.serp { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); }
.serp-title { color: #1a0dab; font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.serp-url { color: #006621; font-size: 11px; margin: 2px 0 4px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.serp-desc { color: var(--ink-3); font-size: 11.5px; line-height: 1.45; }
.social-card { border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.social-img { width: 100%; aspect-ratio: 1.9 / 1; background: var(--surface-3) center/cover no-repeat; }
.social-img.empty { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 10px, var(--surface-3) 10px, var(--surface-3) 20px); }
.social-meta { padding: 9px 12px; background: var(--surface-2); }
.social-domain { font-size: 10.5px; letter-spacing: .04em; color: var(--faint); text-transform: uppercase; }
.social-title { font-size: 12.5px; font-weight: 600; color: var(--ink); margin: 2px 0; overflow: hidden; text-overflow: ellipsis; }
.social-desc { font-size: 11px; color: var(--ink-3); line-height: 1.4; }
.hist-panel { position: relative; max-width: 560px; margin: 6vh auto 0; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 22px 24px 26px; }
.hist-title { font-family: var(--serif); font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.hist-list { display: flex; flex-direction: column; gap: 8px; max-height: 62vh; overflow-y: auto; }
.hist-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.hist-when { font-size: 12px; font-weight: 500; color: var(--ink); }
.hist-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.hist-actions { display: flex; gap: 6px; flex-shrink: 0; }
.hist-actions button { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 5px 11px; font-size: 11.5px; font-weight: 500; cursor: pointer; font-family: var(--font); color: var(--ink-2); }
.hist-view:hover { border-color: var(--plum); color: var(--plum); }
.hist-restore:hover { background: var(--plum); color: #fff; border-color: var(--plum); }
.hist-empty { padding: 16px; text-align: center; color: var(--faint); font-size: 12px; }
.rev-badge { display: inline-block; background: var(--plum-soft); color: var(--plum); font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; margin-bottom: 12px; font-family: var(--mono); }
.feat-badge { display: inline-block; background: var(--plum-soft); color: var(--plum); font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle; letter-spacing: .02em; }

/* Advanced collapsible sidebar panels (blog editor) */
.be-panel { padding: 0; overflow: hidden; }
.be-panel-h { display: flex; align-items: center; gap: 9px; width: 100%; background: none; border: none; padding: 12px 15px; cursor: pointer; font-family: var(--font); font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.be-panel-h .be-panel-ico { width: 15px; height: 15px; stroke: var(--plum); flex-shrink: 0; }
.be-panel-h > span { flex: 1; text-align: left; }
.be-chev { width: 15px; height: 15px; stroke: var(--faint); transition: transform .2s ease; flex-shrink: 0; }
.be-panel.collapsed .be-chev { transform: rotate(-90deg); }
.be-panel-h:hover { color: var(--ink); } .be-panel-h:hover .be-chev { stroke: var(--ink); }
.be-panel-body { padding: 0 15px 15px; }
.be-panel.collapsed .be-panel-body { display: none; }
.danger-zone .be-panel-ico { stroke: var(--danger); }
.slug-status b { font-weight: 700; color: var(--ink-2); }
.slug-use { background: var(--plum); color: #fff; border: none; border-radius: var(--radius-sm); font-size: 10.5px; font-weight: 600; padding: 2px 8px; margin-left: 4px; cursor: pointer; font-family: var(--font); }
.slug-use:hover { background: var(--plum-deep); }

/* Featured image drop zone */
.cover-drop { border: 1.5px dashed var(--line-2); border-radius: var(--radius); background: var(--surface-2); min-height: 150px; display: flex; align-items: center; justify-content: center; cursor: pointer; text-align: center; transition: border-color .12s, background .12s; overflow: hidden; }
.cover-drop:hover, .cover-drop.drag { border-color: var(--plum); background: var(--plum-soft); }
.cover-drop.has-image { min-height: 0; border-style: solid; border-color: var(--line); background: var(--surface); }
.cover-drop.has-image img { width: 100%; display: block; }
.cover-drop-inner { padding: 22px 14px; }
.cover-ico { width: 32px; height: 32px; stroke: var(--faint); margin-bottom: 8px; }
.cover-drop-title { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.cover-drop-sub { font-size: 11px; color: var(--faint); margin-top: 3px; }

/* ---------- Speed test (skeleton) ---------- */
.speedtest { max-width: 560px; }
.st-note { margin: 0 0 20px; line-height: 1.55; color: var(--ink-3); }
.st-results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 4px 0 14px; }
.st-tile { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; text-align: center; background: var(--surface); }
.st-tile-label { display: block; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 600; margin-bottom: 9px; }
.st-tile-value { font-family: var(--mono); font-size: 17px; font-weight: 600; color: var(--ink); letter-spacing: -.02em; }
.st-tile-unit { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-left: 3px; }
.st-status { font-size: 11.5px; color: var(--ink-3); margin: 2px 0 16px; }
.st-skel { display: none; width: 64%; height: 22px; margin: 2px auto 0; border-radius: 4px; background: linear-gradient(90deg, var(--surface-3) 25%, #faf6f0 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.25s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.st-results.loading .st-tile-value, .st-results.loading .st-tile-unit { display: none; }
.st-results.loading .st-skel { display: block; }
.st-meta { margin: 0 0 16px; font-family: var(--mono); font-size: 11px; color: var(--ink-3); } .st-meta a { color: var(--plum); text-decoration: underline; }
.st-run { width: auto; }

/* ---------- Modal dialog ---------- */
.list-actions { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.modal { border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 0; width: 430px; max-width: 92vw; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(44,37,48,.42); backdrop-filter: blur(2px); }
.modal form { padding: 22px 24px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-family: var(--serif); font-size: 15.5px; font-weight: 600; color: var(--ink); }
.modal-x { background: none; border: none; font-size: 13px; color: var(--faint); cursor: pointer; line-height: 1; padding: 2px; } .modal-x:hover { color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) { .cards, .chart-grid, .two-col { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) {
  .scrim { display: block; position: fixed; inset: 0; background: rgba(44,37,48,.42); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 55; }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .sidebar { position: fixed; z-index: 60; transform: translateX(-100%); transition: transform .26s ease; box-shadow: var(--shadow); width: 268px; }
  .app.nav-open .sidebar { transform: translateX(0); }
  .topbar { display: none; }
  .mobile-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
  .mobile-logo { height: 34px; width: auto; }
  .mobile-out { margin-left: auto; }
  .content { padding: 18px 16px 56px; }
  .be-grid { grid-template-columns: 1fr; } .be-side { position: static; }
}
@media (max-width: 640px) {
  .cards, .chart-grid, .two-col, .row3, .st-results { grid-template-columns: 1fr; }
  .crumbs strong { font-size: 14.5px; }
}

/* ============================================================
   Media library + reusable picker
   ============================================================ */
.media-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.media-head-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.media-search { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 8px 12px; font-size: 12px; font-family: var(--font); background: var(--surface); color: var(--ink); min-width: 200px; }
.media-search:focus, .media-sort:focus { outline: none; border-color: var(--plum); }
.media-sort { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 8px 10px; font-size: 12px; font-family: var(--font); background: var(--surface); color: var(--ink); cursor: pointer; }
/* <button> variant of the filter tabs (blog uses <a>) */
.filter-tabs button { background: none; border: none; cursor: pointer; padding: 7px 12px; border-radius: var(--radius); font-size: 12px; font-weight: 500; color: var(--ink-3); font-family: var(--font); }
.filter-tabs button:hover { background: var(--surface-2); color: var(--ink); }
.filter-tabs button.on { background: var(--plum); color: #fff; }
.filter-tabs button .cnt { font-family: var(--mono); font-size: 10.5px; opacity: .7; margin-left: 3px; }

/* storage bar */
.storage-panel { padding: 12px 16px; }
.storage-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.storage-title { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.storage-title .muted { text-transform: none; letter-spacing: 0; font-weight: 500; margin-left: 2px; }
.storage-cap { font-family: var(--mono); font-size: 11px; color: var(--ink-2); text-align: right; }
.storage-bar { display: flex; height: 8px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.storage-bar .seg { height: 100%; transition: width .4s ease; }
.seg-media { background: var(--plum); }
.seg-other { background: var(--taupe); opacity: .5; }
.storage-legend { display: flex; gap: 16px; margin-top: 8px; font-size: 11px; color: var(--ink-3); }
.storage-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.dot-media { background: var(--plum); } .dot-other { background: var(--taupe); opacity: .5; } .dot-free { background: var(--surface-3); }

/* grid + tiles (shared by library and picker) */
.media-drop { position: relative; border-radius: var(--radius); transition: box-shadow .12s, background .12s; }
.media-drop.drag { box-shadow: inset 0 0 0 2px var(--plum); background: var(--plum-soft); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(154px, 1fr)); gap: 10px; }
.media-empty { padding: 44px 20px; text-align: center; border: 1.5px dashed var(--line-2); border-radius: var(--radius); }

.m-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); position: relative; transition: box-shadow .12s, border-color .12s; }
.m-tile:hover { box-shadow: var(--shadow); }
.m-thumb { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); cursor: pointer; overflow: hidden; display: block; }
.m-thumb-inner { width: 100%; height: 100%; }
.m-thumb-inner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.m-noposter { width: 100%; height: 100%; background: linear-gradient(135deg, var(--surface-3), var(--surface-2)); }
.m-badge { position: absolute; top: 6px; left: 6px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .06em; color: #fff; background: rgba(44,37,48,.7); padding: 2px 6px; border-radius: var(--radius-sm); }
.m-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.m-play svg { width: 40px; height: 40px; color: #fff; filter: drop-shadow(0 1px 4px rgba(0,0,0,.5)); opacity: .92; }
.m-meta { padding: 8px 9px; }
.m-name { font-size: 11.5px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-sub { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-top: 2px; text-transform: uppercase; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.m-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.m-tile:hover .m-actions { opacity: 1; }
.m-act { width: 26px; height: 26px; border-radius: var(--radius-sm); border: none; background: rgba(255,255,255,.92); color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); }
.m-act svg { width: 14px; height: 14px; }
.m-act:hover { background: #fff; color: var(--plum); }
.m-act.m-del:hover { color: var(--danger); }

/* progress overlay (upload + transcode %) */
.m-overlay { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgba(44,37,48,.62); color: #fff; padding: 12px; }
.m-tile.busy .m-overlay, .m-tile.error .m-overlay { display: flex; }
.m-tile.error .m-overlay { background: rgba(168,72,63,.72); }
.m-bar-wrap { width: 78%; height: 5px; background: rgba(255,255,255,.28); border-radius: 3px; overflow: hidden; }
.m-bar { height: 100%; width: 0; background: #fff; border-radius: 3px; transition: width .3s ease; }
.m-ov-txt { font-family: var(--mono); font-size: 11px; letter-spacing: .02em; }
.m-ov-txt .m-pct { font-weight: 600; }
/* indeterminate (Saving…/Queued): full-width shimmering bar so it never looks frozen */
.m-tile.indet .m-bar { width: 100% !important; background-image: linear-gradient(90deg, rgba(255,255,255,.3) 0%, #fff 50%, rgba(255,255,255,.3) 100%); background-size: 200% 100%; animation: m-shimmer 1.15s linear infinite; }
@keyframes m-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* selection (picker) */
.m-check { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--plum); color: #fff; display: none; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.m-check svg { width: 13px; height: 13px; }
.m-tile.sel { border-color: var(--plum); box-shadow: 0 0 0 2px var(--plum); }
.m-tile.sel .m-check { display: flex; }

/* picker modal */
body.mp-open { overflow: hidden; }
.mp-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(44,37,48,.5); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.mp-modal { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-lg); width: 860px; max-width: 96vw; height: 620px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow); overflow: hidden; }
.mp-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.mp-title { font-family: var(--serif); font-size: 15.5px; font-weight: 600; color: var(--ink); }
.mp-close { background: none; border: none; font-size: 16px; line-height: 1; color: var(--faint); cursor: pointer; padding: 2px 6px; }
.mp-close:hover { color: var(--ink); }
/* a button that is both a closer and a primary button keeps white text (never dark-on-plum) */
.btn-primary.mp-close, .btn-primary.mp-close:hover { color: #fff; }
.mp-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mp-tabs { display: flex; gap: 4px; }
.mp-tabs button { background: none; border: none; cursor: pointer; padding: 6px 11px; border-radius: var(--radius); font-size: 12px; font-weight: 500; color: var(--ink-3); font-family: var(--font); }
.mp-tabs button:hover { background: var(--surface-2); color: var(--ink); }
.mp-tabs button.on { background: var(--plum); color: #fff; }
.mp-search { flex: 1; min-width: 140px; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 8px 12px; font-size: 12px; font-family: var(--font); background: var(--surface); color: var(--ink); }
.mp-search:focus, .mp-sort:focus { outline: none; border-color: var(--plum); }
.mp-sort { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 8px 10px; font-size: 12px; font-family: var(--font); background: var(--surface); cursor: pointer; }
.mp-upload.btn-primary.sm { width: auto; }
.mp-body { flex: 1; overflow-y: auto; padding: 14px 18px; position: relative; }
.mp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.mp-empty, .mp-loading { text-align: center; color: var(--ink-3); padding: 40px 20px; font-size: 12px; }
.mp-loading { position: absolute; left: 0; right: 0; bottom: 6px; padding: 8px; }
.mp-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--line); }
.mp-count { font-size: 11.5px; color: var(--ink-3); }
.mp-foot-btns { display: flex; gap: 8px; }
.mp-cancel, .mp-copy { background: var(--surface); border: 1px solid var(--line-2); color: var(--ink); padding: 9px 16px; border-radius: var(--radius); font-size: 12px; font-weight: 500; font-family: var(--font); cursor: pointer; }
.mp-cancel:hover, .mp-copy:hover { background: var(--surface-2); }
.mp-foot .btn-primary { width: auto; }

/* info modal */
.mp-info-modal { width: 480px; height: auto; }
.mp-info-body { padding: 16px 18px; display: flex; gap: 16px; }
.mp-info-prev { width: 150px; flex-shrink: 0; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); position: relative; }
.mp-info-prev img { width: 100%; height: 100%; object-fit: cover; }
.mp-info-dl { flex: 1; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; align-content: start; }
.mp-info-dl dt { color: var(--faint); text-transform: uppercase; font-size: 10.5px; letter-spacing: .06em; font-weight: 600; align-self: center; }
.mp-info-dl dd { margin: 0; color: var(--ink); font-family: var(--mono); font-size: 11px; word-break: break-all; }
.mp-info-dl dd a { color: var(--plum); }

@media (max-width: 640px) {
  .media-grid, .mp-grid { grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); }
  .mp-modal { height: 92vh; }
  .mp-info-body { flex-direction: column; }
  .mp-info-prev { width: 100%; aspect-ratio: 16 / 9; }
}
