/* Karia design system: deep navy and one clear blue. Dark by default, light on request.
   Pages use these tokens only; change a colour here and it changes everywhere. */
:root {
    color-scheme: dark;
    --bg: light-dark(#f6f7fb, #07080c);
    --surface: light-dark(#ffffff, #0f1118);
    --surface-2: light-dark(#eceef6, #161924);
    --line: light-dark(#e1e4ee, #1d212d);
    --line-strong: light-dark(#c9cfdf, #2c3244);
    --ink: light-dark(#141722, #fafafa);
    --ink-hover: light-dark(#2b3042, #dfe2ea);
    --on-strong: light-dark(#ffffff, #0f1630);
    --muted: light-dark(#555b70, #9096a9);
    --blue: light-dark(#4f4fc4, #c5c5fc);
    --blue-hover: light-dark(#3f3fae, #d7d5ff);
    --teal: light-dark(#1f9c8d, #2dd4bf);
    --accent: light-dark(#4f4fc4, #c5c5fc);
    --accent-strong: light-dark(#3a3aa0, #d7d5ff);
    --accent-soft: light-dark(#e9e9ff, #1a1c33);
    --switch-on: light-dark(#4f4fc4, #8b8bf5);
    --paw: #c5c5fc;
    --good: light-dark(#1f7a4d, #6fd29d);
    --good-soft: light-dark(#e0f2e8, #13301f);
    --warn: light-dark(#8a5a00, #e8bc6b);
    --warn-soft: light-dark(#fbefd6, #35290f);
    --bad: light-dark(#b3322f, #f2938f);
    --bad-soft: light-dark(#fbe4e3, #3b1b1d);
    --r-s: 8px;
    --r-m: 10px;
    --r-l: 16px;
    --shadow: 0 30px 60px -30px light-dark(rgb(30 45 90 / .3), rgb(0 0 0 / .75));
    --display: "Poppins", system-ui, sans-serif;
    --body: "Poppins", system-ui, sans-serif;
    --condensed: "Barlow Semi Condensed", "Poppins", sans-serif;
    --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ---- base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; overflow-x: clip; background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--body); }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.18; letter-spacing: -.01em; margin: 0 0 .4em; text-wrap: balance; }
h1 { font-size: 28px; font-weight: 600; }
h2 { font-size: 21px; font-weight: 600; }
h3 { font-size: 17px; font-weight: 600; }
h4 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: 3px; }
img, svg { max-width: 100%; vertical-align: middle; }
code, .mono { font-family: var(--mono); font-size: .9em; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* ---- controls ------------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 18px; border: 1px solid transparent; border-radius: var(--r-m); background: var(--surface-2); color: var(--ink); font: 600 14px/1.2 var(--body); text-decoration: none; cursor: pointer; transition: background-color .15s, border-color .15s; touch-action: manipulation; }
.site-actions .btn { white-space: nowrap; }
.btn:hover { background: var(--line); }
.btn-primary { background: var(--blue); color: #0f1630; }
:root[data-theme="light"] .btn-primary { color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--surface); border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-lg { min-height: 50px; padding: 13px 24px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="hidden"])), select, textarea {
    width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-s);
    background: var(--surface); color: var(--ink); font: inherit;
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }

/* A checkbox drawn as a switch: <input type="checkbox" class="k-switch"> */
input.k-switch { appearance: none; flex: none; position: relative; width: 44px; height: 26px; margin: 0; border-radius: 99px; background: var(--line-strong); cursor: pointer; transition: background-color .15s; }
input.k-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .15s; }
input.k-switch:checked { background: var(--switch-on); }
input.k-switch:checked::after { transform: translateX(18px); }

/* ---- shared page components --------------------------------------------- */
.k-page { display: grid; gap: 18px; }
.k-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.k-page-head p { color: var(--muted); margin: 0; max-width: 68ch; }
.k-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 18px; align-items: start; }
.k-stack { display: grid; gap: 18px; min-width: 0; }
.k-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 20px 22px; min-width: 0; }
.k-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.k-card-head p { color: var(--muted); margin: 0; }
.k-card-body { display: grid; gap: 16px; margin-top: 16px; }
.k-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.k-row small { display: block; color: var(--muted); }
.k-field { display: grid; gap: 6px; min-width: 0; }
.k-label { font-weight: 600; font-size: 14px; }
.k-hint { color: var(--muted); font-size: 13px; margin: 0; }
.k-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.k-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.k-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.k-badge.is-on { background: var(--good-soft); color: var(--good); }
.k-badge.is-warn { background: var(--warn-soft); color: var(--warn); }
.k-badge.is-bad { background: var(--bad-soft); color: var(--bad); }
.k-table-wrap { overflow-x: auto; }
.k-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.k-table th, .k-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.k-table th { color: var(--muted); font-size: 13px; font-weight: 600; }
.k-empty { padding: 32px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r-m); }
.k-preview { position: sticky; top: 84px; }
.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: k-spin .7s linear infinite; }
@keyframes k-spin { to { transform: rotate(360deg); } }

/* A Discord message preview, used on the home page and next to settings. */
.k-msg { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; }
.k-msg + .k-msg { margin-top: 16px; }
.k-msg-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--line); object-fit: cover; }
.k-msg b { display: block; font-weight: 600; }
.k-msg span { display: block; overflow-wrap: anywhere; }
.k-embed { margin-top: 6px; padding: 9px 12px; border: 1px solid var(--line); border-left: 4px solid var(--embed, var(--accent)); border-radius: 6px; background: var(--bg); font-size: 14px; overflow-wrap: anywhere; }

/* ---- alerts --------------------------------------------------------------- */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: 16px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line-strong); }
.alert-icon { flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: var(--muted); }
.alert-text { flex: 1; }
.alert-success { background: var(--good-soft); border-color: transparent; } .alert-success .alert-icon { background: var(--good); }
.alert-error, .alert-danger { background: var(--bad-soft); border-color: transparent; } .alert-error .alert-icon, .alert-danger .alert-icon { background: var(--bad); }
.alert-warning { background: var(--warn-soft); border-color: transparent; } .alert-warning .alert-icon { background: var(--warn); }
.alert-close { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; }

/* ---- brand and public chrome ---------------------------------------------- */
.mark { display: block; width: 100%; height: auto; }
.mark-bg { fill: #c5c5fc; }
.mark-head { fill: #0f1630; }
.mark-eye { fill: #62c4b0; }
.site-wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding-inline: 32px; }
/* the floating bar */
.site-nav { position: sticky; top: 0; z-index: 30; height: 0; }
.site-nav + main { padding-top: 88px; }
.site-nav > .site-wrap { position: relative; top: 14px; display: flex; align-items: center; gap: 28px; max-width: 1080px; width: calc(100% - 32px); min-height: 60px; padding-inline: 20px 12px; background: color-mix(in srgb, var(--surface) 86%, transparent); border: 1px solid var(--line); border-radius: var(--r-l); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 800 21px var(--display); letter-spacing: -.02em; }
.brand .mark { width: 28px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.site-links { display: flex; gap: 28px; margin-inline: auto; }
.site-links a, .site-sheet a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.site-links a:hover, .site-sheet a:hover { color: var(--ink); }
.site-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.site-links + .site-actions { margin-left: 0; }
.site-actions form { margin: 0; }
.site-actions .btn-quiet { background: none; }
.site-actions .btn-quiet:hover { background: var(--surface-2); }
.site-burger { display: none; }
.site-sheet { position: absolute; top: 100%; left: 16px; right: 16px; display: grid; gap: 2px; padding: 10px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-l); box-shadow: var(--shadow); }
.site-sheet a { padding: 10px; }
.theme-icon { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; }

.site-footer { background: light-dark(#eceef6, #0e1017); border-top: 1px solid var(--line); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; padding-block: 56px; }
.footer-grid p { max-width: 32ch; margin-top: 14px; color: var(--muted); font-size: 14px; }
.footer-grid nav { display: grid; align-content: start; gap: 10px; font-size: 14px; }
.footer-grid nav h4 { margin-bottom: 4px; }
.footer-grid nav a { color: var(--muted); text-decoration: none; }
.footer-grid nav a:hover { color: var(--ink); }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding-block: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* error and 404 */
.notice { max-width: 520px; margin: 72px auto 112px; padding: 0 24px; text-align: center; }
.notice .mark { width: 96px; margin: 0 auto 24px; }
.notice .code { font: 800 72px/1 var(--display); letter-spacing: -.04em; }

/* ---- application shell ---------------------------------------------------- */
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.app-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--line); overscroll-behavior: contain; }
.app-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--ink); text-decoration: none; font: 800 20px var(--display); }
.app-brand .mark { width: 28px; }
.brand-dot { color: var(--accent); }
.app-guild-card { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-m); color: var(--ink); text-decoration: none; }
.app-guild-card:hover { border-color: var(--line-strong); background: var(--bg); }
.guild-icon, .guild-fallback, .app-guild-empty-icon { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--surface-2); font-weight: 600; }
.app-guild-meta { display: grid; flex: 1; min-width: 0; }
.app-guild-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-guild-meta span { color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.app-sidebar-search, .app-topbar-search { display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg); color: var(--muted); }
.app-sidebar-search:focus-within, .app-topbar-search:focus-within { border-color: var(--accent); }
.app-sidebar-search input, .app-topbar-search input { min-height: 36px; padding: 6px 0; border: 0; background: none; }
.app-nav { display: grid; gap: 2px; }
.app-nav-section { padding: 14px 10px 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.app-nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-s); color: var(--muted); text-decoration: none; font-weight: 500; }
.app-nav-link:hover { background: var(--bg); color: var(--ink); }
.app-nav-link.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.app-sidebar-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--line); }
.app-user-meta { display: grid; flex: 1; min-width: 0; font-size: 13px; }
.app-user-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user-meta span { color: var(--muted); }
.app-sidebar-user form { margin: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; }
.app-body { display: flex; flex-direction: column; min-width: 0; }
.app-topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 28px; background: var(--bg); border-bottom: 1px solid var(--line); }
.app-breadcrumb { display: flex; align-items: center; gap: 8px; min-width: 0; margin-right: auto; color: var(--muted); white-space: nowrap; overflow: hidden; }
.app-breadcrumb a { color: var(--muted); text-decoration: none; }
.app-breadcrumb strong { color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.app-topbar-actions { display: flex; align-items: center; gap: 8px; }
.app-topbar-search { width: 230px; background: var(--surface); }
.app-topbar-search kbd { font: 11px var(--mono); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
.app-icon-btn { position: relative; display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); color: var(--ink); font: 600 12px var(--body); text-decoration: none; cursor: pointer; }
.app-icon-btn:hover { border-color: var(--line-strong); }
.app-avatar { display: inline-flex; }
.app-main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px; }
.app-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 18px 28px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.app-menu-btn { display: none; flex-direction: column; justify-content: center; align-items: center; gap: 4px; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); cursor: pointer; }
.app-menu-btn span { width: 16px; height: 2px; border-radius: 2px; background: var(--ink); }
.app-backdrop { display: none; }

/* system status menu */
.app-system-container { position: relative; }
.app-system-menu { position: absolute; z-index: 40; top: calc(100% + 8px); right: 0; display: none; width: 290px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow); overflow: hidden; }
.app-system-menu.active { display: block; }
.app-system-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.app-system-header h3 { margin: 0; }
.app-system-badge { padding: 2px 10px; border-radius: 99px; background: var(--surface-2); font-size: 12px; font-weight: 600; }
.app-system-badge.is-online { background: var(--good-soft); color: var(--good); }
.app-system-badge.is-offline { background: var(--bad-soft); color: var(--bad); }
.app-system-list { display: grid; gap: 4px; padding: 10px 16px; }
.app-system-item { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 13px; }
.app-system-label { color: var(--muted); }
.app-system-value { font-weight: 600; }
.app-system-value.is-online { color: var(--good); }
.app-system-value.is-offline { color: var(--bad); }
.app-system-empty { padding: 14px; text-align: center; color: var(--muted); }
.app-system-actions { padding: 10px 16px; border-top: 1px solid var(--line); text-align: center; }

