/* The web panel's styles. Dark, Discord-adjacent, no external fonts or frameworks. */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e6e8ee;
  --muted: #9aa1b2;
  --faint: #6b7283;
  --accent: #5865f2;
  --accent-2: #7983f5;
  --good: #3ba55d;
  --warn: #faa61a;
  --bad: #ed4245;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: .85rem; }
.boot { padding: 4rem; text-align: center; color: var(--muted); }

/* ── Buttons and inputs ── */
button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem;
  text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { border-color: #3a4150; text-decoration: none; }
button:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { color: #ff8a8c; }
.btn-danger:hover { border-color: var(--bad); }
.btn-small { padding: .25rem .6rem; font-size: .85rem; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--line); }
input, select, textarea {
  font: inherit; color: var(--text); background: #0c0e12; border: 1px solid var(--line); border-radius: 8px;
  padding: .5rem .65rem; width: 100%; min-width: 0;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=color] { padding: 0; width: 2.6rem; height: 2.3rem; flex: none; cursor: pointer; }
input[type=checkbox] { width: auto; }
label { display: block; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #3a3f4b; border-radius: 99px; transition: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); }
.switch input:disabled + span { opacity: .5; cursor: default; }

/* ── Layout ── */
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .7rem 1.25rem; border-bottom: 1px solid var(--line);
  background: rgba(15, 17, 21, .9); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 650; color: var(--text); }
.brand img { width: 30px; height: 30px; border-radius: 50%; }
.topbar .spacer { flex: 1; }
.user { display: flex; align-items: center; gap: .5rem; color: var(--muted); }
.user img { width: 28px; height: 28px; border-radius: 50%; }

.shell { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 53px); }
.sidebar { border-right: 1px solid var(--line); padding: 1rem .75rem; position: sticky; top: 53px; height: calc(100vh - 53px); overflow-y: auto; }
.sidebar .server { display: flex; align-items: center; gap: .6rem; padding: .3rem .4rem .9rem; }
.sidebar .server select { padding: .35rem .5rem; }
.menu-toggle { display: none; }
.nav-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 1rem .5rem .35rem; }
.nav a {
  display: flex; align-items: center; gap: .55rem; padding: .42rem .6rem; border-radius: 7px; color: var(--muted);
  text-decoration: none; font-size: .93rem;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: rgba(88, 101, 242, .16); color: #fff; }
.nav .icon { width: 1.3rem; text-align: center; }
.nav .dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.nav .dot.off { background: #4a4f5c; }
.content { padding: 1.5rem 2rem 4rem; max-width: 1150px; width: 100%; }

.page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head .icon { font-size: 2rem; }
.page-head .grow { flex: 1; min-width: 240px; }
.page-head p { margin: .2rem 0 0; color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.25rem; margin-bottom: 1rem; }
.card-head { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .85rem; }
.card-head .grow { flex: 1; }
.card-head p { margin: .2rem 0 0; color: var(--muted); font-size: .9rem; }
.notice { background: rgba(250, 166, 26, .08); border: 1px solid rgba(250, 166, 26, .35); border-radius: 8px; padding: .65rem .85rem; color: #f6d29a; font-size: .9rem; }
.empty { color: var(--faint); padding: .6rem 0; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .9rem 1.2rem; }
.field.wide { grid-column: 1 / -1; }
.field > .label { font-size: .88rem; font-weight: 600; margin-bottom: .3rem; display: flex; align-items: center; gap: .5rem; }
.field .help { font-size: .8rem; color: var(--faint); margin-top: .3rem; }
.field-row { display: flex; gap: .5rem; align-items: center; }
.bool-field { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .75rem; }
.bool-field .label { margin: 0; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; align-items: center; }
.form-actions .status { margin-right: auto; font-size: .85rem; color: var(--faint); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chips a { padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 99px; font-size: .85rem; color: var(--muted); text-decoration: none; }
.chips a:hover { color: var(--text); border-color: #3a4150; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: .55rem .9rem; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--faint); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; padding: .45rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .55rem .6rem; border-bottom: 1px solid #20242d; vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.actions { text-align: right; white-space: nowrap; width: 1%; }
td .clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.child { background: #12151b; border: 1px solid var(--line); border-radius: 8px; padding: .75rem; margin: .4rem 0 .2rem; }
.mention { background: rgba(88, 101, 242, .18); color: #c9cdfb; border-radius: 4px; padding: 0 .3rem; white-space: nowrap; }
.swatch { display: inline-block; width: .85rem; height: .85rem; border-radius: 3px; vertical-align: -2px; margin-right: .35rem; border: 1px solid rgba(255, 255, 255, .2); }
.pill { font-size: .75rem; border-radius: 99px; padding: .1rem .5rem; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.pill.on { color: #9fe0b3; border-color: rgba(59, 165, 93, .5); }
.filter { max-width: 280px; margin-bottom: .6rem; }

/* Server picker */
.servers { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.server-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; display: flex; flex-direction: column; align-items: center; gap: .7rem; text-align: center; color: var(--text); text-decoration: none; }
.server-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.server-card.invite { border-style: dashed; color: var(--muted); }
.gicon { width: 64px; height: 64px; border-radius: 18px; background: var(--panel-2); display: grid; place-items: center; font-weight: 700; color: var(--muted); overflow: hidden; flex: none; }
.gicon img { width: 100%; height: 100%; object-fit: cover; }
.gicon.small { width: 34px; height: 34px; border-radius: 10px; font-size: .8rem; }

/* Module grid */
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .9rem; }
.module-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.module-card .top { display: flex; align-items: center; gap: .6rem; }
.module-card .top .icon { font-size: 1.4rem; }
.module-card .top h3 { flex: 1; }
.module-card p { margin: 0; color: var(--muted); font-size: .86rem; flex: 1; }

/* Stats */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .8rem .9rem; }
.tile .value { font-size: 1.35rem; font-weight: 700; }
.tile .label { color: var(--faint); font-size: .8rem; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding: .5rem 0 0; border-bottom: 1px solid var(--line); }
.bars .bar { flex: 1; background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars .bar:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #000; padding: .15rem .4rem; border-radius: 4px; font-size: .75rem; white-space: nowrap; margin-bottom: 4px; }
.bar-labels { display: flex; justify-content: space-between; color: var(--faint); font-size: .72rem; margin: .3rem 0 1rem; }

/* Message builder */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
/* Message preview (Discord-like) */
.preview { background: #313338; border-radius: 8px; padding: 1rem; color: #dbdee1; font-size: .95rem; line-height: 1.375; }
.preview .msg-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .2rem; }
.preview .msg-head img { width: 40px; height: 40px; border-radius: 50%; }
.preview .msg-head b { color: #f2f3f5; }
.preview .bot-tag { background: #5865f2; color: #fff; font-size: .62rem; padding: .05rem .3rem; border-radius: 3px; font-weight: 700; }
.preview .msg-head .faint { font-size: .75rem; }
.preview .msg-body { margin-left: 3rem; min-width: 0; }
.preview .content { margin-bottom: .3rem; overflow-wrap: anywhere; }
.preview a { color: #00a8fc; }
.embed { background: #2b2d31; border-left: 4px solid #1e1f22; border-radius: 4px; padding: .55rem 1rem .8rem .75rem; max-width: 520px; margin-top: .3rem; overflow-wrap: anywhere; }
.embed .e-main { display: flex; gap: 1rem; }
.embed .e-body { flex: 1; min-width: 0; }
.embed .e-author { display: flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 600; margin-top: .3rem; color: #f2f3f5; }
.embed .e-author img, .embed .e-footer img { width: 22px; height: 22px; border-radius: 50%; }
.embed .e-author a { color: #f2f3f5; }
.embed .e-title { font-weight: 700; margin-top: .3rem; color: #f2f3f5; }
.embed .e-desc { font-size: .88rem; margin-top: .3rem; }
.embed .e-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; margin-top: .4rem; flex: none; }
.embed .e-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem 1rem; margin-top: .5rem; }
.embed .e-field { grid-column: 1 / -1; font-size: .88rem; }
.embed .e-field.inline { grid-column: auto; }
.embed .e-fname { font-weight: 700; color: #f2f3f5; margin-bottom: .1rem; }
.embed .e-image { display: block; max-width: 100%; max-height: 300px; border-radius: 4px; margin-top: .7rem; }
.embed .e-footer { display: flex; align-items: center; gap: .4rem; font-size: .75rem; color: #b5bac1; margin-top: .55rem; }
.d-row { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .45rem; }
.d-button { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .9rem; border-radius: 4px; font-size: .85rem; font-weight: 500; color: #fff; background: #4e5058; }
.d-button.primary { background: #5865f2; } .d-button.success { background: #248046; } .d-button.danger { background: #da373c; }
.d-button .ext { opacity: .7; font-size: .75rem; }
.d-select { margin-top: .45rem; max-width: 400px; background: #1e1f22; border-radius: 4px; padding: .55rem .7rem; color: #b5bac1; font-size: .88rem; display: flex; justify-content: space-between; }
.md-line, .md-li { min-height: 1.2em; }
.md-h1 { font-size: 1.4rem; font-weight: 700; margin: .4rem 0 .2rem; } .md-h2 { font-size: 1.2rem; font-weight: 700; margin: .35rem 0 .15rem; } .md-h3 { font-size: 1.05rem; font-weight: 700; margin: .3rem 0 .1rem; }
.md-sub { font-size: .75rem; color: #949ba4; }
.md-quote { border-left: 4px solid #4e5058; padding-left: .6rem; }
.md-code { background: #1e1f22; border-radius: 3px; padding: 0 .25rem; font-size: .85em; }
.md-pre { background: #1e1f22; border: 1px solid #1a1b1e; border-radius: 4px; padding: .5rem; white-space: pre-wrap; font-size: .82rem; margin: .2rem 0; }
.md-spoiler { background: #1e1f22; color: transparent; border-radius: 3px; } .md-spoiler:hover { color: inherit; }
.md-mention { background: rgba(88, 101, 242, .3); color: #c9cdfb; border-radius: 3px; padding: 0 .15rem; font-weight: 500; }
.md-time { background: rgba(255, 255, 255, .06); border-radius: 3px; padding: 0 .15rem; }
.md-var { background: rgba(250, 166, 26, .18); color: #f0b232; border-radius: 3px; padding: 0 .2rem; font-family: ui-monospace, monospace; font-size: .85em; }
.md-emoji { width: 1.3em; height: 1.3em; vertical-align: -.3em; object-fit: contain; }
/* Embed builder */
.mb { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; align-items: start; margin-top: .8rem; }
.mb-preview { position: sticky; top: 70px; }
.modal.wide .mb-preview { top: 0; }
.mb-editor { display: flex; flex-direction: column; gap: .7rem; min-width: 0; }
.mb-toolbar { display: flex; flex-wrap: wrap; gap: .4rem; }
.mb-field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.mb-field .label { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.mb-check { flex-direction: row; align-items: center; align-self: end; gap: .4rem; font-size: .88rem; padding-bottom: .5rem; }
.mb-count { font-size: .72rem; color: var(--faint); font-weight: 400; white-space: nowrap; }
.mb-count.over { color: var(--bad); font-weight: 700; }
.mb-embed { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid #4e5058; border-radius: 8px; padding: .5rem .8rem; }
.mb-embed > summary { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 600; padding: .2rem 0; list-style: none; }
.mb-embed > summary::-webkit-details-marker { display: none; }
.mb-embed > summary::before { content: "▸"; color: var(--faint); } .mb-embed[open] > summary::before { content: "▾"; }
.mb-tools { display: inline-flex; gap: .25rem; }
.mb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .8rem; margin-top: .6rem; }
.mb-grid .wide, .mb-editor .wide { grid-column: 1 / -1; }
.mb-hex { width: 7rem; }
.mb-fields { display: flex; flex-direction: column; gap: .45rem; }
.mb-fieldrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto; gap: .4rem; align-items: start; }
.mb-inline { font-size: .8rem; white-space: nowrap; padding-top: .45rem; }
.mb-buttonrow { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) minmax(0, 1.6fr) auto; gap: .4rem; margin-bottom: .4rem; }
.mb-row { display: flex; align-items: center; gap: .6rem; }
.mb-vars { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.mb-vars .help { width: 100%; }
.mb-json { width: 100%; min-height: 50vh; font-family: ui-monospace, monospace; font-size: .8rem; }
.mb-templates { display: flex; flex-direction: column; gap: .4rem; }
.mb-template { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; }
.mb-send { align-items: center; }
.mb-send select { max-width: 280px; }
.msgfield { align-items: center; }
.msgfield .clip { flex: 1; }
.modal.wide { width: min(1280px, 100%); max-height: 94vh; }
.form-group-title { grid-column: 1 / -1; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: .3rem; margin-top: .6rem; }
.field-list .item { display: grid; grid-template-columns: 1fr 1.6fr auto auto; gap: .4rem; align-items: center; margin-bottom: .4rem; }

/* Schedule */
.schedule { display: grid; grid-template-columns: 7.5rem auto 1fr auto 1fr; gap: .4rem .6rem; align-items: center; }
.schedule input[type=time] { padding: .35rem .5rem; }

/* Multi picker */
.multi { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.multi .chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: .1rem .2rem .1rem .55rem; font-size: .82rem; display: inline-flex; align-items: center; gap: .2rem; }
.multi .chip button { padding: 0 .35rem; border: none; background: none; color: var(--faint); }
.multi select { width: auto; max-width: 220px; padding: .25rem .4rem; font-size: .85rem; }

/* Commands */
.cmd { display: grid; grid-template-columns: minmax(200px, 1.1fr) auto minmax(0, 1fr) minmax(0, 1fr) auto; gap: .8rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid #20242d; }
.cmd:last-child { border-bottom: none; }
.cmd code { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; color: #c9cdfb; }
.cmd .sub { padding-left: 1.2rem; }
.cmd .desc { display: block; font-size: .8rem; color: var(--faint); }

/* Modal + toasts */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(640px, 100%); max-height: 90vh; overflow-y: auto; padding: 1.3rem; box-shadow: var(--shadow); }
.modal h2 { margin-bottom: .3rem; }
.modal .form-grid { grid-template-columns: 1fr; margin-top: 1rem; }
#toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 60; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: 8px; padding: .65rem .9rem; box-shadow: var(--shadow); max-width: 380px; }
.toast.error { border-left-color: var(--bad); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 2.2rem; width: min(420px, 100%); text-align: center; }
.login img { width: 72px; height: 72px; border-radius: 50%; margin-bottom: .8rem; }
.login .btn { justify-content: center; width: 100%; margin-top: 1.4rem; padding: .7rem; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--line); padding-bottom: .2rem; }
  .menu-toggle { display: inline-flex; }
  .sidebar .nav { display: none; }
  .sidebar.open .nav { display: block; }
  .content { padding: 1rem; }
  .builder { grid-template-columns: 1fr; }
  .preview, .mb-preview { position: static; }
  .mb, .mb-grid, .mb-fieldrow, .mb-buttonrow { grid-template-columns: 1fr; }
  .cmd { grid-template-columns: 1fr auto; }
}
