/* Levera palette: stone canvas + ink in light mode, near-black + brand cream in dark. */
:root {
  --bg: #f1f0ec;
  --card: #faf9f6;
  --surface: #eae9e4;
  --surface-2: #f4f3ef;
  --hover: #ecebe6;
  --border: #dfddd7;
  --fg: #1a1917;
  --secondary: #403e3a;
  --muted: #706c66;
  --accent: #1a1917;
  --accent-ink: #faf9f6;
  --green: #159144;
  --red: #cf2a2a;
  --yellow: #b07a08;
  --shadow: 0 8px 20px -10px rgb(26 25 23 / 0.14);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0b09;
    --card: #141414;
    --surface: #1e1e1e;
    --surface-2: #1a1a1a;
    --hover: #222;
    --border: #252525;
    --fg: #fafafa;
    --secondary: #a1a1aa;
    --muted: #71717a;
    --accent: #ece3d1;
    --accent-ink: #0a0a0a;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;
    --shadow: 0 20px 40px -12px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0b09;
  --card: #141414;
  --surface: #1e1e1e;
  --surface-2: #1a1a1a;
  --hover: #222;
  --border: #252525;
  --fg: #fafafa;
  --secondary: #a1a1aa;
  --muted: #71717a;
  --accent: #ece3d1;
  --accent-ink: #0a0a0a;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --shadow: 0 20px 40px -12px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; font-size: 15px; }
.brand b { color: var(--muted); font-weight: 500; }
.userchip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface); object-fit: cover; flex: none; }

main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 120px; }
.loading { padding: 80px 0; text-align: center; color: var(--muted); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card);
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { opacity: 0.9; }
.btn.danger { color: var(--red); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.iconbtn { width: 30px; padding: 0; }

/* landing / login */
.hero { text-align: center; padding: 72px 0 40px; display: grid; gap: 16px; justify-items: center; }
.hero h1 { font-size: 34px; }
.hero p { max-width: 520px; color: var(--secondary); }
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 24px; }

/* server picker */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.guild { display: flex; align-items: center; gap: 12px; cursor: pointer; text-decoration: none; }
.guild:hover { background: var(--hover); }
.gicon { width: 48px; height: 48px; border-radius: 14px; background: var(--surface); display: grid; place-items: center; font-weight: 700; flex: none; object-fit: cover; }

/* guild layout */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
.side { position: sticky; top: 80px; display: grid; gap: 18px; }
.side .gname { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.side .gname .gicon { width: 36px; height: 36px; border-radius: 10px; font-size: 13px; }
.navgroup { display: grid; gap: 2px; }
.navgroup > span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0 10px 4px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; text-decoration: none; color: var(--secondary); }
.nav:hover { background: var(--hover); color: var(--fg); }
.nav.on { background: var(--surface); color: var(--fg); font-weight: 500; }
.nav .dot { width: 6px; height: 6px; border-radius: 50%; margin-left: auto; background: var(--green); }
.navtoggle { display: none; }

.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.pagehead p { color: var(--secondary); margin-top: 4px; max-width: 640px; }
.stack { display: grid; gap: 14px; }
.section { display: grid; gap: 14px; }
.section > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.row:first-of-type { border-top: 0; }
.row .label { display: grid; gap: 2px; }
.row .label .hint { color: var(--muted); font-size: 12px; }
.row.toggle-row { grid-template-columns: minmax(0, 1fr) auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* inputs */
.input, textarea.input {
  width: 100%; min-height: 36px; padding: 7px 11px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; outline: none;
}
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { border-color: var(--muted); }
.input.num { max-width: 120px; }

.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; transition: 0.15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: 0.15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { left: 20px; background: var(--accent-ink); }
.switch input:focus-visible + span { outline: 2px solid var(--muted); outline-offset: 2px; }

/* brand dropdown (no native select) */
.dd { position: relative; }
.dd-btn { width: 100%; display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 5px 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; text-align: left; flex-wrap: wrap; }
.dd-btn .ph { color: var(--muted); }
.dd-btn .chev { margin-left: auto; color: var(--muted); }
.dd-menu { position: absolute; z-index: 45; left: 0; right: 0; top: calc(100% + 4px); background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid; gap: 2px; }
.dd-menu.up { top: auto; bottom: calc(100% + 4px); }
.dd-search { position: sticky; top: 0; margin-bottom: 4px; }
.dd-list { max-height: 360px; overflow: auto; display: grid; gap: 1px; }
.dd-item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 8px; cursor: pointer; background: none; border: 0; text-align: left; width: 100%; }
.dd-item:hover, .dd-item.active { background: var(--hover); }
.dd-item.sel { font-weight: 600; }
.dd-item.disabled { opacity: 0.45; }
.dd-group { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 8px 9px 3px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: var(--surface); font-size: 12.5px; max-width: 100%; }
.chip button { background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); line-height: 1; }
.rdot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* list editors */
.items { display: grid; gap: 10px; }
.item { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.empty { padding: 20px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 12px; }

/* overview */
.plugins { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.plugin { display: grid; gap: 6px; text-decoration: none; }
.plugin:hover { background: var(--hover); }
.plugin .ico { font-size: 22px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.badge.on { color: var(--green); }
.badge.on::before, .badge.off::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.warn { border-color: color-mix(in srgb, var(--yellow) 50%, var(--border)); background: color-mix(in srgb, var(--yellow) 8%, var(--card)); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-top: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; border-top: 0; }
.pager { display: flex; justify-content: flex-end; gap: 6px; align-items: center; margin-top: 10px; }

/* save bar */
.savebar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(140%);
  width: min(720px, calc(100% - 32px));
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  transition: transform 0.2s; z-index: 40;
}
.savebar.show { transform: translateX(-50%) translateY(0); }
.savebar p { flex: 1; font-weight: 500; }

#toast { position: fixed; top: 68px; right: 16px; z-index: 50; display: grid; gap: 8px; }
.toast { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 360px; }
.toast.err { border-color: var(--red); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; }
  .navtoggle { display: inline-flex; }
  .side .navs { display: none; }
  .side.open .navs { display: grid; gap: 18px; }
  .row { grid-template-columns: 1fr; gap: 8px; }
  .row.toggle-row { grid-template-columns: minmax(0, 1fr) auto; }
  .two { grid-template-columns: 1fr; }
  .pagehead { flex-direction: column; }
  .hero h1 { font-size: 26px; }
  table .hide-sm { display: none; }
}
