:root {
  --ink: #173149;
  --ink-soft: #5f7080;
  --blue-deep: #0b3b66;
  --blue: #1d628e;
  --blue-air: #dbeef7;
  --sea: #9bcad9;
  --marble: #f7f4ed;
  --marble-bright: #fffdf8;
  --stone: #d9d2c3;
  --gold: #b59a62;
  --gold-soft: #d5c29c;
  --danger: #9b3d3d;
  --shadow: 0 24px 70px rgba(19, 54, 82, .13);
  --radius: 24px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #eaf4f7; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 18% 8%, rgba(255,255,255,.95) 0 11%, rgba(255,255,255,0) 34%),
    radial-gradient(circle at 88% 18%, rgba(184,222,238,.65) 0 12%, rgba(184,222,238,0) 36%),
    linear-gradient(180deg, #dff1f8 0%, #edf6f4 42%, #f5f0e6 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .34;
  background-image:
    linear-gradient(112deg, transparent 0 47%, rgba(70,92,111,.06) 47.3% 47.6%, transparent 48%),
    linear-gradient(72deg, transparent 0 62%, rgba(181,154,98,.06) 62.3% 62.6%, transparent 63%);
  background-size: 780px 620px, 980px 760px;
  mix-blend-mode: multiply;
}

.ambient { position: fixed; border-radius: 50%; filter: blur(50px); opacity: .23; pointer-events: none; }
.ambient-one { width: 360px; height: 360px; background: #7dbbd0; right: -120px; top: 20vh; }
.ambient-two { width: 420px; height: 420px; background: #f4dfb6; left: -180px; bottom: -80px; }

.shell { width: min(1080px, calc(100% - 32px)); margin: 0 auto; min-height: 100vh; padding: 34px 0 26px; position: relative; z-index: 1; }
.brand { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 8px auto 34px; color: var(--blue-deep); }
.brand.compact { justify-content: flex-start; margin-bottom: 26px; }
.brand-name { font-family: var(--serif); font-size: clamp(26px, 4vw, 38px); line-height: .95; letter-spacing: .18em; font-weight: 600; }
.brand-subtitle { margin-top: 7px; font-size: 9px; letter-spacing: .34em; color: var(--gold); font-weight: 700; }
.brand-mark { width: 34px; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.column-cap, .column-base { display: block; width: 30px; height: 5px; border: 1px solid rgba(11,59,102,.45); background: rgba(255,255,255,.35); }
.column-cap { border-radius: 2px 2px 0 0; box-shadow: 0 4px 0 -2px var(--gold-soft); }
.column-shaft { display: block; width: 18px; height: 34px; border-left: 1px solid rgba(11,59,102,.38); border-right: 1px solid rgba(11,59,102,.38); background: repeating-linear-gradient(90deg, rgba(255,255,255,.5) 0 3px, rgba(63,102,128,.08) 3px 4px); }
.column-base { width: 34px; border-radius: 0 0 2px 2px; }

.panel, .chat-panel, .admin-panel {
  background: linear-gradient(135deg, rgba(255,253,248,.95), rgba(247,244,237,.92));
  border: 1px solid rgba(148,131,96,.22);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.panel { border-radius: var(--radius); }
.login-panel { width: min(620px, 100%); margin: 0 auto; padding: clamp(28px, 5vw, 52px); text-align: center; position: relative; overflow: hidden; }
.login-panel::before { content: ""; position: absolute; inset: 12px; border: 1px solid rgba(181,154,98,.17); border-radius: 18px; pointer-events: none; }
.login-panel.narrow { width: min(520px, 100%); }
.ornament { display: flex; justify-content: center; margin: -5px 0 20px; }
.ornament span { width: 80px; height: 8px; border-top: 1px solid var(--gold-soft); border-bottom: 1px solid var(--gold-soft); position: relative; }
.ornament span::before, .ornament span::after { content: ""; position: absolute; top: 2px; width: 6px; height: 6px; border: 1px solid var(--gold); transform: rotate(45deg); background: var(--marble-bright); }
.ornament span::before { left: 18px; } .ornament span::after { right: 18px; }
.eyebrow { margin: 0 0 10px; text-transform: uppercase; letter-spacing: .18em; font-size: 11px; font-weight: 800; color: var(--gold); }
h1, h2 { font-family: var(--serif); font-weight: 500; color: var(--blue-deep); }
h1 { margin: 0 0 16px; font-size: clamp(34px, 5vw, 52px); line-height: 1.08; }
h2 { margin: 0 0 16px; font-size: 24px; }
.lead { max-width: 510px; margin: 0 auto 30px; color: var(--ink-soft); line-height: 1.7; font-size: 16px; }

.stack { display: grid; gap: 16px; text-align: left; max-width: 420px; margin: 0 auto; }
.compact-stack { max-width: none; margin: 0; }
label span { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 750; color: #41576a; letter-spacing: .02em; }
input, textarea {
  width: 100%; border: 1px solid rgba(48,81,105,.20); background: rgba(255,255,255,.78); color: var(--ink); border-radius: 13px;
  font: inherit; outline: none; transition: border-color .18s, box-shadow .18s, background .18s;
}
input { min-height: 48px; padding: 11px 13px; }
textarea { resize: none; max-height: 170px; min-height: 52px; padding: 15px 62px 14px 16px; line-height: 1.45; }
input:focus, textarea:focus { border-color: rgba(29,98,142,.52); box-shadow: 0 0 0 4px rgba(29,98,142,.09); background: #fff; }
button, .link-button { font: inherit; border: 0; cursor: pointer; transition: transform .12s, box-shadow .18s, background .18s, color .18s; }
button:active, .link-button:active { transform: translateY(1px); }
.primary, .secondary { border-radius: 13px; min-height: 48px; padding: 12px 18px; font-weight: 750; }
.primary { background: linear-gradient(135deg, #0b3b66, #195e88); color: white; box-shadow: 0 12px 24px rgba(11,59,102,.17); }
.primary:hover { box-shadow: 0 14px 28px rgba(11,59,102,.25); }
.secondary { background: #e7f1f4; color: var(--blue-deep); border: 1px solid rgba(29,98,142,.17); }
.ghost { background: transparent; color: #476073; border: 1px solid rgba(48,81,105,.16); padding: 8px 12px; border-radius: 10px; font-size: 12px; font-weight: 700; text-decoration: none; }
.ghost:hover { background: rgba(255,255,255,.6); color: var(--blue-deep); }
.ghost.danger { color: var(--danger); border-color: rgba(155,61,61,.18); }
.quiet-note { margin: 24px auto 0; max-width: 430px; font-size: 12px; line-height: 1.6; color: #7b858d; }
.form-error { margin: 0; color: #9b3d3d; font-size: 13px; text-align: left; }
.form-message { margin: 0; color: var(--blue-deep); font-size: 13px; }

.chat-panel { width: min(850px, 100%); height: min(760px, calc(100vh - 160px)); min-height: 570px; margin: 0 auto; border-radius: 30px; overflow: hidden; display: grid; grid-template-rows: auto 1fr auto auto; }
.chat-topbar { padding: 18px 22px; border-bottom: 1px solid rgba(48,81,105,.09); display: flex; align-items: center; justify-content: space-between; gap: 18px; background: rgba(255,255,255,.42); }
.chat-title { font-family: var(--serif); color: var(--blue-deep); font-size: 23px; }
.chat-status { font-size: 11px; color: #72818d; margin-top: 2px; }
.status-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: #77a695; margin-right: 6px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.messages { min-height: 0; overflow-y: auto; padding: 28px clamp(18px, 5vw, 48px); scroll-behavior: smooth; }
.message { display: flex; margin: 0 0 18px; animation: rise .2s ease-out; }
.message.user { justify-content: flex-end; }
.bubble { max-width: min(690px, 88%); padding: 13px 16px; border-radius: 18px; line-height: 1.62; font-size: 15px; white-space: normal; overflow-wrap: anywhere; }
.message.assistant .bubble { background: rgba(255,255,255,.69); border: 1px solid rgba(139,124,92,.14); border-top-left-radius: 5px; color: #263f53; }
.message.user .bubble { background: linear-gradient(135deg, #155276, #0b3b66); color: #fff; border-bottom-right-radius: 5px; box-shadow: 0 8px 18px rgba(11,59,102,.12); }
.bubble p { margin: 0 0 10px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 8px 0 8px 20px; padding: 0; }
.bubble strong { font-weight: 750; }
.typing { display: inline-flex; gap: 4px; align-items: center; min-width: 44px; }
.typing span { width: 6px; height: 6px; background: #7890a1; border-radius: 50%; animation: pulse 1.15s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .13s; } .typing span:nth-child(3) { animation-delay: .26s; }
.composer { position: relative; padding: 12px 18px 10px; border-top: 1px solid rgba(48,81,105,.08); background: rgba(255,255,255,.46); }
.send-button { position: absolute; right: 28px; bottom: 19px; width: 38px; height: 38px; border-radius: 50%; background: var(--blue-deep); color: #fff; font-size: 22px; display: grid; place-items: center; }
.send-button:disabled { opacity: .45; cursor: default; }
.chat-footnote { padding: 0 20px 13px; text-align: center; font-size: 10.5px; color: #88939a; background: rgba(255,255,255,.46); }

.site-footer { display: flex; justify-content: center; gap: 9px; align-items: center; margin: 24px auto 0; color: #75858d; font-size: 11px; }
.site-footer a { color: inherit; text-decoration: none; } .site-footer a:hover { color: var(--blue-deep); }

.admin-shell { width: min(1180px, calc(100% - 32px)); }
.admin-panel { padding: clamp(20px, 3vw, 32px); border-radius: 28px; }
.admin-header, .section-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.admin-header h1 { font-size: clamp(32px, 4vw, 44px); margin-bottom: 26px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.admin-card { padding: 24px; box-shadow: none; background: rgba(255,255,255,.52); }
.users-card { margin-top: 18px; }
.muted { color: #72818d; line-height: 1.6; }
.small { font-size: 12px; }
.connection-status { margin: 16px 0; padding: 12px 14px; border-radius: 12px; background: rgba(219,238,247,.55); color: var(--blue-deep); font-size: 13px; }
.button-row { display: flex; gap: 9px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: #6e7c87; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; text-align: left; padding: 12px 10px; border-bottom: 1px solid rgba(48,81,105,.12); }
td { padding: 14px 10px; border-bottom: 1px solid rgba(48,81,105,.07); vertical-align: middle; }
.badge { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 99px; font-size: 11px; font-weight: 750; }
.badge.active { background: #e4f1e9; color: #3d7559; } .badge.inactive { background: #f2e7e4; color: #8a5650; }
.action-row { display: flex; gap: 6px; flex-wrap: wrap; }

.prose-shell { width: min(840px, calc(100% - 32px)); }
.prose { padding: clamp(28px, 5vw, 54px); line-height: 1.76; }
.prose h1 { font-size: clamp(34px, 5vw, 48px); }
.prose h2 { margin-top: 34px; font-size: 24px; }
.prose p { color: #42586b; }
.notice { background: #f6edda; border-left: 3px solid var(--gold); padding: 13px 15px; border-radius: 8px; color: #5b554a; }
.text-link { color: var(--blue-deep); }
.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; }
[hidden] { display: none !important; }

@keyframes pulse { 0%, 80%, 100% { transform: scale(.75); opacity: .55; } 40% { transform: scale(1); opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (max-width: 720px) {
  .shell { width: min(100% - 18px, 1080px); padding-top: 20px; }
  .brand { margin-bottom: 20px; }
  .login-panel { padding: 30px 22px; }
  .chat-panel { height: calc(100vh - 120px); min-height: 520px; border-radius: 22px; }
  .chat-topbar { padding: 14px 14px; align-items: flex-start; }
  .top-actions { gap: 5px; }
  .ghost { padding: 7px 9px; }
  .messages { padding: 20px 13px; }
  .bubble { max-width: 93%; font-size: 14px; }
  .composer { padding: 10px 10px 8px; }
  .send-button { right: 19px; bottom: 17px; }
  .chat-footnote { font-size: 9.5px; padding-inline: 10px; }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-header, .section-row { align-items: flex-start; flex-direction: column; }
}
