/* Deep navy with cyan and violet. Stars sit behind the page. */
:root {
  --ground: #070b1c;
  --surface: #12182e;
  --raised: #1c2444;
  --border: rgba(167, 139, 250, 0.24);
  --rule: rgba(167, 139, 250, 0.14);
  --control: #3d4d78;
  --text: #e8eefc;
  --muted: #b7c3e6;
  --faint: #8b9bc4;
  --accent: #67e8f9;
  --accent-deep: #6366f1;
  --positive: #3fc07a;
  --negative: #e5566f;
  --warning: #e5a93b;
  --pill-positive-bg: #172a1d;
  --pill-positive-ink: #3fc07a;
  --pill-negative-bg: #2c1a20;
  --pill-negative-ink: #e5566f;
  --pill-warning-bg: #2b2414;
  --pill-warning-ink: #e5a93b;
  --pill-neutral-bg: #222018;
  --radius-card: 20px;
  --radius-control: 8px;
  --gap: 16px;
  --pad: 32px;
  --card-pad: 20px;
  --sidebar: 256px;
  --control-height: 36px;
  --font: "Inter", system-ui, sans-serif;
  --emoji: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { color-scheme: dark; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 22px;
  color: var(--text);
  background:
    radial-gradient(980px 520px at 8% -12%, rgba(124, 58, 237, 0.38), transparent 58%),
    radial-gradient(720px 460px at 100% 0%, rgba(14, 165, 233, 0.22), transparent 52%),
    radial-gradient(860px 540px at 78% 110%, rgba(232, 121, 249, 0.16), transparent 55%),
    var(--ground);
}
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: block;
}
::selection { background: var(--accent); color: #071018; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.emoji {
  font-family: var(--emoji);
  font-style: normal;
  font-weight: 400;
  line-height: 1;
  font-variant-emoji: emoji;
}
img { max-width: 100%; }

