:root {
  --bg: #0f0f12; --panel: #16161b; --panel-2: #1c1c22; --line: #26262e; --line-2: #32323c;
  --text: #e6e6ea; --muted: #8b8b96; --accent: #9b87f5; --accent-ink: #0f0f12;
  --danger: #ef6a6a; --ok: #5fd08a; --live: #ef4444;
  --radius: 6px; --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.45 var(--font); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
h3 { font-size: 12px; color: var(--muted); font-weight: 500; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
input, select, textarea {
  font: 13px var(--font); color: var(--text); background: var(--bg); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 7px 9px; width: 100%; min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.check { flex-direction: row; align-items: center; gap: 7px; color: var(--text); margin: 0; }
.check input { width: auto; accent-color: var(--accent); }
.check.inline { align-self: end; margin-bottom: 18px; }
.opt { color: #5f5f6a; font-size: 11px; margin-left: 4px; }
.hint { font-size: 11px; color: var(--muted); min-height: 14px; }
.hint.ok { color: var(--ok); }
.hint.err { color: var(--danger); }
.settings { max-width: 640px; }
.settings h2 { margin-bottom: 4px; }
.settings p { margin: 0 0 10px; }
.settings code { font-family: var(--mono); color: var(--text); }
.spaced { margin-top: 12px; }
.checks { display: flex; gap: 18px; align-items: end; padding-bottom: 18px; }

.btn {
  font: 500 13px var(--font); color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 7px 12px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #46464f; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.login-card h1 { font-size: 16px; margin-bottom: 4px; }
.login-card p { margin: 0 0 18px; }
.login-card .btn { width: 100%; margin-top: 4px; }
.error { color: var(--danger); min-height: 1em; margin: 10px 0 0 !important; font-size: 12px; }

/* shell */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.top-right { display: flex; align-items: center; gap: 8px; }
.bot { color: var(--muted); font-size: 12px; margin-right: 4px; }
.bot.on::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: 1px; }

.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 49px); }
.side { border-right: 1px solid var(--line); padding: 14px 10px; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 10px; }
.subs { list-style: none; margin: 0; padding: 0; }
.subs li button {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 6px; background: none; border: 0;
  border-radius: var(--radius); color: var(--text); font: 13px var(--font); text-align: left; cursor: pointer;
}
.subs li button:hover { background: var(--panel); }
.subs li button.active { background: var(--panel-2); }
.subs img, .subs .ph { width: 24px; height: 24px; border-radius: 50%; flex: none; background: var(--line); }
.subs .meta { min-width: 0; flex: 1; }
.subs .name, .subs .where { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subs .where { color: var(--muted); font-size: 11px; }
.subs .tag { font-size: 10px; font-weight: 600; letter-spacing: .05em; color: var(--live); }
.subs .off { opacity: .45; }
.empty { padding: 0 6px; }

.editor { padding: 18px 22px 0; min-width: 0; }
.placeholder { display: grid; place-items: center; }
.grid.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
.grid.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px); gap: 24px; border-top: 1px solid var(--line); margin-top: 4px; }
.color-row { display: flex; gap: 6px; }
.color-row input[type=color] { width: 36px; padding: 2px; flex: none; height: 33px; }
.fields-head { display: flex; align-items: center; justify-content: space-between; }
.fields-head h3 { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1.4fr auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.vars { margin: 14px 0 20px; color: var(--muted); }
.vars summary { cursor: pointer; font-size: 12px; }
.vars dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 10px 0; font-size: 12px; }
.vars dt { font-family: var(--mono); color: var(--text); }
.vars dd { margin: 0; }

.preview-col { position: sticky; top: 0; align-self: start; padding-bottom: 20px; }

.actions {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 12px 0;
  background: var(--bg); border-top: 1px solid var(--line); margin-top: 8px;
}
.spacer { flex: 1; }
.status { font-size: 12px; color: var(--muted); }
.status.err { color: var(--danger); }
.status.ok { color: var(--ok); }

/* Discord message preview */
.discord { background: #313338; border-radius: 8px; padding: 14px 16px; color: #dbdee1; font: 15px/1.375 "gg sans", "Noto Sans", var(--font); }
.d-msg { display: flex; gap: 14px; }
.d-avatar { width: 40px; height: 40px; border-radius: 50%; background: #5865f2; flex: none; }
.d-body { min-width: 0; flex: 1; }
.d-head { display: flex; align-items: baseline; gap: 6px; }
.d-name { color: #f2f3f5; font-weight: 500; }
.d-badge { background: #5865f2; color: #fff; font-size: 10px; font-weight: 600; padding: 0 4px; border-radius: 3px; line-height: 15px; }
.d-time { color: #949ba4; font-size: 12px; }
.d-content { white-space: pre-wrap; word-wrap: break-word; }
.d-mention { background: rgba(88,101,242,.3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; }
.d-embed {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; max-width: 432px; margin-top: 4px;
  background: #2b2d31; border-left: 4px solid; border-radius: 4px; padding: 8px 16px 16px 12px; font-size: 14px;
}
.d-embed > * { grid-column: 1; }
.d-author { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; font-weight: 600; color: #f2f3f5; }
.d-author img { width: 24px; height: 24px; border-radius: 50%; }
.d-title { margin-top: 8px; font-size: 16px; font-weight: 600; color: #f2f3f5; }
.d-desc { margin-top: 8px; white-space: pre-wrap; word-wrap: break-word; }
.d-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.d-field { grid-column: 1 / -1; min-width: 0; }
.d-field.inline { grid-column: auto; }
.d-field-name { font-weight: 600; color: #f2f3f5; margin-bottom: 2px; }
.d-field-value { white-space: pre-wrap; word-wrap: break-word; }
.d-thumb { grid-column: 2; grid-row: 1 / 8; margin: 8px 0 0 16px; width: 80px; height: auto; max-height: 80px; object-fit: contain; border-radius: 4px; }
.d-image { grid-column: 1 / -1; margin-top: 16px; width: 100%; border-radius: 4px; }
.d-footer { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: #b5bac1; }
.d-footer img { width: 20px; height: 20px; border-radius: 50%; }
.discord a { color: #00a8fc; text-decoration: none; }
.discord a:hover { text-decoration: underline; }
.discord code { font-family: var(--mono); font-size: 85%; background: #1e1f22; padding: 0 3px; border-radius: 3px; }
.d-ts { background: rgba(255,255,255,.06); border-radius: 3px; padding: 0 2px; }

@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .preview-col { position: static; }
}
@media (max-width: 720px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .editor { padding: 16px 16px 0; }
  .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); }
  .field-row { grid-template-columns: 1fr 1fr; }
  .top { flex-wrap: wrap; }
  .bot { display: none; }
}
