:root {
  color-scheme: dark;
  --bg: #07090b;
  --bg-elevated: #0d1013;
  --panel: #111519;
  --panel-2: #161b20;
  --panel-3: #1c2228;
  --line: #2b3239;
  --line-soft: #20262b;
  --text: #f3f4f4;
  --muted: #929aa2;
  --muted-2: #69727a;
  --red: #b92837;
  --red-bright: #dd3548;
  --red-dark: #67151f;
  --amber: #d4a84e;
  --green: #45b883;
  --blue: #5c9bcf;
  --danger: #e1505e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 22px 70px rgba(0, 0, 0, .35);
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 0;
  background:
    radial-gradient(circle at 78% 0%, rgba(185, 40, 55, .09), transparent 28rem),
    linear-gradient(180deg, #080a0c, var(--bg));
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--red-bright);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; }
.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: rgba(8, 10, 12, .94);
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(16px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  width: fit-content;
  padding: 5px 10px 5px 5px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  position: relative;
  isolation: isolate;
  transition: border-color .18s ease, background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.brand::after {
  content: '';
  position: absolute;
  left: 60px;
  right: 10px;
  bottom: 2px;
  height: 1px;
  background: linear-gradient(90deg, rgba(201, 49, 66, .72), rgba(201, 49, 66, 0));
  opacity: .48;
  pointer-events: none;
}
.brand:hover {
  border-color: rgba(190, 46, 62, .24);
  background: linear-gradient(90deg, rgba(145, 25, 39, .10), rgba(255,255,255,.015));
  box-shadow: 0 0 28px rgba(166, 30, 45, .08);
  transform: translateY(-1px);
}
.brand-sigil {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  padding: 2px;
  border: 1px solid rgba(185, 40, 55, .72);
  border-radius: 11px;
  background:
    linear-gradient(#0c0f12, #0c0f12) padding-box,
    linear-gradient(135deg, #d24556, #4b171f 55%, #1b2025) border-box;
  color: #f5d8dc;
  font: 800 19px/1 var(--mono);
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 0 1px rgba(0,0,0,.65), 0 8px 24px rgba(0,0,0,.30), inset 0 0 18px rgba(185,40,55,.08);
}
.brand-sigil::before,
.brand-sigil::after {
  content: '';
  position: absolute;
  z-index: 2;
  width: 10px;
  height: 10px;
  pointer-events: none;
}
.brand-sigil::before { top: 3px; left: 3px; border-top: 1px solid rgba(255,123,137,.8); border-left: 1px solid rgba(255,123,137,.8); }
.brand-sigil::after { right: 3px; bottom: 3px; border-right: 1px solid rgba(185,40,55,.8); border-bottom: 1px solid rgba(185,40,55,.8); }
.brand-guild-icon {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 7px;
  filter: saturate(.92) contrast(1.04);
}
.brand-guild-icon[hidden] { display: none; }
.brand-sigil-fallback { display: grid; place-items: center; width: 100%; height: 100%; }
.brand-sigil-fallback[hidden] { display: none; }
.brand-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding-right: 4px;
}
.brand-title {
  color: #f5f6f7;
  font: 900 17px/1 var(--mono);
  letter-spacing: .16em;
  text-shadow: 0 0 18px rgba(255,255,255,.05);
  white-space: nowrap;
}
.brand-tagline {
  color: #9a8084;
  font: 700 9px/1.15 var(--mono);
  letter-spacing: .18em;
  white-space: nowrap;
  text-transform: uppercase;
}
.brand:hover .brand-title { color: #ffffff; }
.brand:hover .brand-tagline { color: #c0878f; }
.topbar-status { justify-self: center; display: flex; align-items: center; gap: 8px; color: var(--muted); font: 12px var(--mono); letter-spacing: .05em; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(212, 168, 78, .08); }
.app-shell[data-state="ready"] .status-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(69, 184, 131, .08); }
.operator { justify-self: end; display: flex; align-items: center; gap: 10px; min-width: 0; }
.operator-copy { display: grid; text-align: right; min-width: 0; }
.operator-copy strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.operator-copy small { color: var(--muted); font: 10px var(--mono); }
.operator-avatar, .server-icon { border-radius: 8px; object-fit: cover; background: var(--panel-3); }
.operator-avatar { width: 38px; height: 38px; border: 1px solid var(--line); }
.hazard-line { height: 4px; background: repeating-linear-gradient(135deg, #7d1b27 0 14px, #111 14px 28px); opacity: .75; }

.workspace { display: grid; grid-template-columns: 260px minmax(0, 1fr); max-width: 1720px; margin: 0 auto; }
.sidebar {
  min-width: 0;
  min-height: calc(100vh - 76px);
  border-right: 1px solid var(--line-soft);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: rgba(9, 11, 13, .5);
}
.server-card { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line-soft); background: rgba(255,255,255,.02); border-radius: var(--radius-sm); min-width: 0; }
.server-icon { width: 42px; height: 42px; flex: 0 0 auto; }
.server-copy { min-width: 0; display: grid; }
.server-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.server-copy small { color: var(--muted); font-size: 11px; }
.eyebrow { margin: 0 0 5px; color: #c7747e; font: 700 10px/1.3 var(--mono); letter-spacing: .12em; }
.nav-list { display: grid; gap: 6px; }
.nav-item {
  border: 1px solid transparent;
  background: transparent;
  min-height: 46px;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  color: var(--muted);
}
.nav-item:hover { background: rgba(255,255,255,.035); color: var(--text); }
.nav-item.is-active { background: linear-gradient(90deg, rgba(185, 40, 55, .17), rgba(185, 40, 55, .03)); border-color: rgba(185,40,55,.26); color: var(--text); }
.nav-code { color: #7e858d; font: 11px var(--mono); }
.nav-badge { justify-self: end; padding: 2px 6px; border-radius: 999px; background: #20262b; color: #afb6bc; font: 10px var(--mono); }
.nav-item.is-active .nav-badge { background: #571821; color: #efb8bf; }
.sidebar-meta { margin-top: auto; padding: 14px; border-left: 2px solid var(--red-dark); display: grid; gap: 4px; color: var(--muted); }
.sidebar-meta span { font: 9px var(--mono); letter-spacing: .14em; }
.sidebar-meta strong { color: #d6b0b5; font: 12px var(--mono); }
.sidebar-meta small { font-size: 11px; }

.main-content { min-width: 0; padding: 34px clamp(18px, 3vw, 44px) 70px; }
.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 42px); line-height: 1.08; letter-spacing: -.03em; }
h2 { margin-bottom: 4px; font-size: 20px; }
h3 { margin-bottom: 4px; font-size: 16px; }
.hero-description { max-width: 720px; margin: 0; color: var(--muted); }
.hero-actions, .maintenance-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.button, .icon-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.button { min-height: 42px; padding: 9px 14px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; text-decoration: none; font-weight: 700; font-size: 13px; }
.icon-button { width: 40px; height: 40px; border-radius: 7px; display: grid; place-items: center; font-size: 18px; }
.button:hover, .icon-button:hover { border-color: #4a535d; background: #1d2328; }
.button:active, .icon-button:active { transform: translateY(1px); }
.button-primary { background: linear-gradient(180deg, #b92d3c, #8f1e2b); border-color: #ce4150; color: white; }
.button-primary:hover { background: linear-gradient(180deg, #ce3546, #9e2230); border-color: #e55361; }
.button-secondary { background: #171c20; }
.button-ghost { background: transparent; }
.button-danger { background: #301216; border-color: #6c202a; color: #ffc7cd; }
.button-danger:hover { background: #45161d; border-color: #9b2b39; }
.button-large { min-height: 50px; width: 100%; font-size: 14px; }
.button[disabled], .icon-button[disabled] { opacity: .46; cursor: not-allowed; transform: none; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric-card { min-width: 0; border: 1px solid var(--line-soft); background: linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.012)); border-radius: var(--radius-sm); padding: 16px; display: grid; gap: 3px; }
.metric-card-accent { border-color: rgba(185,40,55,.32); background: linear-gradient(145deg, rgba(185,40,55,.12), rgba(255,255,255,.015)); }
.metric-label { color: var(--muted); font: 10px var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.metric-card strong { font: 800 26px/1.2 var(--mono); }
.metric-card small { color: var(--muted-2); }

.card { border: 1px solid var(--line-soft); background: rgba(14, 17, 20, .93); border-radius: var(--radius); box-shadow: 0 1px 0 rgba(255,255,255,.025) inset; }
.dashboard-grid { display: grid; grid-template-columns: minmax(290px, 390px) minmax(0, 1fr); gap: 18px; align-items: start; }
.panel-browser { min-width: 0; overflow: hidden; }
.section-heading { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 18px 14px; border-bottom: 1px solid var(--line-soft); }
.section-heading.compact { padding: 0 0 12px; border-bottom: 0; }
.section-heading h2, .section-heading h3 { margin: 0; }
.search-field { width: min(170px, 42%); }
.search-field input { width: 100%; }
.panel-list { display: grid; }
.panel-entry {
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: inherit;
  padding: 15px 18px;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  min-width: 0;
}
.panel-entry:last-child { border-bottom: 0; }
.panel-entry:hover { background: rgba(255,255,255,.025); }
.panel-entry.is-selected { background: linear-gradient(90deg, rgba(185,40,55,.15), rgba(185,40,55,.025)); box-shadow: inset 3px 0 var(--red); }
.panel-entry-main { min-width: 0; display: grid; gap: 3px; }
.panel-entry strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.panel-entry small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-entry-meta { display: grid; justify-items: end; gap: 5px; }
.mode-badge, .counter-pill, .health-badge { padding: 3px 7px; border-radius: 999px; border: 1px solid var(--line); background: #171c20; color: #adb5bc; font: 10px var(--mono); white-space: nowrap; }
.counter-pill { color: #d7b4b9; border-color: #54212a; background: #241115; }
.empty-state, .editor-empty { padding: 44px 24px; text-align: center; color: var(--muted); }
.empty-state h3, .editor-empty h2 { color: var(--text); }
.empty-symbol, .terminal-mark { margin: 0 auto 16px; width: 56px; height: 56px; display: grid; place-items: center; border: 1px solid #58202a; color: #d8848f; background: #180d10; border-radius: 50%; font: 700 24px var(--mono); }

.editor-column { min-width: 0; }
#panel-editor { overflow: hidden; }
.editor-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px; border-bottom: 1px solid var(--line-soft); }
.editor-header h2 { font-size: 23px; margin: 0; }
.editor-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px; color: var(--muted); font: 10px var(--mono); }
.editor-meta span { padding: 3px 6px; border: 1px solid var(--line-soft); border-radius: 4px; }
.form-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 20px; }
.field { min-width: 0; display: grid; gap: 7px; align-content: start; }
.field-span-2 { grid-column: 1 / -1; }
.field label { color: #d7dade; font-size: 12px; font-weight: 700; }
.field small { color: var(--muted-2); font-size: 11px; }
input, select, textarea {
  width: 100%; min-width: 0;
  border: 1px solid #303840;
  background: #090c0f;
  color: var(--text);
  border-radius: 7px;
  padding: 10px 11px;
  min-height: 42px;
}
textarea { min-height: 112px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #46515a; }
input:focus, select:focus, textarea:focus { border-color: #9e303d; }
.color-control { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 8px; }
input[type="color"] { padding: 5px; cursor: pointer; }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line-soft); padding-top: 15px; }
.save-state { color: var(--muted); font-size: 12px; }
.save-state.is-dirty { color: var(--amber); }
.save-state.is-saved { color: var(--green); }

.preview-block, .mapping-section, .maintenance-section { border-top: 1px solid var(--line-soft); padding: 20px; }
.discord-message-preview { max-width: 640px; }
.discord-preview { display: grid; grid-template-columns: 4px minmax(0, 1fr); width: 100%; background: #2b2d31; border-radius: 4px; overflow: hidden; }
.discord-accent { background: #991d29; }
.discord-embed { padding: 12px 14px; min-width: 0; }
.discord-embed > strong { display: block; font-size: 16px; margin-bottom: 7px; }
.discord-embed p { white-space: pre-wrap; overflow-wrap: anywhere; color: #dbdee1; margin-bottom: 12px; }
.preview-field { display: grid; gap: 4px; color: #dbdee1; font-size: 13px; margin-bottom: 12px; }
.preview-field b { font-size: 12px; }
.preview-field div { white-space: pre-wrap; overflow-wrap: anywhere; }
.discord-embed small { color: #b5bac1; font-size: 11px; }
.preview-reactions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 6px; }
.preview-reactions[hidden] { display: none; }
.preview-reaction { height: 30px; min-width: 44px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: #b5bac1; background: #2b2d31; border: 1px solid #3f4147; border-radius: 8px; font-size: 14px; line-height: 1; user-select: none; }
.preview-reaction:hover { background: #313338; border-color: #5d6068; }
.preview-reaction.is-missing { border-color: #8c3a43; background: rgba(153, 29, 41, .13); opacity: .82; }
.preview-reaction.is-draft { border-style: dashed; border-color: #7b8290; opacity: .78; }
.preview-reaction-image { width: 20px; height: 20px; object-fit: contain; }
.preview-reaction-unicode { font-size: 18px; line-height: 1; }
.preview-reaction-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.mapping-form { display: grid; grid-template-columns: minmax(150px, .75fr) minmax(190px, 1fr) auto; align-items: end; gap: 10px; }
.emoji-shortcuts { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: thin; }
.emoji-chip { flex: 0 0 auto; width: 38px; height: 38px; border: 1px solid var(--line); background: #0c0f12; border-radius: 7px; display: grid; place-items: center; cursor: pointer; }
.emoji-chip:hover { border-color: #7b2a35; background: #171013; }
.emoji-chip img { max-width: 24px; max-height: 24px; object-fit: contain; }
.mapping-list { display: grid; margin-top: 12px; border: 1px solid var(--line-soft); border-radius: 8px; overflow: hidden; }
.mapping-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 12px; border-bottom: 1px solid var(--line-soft); }
.mapping-row:last-child { border-bottom: 0; }
.mapping-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mapping-emoji { font-size: 21px; min-width: 30px; text-align: center; }
.mapping-role { min-width: 0; display: grid; gap: 2px; }
.mapping-role strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapping-role small { color: var(--muted); font: 10px var(--mono); }
.role-color-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: #99aab5; }
.remove-mapping { min-width: 38px; height: 38px; border-radius: 7px; border: 1px solid #51202a; background: #221014; color: #e8a6ae; cursor: pointer; }
.remove-mapping:hover { background: #35141a; border-color: #7d2935; }
.mapping-empty { padding: 18px; text-align: center; color: var(--muted); }
.maintenance-section { display: grid; gap: 14px; }
.health-result { border: 1px solid var(--line); background: #0b0e10; border-radius: 8px; padding: 13px; }
.health-result h4 { margin: 0 0 7px; }
.health-result ul { margin: 7px 0 0; padding-left: 20px; color: var(--muted); }

.health-overview { overflow: hidden; }
.health-intro { color: var(--muted); margin: 0; padding: 16px 18px 0; }
.health-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; padding: 18px; }
.health-card { border: 1px solid var(--line-soft); background: #0b0e11; border-radius: 9px; padding: 14px; min-width: 0; }
.health-card-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 10px; }
.health-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-badge.healthy { color: #9de0c1; border-color: #215f46; background: #10271e; }
.health-badge.warning { color: #efd799; border-color: #685422; background: #2c2411; }
.health-badge.critical { color: #f2a6af; border-color: #772933; background: #321318; }
.health-score { font: 700 26px var(--mono); }
.health-card p { color: var(--muted); margin: 5px 0 0; font-size: 12px; }

.dialog { width: min(720px, calc(100% - 24px)); max-height: calc(100% - 24px); border: 1px solid #333b42; border-radius: 12px; padding: 0; background: #0d1013; color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(4px); }
.dialog-small { max-width: 480px; }
.dialog-card { margin: 0; }
.dialog-header { padding: 18px 20px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.dialog-header h2 { margin: 0; }
.dialog-body { padding: 18px 20px; }
.dialog-actions { padding: 14px 20px 18px; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.confirm-message { padding: 18px 20px 0; color: var(--muted); }

.toast-region { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(380px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; border: 1px solid #394149; background: #13171b; border-radius: 9px; padding: 12px 14px; box-shadow: 0 16px 50px rgba(0,0,0,.38); display: grid; grid-template-columns: 4px minmax(0,1fr); gap: 10px; animation: toast-in .18s ease-out; }
.toast-bar { border-radius: 9px; background: var(--blue); }
.toast.success .toast-bar { background: var(--green); }
.toast.error .toast-bar { background: var(--danger); }
.toast strong { display: block; margin-bottom: 2px; }
.toast p { margin: 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 15%, rgba(160,29,43,.13), transparent 28rem), #06080a; }
.login-shell { width: min(560px, 100%); }
.login-card { position: relative; overflow: hidden; border: 1px solid #333a40; background: rgba(11,14,16,.96); border-radius: 14px; padding: clamp(22px, 5vw, 38px); box-shadow: var(--shadow); }
.login-card::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, transparent 0 28px, rgba(255,255,255,.012) 28px 29px); pointer-events: none; }
.classification-line { position: relative; z-index: 1; margin-bottom: 24px; color: #c76f7a; font: 10px var(--mono); letter-spacing: .13em; }
.login-mark { height: 150px; display: grid; place-items: center; overflow: hidden; margin: -12px 0 10px; }
.login-mark img { width: 170px; opacity: .28; filter: grayscale(1) contrast(1.25); }
.login-copy { position: relative; z-index: 1; text-align: center; }
.login-copy h1 { font-size: clamp(28px, 8vw, 40px); }
.login-copy p:not(.eyebrow) { color: var(--muted); }
.login-note { position: relative; z-index: 1; margin: 14px 0 0; text-align: center; color: var(--muted-2); font-size: 11px; }
.alert { margin-top: 14px; padding: 11px 12px; border-radius: 7px; font-size: 12px; }
.alert-danger { border: 1px solid #682630; background: #2e1217; color: #f0adb5; }


.emoji-input-control { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.button-emoji { min-width: 96px; white-space: nowrap; }
.mapping-submit-actions { display: flex; align-items: end; gap: 8px; }
.mapping-submit-actions .button { min-height: 42px; }
.mapping-edit-state { margin: 10px 0 0; padding: 10px 12px; border: 1px solid #5e4920; border-radius: 7px; background: #211b0d; color: #e5cf91; font-size: 12px; }
.mapping-row-actions { display: flex; gap: 7px; }
.edit-mapping, .remove-mapping { min-width: 38px; height: 38px; border-radius: 7px; cursor: pointer; }
.edit-mapping { border: 1px solid #31495e; background: #101b24; color: #9dc7e8; }
.edit-mapping:hover { background: #162839; border-color: #466d8c; }

.emoji-dialog { width: min(760px, calc(100% - 24px)); }
.emoji-tabs { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0; border-bottom: 1px solid var(--line-soft); background: #090c0f; }
.emoji-tab { min-height: 46px; border: 0; border-right: 1px solid var(--line-soft); background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.emoji-tab:last-child { border-right: 0; }
.emoji-tab.is-active { color: var(--text); background: linear-gradient(180deg, rgba(159,35,48,.18), rgba(159,35,48,.04)); box-shadow: inset 0 -2px #a82c3b; }
.emoji-pane { padding: 14px; min-height: min(520px, 60vh); }
emoji-picker { width: 100%; height: min(520px, 60vh); --background: #0b0e11; --border-color: #303840; --input-border-color: #303840; --input-font-color: #eceff1; --input-placeholder-color: #7d8790; --outline-color: #a52d3a; --indicator-color: #b33140; --category-emoji-padding: .55rem; }
.emoji-server-search { width: 100%; margin-bottom: 12px; }
.server-emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; max-height: min(460px, 55vh); overflow: auto; padding: 2px; }
.server-emoji-button { min-width: 0; min-height: 64px; padding: 7px 4px; display: grid; place-items: center; gap: 4px; border: 1px solid var(--line-soft); background: #0a0d10; color: var(--text); border-radius: 8px; cursor: pointer; }
.server-emoji-button:hover, .server-emoji-button:focus-visible { border-color: #8e2d39; background: #171013; }
.server-emoji-button img { width: 30px; height: 30px; object-fit: contain; }
.server-emoji-button span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font: 9px var(--mono); }
.emoji-dialog-footer { align-items: center; justify-content: space-between; border-top: 1px solid var(--line-soft); }
.emoji-dialog-footer .save-state { flex: 1 1 240px; }

@media (max-width: 1120px) {
  .dashboard-grid { grid-template-columns: minmax(260px, 330px) minmax(0, 1fr); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mapping-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mapping-form .button { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; padding: 10px 14px; }
  .topbar-status { display: none; }
  .operator-copy { display: none; }
  .workspace { display: block; }
  .sidebar { min-height: 0; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line-soft); display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; position: sticky; top: 67px; z-index: 30; background: rgba(8,10,12,.96); backdrop-filter: blur(14px); }
  .server-card, .sidebar-meta { display: none; }
  .nav-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
  .nav-item { min-height: 42px; grid-template-columns: 24px minmax(0,1fr) auto; background: #101417; border-color: var(--line-soft); }
  .main-content { padding: 24px 14px 60px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .panel-browser { max-height: none; }
  .panel-list { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; padding: 10px; }
  .panel-entry { border: 1px solid var(--line-soft); border-radius: 8px; padding: 12px; }
  .panel-entry:last-child { border-bottom: 1px solid var(--line-soft); }
  .panel-entry.is-selected { box-shadow: inset 3px 0 var(--red); }
  .editor-column { min-width: 0; }
}

@media (max-width: 620px) {
  .brand { gap: 10px; padding-right: 7px; }
  .brand-sigil { width: 42px; height: 42px; flex-basis: 42px; }
  .brand::after { left: 52px; }
  .brand-title { font-size: 14px; letter-spacing: .12em; }
  .brand-tagline { font-size: 7.5px; letter-spacing: .12em; }
  .operator-avatar { width: 34px; height: 34px; }
  .hero-row { align-items: stretch; flex-direction: column; gap: 16px; }
  .hero-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .metric-card { padding: 12px; }
  .metric-card strong { font-size: 22px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .panel-list { grid-template-columns: 1fr; }
  .editor-header { flex-direction: column; }
  .editor-header .button { width: 100%; }
  .form-layout { grid-template-columns: 1fr; padding: 16px; gap: 14px; }
  .field-span-2 { grid-column: auto; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions .button { width: 100%; }
  .mapping-form { grid-template-columns: 1fr; }
  .mapping-form .button { grid-column: auto; }
  .emoji-input-control { grid-template-columns: 1fr; }
  .mapping-submit-actions { display: grid; grid-template-columns: 1fr; }
  .server-emoji-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .emoji-dialog-footer { grid-template-columns: 1fr; }
  .maintenance-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .health-grid { grid-template-columns: 1fr; padding: 12px; }
  .dialog { width: calc(100% - 12px); max-height: calc(100% - 12px); }
  .dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 390px) {
  .topbar { gap: 7px; }
  .brand { gap: 8px; padding: 3px 4px 3px 3px; }
  .brand-sigil { width: 36px; height: 36px; flex-basis: 36px; border-radius: 9px; }
  .brand::after { left: 44px; right: 4px; }
  .brand-title { font-size: 12px; letter-spacing: .09em; }
  .brand-tagline { max-width: 140px; overflow: hidden; text-overflow: ellipsis; font-size: 6.5px; letter-spacing: .08em; }
  .icon-button { width: 36px; height: 36px; }
  .nav-code { display: none; }
  .nav-item { grid-template-columns: minmax(0,1fr) auto; }
  .metric-grid { grid-template-columns: 1fr; }
  .maintenance-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* =========================================================
   AZAQUOR WHITE / BLACK THEME
   ========================================================= */
.theme-toggle {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  font: 800 18px/1 var(--mono);
}
.theme-toggle::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid transparent;
  border-radius: 5px;
  pointer-events: none;
}
.theme-toggle:hover::after { border-color: rgba(185,40,55,.28); }
.theme-toggle [data-theme-icon] { transform: translateY(-1px); }
.login-theme-toggle { position: fixed; z-index: 20; top: 18px; right: 18px; }

html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f3;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel-2: #f1f1ef;
  --panel-3: #e8e9e7;
  --line: #c9ccca;
  --line-soft: #dfe1df;
  --text: #111315;
  --muted: #5f666c;
  --muted-2: #7b8287;
  --red: #a8192b;
  --red-bright: #c92338;
  --red-dark: #7f1421;
  --amber: #9a6b09;
  --green: #16784e;
  --blue: #286c9d;
  --danger: #b52235;
  --shadow: 0 22px 70px rgba(24, 28, 31, .13);
}

html[data-theme="light"] body {
  background:
    radial-gradient(circle at 78% 0%, rgba(168, 25, 43, .07), transparent 28rem),
    linear-gradient(180deg, #ffffff, var(--bg));
  color: var(--text);
}
html[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, .94);
  border-bottom-color: var(--line-soft);
  box-shadow: 0 8px 30px rgba(20,24,28,.045);
}
html[data-theme="light"] .brand:hover {
  background: linear-gradient(90deg, rgba(168,25,43,.065), rgba(0,0,0,.012));
  box-shadow: 0 0 28px rgba(166,30,45,.055);
}
html[data-theme="light"] .brand-sigil {
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(135deg, #c83447, #7c303a 55%, #d9dcda) border-box;
  color: #8e1827;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.08), inset 0 0 18px rgba(185,40,55,.04);
}
html[data-theme="light"] .brand-guild-icon { filter: saturate(.98) contrast(1.02); }
html[data-theme="light"] .brand-title { color: #111315; text-shadow: none; }
html[data-theme="light"] .brand-tagline { color: #7f4c53; }
html[data-theme="light"] .brand:hover .brand-title { color: #000; }
html[data-theme="light"] .brand:hover .brand-tagline { color: #9e2636; }
html[data-theme="light"] .hazard-line {
  background: repeating-linear-gradient(135deg, #9d1c2d 0 14px, #e2e2df 14px 28px);
  opacity: .82;
}
html[data-theme="light"] .sidebar { background: rgba(249,250,248,.78); }
html[data-theme="light"] .server-card,
html[data-theme="light"] .metric-card {
  background: rgba(255,255,255,.82);
}
html[data-theme="light"] .nav-item:hover { background: rgba(0,0,0,.035); }
html[data-theme="light"] .nav-item.is-active {
  background: linear-gradient(90deg, rgba(168,25,43,.11), rgba(168,25,43,.025));
}
html[data-theme="light"] .nav-badge { background: #e7e9e7; color: #4f565b; }
html[data-theme="light"] .nav-item.is-active .nav-badge { background: #f0d8dc; color: #851827; }
html[data-theme="light"] .sidebar-meta strong { color: #7d2531; }
html[data-theme="light"] .eyebrow { color: #9f2635; }

html[data-theme="light"] .button,
html[data-theme="light"] .icon-button { background: #f5f5f3; border-color: #c9ccca; color: #17191b; }
html[data-theme="light"] .button:hover,
html[data-theme="light"] .icon-button:hover { background: #e9eae8; border-color: #aeb3b0; }
html[data-theme="light"] .button-primary { background: linear-gradient(180deg, #b9273b, #941c2b); border-color: #c7374a; color: #fff; }
html[data-theme="light"] .button-primary:hover { background: linear-gradient(180deg, #ca3045, #a32132); border-color: #d74658; }
html[data-theme="light"] .button-secondary { background: #f1f2ef; }
html[data-theme="light"] .button-ghost { background: transparent; }
html[data-theme="light"] .button-danger { background: #fff0f1; border-color: #d9a0a7; color: #8f1c2b; }
html[data-theme="light"] .button-danger:hover { background: #f9dde1; border-color: #c87580; }

html[data-theme="light"] .metric-card {
  border-color: var(--line-soft);
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(245,246,244,.98));
}
html[data-theme="light"] .metric-card-accent {
  border-color: rgba(168,25,43,.24);
  background: linear-gradient(145deg, rgba(168,25,43,.075), rgba(255,255,255,.95));
}
html[data-theme="light"] .card {
  background: rgba(255,255,255,.96);
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 8px 28px rgba(20,24,28,.04);
}
html[data-theme="light"] .panel-entry:hover { background: rgba(0,0,0,.025); }
html[data-theme="light"] .panel-entry.is-selected {
  background: linear-gradient(90deg, rgba(168,25,43,.10), rgba(168,25,43,.018));
}
html[data-theme="light"] .mode-badge,
html[data-theme="light"] .health-badge { background: #f1f2f0; color: #535b60; }
html[data-theme="light"] .counter-pill { color: #8a2532; border-color: #ddbbc0; background: #fff1f3; }
html[data-theme="light"] .empty-symbol,
html[data-theme="light"] .terminal-mark { border-color: #d8a8ae; color: #9e2636; background: #fff0f2; }
html[data-theme="light"] .field label { color: #34383c; }
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {
  border-color: #c9cecb;
  background: #ffffff;
  color: #141719;
}
html[data-theme="light"] input:hover,
html[data-theme="light"] select:hover,
html[data-theme="light"] textarea:hover { border-color: #a8afab; }
html[data-theme="light"] input:focus,
html[data-theme="light"] select:focus,
html[data-theme="light"] textarea:focus { border-color: #a62435; }

html[data-theme="light"] .discord-preview { background: #f2f3f5; border: 1px solid #d6d8dc; }
html[data-theme="light"] .discord-embed { color: #313338; }
html[data-theme="light"] .discord-embed p,
html[data-theme="light"] .preview-field { color: #313338; }
html[data-theme="light"] .discord-embed small { color: #5f6269; }
html[data-theme="light"] .preview-reaction { color: #4e5058; background: #f2f3f5; border-color: #c4c7cc; }
html[data-theme="light"] .preview-reaction:hover { background: #e9eaec; border-color: #9fa3aa; }
html[data-theme="light"] .preview-reaction.is-missing { border-color: #c47781; background: #fff0f2; }
html[data-theme="light"] .preview-reaction.is-draft { border-color: #8b9097; }

html[data-theme="light"] .emoji-chip { border-color: #d3d6d3; background: #fff; }
html[data-theme="light"] .emoji-chip:hover { border-color: #c4868e; background: #fff5f6; }
html[data-theme="light"] .mapping-edit-state { border-color: #d8bd77; background: #fff8df; color: #70551e; }
html[data-theme="light"] .edit-mapping { border-color: #a9c3d5; background: #edf7fe; color: #28668f; }
html[data-theme="light"] .edit-mapping:hover { background: #deeffb; border-color: #83aac5; }
html[data-theme="light"] .remove-mapping { border-color: #dcb5bb; background: #fff0f2; color: #a12636; }
html[data-theme="light"] .remove-mapping:hover { background: #f9dfe3; border-color: #c88690; }
html[data-theme="light"] .health-result { border-color: var(--line); background: #fafaf8; }
html[data-theme="light"] .health-card { background: #fff; }

html[data-theme="light"] .dialog { border-color: #c9cecb; background: #ffffff; color: #141719; }
html[data-theme="light"] .dialog::backdrop { background: rgba(20,24,28,.36); }
html[data-theme="light"] .emoji-tabs { background: #f6f7f5; }
html[data-theme="light"] .emoji-tab.is-active { background: linear-gradient(180deg, rgba(168,25,43,.09), rgba(168,25,43,.018)); }
html[data-theme="light"] emoji-picker {
  --background: #ffffff;
  --border-color: #cbd0cd;
  --input-border-color: #cbd0cd;
  --input-font-color: #17191b;
  --input-placeholder-color: #737a7f;
  --outline-color: #a52d3a;
  --indicator-color: #a52d3a;
}
html[data-theme="light"] .server-emoji-button { border-color: #d9dcda; background: #fff; color: #17191b; }
html[data-theme="light"] .server-emoji-button:hover,
html[data-theme="light"] .server-emoji-button:focus-visible { border-color: #bf7b84; background: #fff4f5; }

html[data-theme="light"] .toast { border-color: #c9cecb; background: #ffffff; box-shadow: 0 16px 50px rgba(20,24,28,.14); }
html[data-theme="light"] .login-page {
  background:
    radial-gradient(circle at 50% 15%, rgba(160,29,43,.08), transparent 28rem),
    #f5f5f3;
}
html[data-theme="light"] .login-card {
  border-color: #c9cecb;
  background: rgba(255,255,255,.97);
}
html[data-theme="light"] .login-card::before {
  background: repeating-linear-gradient(135deg, transparent 0 28px, rgba(0,0,0,.018) 28px 29px);
}
html[data-theme="light"] .classification-line { color: #9d2836; }
html[data-theme="light"] .login-mark img { opacity: .18; filter: grayscale(1) contrast(1.12); }
html[data-theme="light"] .alert-danger { border-color: #d7a1a8; background: #fff0f2; color: #941f2f; }

@media (max-width: 860px) {
  html[data-theme="light"] .sidebar { background: rgba(255,255,255,.97); }
}
@media (max-width: 620px) {
  .theme-toggle { width: 36px; height: 36px; }
  .login-theme-toggle { top: 12px; right: 12px; }
}

/* EN / FR language control */
.language-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 38px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: color-mix(in srgb, var(--panel-2) 88%, transparent);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.015);
  font: 700 10px/1 var(--mono);
  letter-spacing: .08em;
  color: var(--muted);
  user-select: none;
}
.language-switch button {
  min-width: 28px;
  height: 26px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.language-switch button:hover { color: var(--text); transform: translateY(-1px); }
.language-switch button.is-active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(153,29,41,.2);
}
html[data-theme="light"] .language-switch button.is-active { color: #fff; }
.login-language-switch {
  position: fixed;
  z-index: 20;
  top: 18px;
  right: 66px;
}
@media (max-width: 620px) {
  .language-switch { height: 36px; padding: 0 5px; }
  .language-switch button { min-width: 25px; padding: 0 4px; }
  .login-language-switch { top: 12px; right: 58px; }
}
@media (max-width: 390px) {
  .operator .language-switch { height: 34px; }
  .operator .language-switch button { min-width: 23px; font-size: 9px; }
}