a { color: inherit; text-decoration: none; }
a:hover { color: #fff; }
.prose a, .lead a, .meta a, .muted a, .topbar-end a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.frame {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  background: linear-gradient(180deg, rgba(12, 16, 40, 0.94), rgba(7, 11, 28, 0.92));
  color: var(--text);
  padding: 22px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(103, 232, 249, 0.45) transparent;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: #fff;
  padding: 0 8px;
  text-decoration: none;
}
.brand:hover { color: #fff; }
.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.brand-mark img {
  width: 48px;
  height: 48px;
  max-width: 48px;
  object-fit: cover;
  display: block;
}
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand strong { display: block; font-weight: 600; font-size: 14px; letter-spacing: 0; }
.brand small { color: var(--muted); font-size: 12px; line-height: 16px; }
.brand .studio { color: var(--faint); font-size: 12px; }

nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  color: var(--muted);
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
}
.nav-item .emoji { width: 1.35em; flex: 0 0 1.35em; text-align: center; font-size: 16px; }
.nav-item:hover { color: #fff; background: rgba(103, 232, 249, 0.1); }
.nav-item.active {
  color: #fff;
  font-weight: 500;
  background: linear-gradient(90deg, rgba(103, 232, 249, 0.22), rgba(167, 139, 250, 0.16));
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.sidebar a.btn,
.sidebar a.btn.ghost,
.sidebar .btn,
.sidebar .btn.ghost {
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 8px;
  height: 34px;
  padding: 0 10px;
  justify-content: flex-start;
  font-weight: 500;
  box-shadow: none;
}
.sidebar a.btn:hover,
.sidebar a.btn.ghost:hover,
.sidebar .btn:hover,
.sidebar .btn.ghost:hover { background: rgba(103, 232, 249, 0.12); color: #fff; }
.muted { color: var(--muted); font-size: 14px; opacity: 1; }
.sidebar-foot .muted { min-height: 34px; display: flex; align-items: center; padding: 0 10px; }

.workspace { min-width: 0; display: flex; flex-direction: column; background: transparent; }
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 var(--pad);
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 28, 0.9);
  position: sticky;
  top: 0;
  z-index: 12;
}
.nav-toggle {
  display: none;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--control);
  background: transparent;
  color: #fff;
  font: 500 14px/1 var(--font);
  cursor: pointer;
}
.topbar .search { flex: 1; min-width: 0; }
.topbar-end {
  flex-shrink: 0;
  padding-left: 14px;
  border-left: 1px solid var(--border);
  min-height: 64px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}
.scope { color: var(--muted); }
.nav-backdrop { display: none; }

.content {
  padding: var(--pad) var(--pad) 72px;
  background: transparent;
}
.content > section + section,
.content > header + section,
.content > header + .list,
.content > header + .grid,
.content > header + .form,
.content > header + .media-grid,
.content > header + .audit-table-wrap,
.content > .dev-tabs + header { margin-top: 52px; }
.content > .flashes + * { margin-top: 20px; }

h1, h2, h3 {
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0;
  margin: 0 0 8px;
  line-height: 1.25;
}
h1 { font-size: 28px; letter-spacing: -0.03em; }
h1 .emoji { margin-right: 0.2em; font-size: 0.9em; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 32px;
  row-gap: 14px;
  align-items: center;
  padding: 8px 0 4px;
}
.hero h1 { grid-column: 1; grid-row: 1; margin: 0; align-self: center; }
.hero .lead { grid-column: 1 / -1; grid-row: 2; margin: 0; max-width: 72ch; }
.hero-actions {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.page-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: 0;
}
.section-title { margin: 0 0 14px; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 16px;
  color: var(--faint);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.eyebrow a { color: var(--muted); text-decoration: none; }
.eyebrow a:hover { color: #fff; }
.lead {
  font-size: 16px;
  line-height: 24px;
  max-width: 68ch;
  margin: 0 0 12px;
  color: var(--text);
}
.meta { font-size: 12px; line-height: 16px; color: var(--faint); font-variant-numeric: tabular-nums; }
.count { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-height);
  padding: 0 16px;
  background: linear-gradient(180deg, #67e8f9 0%, #22d3ee 42%, #6366f1 100%);
  color: #f8fafc;
  border: 0;
  border-radius: 999px;
  font: 600 14px/1 var(--font);
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
}
a.btn:hover, .btn:hover { background: linear-gradient(180deg, #a5f3fc, #22d3ee 40%, #818cf8); color: #f8fafc; }
.btn:active { background: var(--accent-deep); color: #f8fafc; }
.btn.ghost {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(167, 139, 250, 0.5);
}
a.btn.ghost:hover, .btn.ghost:hover { background: rgba(103, 232, 249, 0.12); color: #fff; }
.btn.danger {
  background: transparent;
  color: var(--negative);
  border: 1px solid #5c3034;
}
a.btn.danger:hover, .btn.danger:hover { background: var(--pill-negative-bg); color: var(--negative); }

.search input, .form input, .form textarea, .form select {
  width: 100%;
  border: 1px solid var(--control);
  border-radius: 999px;
  height: var(--control-height);
  padding: 0 14px;
  font: 400 14px/20px var(--font);
  background: var(--surface);
  color: var(--text);
}
.form textarea, .dev-chat-form textarea {
  height: auto;
  min-height: 120px;
  padding: 10px 14px;
  border-radius: var(--radius-control);
  resize: vertical;
}
.search input { background: var(--surface); }
.search input::placeholder, .form input::placeholder, .form textarea::placeholder { color: var(--faint); }
.search input:focus, .form input:focus, .form textarea:focus, .form select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.grid.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}
.grid.cards:has(> :nth-child(2):last-child) {
  grid-template-columns: 1fr 1fr;
}
.grid.cards:has(> :nth-child(4):last-child),
.grid.cards:has(> :nth-child(8):last-child) {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid.cards:not(:has(> :nth-child(4):last-child)):not(:has(> :nth-child(8):last-child)) > :last-child:nth-child(3n + 1) {
  grid-column: 1 / -1;
}
.card, .list-item {
  background: linear-gradient(180deg, rgba(22, 28, 58, 0.94), rgba(12, 16, 36, 0.94));
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-radius: var(--radius-card);
  padding: var(--card-pad);
  color: inherit;
  box-shadow: none;
  text-decoration: none;
  overflow: hidden;
}
.card:hover, .list-item:hover {
  background: linear-gradient(180deg, rgba(32, 42, 82, 0.96), rgba(16, 22, 48, 0.96));
  border-color: rgba(103, 232, 249, 0.4);
  color: inherit;
}
.card-emoji { display: block; font-size: 28px; line-height: 1; margin-bottom: 12px; }
.card h3 { margin: 0 0 6px; }
.card p, .list-item p { margin: 0 0 12px; color: var(--muted); line-height: 22px; }
.card .meta, .list-item .meta { display: block; }
.cover, .article-cover {
  width: calc(100% + var(--card-pad) * 2);
  max-width: none;
  margin: calc(var(--card-pad) * -1) calc(var(--card-pad) * -1) 14px;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  max-height: 220px;
  object-fit: cover;
  display: block;
}
.list {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(18, 24, 52, 0.96), rgba(10, 14, 32, 0.96));
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.list-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-radius: 0;
  background: transparent;
  padding: 16px 20px;
  border: 0;
  border-bottom: 1px solid var(--rule);
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: rgba(103, 232, 249, 0.08); border-color: var(--rule); }
.list-item strong { font-weight: 600; }
.list > .muted { padding: 20px; margin: 0; }

.form { display: flex; flex-direction: column; gap: 14px; max-width: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 14px; }
.check-row { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
.check-row input { width: auto; height: auto; }
.badge-hidden {
  display: inline-block;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: middle;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--pill-warning-bg);
  border: 0;
  color: var(--pill-warning-ink);
}
.narrow { max-width: 480px; }

.page-head + .prose { margin-top: 28px; }
.prose {
  font-size: 16px;
  line-height: 26px;
  max-width: 72ch;
}
.prose h2, .prose h3 { margin-top: 1.4em; }
.prose p { margin: 0 0 1em; }
.prose img { max-width: 100%; height: auto; border-radius: 8px; }
.prose img[data-align="left"] { float: left; margin: 0 1.2em 1em 0; }
.prose img[data-align="right"] { float: right; margin: 0 0 1em 1.2em; }
.prose img[data-align="center"] { display: block; margin: 1em auto; float: none; }
.prose::after { content: ""; display: block; clear: both; }
.prose table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 14px; }
.prose th, .prose td { border-bottom: 1px solid var(--rule); padding: 8px 10px; text-align: left; }
.prose th { color: var(--muted); font-weight: 500; font-size: 12px; background: transparent; }
.prose blockquote {
  margin: 1em 0;
  padding: 12px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.ql-toolbar.ql-snow, .ql-container.ql-snow {
  border-color: var(--control);
  background: #fff;
  color: #111;
}
.ql-container.ql-snow { min-height: 360px; border-radius: 0 0 8px 8px; font-family: var(--font); }
.ql-toolbar.ql-snow { border-radius: 8px 8px 0 0; }
.ql-editor img { max-width: 100%; height: auto; cursor: pointer; border-radius: 8px; }
.ql-editor img[data-align="left"] { float: left; margin: 0 1em 1em 0; }
.ql-editor img[data-align="right"] { float: right; margin: 0 0 1em 1em; }
.ql-editor img[data-align="center"] { display: block; margin: 1em auto; float: none; }
.ql-editor::after { content: ""; display: block; clear: both; }

.editor-block { position: relative; }
.editor-toolbar-extra { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.upload-chip {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--control);
  border-radius: 999px;
  height: 36px;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  font: 500 14px/1 var(--font);
}
.upload-chip:hover { background: rgba(103, 232, 249, 0.12); }

.img-controls { position: absolute; z-index: 8; pointer-events: none; }
.img-controls .img-frame {
  border: 2px solid #fff;
  box-shadow: none;
  pointer-events: none;
}
.img-controls .img-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 2px solid #000;
  border-radius: 2px;
  pointer-events: auto;
  cursor: nwse-resize;
}
.img-controls .img-handle.se { right: -6px; bottom: -6px; }
.img-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  pointer-events: auto;
  background: var(--surface);
  border: 0;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}
.img-toolbar button, .img-toolbar input {
  font: 500 12px/1 var(--font);
  border: 1px solid var(--control);
  background: var(--ground);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 8px;
  cursor: pointer;
}
.img-toolbar button.active, .img-toolbar button:hover { background: #fff; color: #000; border-color: #fff; }
.img-toolbar input { width: 110px; cursor: text; border-radius: 8px; }

.picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 40;
  display: none;
  place-items: center;
  padding: 24px;
}
.picker-backdrop.is-open { display: grid; }
.picker-modal {
  width: min(860px, 100%);
  max-height: 80vh;
  overflow: auto;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.picker-modal h2 { margin-top: 0; }
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.picker-grid button {
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--raised);
  cursor: pointer;
}
.picker-grid img { width: 100%; height: 110px; object-fit: cover; display: block; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--gap);
}
.media-card {
  margin: 0;
  background: var(--surface);
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 0;
}
.media-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.media-card figcaption {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}
.media-card .btn, .vault-card .btn { align-self: flex-start; }
.vault-card figcaption {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}
.vault-card strong { font-size: 14px; line-height: 1.3; color: var(--text); }
.vault-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.vault-thumb {
  height: 120px;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--muted);
  background: var(--raised);
}

.confirm-dialog {
  width: min(440px, calc(100% - 32px));
  border: 0;
  border-radius: var(--radius-card);
  padding: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.confirm-dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
.confirm-dialog h2 { margin: 0 0 8px; font-size: 16px; }
.confirm-dialog p { margin: 0 0 18px; line-height: 1.45; color: var(--muted); }
.confirm-dialog .hero-actions { justify-content: flex-end; gap: 8px; }

.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash { padding: 10px 12px; border-radius: 8px; background: var(--pill-neutral-bg); color: #fff; }
.flash.ok { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.flash.error { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }

.audit-table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius-card); }
.audit-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.audit-table th, .audit-table td {
  border-bottom: 1px solid var(--rule);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}
.audit-table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.audit-chg {
  color: #ff6b6b;
  text-decoration: underline;
  text-decoration-color: #ff6b6b;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  background: rgba(229, 86, 111, 0.16);
}
.audit-del {
  text-decoration: underline line-through;
  text-decoration-color: #ff6b6b;
}
.audit-chg-img {
  display: inline-block;
  vertical-align: middle;
  border-bottom: 3px solid #ff6b6b;
  padding: 4px 4px 6px;
}
.audit-chg-img img { outline: 2px solid #ff6b6b; max-width: 280px; }
.audit-detail { max-width: 72ch; line-height: 1.7; }

.dev-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 28px;
  padding: 0;
  border: 0;
}
.dev-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: var(--text);
  border: 1px solid rgba(167, 139, 250, 0.22);
  border-radius: 16px;
  padding: 14px 10px;
  font-size: 14px;
  line-height: 1.3;
  min-height: 64px;
  background: linear-gradient(180deg, rgba(22, 28, 58, 0.94), rgba(12, 16, 36, 0.94));
  text-decoration: none;
}
.dev-tab.active,
.dev-tab:hover {
  color: #fff;
  border-color: rgba(103, 232, 249, 0.45);
  background: linear-gradient(180deg, rgba(103, 232, 249, 0.2), rgba(167, 139, 250, 0.16));
}

.dev-chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: calc(100vh - 220px);
  border: 0;
  border-radius: var(--radius-card);
  background: var(--surface);
  overflow: hidden;
}
.dev-chat-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
}
.dev-chat-bar .muted { margin: 0; }
.dev-chat-online { display: flex; flex-wrap: wrap; gap: 6px; }
.dev-chat-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 0;
  background: var(--raised);
  color: var(--text);
}
.dev-chat-log {
  overflow-y: auto;
  padding: 16px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(62vh, 640px);
  min-height: 320px;
}
.dev-chat-empty { margin: auto; color: var(--muted); }
.dev-chat-msg {
  max-width: min(72%, 640px);
  padding: 10px 12px;
  border-radius: 12px;
  border: 0;
  background: var(--raised);
}
.dev-chat-msg.mine { align-self: flex-end; background: #222; }
.dev-chat-msg.bot { align-self: flex-start; max-width: min(86%, 720px); background: #1a1a1a; }
.dev-chat-msg header { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.dev-chat-msg strong { font-size: 13px; font-weight: 600; }
.dev-chat-msg time { font-size: 12px; color: var(--faint); }
.dev-chat-msg p { margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.dev-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--rule);
  align-items: end;
}
.dev-chat-form textarea { min-height: 52px; max-height: 140px; margin: 0; }

.account-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}
.account-card {
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-radius: var(--radius-card);
  padding: 20px;
  background: linear-gradient(180deg, rgba(22, 28, 58, 0.94), rgba(12, 16, 36, 0.94));
}
.account-card h2 { margin: 0 0 8px; font-size: 16px; }
.account-card .narrow { max-width: none; }
.account-card .lead { font-size: 14px; line-height: 20px; color: var(--muted); }
.color-row input[type="color"] {
  width: 72px;
  height: 36px;
  padding: 4px;
  cursor: pointer;
  background: transparent;
  border-radius: 8px;
}
.account-admin-row {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.account-admin-row input { margin: 0; }
.cabinet-profile .avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  background: var(--raised);
  font-weight: 600;
  font-size: 24px;
  color: var(--text);
}
.cabinet-profile .avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.notice-row, .wall-post, .question-reply {
  border-top: 1px solid var(--rule);
  padding-top: 12px;
  margin-top: 12px;
}
.question-list { display: flex; flex-direction: column; gap: 16px; }
.question-card h2 { font-size: 16px; }
.nick { font-weight: 600; }
.dev-sheet-frame {
  border: 0;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--surface);
  min-height: calc(100vh - 240px);
}
.dev-sheet-frame iframe {
  display: block;
  width: 100%;
  height: calc(100vh - 240px);
  min-height: 640px;
  border: 0;
  background: #fff;
}

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.monitor-grid .account-card { border-radius: 0; }
.monitor-grid .account-card:last-child { grid-column: span 2; }
.monitor-num {
  font-size: 24px;
  font-weight: 500;
  line-height: 1.2;
  margin: 8px 0 6px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.monitor-num-sm { font-size: 24px; }
.monitor-top { margin-top: 14px; }
.monitor-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
}
.monitor-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.monitor-list li:last-child { border-bottom: 0; }
.monitor-list strong { font-variant-numeric: tabular-nums; font-weight: 600; }

