@font-face { font-family: "UI"; src: url(/fonts/BeVietnamPro-Regular.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: "UI"; src: url(/fonts/BeVietnamPro-Bold.ttf); font-weight: 700; font-display: swap; }

:root {
  --bg: #0d1110;
  --surface: #151a18;
  --surface-2: #1c2320;
  --line: #2a332f;
  --line-strong: #3a4540;
  --text: #eef2ea;
  --muted: #9aa69f;
  --accent: #d7ff70;
  --accent-ink: #101510;
  --danger: #ff8a8a;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 "UI", system-ui, -apple-system, "Segoe UI", sans-serif;
}
[hidden] { display: none !important; }
h1 { font-size: clamp(24px, 4vw, 32px); line-height: 1.2; margin: 4px 0 8px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: .92em; }
a { color: var(--accent); }
.eyebrow { margin: 0; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.lead { color: var(--muted); max-width: 70ch; margin: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.hint[data-kind="error"] { color: var(--danger); }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 12px max(16px, calc((100vw - 1280px) / 2)); background: #0d1110e6;
  border-bottom: 1px solid var(--line); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; }
.brand-mark { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; }
.brand-sub { color: var(--muted); font-weight: 400; }
.guild-picker select { max-width: 220px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.account { display: flex; align-items: center; gap: 10px; }
.account-avatar { border-radius: 50%; }
.account-name { color: var(--muted); font-size: 14px; }

/* Layout */
.page { max-width: 1280px; margin: 0 auto; padding: 28px 16px 40px; }
.page.has-actionbar { padding-bottom: 110px; }
.page-head { margin-bottom: 20px; }
.center-card { max-width: 560px; margin: 10vh auto 0; padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.center-card p:not(.eyebrow) { color: var(--muted); }
.notice { margin: 0 0 20px; padding: 14px 16px; border-radius: 12px; background: #2b2412; border: 1px solid #5a4a1c; color: #f5e3b3; }
.notice strong { display: block; color: #ffe39a; }

.editor-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, 1fr); gap: 24px; align-items: start; }
.preview-col { position: sticky; top: 76px; display: grid; gap: 10px; }
.preview-frame { border-radius: 18px; padding: 12px; background: repeating-conic-gradient(#151a18 0 25%, #121614 0 50%) 0 0 / 22px 22px; border: 1px solid var(--line); }
#preview { display: block; width: 100%; height: auto; aspect-ratio: 960 / 360; }
.controls { display: grid; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; }
.panel > .hint { margin-top: -8px; }

/* Fields */
.field { display: grid; grid-template-columns: minmax(120px, 1fr) auto; align-items: center; gap: 12px; }
.field-label { display: grid; }
.field-label small { color: var(--muted); font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stack { display: grid; gap: 6px; justify-items: end; }
.color-input { display: flex; align-items: center; gap: 6px; }
.swatch { width: 38px; height: 34px; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; background: none; cursor: pointer; }
.swatch::-webkit-color-swatch-wrapper { padding: 3px; }
.swatch::-webkit-color-swatch { border: 0; border-radius: 5px; }
.hex, .text, select {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 7px 10px; min-height: 34px;
}
.hex { width: 92px; font-variant-numeric: tabular-nums; text-transform: uppercase; }
.text { width: 100%; }
.stack .text { width: 220px; }
input:focus-visible, select:focus-visible, button:focus-visible, .button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="range"] { width: 170px; accent-color: var(--accent); }
.value { width: 42px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.switch { appearance: none; width: 40px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); background: var(--accent-ink); }
.switch:disabled { opacity: .5; cursor: not-allowed; }

/* Buttons */
button, .button {
  font: inherit; font-weight: 700; font-size: 14px; border-radius: 10px; padding: 9px 16px; cursor: pointer;
  border: 1px solid transparent; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:hover:not(:disabled) { filter: brightness(1.06); }
.secondary { background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
.secondary:hover:not(:disabled) { border-color: var(--muted); }
.ghost { background: transparent; color: var(--muted); border-color: transparent; }
.ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.small { padding: 5px 10px; font-size: 13px; }
.icon-button { width: 34px; height: 34px; padding: 0; background: var(--surface-2); color: var(--muted); border-color: var(--line-strong); }
.icon-button:hover:not(:disabled) { color: var(--text); }

.segmented { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px; }
.segmented button { padding: 6px 12px; background: transparent; color: var(--muted); border-radius: 7px; font-size: 13px; }
.segmented button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }

.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.preset { justify-content: flex-start; background: var(--surface-2); color: var(--text); border-color: var(--line-strong); font-weight: 400; font-size: 13px; padding: 8px 10px; }
.preset:hover:not(:disabled) { border-color: var(--accent); }
.preset-swatch { width: 22px; height: 22px; border-radius: 6px; flex: none; }

.fonts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; grid-column: 1 / -1; }
.field:has(.fonts) { grid-template-columns: 1fr; }
.font { flex-direction: column; align-items: flex-start; gap: 2px; background: var(--surface-2); color: var(--text); border-color: var(--line-strong); padding: 10px 12px; font-weight: 400; }
.font[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.font-sample { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.font small { color: var(--muted); font-size: 12px; }

.dropzone { display: grid; gap: 6px; justify-items: start; padding: 16px; border: 1.5px dashed var(--line-strong); border-radius: 12px; background: var(--surface-2); }
.dropzone span { color: var(--muted); font-size: 13px; }
.dropzone .row { justify-content: flex-start; margin-top: 6px; }
.dropzone.over { border-color: var(--accent); background: #1f2a1a; }
.dropzone.disabled { opacity: .55; }

/* Action bar */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 12px max(16px, calc((100vw - 1280px) / 2)); background: #0d1110f0; border-top: 1px solid var(--line); backdrop-filter: blur(10px);
}
.dirty { margin-right: auto; color: var(--accent); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.dirty::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 30; max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: 12px; background: #233019; border: 1px solid #4d6a2a; color: #e8ffc0; box-shadow: 0 10px 30px #0008;
}
.toast[data-kind="error"] { background: #341b1b; border-color: #6e3434; color: #ffd0d0; }

/* Admin */
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 20px; align-items: start; }
.count { background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 9px; font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-strong); font-size: 14px; }
.chip-remove { width: 24px; height: 24px; padding: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 16px; }
.chip-remove:hover { background: var(--line-strong); color: var(--text); }
.roles { display: grid; gap: 2px; max-height: 60vh; overflow: auto; margin: 0 -6px; padding: 0 6px; }
.role { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 8px; cursor: pointer; }
.role:hover { background: var(--surface-2); }
.role input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.role-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #26331a; color: var(--accent); }
.badge.muted { background: var(--surface-2); color: var(--muted); }

@media (max-width: 900px) {
  .editor-grid, .admin-grid { grid-template-columns: 1fr; }
  .preview-col { top: 60px; z-index: 10; background: var(--bg); padding-bottom: 8px; }
  .preview-col .hint { display: none; }
  .preview-frame { padding: 6px; border-radius: 12px; }
  .brand-sub, .account-name { display: none; }
}
@media (max-width: 520px) {
  .field { grid-template-columns: 1fr; gap: 8px; }
  .row, .stack { justify-content: flex-start; justify-items: start; }
  .stack .text { width: 100%; }
  .actionbar { gap: 6px; }
  .actionbar button { padding: 9px 12px; }
  .dirty { display: none; }
  .topbar { gap: 10px; }
  .guild-picker select { max-width: 130px; }
}
