:root {
  color-scheme: light;
  --bg: #07110d;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #ffffff;
  --text: #102018;
  --muted: #607066;
  --line: rgba(17, 54, 36, 0.14);
  --green: #1c8b4a;
  --green-dark: #116c38;
  --gold: #c98b2c;
  --red: #c43d3d;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
  --topbar-height: 48px;
  --composer-height: 248px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", "Aptos", sans-serif;
}

.frontpage-video {
  position: fixed;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  background: #050f0a;
}

.frontpage-video iframe,
.frontpage-video video {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100vw, 177.78vh);
  height: max(56.25vw, 100vh);
  border: 0;
  object-fit: cover;
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: saturate(1.08) contrast(1.04);
}

body.chat-unlocked .frontpage-video {
  display: none;
}

body::before {
  content: "";
  position: fixed;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.28), transparent 34%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.22), transparent 42%, rgba(0, 0, 0, 0.16));
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
}

.hidden {
  display: none !important;
}

.topbar {
  position: fixed;
  z-index: 30;
  top: auto;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-height);
  gap: 10px;
  padding: 5px clamp(10px, 1.4vw, 20px);
  color: #fff;
  background: linear-gradient(135deg, rgba(10, 60, 38, 0.94), rgba(19, 118, 70, 0.88));
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  border-bottom: 0;
  box-shadow: 0 -14px 34px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(18px);
}

body.chat-unlocked .topbar {
  top: 0;
  bottom: auto;
  justify-content: flex-start;
  border-top: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2);
}