@media (max-width: 1100px) {
  .grid.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cards > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .account-grid { grid-template-columns: 1fr 1fr; }
  .monitor-grid { grid-template-columns: 1fr 1fr; }
  .monitor-grid .account-card:last-child { grid-column: 1 / -1; }
  .dev-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  h1 { font-size: 24px; }
  .hero { grid-template-columns: 1fr; padding: 2px 0 0; }
  .hero h1, .hero-actions, .hero .lead { grid-column: 1; grid-row: auto; }
  .hero-actions { justify-content: flex-start; gap: 8px; }
  .frame { display: block; }
  .nav-toggle { display: none; }
  .sidebar {
    position: relative;
    z-index: auto;
    top: auto;
    left: auto;
    width: auto;
    height: auto;
    max-height: none;
    transform: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(12, 16, 40, 0.94), rgba(7, 11, 28, 0.92));
    padding-bottom: 12px;
  }
  .topbar {
    height: 56px;
    gap: 8px;
    padding: 0 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .topbar .search { flex: 1; min-width: 0; }
  .scope { display: none; }
  .topbar-end:not(:has(a)) { display: none; }
  .topbar-end { min-height: 56px; padding-left: 8px; }
  .content {
    padding: 20px 16px 64px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .content > section + section,
  .content > header + section,
  .content > header + .list,
  .content > header + .grid,
  .content > header + .form,
  .content > header + .media-grid,
  .content > header + .audit-table-wrap,
  .content > .dev-tabs + header { margin-top: 36px; }
  .form-grid, .account-grid, .monitor-grid { grid-template-columns: 1fr; }
  .monitor-grid .account-card:last-child { grid-column: auto; }
  .dev-chat-msg { max-width: 92%; }
  .account-admin-row { grid-template-columns: 1fr; }
  .cover, .article-cover { width: calc(100% + var(--card-pad) * 2); }
  .prose img[data-align="left"],
  .prose img[data-align="right"] {
    float: none;
    display: block;
    margin: 1em 0;
  }
  .list-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 14px 16px;
  }
}

@media (max-width: 640px) {
  .grid.cards,
  .grid.cards:has(> :nth-child(2):last-child),
  .grid.cards:has(> :nth-child(4):last-child),
  .grid.cards:has(> :nth-child(8):last-child) { grid-template-columns: 1fr; }
  .grid.cards > :last-child { grid-column: auto; }
}

@media (max-width: 420px) {
  .hero-actions .btn { padding: 0 12px; }
  .page-head { gap: 12px; }
  .card-emoji { font-size: 26px; margin-bottom: 10px; }
  .dev-tabs { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
