:root { --accent: #F06B55; --ink: #0F1D33; --ink-2: #3c4a5e; --muted: #6b7686; --line: #e3e7ed; --bg: #f5f6f8; --card: #fff; --ok: #1f7a3a; --bad: #b42318; --radius: 10px; font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: var(--ink); }
* { box-sizing: border-box; }
/* The `hidden` attribute must beat any class that sets display (e.g. the site
   switcher menu, the superadmin buttons), otherwise toggling it does nothing. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: #c5ccd6; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { filter: brightness(.95); border-color: var(--accent); }
.btn--danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--sm { padding: 4px 10px; font-size: 13px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 600; }
.badge { background: #fff; color: var(--accent); border-radius: 99px; padding: 0 7px; font-size: 12px; min-width: 20px; text-align: center; }
.badge[data-n="0"] { display: none; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #dfe4ec; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side__brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; font-weight: 700; color: #fff; border-bottom: 1px solid #22324a; position: relative; }
.side__dot { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); flex: none; }
.side__switch { display: flex; align-items: center; gap: 7px; min-width: 0; background: none; border: 0; color: #fff; font: inherit; font-weight: 700; cursor: pointer; padding: 5px 7px; margin: -5px -7px; border-radius: 8px; }
.side__switch #site-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side__switch:hover { background: #18273d; }
.side__switch[aria-expanded="true"] { background: #18273d; }
.side__switch.single { cursor: default; }
.side__switch.single:hover { background: none; }
.side__switch.single .side__caret { display: none; }
.side__caret { font-size: 11px; color: #8f9aaa; flex: none; transition: transform .15s; }
.side__switch[aria-expanded="true"] .side__caret { transform: rotate(180deg); }
.site-menu { position: absolute; top: calc(100% - 6px); left: 14px; right: 14px; z-index: 30; background: #22324a; border: 1px solid #35496a; border-radius: 10px; padding: 6px; box-shadow: 0 12px 34px rgb(0 0 0 / .4); display: grid; gap: 2px; }
.site-menu a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border-radius: 7px; color: #dfe4ec; text-decoration: none; font-weight: 500; font-size: 13.5px; }
.site-menu a:hover { background: #2c3f5c; }
.site-menu a.current { color: #fff; font-weight: 700; }
.site-menu__tick { color: var(--accent); flex: none; }
.site-menu__all { margin-top: 2px; border-top: 1px solid #35496a; border-radius: 0 0 7px 7px; color: #9aa6b6 !important; font-size: 12.5px; }
.side nav { flex: 1; overflow: auto; padding: 10px 8px; }
.side nav h2 { font-size: 12px; font-weight: 600; color: #8f9aaa; margin: 16px 10px 4px; }
.side nav a { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 7px; text-decoration: none; color: #dfe4ec; }
.side nav a:hover { background: #18273d; }
.side nav a[aria-current="page"] { background: #22324a; color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.side nav a.nav-ai { color: #fff; font-weight: 600; }
.side__foot { padding: 12px 14px; border-top: 1px solid #22324a; display: grid; gap: 10px; }
.side__foot-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #8f9aaa; padding: 0 4px; }
.side__admin { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 12px; border-radius: 8px; background: #22324a; border: 1px solid #35496a; color: #fff !important; text-decoration: none; font-weight: 600; font-size: 13.5px; }
.side__admin:hover { background: #2c3f5c; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 16px; padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 18px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top__actions { display: flex; gap: 8px; }
.top__menu { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; }
.view { padding: 28px; max-width: none; width: 100%; outline: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgb(0 0 0 / .35); }
  .top { padding: 12px 16px; } .top__menu { display: block; } #view-site { display: none; }
  .view { padding: 18px 16px; }
}

/* Cards, forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.help { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; text-decoration: none; }
.tile:hover { border-color: var(--accent); }
.tile strong { display: block; font-size: 15px; margin-bottom: 4px; }
.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field > label, .field > .label { font-weight: 600; font-size: 13.5px; }
.field input:not([type=checkbox]), .field textarea, .field select { width: 100%; border: 1px solid #cfd5dd; border-radius: 8px; padding: 9px 11px; background: #fff; }
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
fieldset.group { border: 1px solid var(--line); border-radius: 12px; padding: 16px 16px 4px; margin: 0 0 16px; background: #fff; }
fieldset.group > legend { font-weight: 700; padding: 0 6px; font-size: 14px; }
fieldset.group fieldset.group { background: #fafbfc; }
.list { display: grid; gap: 10px; margin-bottom: 8px; }
.list-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 12px 2px; background: #fff; position: relative; }
.list-item__bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.list-item__bar strong { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item__tools { display: flex; gap: 4px; flex: none; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 6px; width: 28px; height: 28px; cursor: pointer; line-height: 1; }
.icon-btn:hover { border-color: var(--ink-2); }
.row-inline { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.row-inline > :first-child { flex: 1; }
.savebar { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.savebar .muted { margin-right: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { background: #fafbfc; font-size: 12.5px; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; } tr.click:hover td { background: #fafbfc; }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: #eef1f5; color: var(--ink-2); font-weight: 600; }
.pill--added { background: #e6f6ea; color: var(--ok); } .pill--deleted { background: #fdecea; color: var(--bad); } .pill--modified { background: #fff4e0; color: #8a5300; }
.pill--draft { background: #fff4e0; color: #8a5300; }
.diff { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: #fbfbfc; border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 420px; margin: 8px 0 0; padding: 8px 0; white-space: pre; }
.diff span { display: block; padding: 0 12px; }
.diff .add { background: #e8f7ec; color: #14532d; } .diff .del { background: #fdecec; color: #7f1d1d; } .diff .hunk { color: #6b7686; background: #f1f3f6; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; }
.toast.bad { background: var(--bad); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.media-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.media-grid figure { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.media-grid img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: #eef1f5; }
.media-grid figcaption { padding: 8px; font-size: 12px; display: grid; gap: 6px; }
.media-grid figcaption code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop { border: 2px dashed #cfd5dd; border-radius: 12px; padding: 24px; text-align: center; margin-bottom: 16px; color: var(--muted); }
.drop.over { border-color: var(--accent); background: #fff7f5; }
.md-tools { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.md-tools button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: 13px; }
.md-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.md-split textarea { min-height: 460px; font: 14px/1.6 ui-monospace, Menlo, monospace; }
.md-preview { border: 1px solid var(--line); border-radius: 8px; padding: 4px 16px; background: #fff; overflow: auto; max-height: 560px; }
.md-preview img { max-width: 100%; }
@media (max-width: 900px) { .md-split { grid-template-columns: 1fr; } }
.img-field { display: flex; gap: 10px; align-items: center; }
.img-field img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #eef1f5; }

/* AI Updates */
.ai { display: grid; grid-template-columns: 240px 1fr; gap: 16px; height: calc(100vh - 140px); min-height: 480px; }
.ai__list { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: auto; padding: 8px; }
.ai__list a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai__list a[aria-current="true"] { background: #f1f3f6; font-weight: 600; }
.ai__list a small { display: block; color: var(--muted); font-weight: 400; }
.ai__chat { background: #fff; border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; }
.ai__log { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.msg { max-width: 760px; }
.msg--user { align-self: flex-end; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.msg--ai { align-self: flex-start; width: 100%; }
.msg--ai .text { white-space: pre-wrap; }
.steps { list-style: none; margin: 0 0 8px; padding: 0; font-size: 13px; color: var(--muted); display: grid; gap: 2px; }
.steps li::before { content: '› '; color: var(--accent); }
.steps li.err { color: var(--bad); }
.thinking { font-size: 13px; color: var(--muted); font-style: italic; margin-bottom: 6px; max-height: 3.2em; overflow: hidden; }
.ai-changes { border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; padding: 10px 12px; background: #fafbfc; }
.ai-changes summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.ai-err { color: var(--bad); font-weight: 500; }
.ai__compose { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 10px; align-items: flex-end; }
.ai__compose textarea { flex: 1; resize: none; border: 1px solid #cfd5dd; border-radius: 10px; padding: 10px 12px; min-height: 46px; max-height: 200px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.chips button:hover { border-color: var(--accent); }
@media (max-width: 860px) { .ai { grid-template-columns: 1fr; height: auto; } .ai__list { max-height: 160px; } .ai__chat { height: calc(100vh - 300px); min-height: 420px; } }

/* AI Updates full-width: break out of the centered column so the conversation
   menu and the compose box span the whole page. */
.view--ai { max-width: none; }
.view--ai .ai { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: calc(100vh - 150px); }
.view--ai .ai__list { flex-direction: row; gap: 8px; overflow-x: auto; overflow-y: hidden; }
.view--ai .ai__list a { flex: none; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view--ai .ai__list a small { display: inline; margin-left: 6px; }

/* Hub (site picker + user management) */
.hub__top { display: flex; align-items: center; gap: 16px; padding: 14px 28px; background: var(--ink); color: #fff; }
.hub__top .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; flex: 1; min-width: 0; }
.hub__top .brand .side__dot { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); flex: none; }
.hub__top a, .hub__top button { color: #dfe4ec; }
.hub__top .btn { background: #22324a; border-color: #22324a; color: #fff; }
.hub__top .btn:hover { border-color: #3a4d6b; }
.hub__wrap { padding: 32px 28px; max-width: 980px; margin: 0 auto; width: 100%; }
.hub__wrap > h1 { font-size: 22px; margin: 0 0 4px; }
.suggestions { display: grid; gap: 8px; }
.suggestion { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.suggestion strong { font-size: 14.5px; }
.suggestion .btn { flex: none; }
.tile .role { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--muted); }
.tile .role.super { color: var(--accent); font-weight: 600; }
.chk { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; margin: 6px 0; }
.chk input { width: auto; }
.sites-checks { display: grid; gap: 4px; margin: 6px 0 14px; }
@media (max-width: 860px) { .hub__top { padding: 12px 16px; } .hub__wrap { padding: 20px 16px; } }

/* Login */
body.login { display: grid; place-items: center; min-height: 100vh; background: var(--ink); padding: 16px; }
.login__card { background: #fff; border-radius: 16px; padding: 32px; width: min(380px, 100%); }
.login__card h1 { font-size: 22px; margin: 4px 0 20px; }
.login__site { margin: 0; color: var(--accent); font-weight: 700; }
.login__card label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.login__card input { border: 1px solid #cfd5dd; border-radius: 8px; padding: 10px 12px; font-weight: 400; }
.login__card .btn { width: 100%; justify-content: center; padding: 11px; }
.login__card .msg { color: var(--bad); min-height: 1.2em; margin: 0 0 10px; font-size: 14px; }