.auth-typewriter {
  overflow: hidden;
  width: 24ch;
  color: #fff;
  font-size: clamp(0.9rem, 1.5vw, 1.2rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

body.chat-unlocked .auth-typewriter {
  display: none;
}

.top-actions,
.status-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.top-actions {
  position: static;
  flex: 0 0 auto;
  justify-content: flex-end;
  flex-wrap: nowrap;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  transform: none;
}

body.chat-unlocked .top-actions {
  position: absolute;
  top: 50%;
  right: clamp(8px, 1.4vw, 18px);
  bottom: auto;
  left: auto;
  justify-content: flex-end;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  transform: translateY(-50%);
}

.primary-button,
.ghost-button,
.danger-button,
.tool-button,
.send-button,
.link-button {
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  text-decoration: none;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, #17934b, #0f6f3b);
  border-radius: 999px;
  padding: 11px 18px;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(15, 111, 59, 0.3);
}

.ghost-button {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 800;
  backdrop-filter: blur(14px);
}

.danger-button {
  color: #fff;
  background: rgba(196, 61, 61, 0.9);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 800;
}

.topbar .top-actions .primary-button,
.topbar .top-actions .ghost-button,
.topbar .top-actions .danger-button {
  min-height: 32px;
  padding: 7px 12px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.contact-button {
  background: linear-gradient(135deg, rgba(16, 95, 168, 0.88), rgba(8, 62, 127, 0.88));
  border-color: rgba(214, 232, 255, 0.42);
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.tool-button:hover,
.send-button:hover {
  transform: translateY(-1px);
}

.app-shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  padding: var(--topbar-height) 4px calc(var(--composer-height) + 6px);
}

body.chat-unlocked .app-shell {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  padding-top: calc(var(--topbar-height) + 4px);
  background: #fff;
}

.hero-card,
.status-card,
.setup-card,
.source-card {
  width: min(960px, 96vw);
  margin: 0 auto 18px;
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 28px;
  color: #fff;
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero-card {
  margin-top: min(10vh, 90px);
}

body.chat-unlocked .hero-card {
  display: none;
}

.hero-kicker,
.modal-kicker,
.status-label,
.step-label {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
}

.hero-card h1,
.setup-card h2,
.modal-card h2 {
  margin: 0;
}

.hero-card h1 {
  font-size: clamp(2.4rem, 8vw, 6rem);
  line-height: 0.9;
  letter-spacing: -0.08em;
}

.hero-copy,
.setup-card p {
  max-width: 760px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.82);
}

.topbar .status-card,
body.chat-unlocked .topbar .status-card {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  width: auto;
  max-width: calc(100vw - 230px);
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 5px 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  box-shadow: none;
  backdrop-filter: blur(18px);
}

.topbar .status-card > div {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
}

.topbar .currency-choice,
.topbar .limit-choice,
.topbar .overage-toggle {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.topbar .currency-choice select,
.topbar .limit-choice input {
  width: auto;
  min-height: 26px;
  padding: 0 22px 0 8px;
  border-radius: 999px;
  color: #10331f;
  font-size: 0.68rem;
  font-weight: 800;
}

.topbar .limit-choice input {
  width: 72px;
  padding-right: 8px;
}

.topbar .overage-toggle {
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}

.topbar .status-card .status-label {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
}

.topbar .status-card strong {
  display: block;
  max-width: 190px;
  overflow: hidden;
  color: #fff;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .status-actions {
  flex-wrap: nowrap;
  gap: 5px;
}

.topbar .status-card .primary-button,
.topbar .status-card .ghost-button {
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  box-shadow: none;
}

.topbar .status-card .primary-button {
  color: #fff;
  background: linear-gradient(135deg, #16a15a, #0e6f3b);
}

.topbar .status-card .ghost-button {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
}

.setup-card {
  position: relative;
  z-index: 1;
  margin-top: 70px;
}

.mfa-grid {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 22px;
  align-items: center;
  margin: 18px 0;
}

.qr-box {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  overflow: hidden;
}

.qr-box img {
  width: 100%;
  max-width: 190px;
  height: auto;
}

.inline-form {
  display: grid;
  gap: 12px;
}

.passkey-step {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: min(1500px, calc(100vw - 24px));
  height: calc(100vh - var(--topbar-height) - var(--composer-height) - 28px);
  min-height: 360px;
  margin: 0 auto;
  padding: 18px 20px 22px;
  overflow-y: scroll;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  backdrop-filter: none;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body:not(.chat-unlocked) .messages,
body:not(.chat-unlocked) .composer {
  display: none !important;
}

body.chat-unlocked .messages {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 18px 20px 22px;
  border-radius: 0;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

.messages::-webkit-scrollbar {
  width: 14px;
}

.messages::-webkit-scrollbar-track {
  background: rgba(14, 24, 18, 0.06);
  border-radius: 999px;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(15, 111, 67, 0.55);
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.8);
}

.messages::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 111, 67, 0.78);
}

.message {
  width: min(100%, 1360px);
  padding: 22px 12px;
  border-radius: 0;
  box-shadow: none;
  line-height: 1.72;
}

body.chat-unlocked .message {
  width: 100%;
  max-width: none;
}

.assistant-message {
  align-self: stretch;
  display: block;
  background: transparent;
  border-bottom: 1px solid rgba(16, 32, 24, 0.08);
  padding-top: 24px;
  padding-bottom: 24px;
}

.user-message {
  align-self: flex-end;
  width: fit-content;
  max-width: min(980px, 82vw);
  margin: 14px 0;
  padding: 14px 18px;
  border-radius: 22px 22px 6px 22px;
  color: #fff;
  background: linear-gradient(135deg, rgba(22, 139, 74, 0.95), rgba(14, 102, 54, 0.95));
  box-shadow: 0 12px 28px rgba(14, 102, 54, 0.2);
}

.error-message {
  align-self: stretch;
  background: #fff4f4;
  border: 1px solid #ffd0d0;
  border-radius: 18px;
}

.message-role {
  display: none;
}

.message-content {
  max-width: 100%;
  color: #14251c;
  font-size: 1.03rem;
  letter-spacing: -0.005em;
}

.user-message .message-content {
  color: #fff;
}

.message-content > :first-child {
  margin-top: 0;
}

.message-content > :last-child {
  margin-bottom: 0;
}

.message-content p {
  margin: 0 0 0.95rem;
}

.message-content h1,
.message-content h2,
.message-content h3 {
  margin: 1.2rem 0 0.6rem;
  letter-spacing: -0.02em;
  line-height: 1.22;
}

.message-content h1 {
  font-size: 1.55rem;
}

.message-content h2 {
  font-size: 1.35rem;
}

.message-content h3 {
  font-size: 1.15rem;
}

.message-content ul,
.message-content ol {
  margin: 0.6rem 0 1rem;
  padding-left: 1.4rem;
}

.message-content li {
  margin: 0.38rem 0;
  padding-left: 0.12rem;
}

.message-content a {
  color: #0f766e;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.message-content a:hover {
  color: #1d4ed8;
}

.message-content blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 4px solid #1c8b4a;
  border-radius: 0 14px 14px 0;
  color: #415348;
  background: #f1f8f4;
}

.message-content pre {
  overflow: auto;
  margin: 1rem 0;
  padding: 16px;
  border-radius: 16px;
  background: #0e1812;
  color: #f1fff6;
}

.message-content code {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.92em;
}

.message-content :not(pre) > code {
  padding: 0.14rem 0.34rem;
  border-radius: 6px;
  color: #102018;
  background: #edf4ef;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid #dce7df;
  border-radius: 14px;
}

.message-content table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  margin: 0;
}

.message-content th,
.message-content td {
  padding: 10px 12px;
  border: 1px solid #dce7df;
  text-align: left;
}

.message-content th {
  background: #eef7f1;
  font-weight: 900;
}

.media-output {
  margin-top: 1rem;
  padding: 12px;
  border: 1px solid #d8eadf;
  border-radius: 18px;
  background: #f6fbf8;
}

.media-output p {
  margin: 0 0 0.7rem;
  font-weight: 900;
  color: #173522;
}

.media-output img,
.media-output video {
  display: block;
  width: 100%;
  max-width: 860px;
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(12, 33, 22, 0.16);
}

.media-output audio {
  width: 100%;
}

.composer {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: calc(100vw - 8px);
  padding: 0 4px 4px;
  border-radius: 0;
  background: #fff;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.tool-button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  color: #fff;
  background: linear-gradient(135deg, #1b8c4b, #126f3b);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 8px 18px rgba(16, 32, 24, 0.12);
}

.tool-button {
  min-height: 36px;
  padding: 8px 14px;
  font-size: 0.82rem;
}

.tool-button:hover {
  filter: brightness(1.04);
}

.danger-tool {
  background: linear-gradient(135deg, #d84e4e, #9f2020);
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.mode-row label,
.modal-card label,
.inline-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid #d6e0d9;
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select,
input {
  min-height: 44px;
  padding: 0 13px;
}

textarea {
  resize: none;
  min-height: 54px;
  max-height: 180px;
  padding: 15px 16px;
  line-height: 1.45;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(28, 139, 74, 0.12);
}

.prompt-row {
  display: grid;
  grid-template-columns: 1fr 54px;
  gap: 10px;
  align-items: end;
}

.send-button {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, #16954d, #0e6b38);
  font-size: 1.4rem;
  font-weight: 900;
  box-shadow: 0 14px 26px rgba(22, 149, 77, 0.26);
}

.send-button.stop {
  background: linear-gradient(135deg, #e14a4a, #a92727);
  font-size: 0.82rem;
}

.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.composer-status {
  min-height: 0;
  padding: 0;
  color: transparent;
  font-size: 0;
  line-height: 0;
  overflow: hidden;
}

.modal {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  border-radius: 28px;
  background: transparent;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 28px;
  border-radius: 28px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.modal-card h2 {
  color: var(--text);
  font-size: 2rem;
}

.modal-kicker {
  color: var(--green);
}

.modal-note {
  padding: 12px 14px;
  border: 1px solid rgba(35, 134, 54, 0.18);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(35, 134, 54, 0.08);
  font-size: 0.95rem;
  line-height: 1.45;
}

.modal-note.error {
  border-color: rgba(176, 35, 24, 0.26);
  color: #7f1d1d;
  background: rgba(176, 35, 24, 0.08);
}

.close-button {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: #f0f4f2;
  cursor: pointer;
  font-size: 1.25rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.full-button {
  width: 100%;
  justify-content: center;
}

.link-button {
  color: var(--green-dark);
  background: transparent;
  text-decoration: underline;
  font-weight: 800;
}

.captcha-slot {
  min-height: 1px;
}

.toast {
  position: fixed;
  z-index: 70;
  right: 20px;
  bottom: calc(var(--composer-height) + 32px);
  width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 18px;
  color: #fff;
  background: rgba(12, 33, 22, 0.94);
  box-shadow: var(--shadow);
}

.contact-page,
.admin-page {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px 16px;
}

.contact-card,
.admin-card {
  width: min(980px, calc(100vw - 28px));
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.contact-card h1,
.admin-card h1 {
  margin: 0 0 10px;
  letter-spacing: -0.04em;
}

.contact-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.contact-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.contact-form textarea {
  min-height: 160px;
  resize: vertical;
}

.form-message {
  min-height: 24px;
  color: var(--green-dark);
  font-weight: 800;
}

.form-message.error {
  color: #991b1b;
}

.admin-grid {
  display: grid;
  gap: 28px;
  margin-top: 24px;
}

.admin-section {
  overflow: hidden;
  border: 1px solid #dce7df;
  border-radius: 20px;
  background: #fff;
}

.admin-section h2 {
  margin: 0;
  padding: 16px 18px;
  color: #11351f;
  background: #eef7f1;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 11px 12px;
  border-top: 1px solid #e6eee9;
  text-align: left;
  vertical-align: top;
  font-size: 0.86rem;
}

.admin-table th {
  color: #173522;
  font-weight: 900;
}

.admin-table td {
  color: #34443a;
}

.admin-table .comment-cell {
  min-width: 280px;
  white-space: pre-wrap;
}

@media (max-width: 1180px) {
  :root {
    --topbar-height: 58px;
  }

  .topbar .status-card {
    max-width: calc(100vw - 210px);
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-height: 58px;
    --composer-height: 364px;
  }

  .topbar {
    padding: 7px 8px;
  }

  .top-actions {
    width: auto;
    justify-content: flex-end;
    gap: 6px;
  }

  .auth-typewriter {
    font-size: 0.76rem;
  }

  body.chat-unlocked .top-actions {
    right: 8px;
    width: auto;
  }

  .topbar .status-card {
    max-width: calc(100vw - 150px);
    flex-wrap: nowrap;
    gap: 6px;
    padding: 5px 7px;
    border-radius: 16px;
  }

  .topbar .status-actions {
    display: none;
  }

  .topbar .status-card strong {
    max-width: 120px;
    font-size: 0.72rem;
  }

  .hero-card {
    margin-top: 88px;
  }

  .mfa-grid,
  .mode-row,
  .two-col {
    grid-template-columns: 1fr;
  }

  .composer {
    bottom: 8px;
  }

  .quick-actions {
    gap: 7px;
  }
}