/* ---- server list and overview --------------------------------------------- */
.ka-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.ka-head p { margin: 0; color: var(--muted); max-width: 60ch; }
.ka-kicker { display: none; }
.ka-guild-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.ka-guild { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); color: var(--ink); text-decoration: none; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.ka-guild:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.ka-guild-banner { display: none; }
.ka-guild-body { flex: 1; padding: 18px; min-width: 0; }
.ka-guild-avatar { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 12px; border-radius: 18px; background: var(--surface-2); overflow: hidden; font: 800 18px var(--display); }
.ka-guild-name { font-size: 18px; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ka-guild-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.ka-guild-perms { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ka-perm { padding: 2px 8px; border-radius: 99px; background: var(--surface-2); font-size: 12px; }
.ka-guild-foot { display: flex; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; }
.ka-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--good); }
.ka-dot.is-off { background: var(--bad); }
.ka-manage { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; }
.ka-guild-add { align-items: center; justify-content: center; gap: 6px; min-height: 190px; padding: 18px; border-style: dashed; border-color: var(--line-strong); background: transparent; text-align: center; }
.ka-guild-add small { color: var(--muted); }
.ka-add-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); }
.ka-empty { display: grid; justify-items: center; gap: 8px; padding: 48px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); text-align: center; }
.ka-empty p { color: var(--muted); max-width: 56ch; }
.ka-empty-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.ka-hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.ka-hero-banner { display: none; }
.ka-hero-id { display: flex; align-items: center; gap: 16px; }
.ka-hero-id h1 { margin: 0; overflow-wrap: anywhere; }
.ka-hero-avatar { flex: none; display: grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; background: var(--surface-2); overflow: hidden; font: 800 24px var(--display); }
.ka-hero-tags, .ka-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ka-tag { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 0; border-radius: 99px; background: var(--surface-2); color: var(--ink); font: 500 13px var(--body); }
.ka-tag.is-copy { cursor: pointer; }
.ka-tag.copied { background: var(--good-soft); color: var(--good); }
.ka-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: center; }
.ka-metric { padding: 12px 16px; border-left: 1px solid var(--line); }
.ka-metric > span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.ka-metric strong { display: block; font: 800 24px var(--display); font-variant-numeric: tabular-nums; }
.ka-metric strong.is-good { color: var(--good); }
.ka-metric strong.is-bad { color: var(--bad); }
.ka-section { margin-top: 32px; }
.ka-section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.ka-section-head p { margin: 0; color: var(--muted); }
.app-module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.app-module-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
.app-module-head { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 16px 18px; color: var(--ink); text-decoration: none; }
.app-module-head h3 { margin: 0 0 2px; }
.app-module-head p { margin: 0; color: var(--muted); font-size: 13px; }
.app-module-head-link:hover { background: var(--bg); }
.app-module-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-m); background: var(--surface-2); color: var(--ink); }
.app-module-badge { padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.app-module-badge.is-active { background: var(--good-soft); color: var(--good); }
.app-module-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 10px 18px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--ink); text-align: left; text-decoration: none; font: inherit; }
.app-module-row:hover { background: var(--bg); }
.app-module-row div { display: flex; flex: 1; justify-content: space-between; gap: 12px; min-width: 0; }
.app-module-row strong { font-weight: 500; }
.app-module-row span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- unsaved changes bar and leave dialog (js/unsaved.js) ------------------ */
.ka-savebar { position: fixed; z-index: 60; left: 50%; bottom: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; width: min(640px, calc(100% - 32px)); padding: 12px 14px 12px 18px; background: var(--ink); color: var(--on-strong); border-radius: var(--r-l); box-shadow: var(--shadow); opacity: 0; visibility: hidden; transform: translate(-50%, 16px); transition: opacity .2s, transform .2s, visibility .2s; }
.ka-savebar.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.ka-savebar-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--paw); }
.ka-savebar-text { flex: 1; min-width: 160px; }
.ka-savebar-actions { display: flex; gap: 8px; }
.ka-savebar .btn-primary { background: var(--paw); color: var(--navy); }
.ka-savebar .btn-ghost { background: transparent; color: var(--on-strong); border-color: currentColor; }
.ka-unsaved-hidden { display: none !important; }
.ka-leave { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; padding: 20px; background: rgb(16 23 43 / .4); overscroll-behavior: contain; }
.ka-leave.is-open { display: grid; }
.ka-leave-card { width: min(440px, 100%); padding: 24px; background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow); }
.ka-leave-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 12px; border-radius: 50%; background: var(--warn-soft); color: var(--warn); }
.ka-leave-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.ka-leave-discard { color: var(--bad); }
.ka-leave-error { color: var(--bad); }

