:root {
  --bg: #100c0b;
  --bg-2: #1a1412;
  --bg-3: #241c19;
  --line: rgba(255, 236, 224, 0.12);
  --text: #f6efe8;
  --muted: #b3a59c;
  --red: #c8102e;
  --red-2: #ff5a6a;
  --ok: #8fdfb0;
  --warn: #f0c36a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --sans: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ui: "Avenir Next", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(200, 16, 46, 0.18), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: #ffb4be; }
h1, h2, h3, h4, h5 { font-family: var(--sans); font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 2.4rem; line-height: 1; }
h2 { font-size: 1.25rem; }
p { margin: 0; }

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(16, 12, 11, 0.92);
  backdrop-filter: blur(10px);
  z-index: 5;
}
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; }
.brand strong { display: block; font-family: var(--sans); font-size: 1.25rem; }
.brand small { display: block; color: var(--muted); letter-spacing: 0.14em; font-size: 0.68rem; }
.mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--red); color: white; font-family: var(--sans); font-size: 1.3rem;
}
.you { margin-left: auto; color: var(--muted); font-size: 0.92rem; }
.icon-btn, .ghost, .secondary, .primary, .danger {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  min-height: 44px;
  padding: 0 16px;
}
.primary { background: var(--red); border-color: transparent; color: white; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.secondary { background: var(--bg-3); }
.danger { background: transparent; border-color: var(--red-2); color: var(--red-2); }
.ghost { border-style: dashed; }
.icon-btn { padding: 0 12px; }
.frame { display: block; }
.nav {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.nav.open { display: flex; }
.nav a, .nav button {
  text-align: left;
  text-decoration: none;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 12px;
  min-height: 44px;
  padding: 10px 12px;
}
.nav a[aria-current="page"] { background: rgba(200, 16, 46, 0.18); }
.logout { margin: 0; }
.nav-role { color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem; margin: 8px 12px; }
main { padding: 16px 16px 120px; max-width: 860px; }
.solo { max-width: 560px; margin: 0 auto; padding: 48px 20px 64px; }
.gate h1 { margin: 8px 0 12px; }
.eyebrow { letter-spacing: 0.16em; text-transform: uppercase; color: var(--red-2); font-size: 0.75rem; }
.lede { color: var(--muted); font-size: 1.05rem; margin-bottom: 22px; }
.signed-in { margin: 8px 0 16px; }
.hint { color: var(--muted); font-size: 0.92rem; }
#ping-lock { display: block; margin: 10px 0 4px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack button, .gate .primary, .gate .secondary { width: 100%; }
.banner {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.banner-hot { border-color: rgba(255, 90, 106, 0.5); color: #ffd0d4; }
.banner-ok { border-color: rgba(143, 223, 176, 0.4); }
.page-head { margin-bottom: 18px; }
.page-head p, .page-head h1 { margin-bottom: 8px; }
.page-head p { color: var(--muted); }
.empty { color: var(--muted); padding: 24px 0; }

.composer { display: block; }
.view-switch { display: flex; gap: 8px; margin-bottom: 12px; }
.view-switch button[aria-selected="true"] { background: var(--red); border-color: transparent; color: white; }
.view-switch button[aria-selected="false"] { background: transparent; color: var(--text); }
.composer.mode-preview .editor { display: none; }
.composer.mode-edit .preview-wrap { display: none; }
.field, .split, .block { margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span, legend, .preview-label, .block-head h2 { color: var(--muted); font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; }
input, select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
}
textarea { min-height: 110px; resize: vertical; }
.split { display: flex; gap: 8px; align-items: end; }
.split .grow { flex: 1; }
input[type="color"] { padding: 6px; height: 48px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; min-height: 44px; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--red); }
.check input:disabled { opacity: 0.35; }
.check:has(input:disabled) span { color: var(--muted); }
.block, fieldset.block {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
}
.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.file span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  border-radius: 999px; border: 1px dashed var(--line);
}
.file input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.section-card, .mini {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions button { min-height: 36px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; }
.roles { display: flex; flex-direction: column; }

.preview-wrap { margin-top: 8px; }
.discord {
  background: #313338;
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  color: #dbdee1;
  font-family: "Segoe UI", sans-serif;
}
.d-msg { display: flex; gap: 12px; }
.d-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: #c8102e; color: white; display: grid; place-items: center; flex: none; font-weight: 700;
}
.d-col { min-width: 0; flex: 1; }
.d-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.d-name { color: white; font-weight: 600; }
.d-app { background: #5865f2; color: white; border-radius: 4px; font-size: 0.65rem; padding: 1px 4px; letter-spacing: 0.04em; }
.d-card {
  background: #2b2d31;
  border-radius: 8px;
  border-left: 4px solid var(--accent, #cc0000);
  padding: 12px 14px;
}
.d-text h3 { font-family: "Segoe UI", sans-serif; font-size: 1.15rem; color: white; margin-bottom: 6px; }
.d-text h4, .d-text h5 { font-family: "Segoe UI", sans-serif; color: white; margin: 8px 0 4px; }
.d-text p { margin: 0 0 4px; }
.d-sub { color: #949ba4; font-size: 0.82rem; }
.d-section { display: flex; gap: 12px; align-items: flex-start; }
.d-section .d-text { flex: 1; }
.d-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; background: #1e1f22; flex: none; }
.d-sep { border: 0; border-top: 1px solid #3f4147; margin: 10px 0; }
.d-gallery { display: grid; gap: 8px; margin-top: 8px; }
.d-photo, .d-pending { width: 100%; max-height: 220px; object-fit: cover; border-radius: 8px; background: #1e1f22; }
.d-pending { min-height: 80px; display: grid; place-items: center; color: #949ba4; }
.d-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.d-btn {
  background: #4e5058; color: white; text-decoration: none;
  border-radius: 4px; padding: 8px 12px; font-size: 0.92rem;
}
.mention { background: rgba(88, 101, 242, 0.3); color: #c9cdfb; border-radius: 4px; padding: 0 2px; }
.mention-broadcast { background: rgba(200, 16, 46, 0.25); color: #ffd0d4; }
.d-follow { margin-top: 10px; }
.d-code, code { font-family: var(--mono); background: #1e1f22; padding: 0 4px; border-radius: 4px; }
.d-li { padding-left: 8px; }
blockquote { margin: 4px 0; border-left: 3px solid #4e5058; padding-left: 8px; color: #b5bac1; }
#payload { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(16, 12, 11, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.action-end { display: flex; gap: 8px; align-items: center; }
.usage { color: var(--muted); font-size: 0.8rem; }
.credit { margin: 0; max-width: 220px; }
.credit small { display: block; color: var(--muted); font-size: 0.75rem; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  box-shadow: var(--shadow);
}
.toast.bad { border-color: var(--red-2); }
.cards, .audit { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.cards li, .audit li, .settings section, .danger-zone {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}
.cards li { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.card-actions { display: flex; gap: 8px; align-items: center; }
.card-actions form { margin: 0; }
.audit-top { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 0.85rem; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; color: var(--text); }
.audit-summary { margin: 6px 0; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 0.78rem; color: var(--muted); }
.settings { display: flex; flex-direction: column; gap: 12px; }
.checks { display: flex; flex-direction: column; }
.danger-zone { margin-top: 18px; }
.danger-zone h2 { margin-bottom: 8px; }
.logo-preview { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; margin-bottom: 8px; }
.warn-list { color: var(--warn); padding-left: 18px; }
.result { margin: 0 0 12px; }
.result a { overflow-wrap: anywhere; }

@media (min-width: 1040px) {
  .icon-btn { display: none; }
  .frame { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 62px); }
  .nav { display: flex; border-bottom: 0; border-right: 1px solid var(--line); position: sticky; top: 62px; height: calc(100vh - 62px); }
  main { max-width: none; padding: 28px 32px 80px; }
  .view-switch { display: none; }
  .composer.mode-preview .editor, .composer.mode-edit .preview-wrap { display: block; }
  .composer { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 24px; align-items: start; }
  .preview-wrap { position: sticky; top: 84px; }
  .actionbar { left: 220px; }
  .credit { max-width: none; }
}
:focus-visible { outline: 2px solid var(--red-2); outline-offset: 2px; }
