:root {
  --ink: 19 27 35;
  --muted: 103 116 126;
  --line: 210 219 222;
  --paper: 244 247 245;
  --surface: 252 253 251;
  --surface-2: 233 240 238;
  --accent: 74 94 82;
  --accent-deep: 43 64 52;
  --signal: 197 111 68;
  --success: 61 126 89;
  --danger: 176 73 65;
  --shadow: 0 18px 45px rgba(35, 53, 45, .10);
  --display: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
html { background: rgb(var(--paper)); scroll-behavior: smooth; }
body {
  margin: 0;
  color: rgb(var(--ink));
  background:
    radial-gradient(circle at 88% 2%, rgba(187, 202, 193, .34), transparent 30rem),
    rgb(var(--paper));
  font-family: var(--display);
  font-size: 14px;
  min-height: 100dvh;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; transform: none !important; }
.shell { width: min(1380px, calc(100% - 48px)); margin: 0 auto; }
.topbar {
  height: 82px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgb(var(--line) / .8); position: relative; z-index: 1;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-mark { width: 34px; height: 34px; border: 1px solid rgb(var(--ink)); display: grid; place-items: center; position: relative; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; background: rgb(var(--ink)); }
.brand-mark::before { width: 14px; height: 1px; transform: rotate(45deg); }
.brand-mark::after { width: 1px; height: 14px; transform: rotate(45deg); }
.brand-copy { font-weight: 800; letter-spacing: -.04em; }
.brand-copy small { display: block; color: rgb(var(--muted)); font: 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; margin-top: 2px; }
.status { color: rgb(var(--muted)); display: flex; align-items: center; gap: 9px; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: rgb(var(--success)); box-shadow: 0 0 0 4px rgb(var(--success) / .13); }
.status-dot.error { background: rgb(var(--danger)); box-shadow: 0 0 0 4px rgb(var(--danger) / .13); }
.main { padding: 38px 0 90px; }
.dashboard-nav {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px;
  margin-bottom: 42px; background: rgb(var(--line)); border: 1px solid rgb(var(--line));
}
.dashboard-tab {
  display: flex; flex-direction: column; align-items: flex-start; gap: 7px;
  min-height: 70px; padding: 15px 17px; border: 0; color: rgb(var(--muted));
  background: rgb(var(--surface) / .72); text-align: left;
  transition: color .18s, background .18s, box-shadow .18s;
}
.dashboard-tab:hover { color: rgb(var(--ink)); background: rgb(var(--surface)); }
.dashboard-tab.active {
  color: rgb(var(--paper)); background: rgb(var(--accent-deep));
  box-shadow: inset 0 -3px 0 rgb(var(--signal));
}
.dashboard-tab strong { font-size: 13px; }
.dashboard-tab small { color: inherit; opacity: .72; font: 10px var(--mono); letter-spacing: .04em; }
.dashboard-section[hidden] { display: none; }
.dashboard-section { min-width: 0; }
.dashboard-access {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 520px); gap: 28px;
  align-items: center; margin-bottom: 42px; padding: 20px 22px;
  border: 1px solid rgb(var(--accent) / .30); border-left: 4px solid rgb(var(--signal));
  background: linear-gradient(105deg, rgb(var(--surface) / .92), rgb(var(--surface-2) / .72));
  box-shadow: 0 10px 30px rgb(var(--accent-deep) / .06);
}
.access-copy { min-width: 0; }
.access-eyebrow { display: block; color: rgb(var(--signal)); font: 10px var(--mono); letter-spacing: .08em; margin-bottom: 8px; }
.access-copy h2 { margin: 0 0 7px; font-size: 16px; letter-spacing: -.025em; }
.access-copy p { max-width: 600px; margin: 0; color: rgb(var(--muted)); line-height: 1.5; font-size: 12px; }
.access-controls { min-width: 0; }
.access-controls > label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; }
.password-control { display: flex; gap: 8px; align-items: stretch; }
.password-control input { flex: 1 1 auto; min-width: 0; }
.password-control .button { flex: 0 0 68px; padding-left: 10px; padding-right: 10px; }
.dashboard-password-state { min-height: 17px; margin-top: 8px; color: rgb(var(--muted)); font: 10px var(--mono); }
.dashboard-password-state.ready { color: rgb(var(--success)); }
.dashboard-password-state.error { color: rgb(var(--danger)); }
.dashboard-access .feedback { display: block; min-height: 0; margin: 0; text-align: left; }
.discord-metadata-status {
  margin-top: 7px; color: rgb(var(--muted)); font: 10px var(--mono);
}
.discord-metadata-status.ready { color: rgb(var(--success)); }
.discord-metadata-status.error { color: rgb(var(--danger)); }
.role-metadata { min-height: 17px; color: rgb(var(--muted)); font-size: 11px; line-height: 1.4; }
.role-metadata.ready { color: rgb(var(--accent-deep)); }
.role-metadata.missing { color: rgb(var(--signal)); }
.role-chip {
  display: inline-flex; align-items: center; gap: 5px; margin: 0 5px 5px 0;
  padding: 4px 7px; border: 1px solid rgb(var(--line)); border-left: 3px solid var(--role-color, rgb(var(--line)));
  background: rgb(var(--surface-2) / .7); font-size: 11px;
}
.role-chip-id { color: rgb(var(--muted)); font: 9px var(--mono); }
.discord-emoji {
  width: 1.35em; height: 1.35em; display: inline-block; object-fit: contain; vertical-align: -.28em;
}
.discord-emoji-fallback { color: #c8d5ff; font-weight: 600; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 500px); gap: 54px; align-items: start; }
.template-manager { margin-bottom: 42px; }
.template-toolbar { display: flex; align-items: stretch; gap: 12px; }
.template-list {
  display: flex; gap: 10px; overflow-x: auto; flex: 1; min-width: 0;
  padding: 2px 2px 10px; scrollbar-color: rgb(var(--line)) transparent;
}
.template-chip {
  flex: 0 0 min(240px, 72vw); text-align: left; color: rgb(var(--ink));
  background: rgb(var(--surface) / .65); border: 1px solid rgb(var(--line));
  padding: 13px 14px; border-radius: 2px; transition: border-color .18s, background .18s, transform .18s;
}
.template-chip:hover { transform: translateY(-2px); border-color: rgb(var(--accent)); }
.template-chip.selected { border-color: rgb(var(--accent-deep)); background: rgb(var(--surface)); box-shadow: 0 0 0 2px rgb(var(--accent) / .12); }
.template-chip strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.template-chip small { display: block; margin-top: 7px; color: rgb(var(--muted)); font: 9px var(--mono); overflow: hidden; text-overflow: ellipsis; }
.button.compact { flex: 0 0 auto; align-self: flex-start; }
.editor { min-width: 0; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid rgb(var(--line)); padding-bottom: 13px; margin-bottom: 26px; }
.section-heading h2 { font-size: 14px; letter-spacing: -.02em; margin: 0; }
.section-heading span { color: rgb(var(--muted)); font: 11px var(--mono); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field.inline-toggle { padding: 10px 12px; border: 1px solid rgb(var(--line)); background: rgb(var(--surface-2) / .55); }
.field label { font-weight: 700; font-size: 12px; display: flex; justify-content: space-between; }
.field label span { color: rgb(var(--muted)); font-weight: 500; font: 10px var(--mono); }
.toggle { flex-direction: row; justify-content: flex-start !important; align-items: center; gap: 9px; color: rgb(var(--muted)); font-weight: 600 !important; }
.toggle input { width: 16px; height: 16px; accent-color: rgb(var(--accent-deep)); }
.toggle span { font: 600 11px var(--display) !important; color: inherit !important; }
input, textarea, select {
  width: 100%; color: rgb(var(--ink)); background: rgb(var(--surface) / .75);
  border: 1px solid rgb(var(--line)); border-radius: 2px; padding: 12px 13px;
  outline: none; transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input { height: 45px; }
textarea { resize: vertical; min-height: 100px; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: rgb(var(--accent)); box-shadow: 0 0 0 3px rgb(var(--accent) / .14); background: rgb(var(--surface)); }
.input-with-swatch { display: flex; gap: 8px; }
.input-with-swatch input { flex: 1; }
.swatch { width: 45px; height: 45px; border: 1px solid rgb(var(--line)); padding: 3px; background: rgb(var(--surface)); }
.swatch input { width: 100%; height: 100%; padding: 0; border: 0; cursor: pointer; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.preset { border: 1px solid rgb(var(--line)); background: transparent; padding: 8px 10px; color: rgb(var(--muted)); font: 10px var(--mono); transition: transform .18s, border-color .18s, color .18s, background .18s; }
.preset:hover { transform: translateY(-2px); border-color: rgb(var(--accent)); color: rgb(var(--accent-deep)); background: rgb(var(--accent) / .07); }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 36px; padding-top: 20px; border-top: 1px solid rgb(var(--line)); }
.button { border: 1px solid transparent; padding: 12px 18px; min-height: 44px; border-radius: 2px; font-weight: 800; transition: transform .18s, background .18s, color .18s, border-color .18s; }
.button:hover { transform: translateY(-2px); }
.button.primary { background: rgb(var(--accent-deep)); color: rgb(var(--paper)); }
.button.primary:hover { background: rgb(var(--accent)); }
.button.quiet { background: transparent; border-color: rgb(var(--line)); color: rgb(var(--muted)); }
.button.quiet:hover { border-color: rgb(var(--accent)); color: rgb(var(--ink)); }
.button.danger { background: transparent; border-color: rgb(var(--danger) / .55); color: rgb(var(--danger)); }
.button.danger:hover { background: rgb(var(--danger) / .08); border-color: rgb(var(--danger)); }
.feedback { min-height: 22px; margin-left: auto; font-size: 12px; color: rgb(var(--success)); opacity: 0; transition: opacity .2s; }
.feedback.visible { opacity: 1; }
.feedback.error { color: rgb(var(--danger)); }
.preview-wrap { position: sticky; top: 24px; }
.preview-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.preview-label strong { font-size: 12px; }
.preview-label span { color: rgb(var(--muted)); font: 10px var(--mono); }
.discord-window { background: #273039; padding: 11px; box-shadow: var(--shadow); border: 1px solid #39454d; }
.discord-bar { height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 10px; color: #dfe6e7; font-size: 11px; border-bottom: 1px solid #3a454c; }
.discord-bar::before { content: "#"; color: #9da9ad; font-size: 18px; }
.discord-body { min-height: 420px; padding: 36px 24px; background: #303a42; display: flex; align-items: center; justify-content: center; }
.discord-message { width: min(100%, 390px); }
.mention-line { color: #c8d5ff; font-weight: 600; margin: 0 0 8px 4px; font-size: 13px; }
.discord-panel { width: min(100%, 390px); background: #20272d; border-radius: 5px; padding: 20px 21px 17px; box-shadow: 0 10px 24px rgba(13, 18, 20, .25); color: #e8edef; }
.discord-author { display: flex; align-items: center; gap: 8px; color: #f2f5f4; font-size: 12px; font-weight: 700; margin-bottom: 10px; }
.discord-author img { width: 24px; height: 24px; object-fit: cover; border-radius: 50%; background: #39454c; }
.discord-panel-copy { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start; }
.discord-thumbnail { width: 78px; height: 78px; border-radius: 4px; object-fit: cover; background: #39454c; }
.discord-panel h3 { font-size: 16px; margin: 0 0 14px; letter-spacing: -.025em; color: #f2f5f4; }
.discord-panel p { white-space: pre-wrap; margin: 0; color: #c4ced1; line-height: 1.62; font-size: 13px; }
.discord-banner { width: 100%; max-height: 260px; display: block; margin-top: 17px; border-radius: 4px; object-fit: cover; background: #39454c; }
.discord-banner[hidden] { display: none; }
.discord-footer { border-top: 1px solid #39454c; margin-top: 17px; padding-top: 13px; color: #89979c; font: 10px var(--mono); }
.preview-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 1px; background: rgb(var(--line)); }
.meta-cell { background: rgb(var(--surface-2)); padding: 13px; }
.meta-cell small { color: rgb(var(--muted)); font: 10px var(--mono); display: block; margin-bottom: 6px; }
.meta-cell strong { font-size: 12px; overflow-wrap: anywhere; }
.loading { opacity: .5; pointer-events: none; }
.settings-section { margin-top: 0; padding-top: 0; }
.settings-subsection {
  margin-top: 44px; padding-top: 28px;
  border-top: 1px solid rgb(var(--line));
}
.settings-subsection .section-heading { margin-bottom: 18px; }
.settings-subsection h3 { margin: 0; font-size: 14px; letter-spacing: -.02em; }
.lifecycle-help { max-width: 760px; margin: -4px 0 24px; }
.lifecycle-preview-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 24px;
}
.lifecycle-preview {
  min-width: 0; padding: 16px; border: 1px solid rgb(var(--line));
  background: rgb(var(--surface-2) / .55);
}
.lifecycle-preview .preview-label { margin-bottom: 10px; }
.lifecycle-preview-card {
  padding: 15px; border: 1px solid rgba(255,255,255,.15);
  border-radius: 7px; background: #273139; color: #f1f4f5;
}
.lifecycle-preview-card > strong { display: block; margin-bottom: 12px; font-size: 15px; }
.lifecycle-preview-card > strong[hidden] { display: none; }
.lifecycle-preview p {
  min-height: 58px; margin: 0; padding: 12px; white-space: pre-wrap;
  background: rgba(255,255,255,.045); border: 0;
  line-height: 1.55;
}
.lifecycle-preview p.is-disabled { color: rgb(var(--muted)); opacity: .68; }
.lifecycle-preview-banner {
  display: block; width: 100%; max-height: 150px; object-fit: cover;
  margin-top: 12px; border-radius: 4px;
}
.lifecycle-preview-card small {
  display: block; margin-top: 12px; color: #aebbc0; font: 10px var(--mono);
}
.lifecycle-preview-card small[hidden] { display: none; }
.ticket-section { margin-bottom: 76px; }
.ticket-list-wrap { margin-top: 34px; }
.ticket-list { display: grid; gap: 10px; }
.ticket-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.ticket-filters input, .ticket-filters select { min-height: 36px; padding: 7px 9px; border: 1px solid rgb(var(--line)); background: #fff; }
.ticket-card {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 16px; border: 1px solid rgb(var(--line)); border-radius: 10px;
  background: rgba(255,255,255,.52);
}
.ticket-card strong { min-width: 180px; }
.ticket-card small { color: rgb(var(--muted)); flex: 1 1 260px; }
.ticket-card-actions { display: flex; gap: 8px; }
.empty-state { color: rgb(var(--muted)); margin: 0; }
.ticket-preview { margin-top: 22px; max-width: 680px; }
.ticket-preview-card {
  border: 1px solid rgb(var(--line)); border-radius: 12px; padding: 20px;
  background: #20242a; color: #f4f7f5;
}
.ticket-preview-heading { display: flex; gap: 12px; align-items: flex-start; }
.ticket-preview-heading > img {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%;
  object-fit: cover; background: #39454c;
}
.ticket-preview-card h3 { margin: 0 0 8px; font-size: 20px; }
.ticket-preview-card p { white-space: pre-wrap; color: #d7dde0; }
.ticket-preview-request {
  display: grid; gap: 5px; margin: 16px 0; padding: 11px 12px;
  border: 1px solid rgba(255,255,255,.18); border-radius: 6px;
  background: rgba(255,255,255,.05);
}
.ticket-preview-request span { color: #9eabb0; font-size: 12px; }
.ticket-preview-thumbnail, .ticket-preview-banner {
  width: 100%; display: block; object-fit: cover; background: #39454c;
}
.ticket-preview-thumbnail {
  width: 96px; height: 96px; margin: 16px 0 2px auto; border-radius: 6px;
}
.ticket-preview-banner { max-height: 260px; margin-top: 16px; border-radius: 6px; }
.ticket-preview-card img[hidden] { display: none; }
.ticket-preview-card small { color: #aebbc0; }
.ticket-open-preview { margin-top: 24px; }
.ticket-open-message {
  white-space: pre-wrap; padding: 14px 16px; border: 1px solid rgb(var(--line));
  border-radius: 8px; background: rgb(var(--surface)); line-height: 1.55;
}
.ticket-staff-ping { display: block; margin-top: 8px; color: rgb(var(--muted)); font: 10px var(--mono); }
.ticket-preview-type {
  display: flex; gap: 12px; align-items: center; padding: 10px 0;
  border-top: 1px solid rgba(255,255,255,.14);
}
.ticket-preview-type span { color: #b8c2c6; }
@media (max-width: 820px) {
  .lifecycle-preview-grid { grid-template-columns: 1fr; }
}
.ticket-preview-button {
  border: 0; border-radius: 4px; padding: 8px 13px; color: #fff;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.ticket-preview-button-primary { background: #5865f2; }
.ticket-preview-button-secondary { background: #4f545c; }
.ticket-preview-button-success { background: #248046; }
.ticket-preview-button-danger { background: #da373c; }
.ticket-preview-button:disabled { opacity: 1; cursor: default; }
.ticket-type-help { max-width: 780px; }
.field-help { color: rgb(var(--muted)); font-size: 12px; line-height: 1.5; margin: 7px 0 0; }
.field-help code { font-family: var(--mono); color: rgb(var(--ink)); }
.error-text { color: #c75b4a !important; }
.template-actions { flex-wrap: wrap; }
.template-actions .feedback { flex: 1 1 180px; text-align: right; }
@media (max-width: 800px) {
  .shell { width: min(100% - 30px, 680px); }
  .topbar { height: 70px; }
  .main { padding: 30px 0 60px; }
  .dashboard-nav { margin-bottom: 32px; }
  .dashboard-access { grid-template-columns: 1fr; gap: 18px; margin-bottom: 32px; }
  .workspace { grid-template-columns: 1fr; gap: 50px; }
  .preview-wrap { position: static; }
  .template-toolbar { align-items: stretch; }
}
@media (max-width: 520px) {
  .shell { width: calc(100% - 24px); }
  .status { font-size: 0; gap: 7px; }
  .fields { grid-template-columns: 1fr; gap: 18px; }
  .dashboard-nav { grid-template-columns: 1fr; }
  .dashboard-tab { min-height: 58px; }
  .field.full { grid-column: auto; }
  .discord-body { min-height: 370px; padding: 25px 13px; }
  .ticket-preview-type { align-items: flex-start; flex-direction: column; gap: 5px; }
  .actions { flex-wrap: wrap; }
  .feedback { order: 3; flex-basis: 100%; margin-left: 0; }
  .template-toolbar { flex-direction: column; }
  .template-toolbar .button { width: 100%; }
  .template-actions .button { flex: 1 1 calc(50% - 10px); }
}