:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --text: #1b1f24;
  --muted: #646d78;
  --border: #dde1e6;
  --accent: #5865f2;
  --accent-text: #ffffff;
  --danger: #d93a3a;
  --ok: #2f9e5b;
  --warn: #c98a14;
  --code-bg: #f0f2f5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --panel: #1d2026;
    --panel-2: #252931;
    --text: #e6e8eb;
    --muted: #9099a4;
    --border: #2f343c;
    --accent: #7b86ff;
    --accent-text: #0e1016;
    --danger: #f06767;
    --ok: #4cc27f;
    --warn: #e3ab3b;
    --code-bg: #14161a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 13px; margin: 22px 0 8px; text-transform: uppercase;
     letter-spacing: .04em; color: var(--muted); }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* EverythingBot logo (favicon + login + sidebar) */
.logo { width: 76px; height: 76px; border-radius: 16px; justify-self: center;
        box-shadow: var(--shadow); }
.brand-logo { width: 22px; height: 22px; border-radius: 5px;
              vertical-align: -5px; margin-right: 7px; }

input, select, textarea, button {
  font: inherit; color: inherit;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; font-family: inherit; }
button { cursor: pointer; background: var(--panel-2); }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
.small-btn { padding: 4px 8px; font-size: 12px; }
label { display: grid; gap: 4px; font-size: 13px; }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow-1 { flex: 1 1 160px; }
.grow-3 { flex: 3 1 220px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px; box-shadow: var(--shadow); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; display: grid; gap: 14px; }
.login-card form { display: grid; gap: 12px; }
.login-card form.row { display: flex; }
.login-card form.row input { flex: 1; }
.scopes { border: 1px solid var(--border); border-radius: 6px; display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 10px; }
.scopes legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.scopes label { display: flex; align-items: center; gap: 5px; }
.paste summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.msg { margin: 0; min-height: 1.4em; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }

/* shell */
.shell { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--border); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; padding: 4px 10px 14px; }
.side a { color: var(--text); text-decoration: none; padding: 7px 10px; border-radius: 6px; }
.side a:hover { background: var(--panel-2); }
.side a.active { background: var(--accent); color: var(--accent-text); }
.side-foot { margin-top: auto; display: grid; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
.side-foot #who { overflow-wrap: anywhere; }
.content { padding: 20px 24px 40px; min-width: 0; max-width: 1200px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.view > .row { margin-bottom: 12px; }

.toast { position: fixed; right: 16px; bottom: 16px; max-width: min(420px, calc(100vw - 32px)); margin: 0; padding: 10px 14px; border-radius: 8px; background: var(--text); color: var(--bg); z-index: 10; }
.toast.err { background: var(--danger); color: #fff; }

.pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.err { color: var(--danger); border-color: var(--danger); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; overflow-wrap: anywhere; }
.tile .s { font-size: 12px; color: var(--muted); }
.bar { height: 5px; background: var(--panel-2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.hot > span { background: var(--warn); }

/* console */
.run-form { display: grid; gap: 8px; margin-bottom: 12px; }
.output { display: grid; gap: 8px; }
.output:empty::before { content: "No output yet."; color: var(--muted); }
.item { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; }
.item.text { white-space: pre-wrap; }
.item.error { border-color: var(--danger); color: var(--danger); white-space: pre-wrap; }
.item.meta { background: transparent; border-style: dashed; color: var(--muted); font-size: 12px; }
.item .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.embed { border-left: 4px solid var(--border); padding-left: 10px; display: grid; gap: 6px; }
.embed .title { font-weight: 600; }
.embed .desc { white-space: pre-wrap; }
.embed .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.embed .field .n { font-weight: 600; font-size: 13px; }
.embed .field .fv { white-space: pre-wrap; font-size: 13px; }
.embed .footer { font-size: 12px; color: var(--muted); }
.embed img { max-width: 100%; max-height: 320px; border-radius: 6px; }
.components { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.modal-form { display: grid; gap: 8px; }
.modal-form textarea { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; min-height: 70px; }
#run-input { margin-top: 10px; }

/* commands */
.cmd-picker { display: grid; gap: 12px; }
.cmd-picker.collapsed { display: none; }
.split { display: grid; grid-template-columns: minmax(200px, 320px) 1fr; gap: 12px; align-items: start; }
.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; max-height: 70vh; overflow: auto; }
.list li { padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.list li:last-child { border-bottom: 0; }
.list li:hover { background: var(--panel-2); }
.list li.active { background: var(--panel-2); box-shadow: inset 3px 0 var(--accent); }
.list .n { font-weight: 600; }
.list .d { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail { display: grid; gap: 10px; position: sticky; top: 16px; }
.detail pre { background: var(--code-bg); padding: 10px; border-radius: 6px; white-space: pre-wrap; margin: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 200px; }
tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 500; background: var(--panel-2); }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
td .row { gap: 4px; }
.empty td { color: var(--muted); text-align: center; }

.logs { background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; max-height: 420px; overflow: auto; white-space: pre-wrap; margin: 0; }

/* footer credit */
.foot { font-size: 11px; color: var(--muted); margin: 0; }
.foot a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted currentColor; }
.foot a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.foot .sep { opacity: .6; margin: 0 5px; }

/* autocomplete (console intellisense) */
.ac-wrap { position: relative; display: flex; flex-direction: column; }
.ac { position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
      background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, .18); max-height: 300px; overflow: auto; }
.ac-hint { padding: 4px 10px; font-size: 11px; color: var(--muted);
           border-bottom: 1px solid var(--border); }
.ac-item { padding: 6px 10px; cursor: pointer; }
.ac-item + .ac-item { border-top: 1px solid var(--border); }
.ac-item.hover, .ac-item:hover { background: var(--panel-2); }
.ac-item .ac-name { font-weight: 600; }
.ac-item .ac-desc { font-size: 12px; color: var(--muted);
                    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* live help text under the console form */
.help-strip { display: grid; gap: 2px; background: var(--code-bg);
              border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
              margin-bottom: 8px; }
.help-strip .usage { font-weight: 600; overflow-wrap: anywhere; }
.help-strip .d { color: var(--muted); white-space: pre-wrap; }

/* help page */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.crumbs .sep { color: var(--muted); }
.crumbs button { padding: 3px 8px; font-size: 13px; }
.crumbs button[disabled] { opacity: 1; color: var(--text); cursor: default; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.help-card { display: grid; gap: 3px; text-align: left; background: var(--panel); }
.help-card .t { font-weight: 600; overflow-wrap: anywhere; }
.help-card .d { font-size: 12px; color: var(--muted); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px; }
  .brand { width: 100%; padding: 4px 8px 6px; }
  .side-foot { margin: 0; width: 100%; border-top: 0; display: flex; align-items: center; gap: 10px; padding: 6px 8px 0; }
  .content { padding: 16px; }
  .split { grid-template-columns: 1fr; }
  .list { max-height: 40vh; }
  .detail { position: static; }
}