/* ---- responsive ------------------------------------------------------------ */
@media (max-width: 1100px) {
    .k-columns { grid-template-columns: minmax(0, 1fr); }
    .k-preview { position: static; }
    .app-topbar-search { display: none; }
}
@media (max-width: 920px) {
    .ka-hero { grid-template-columns: minmax(0, 1fr); }
    .app-shell { grid-template-columns: minmax(0, 1fr); }
    .app-sidebar { position: fixed; z-index: 50; left: 0; width: 272px; transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility .2s; }
    .app-sidebar.open { transform: none; visibility: visible; }
    .app-backdrop.open { display: block; position: fixed; inset: 0; z-index: 45; background: rgb(16 23 43 / .35); }
    body.app-sidebar-open { overflow: hidden; }
    .app-menu-btn { display: flex; flex: none; }
}
@media (max-width: 760px) {
    .site-links, .site-actions .hide-sm { display: none; }
    .site-wrap { padding-inline: 18px; }
    .site-nav > .site-wrap { gap: 8px; width: calc(100% - 20px); padding-inline: 12px 8px; }
    .site-actions { gap: 2px; }
    .site-actions .btn { padding-inline: 10px; }
    .site-nav .brand span { display: none; }
    .site-actions { margin-left: auto; }
    .site-burger { display: inline-flex; }
    .k-grid-2 { grid-template-columns: minmax(0, 1fr); }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .app-main { padding: 18px 14px; }
    .app-topbar { padding: 10px 14px; gap: 8px; }
    .app-breadcrumb a, .app-breadcrumb span { display: none; }
    .app-module-grid { grid-template-columns: minmax(0, 1fr); }
    .app-system-menu { position: fixed; top: 60px; right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Settings pages sit on the page itself: thin rules separate groups instead of floating boxes. */
.app-main .k-card { border-radius: var(--r-m); box-shadow: none; }

/* ---- dashboard: same near-black ground and lavender light as the home page ---- */
body.app-page { background: radial-gradient(60% 40% at 78% -8%, light-dark(rgb(197 197 252 / .35), rgb(109 93 247 / .20)), transparent 70%), radial-gradient(40% 30% at 8% 0%, light-dark(transparent, rgb(45 212 191 / .07)), transparent 70%), var(--bg); background-attachment: fixed; }
body.app-page .app-sidebar { background: light-dark(var(--surface), rgb(10 11 16 / .86)); backdrop-filter: blur(14px); }
body.app-page .app-main :is(section, .card, .ka-card, .panel, .stat) { border-color: light-dark(var(--line), rgb(255 255 255 / .08)); }
body.app-page .app-main :is(.card, .ka-card, .panel) { background: light-dark(var(--surface), linear-gradient(180deg, rgb(255 255 255 / .045), rgb(255 255 255 / .012))); }
body.app-page .app-sidebar a[aria-current="page"], body.app-page .app-sidebar a.active { background: light-dark(var(--accent-soft), rgb(197 197 252 / .12)); box-shadow: inset 0 0 0 1px light-dark(transparent, rgb(197 197 252 / .28)); color: var(--accent-strong); }
.site-footer .footer-bottom a, .app-footer a, .site-footer span a { color: inherit; text-underline-offset: 3px; }
.site-footer span a:hover { color: var(--accent); }

/* dashboard polish: glass cards that light up on hover, clearer switches */
body.app-page .k-card { background: light-dark(var(--surface), linear-gradient(180deg, rgb(255 255 255 / .05), rgb(255 255 255 / .012))); border-color: light-dark(var(--line), rgb(255 255 255 / .08)); transition: border-color .25s, box-shadow .25s; }
body.app-page .k-card:hover { border-color: light-dark(var(--line-strong), rgb(197 197 252 / .28)); box-shadow: light-dark(none, 0 18px 50px -24px rgb(124 124 240 / .35)); }
input.k-switch { background: light-dark(var(--line-strong), #2a3042); box-shadow: inset 0 0 0 1px light-dark(transparent, rgb(255 255 255 / .12)); }
input.k-switch:checked { background: var(--switch-on); box-shadow: 0 0 14px light-dark(transparent, rgb(139 139 245 / .45)); }
body.app-page .app-main h1 { letter-spacing: -.03em; }
@media (prefers-reduced-motion: no-preference) {
    body.app-page .app-main > * { animation: appIn .45s cubic-bezier(.2, .7, .2, 1) both; }
    body.app-page .app-main > *:nth-child(2) { animation-delay: .05s; }
    body.app-page .app-main > *:nth-child(3) { animation-delay: .1s; }
    body.app-page .app-main > *:nth-child(n+4) { animation-delay: .15s; }
}
@keyframes appIn { from { opacity: 0; transform: translateY(10px); } }
