:root {
  --bg: #0b0f16;
  --surface: rgba(21, 27, 38, 0.92);
  --surface-strong: #171e2a;
  --surface-soft: #202836;
  --line: rgba(214, 190, 137, 0.16);
  --line-strong: rgba(214, 190, 137, 0.34);
  --text: #f2eee6;
  --muted: #989fab;
  --gold: #b6924b;
  --gold-light: #d6be89;
  --danger: #dc5c5c;
  --success: #55b780;
  --discord: #5865f2;
  --radius: 18px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(rgba(11, 15, 22, 0.93), rgba(11, 15, 22, 0.98)),
    repeating-linear-gradient(90deg, transparent 0, transparent 79px, rgba(255, 255, 255, 0.02) 80px),
    repeating-linear-gradient(0deg, transparent 0, transparent 79px, rgba(255, 255, 255, 0.02) 80px);
}

.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; }

.public-view {
  position: relative;
  display: grid;
  min-height: 100svh;
  place-items: center;
  isolation: isolate;
  padding: 40px 20px 64px;
  overflow: hidden;
  background: #090d13;
}
.public-backdrop {
  position: absolute;
  z-index: 0;
  inset: 0;
  background-image: url('/assets/media/courthouse-background.png');
  background-position: center center;
  background-size: cover;
}
.public-view::after {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: linear-gradient(90deg, rgba(5, 8, 12, .1), transparent 24%, transparent 76%, rgba(5, 8, 12, .1));
  content: '';
}
.intake-card {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  border: 1px solid rgba(204, 166, 101, .68);
  background: rgba(9, 14, 20, .88);
  box-shadow: 0 35px 100px rgba(0, 0, 0, .68), inset 0 0 0 7px rgba(10, 15, 22, .95), inset 0 0 0 8px rgba(190, 150, 83, .24);
  backdrop-filter: blur(8px);
}
.intake-card-inner { padding: clamp(36px, 6vw, 67px) clamp(26px, 6vw, 72px) 42px; text-align: center; }
.intake-seal { display: block; width: 92px; height: 92px; margin: 0 auto 23px; object-fit: contain; filter: drop-shadow(0 6px 16px rgba(214, 166, 84, .16)); }
.intake-kicker, .dialog-kicker { margin: 0; color: #d2ae76; font-size: 10px; font-weight: 800; letter-spacing: .25em; text-transform: uppercase; }
.intake-kicker span { padding: 0 8px; color: #8d7c63; }
.intake-card h1 { margin: 31px 0 16px; color: #f3ede1; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(35px, 4.7vw, 54px); font-weight: 400; line-height: 1.12; letter-spacing: -.035em; }
.intake-intro { max-width: 565px; margin: 0 auto 32px; color: #b0ada8; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(16px, 1.6vw, 19px); line-height: 1.55; }
.intake-form { display: grid; gap: 16px; }
.intake-form input { height: 60px; border: 1px solid #7b6549; border-radius: 2px; padding: 0 20px; background: rgba(7, 11, 16, .82); color: #f2eee5; font-family: Georgia, 'Times New Roman', serif; font-size: 17px; }
.intake-form input::placeholder { color: #858077; }
.intake-form input:focus { border-color: #d1aa6a; box-shadow: 0 0 0 3px rgba(195, 154, 87, .14); }
.intake-form button, .auth-action { display: inline-flex; align-items: center; justify-content: center; gap: 16px; min-height: 58px; border: 1px solid #c69c5c; border-radius: 2px; background: #573034; color: #f5e5c6; cursor: pointer; font-size: 12px; font-weight: 800; letter-spacing: .18em; text-decoration: none; text-transform: uppercase; transition: background 150ms ease, transform 150ms ease; }
.intake-form button:hover, .auth-action:hover { background: #713b3d; transform: translateY(-1px); }
.intake-form button:disabled { opacity: .58; cursor: wait; transform: none; }
.intake-form button span { font-size: 18px; font-weight: 400; }
.intake-privacy { margin: 28px 0 0; color: #898780; font-family: Georgia, 'Times New Roman', serif; font-size: 13px; }
.intake-success { display: flex; align-items: center; gap: 14px; margin-top: 20px; border: 1px solid rgba(89, 160, 123, .44); padding: 15px 17px; color: #d4e8d9; background: rgba(22, 60, 42, .35); text-align: left; }
.intake-success p { margin: 0; font-size: 13px; line-height: 1.55; }
.success-emblem { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; border: 1px solid #67b78b; border-radius: 50%; color: #8bd5a8; }
.public-edge-label { position: absolute; z-index: 1; right: 28px; bottom: 22px; color: rgba(217, 183, 125, .45); font-size: 9px; letter-spacing: .22em; text-transform: uppercase; }

.auth-dialog { width: min(390px, calc(100% - 32px)); border: 1px solid #9e7b48; border-radius: 12px; padding: 30px; color: #f2eee6; background: #151c26; box-shadow: 0 30px 100px rgba(0, 0, 0, .7); text-align: center; }
.auth-dialog::backdrop { background: rgba(3, 6, 10, .72); backdrop-filter: blur(5px); }
.auth-dialog img { width: 48px; height: 48px; object-fit: contain; margin: 0 auto 14px; }
.auth-dialog h2 { margin: 11px 0 10px; font-family: Georgia, 'Times New Roman', serif; font-size: 27px; font-weight: 400; }
.auth-dialog p:not(.dialog-kicker) { margin: 0 0 22px; color: #aeb5c0; font-size: 13px; line-height: 1.55; }
.auth-dialog .auth-action { width: 100%; min-height: 46px; font-size: 10px; }
.auth-close { position: absolute; top: 8px; right: 10px; border: 0; padding: 0 8px; color: #b1a99b; background: transparent; cursor: pointer; font-size: 25px; }

.admin-shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; }
.admin-topbar { display: flex; min-height: 88px; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.admin-brand { display: flex; align-items: center; gap: 11px; }
.admin-brand img { object-fit: contain; }
.admin-brand strong { display: block; font-family: Georgia, serif; font-size: 18px; letter-spacing: .12em; }
.admin-brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.page-heading > div:first-child > p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.records-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 22px; }
.intake-panel { padding: 28px; }
.intake-list { display: grid; gap: 10px; }
.intake-record { padding: 14px 16px; border: 1px solid rgba(255,255,255,.07); border-radius: 10px; background: rgba(9,13,19,.42); }
.intake-record p { margin: 0; color: #e0e2e6; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.intake-record small { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.14;
  pointer-events: none;
}
.ambient-one { top: -14rem; right: -8rem; background: var(--gold); }
.ambient-two { bottom: -18rem; left: -14rem; background: #315e9c; }

.shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; }

.topbar {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold-light);
  font-family: Georgia, serif;
  font-size: 24px;
  box-shadow: inset 0 0 0 4px var(--bg), inset 0 0 0 5px var(--line-strong);
}
.brand strong { display: block; font-family: Georgia, serif; font-size: 19px; letter-spacing: 0.17em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }

.user-bar { display: flex; align-items: center; gap: 10px; color: #d9dce2; font-size: 14px; }
.avatar { width: 32px; height: 32px; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface-soft); }

.is-hidden { display: none !important; }

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: 0.55; transform: none; }
.button-primary { border-color: #d0ac64; color: #16130d; background: linear-gradient(135deg, #d6be89, #a77e35); box-shadow: 0 12px 28px rgba(182, 146, 75, 0.18); }
.button-quiet { min-height: 34px; padding: 0 12px; border-color: var(--line); color: var(--muted); background: transparent; font-size: 13px; }

.login-view { display: grid; min-height: calc(100vh - 89px); place-items: center; padding: 48px 0 100px; }
.login-card {
  width: min(600px, 100%);
  padding: 56px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(28, 35, 48, 0.96), rgba(17, 22, 31, 0.96));
  box-shadow: var(--shadow);
  text-align: center;
}
.eyebrow { color: var(--gold-light); font-size: 11px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.login-card h1, .page-heading h1 { margin: 15px 0 14px; font-family: Georgia, serif; font-weight: 500; }
.login-card h1 { font-size: clamp(35px, 6vw, 52px); }
.login-card p { max-width: 470px; margin: 0 auto; color: var(--muted); line-height: 1.7; }
.login-button { width: min(320px, 100%); margin: 34px auto 18px; }
.login-card > small { display: block; color: #717987; }
.discord-symbol { font-size: 20px; }

.app-view { min-height: 100vh; padding: 0 0 80px; background: linear-gradient(rgba(11, 15, 22, .92), rgba(11, 15, 22, .96)), url('/assets/media/courthouse-background.png') center top / cover fixed; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.page-heading h1 { margin-bottom: 0; font-size: clamp(30px, 4vw, 46px); }
.status-chip { display: flex; align-items: center; gap: 9px; padding: 9px 13px; border: 1px solid rgba(85, 183, 128, 0.24); border-radius: 999px; color: #a7d9ba; background: rgba(85, 183, 128, 0.06); font-size: 12px; }
.status-chip span { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 10px var(--success); }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(390px, 0.85fr); gap: 22px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.editor-panel, .preview-panel, .history-panel { padding: 28px; }
.preview-panel { position: sticky; top: 22px; }
.panel-heading { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 26px; }
.section-number { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--gold-light); font-family: Georgia, serif; font-size: 13px; }
.panel-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 20px; font-weight: 500; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.field { display: grid; gap: 8px; margin-top: 20px; }
.field > span:first-child { color: #d7d9df; font-size: 13px; font-weight: 700; }
.field b { color: var(--gold-light); }
.field small { justify-self: end; color: #737b88; font-size: 11px; }
.field .template-description {
  position: relative;
  justify-self: stretch;
  min-height: 34px;
  padding: 9px 12px 9px 29px;
  border: 1px solid color-mix(in srgb, var(--template-color, var(--gold)) 38%, transparent);
  border-radius: 9px;
  color: #9da5b2;
  background: color-mix(in srgb, var(--template-color, var(--gold)) 7%, transparent);
  line-height: 1.45;
}
.template-description::before {
  position: absolute;
  top: 14px;
  left: 13px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--template-color, var(--gold));
  box-shadow: 0 0 10px var(--template-color, var(--gold));
  content: "";
}
.field-row { display: grid; grid-template-columns: minmax(210px, 0.65fr) 1fr; gap: 15px; }
input, select, textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: #111721;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input, select { height: 44px; padding: 0 13px; }
textarea { min-height: 210px; padding: 13px; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(182, 146, 75, 0.12); }
input::placeholder, textarea::placeholder { color: #5f6774; }
select { cursor: pointer; }
.color-control { display: grid; grid-template-columns: 46px 1fr; gap: 8px; }
.color-control input[type="color"] { padding: 5px; cursor: pointer; }

.discord-preview { display: flex; gap: 14px; min-height: 265px; padding: 22px; border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 13px; background: #313338; }
.bot-avatar { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #17130b; background: linear-gradient(145deg, #dcc894, #9c7431); font-family: Georgia, serif; font-size: 22px; }
.message-content { min-width: 0; flex: 1; }
.message-author { color: #f2f3f5; font-size: 14px; font-weight: 700; }
.message-author span { margin-left: 4px; padding: 1px 4px; border-radius: 3px; color: white; background: #5865f2; font-size: 9px; vertical-align: 1px; }
.message-author time { margin-left: 6px; color: #949ba4; font-size: 11px; font-weight: 400; }
.embed-preview { margin-top: 6px; padding: 12px 14px; border-left: 4px solid var(--gold); border-radius: 4px; overflow: hidden; background: #2b2d31; }
.preview-document-type { margin-bottom: 6px; font-size: 9px; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
.embed-preview h3 { margin: 0 0 9px; overflow-wrap: anywhere; color: #f2f3f5; font-size: 15px; }
.preview-body { color: #dbdee1; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.preview-body strong { color: #fff; }
.preview-body em { color: #e8e9eb; }
.preview-body blockquote { margin: 5px 0; padding-left: 9px; border-left: 3px solid #4e5058; color: #b5bac1; }
.preview-body code { padding: 1px 4px; border-radius: 3px; color: #f2f3f5; background: #1e1f22; font-family: "Cascadia Mono", Consolas, monospace; }
.preview-image { display: block; width: 100%; max-height: 300px; margin-top: 12px; border-radius: 4px; object-fit: cover; }
.embed-preview footer { margin-top: 11px; color: #b5bac1; font-size: 10px; }
.publication-notice { margin: 18px 0; padding: 14px 15px; border: 1px solid var(--line); border-radius: 11px; background: rgba(182, 146, 75, 0.05); }
.publication-notice strong { color: var(--gold-light); font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; }
.publication-notice p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.publish-button { width: 100%; min-height: 48px; }

.history-panel { margin-top: 0; }
.history-list { display: grid; gap: 10px; }
.history-item { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 13px 15px; border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 11px; background: rgba(9, 13, 19, 0.42); }
.history-color { width: 6px; height: 34px; border-radius: 999px; }
.history-main { min-width: 0; }
.history-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.history-main small { display: block; margin-top: 4px; color: var(--muted); }
.history-item a { color: var(--gold-light); font-size: 12px; text-decoration: none; }
.history-item a:hover { text-decoration: underline; }
.empty-state { margin: 12px 0; color: var(--muted); text-align: center; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(420px, calc(100% - 48px)); padding: 14px 18px; border: 1px solid var(--line-strong); border-radius: 11px; opacity: 0; transform: translateY(12px); pointer-events: none; color: var(--text); background: #1c2430; box-shadow: var(--shadow); transition: opacity 180ms ease, transform 180ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { border-color: rgba(220, 92, 92, 0.5); }

@media (max-width: 980px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .records-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .public-view { padding: 18px 13px 42px; }
  .public-backdrop { background-position: 43% center; }
  .intake-card-inner { padding: 39px 22px 30px; }
  .intake-seal { width: 72px; height: 72px; margin-bottom: 19px; }
  .intake-card h1 { margin-top: 24px; }
  .intake-form input { height: 54px; }
  .public-edge-label { right: 14px; bottom: 13px; font-size: 8px; }
  .admin-shell { width: min(100% - 24px, 1440px); }
  .admin-topbar { min-height: 74px; }
  .admin-brand small, .user-bar > span { display: none; }
  .admin-brand strong { font-size: 15px; }
  .shell { width: min(100% - 24px, 1440px); }
  .topbar { min-height: 74px; }
  .brand small, .user-bar > span { display: none; }
  .login-card { padding: 38px 22px; }
  .app-view { padding-top: 34px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .editor-panel, .preview-panel, .history-panel { padding: 19px; }
  .intake-panel { padding: 19px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .discord-preview { padding: 16px 12px; }
  .history-item { grid-template-columns: 8px minmax(0, 1fr); }
  .history-item a { grid-column: 2; }
}
