@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --tums-blue: #252b55;
  --tums-blue-2: #1b2147;
  --tums-blue-3: #303766;
  --bg: #f4f7fb;
  --bg-2: #e9eef7;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-strong: #ffffff;
  --text: #111827;
  --heading: #141934;
  --muted: #5f6980;
  --line: rgba(37, 43, 85, 0.14);
  --soft-line: rgba(37, 43, 85, 0.08);
  --accent: #465392;
  --accent-soft: rgba(37, 43, 85, 0.08);
  --bot: #f3f6fb;
  --input: rgba(255, 255, 255, 0.90);
  --user: linear-gradient(135deg, #252b55, #465392);
  --success: #13a06f;
  --warm: #d8b15d;
  --warm-hot: #ff8a2a;
  --shadow: 0 28px 80px rgba(37, 43, 85, 0.16);
  --logo-card: #ffffff;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050608;
  --bg-2: #0b0f18;
  --panel: rgba(13, 16, 24, 0.90);
  --panel-strong: rgba(18, 22, 32, 0.98);
  --text: #f3f6ff;
  --heading: #f8faff;
  --muted: #aab2c8;
  --line: rgba(96, 111, 172, 0.28);
  --soft-line: rgba(255, 255, 255, 0.07);
  --accent: #6f7fd5;
  --accent-soft: rgba(37, 43, 85, 0.42);
  --bot: rgba(255, 255, 255, 0.055);
  --input: rgba(255, 255, 255, 0.06);
  --shadow: 0 34px 100px rgba(0, 0, 0, 0.64);
  --logo-card: #ffffff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
  font-feature-settings: "cv01", "ss03";
  color: var(--text);
  background:
    radial-gradient(circle at 18% 4%, rgba(37, 43, 85, 0.16), transparent 28%),
    radial-gradient(circle at 82% 10%, rgba(70, 83, 146, 0.12), transparent 30%),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-2) 50%, var(--bg) 100%);
}

body[data-theme="dark"] {
  background:
    radial-gradient(circle at 50% -8%, rgba(37, 43, 85, 0.72), transparent 35%),
    radial-gradient(circle at 10% 8%, rgba(70, 83, 146, 0.30), transparent 27%),
    radial-gradient(circle at 90% 18%, rgba(42, 48, 84, 0.42), transparent 29%),
    linear-gradient(135deg, #030405 0%, #0a0c12 42%, #141821 68%, #050608 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.40;
  background-image:
    linear-gradient(rgba(37,43,85,0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,43,85,0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
}

body[data-theme="dark"]::before {
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(96,111,172,0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(96,111,172,0.08) 1px, transparent 1px);
}

.page-shell {
  min-height: 100vh;
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 32px 0 80px;
}

.hero-card,
.chat-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.26);
  backdrop-filter: blur(18px);
}

body[data-theme="dark"] .hero-card,
body[data-theme="dark"] .chat-card {
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.06);
}

.hero-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 18px;
  padding: 18px;
  border-radius: 30px;
  position: sticky;
  top: 20px;
  z-index: 1;
  transform-origin: top center;
  will-change: transform, opacity, filter;
}

.chat-card {
  position: relative;
  z-index: 10;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 154px minmax(0, 1fr);
  align-items: center;
  gap: 22px;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 154px;
  min-height: 172px;
  padding: 14px;
  border: 1px solid rgba(37, 43, 85, 0.10);
  border-radius: 22px;
  background: var(--logo-card);
  box-shadow: 0 16px 40px rgba(37, 43, 85, 0.12);
}

body[data-theme="dark"] .brand-mark {
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(255,255,255,0.04) inset;
}

.brand-mark img {
  display: block;
  width: 112px;
  height: auto;
  object-fit: contain;
}

.brand-copy {
  max-width: 620px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--tums-blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

body[data-theme="dark"] .eyebrow { color: #d8defa; }

h1 {
  margin: 14px 0 9px;
  color: var(--heading);
  font-size: clamp(30px, 4.6vw, 48px);
  line-height: 0.98;
  letter-spacing: -0.052em;
  font-weight: 800;
}

.brand-copy p {
  margin: 0;
  max-width: 560px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.68;
}

.theme-toggle {
  justify-self: end;
  align-self: start;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--input);
  box-shadow: none;
  font-size: 12px;
  font-weight: 700;
}

.chat-card {
  width: 100%;
  min-height: 560px;
  max-height: min(690px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 30px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-strong) 76%, transparent);
  position: relative;
  z-index: 1;
}

.candle {
  position: relative;
  width: 54px;
  height: 58px;
  flex: 0 0 auto;
  image-rendering: pixelated;
  transition: filter 220ms ease, transform 220ms ease;
}

.candle .wax {
  position: absolute;
  left: 17px;
  bottom: 7px;
  width: 22px;
  height: 28px;
  background: #c9cedc;
  box-shadow:
    0 0 0 2px #383d56,
    4px 0 0 0 #eef2ff inset,
    -4px 0 0 0 #7c849e inset,
    0 8px 0 0 rgba(0,0,0,0.16) inset,
    0 28px 0 0 #171a25;
}

.candle .wick {
  position: absolute;
  left: 27px;
  bottom: 36px;
  width: 3px;
  height: 8px;
  background: #12131a;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
  z-index: 2;
}

.candle .flame {
  position: absolute;
  left: 20px;
  bottom: 42px;
  width: 16px;
  height: 16px;
  opacity: 0.22;
  background: #596073;
  clip-path: polygon(50% 0, 75% 25%, 100% 50%, 75% 100%, 25% 100%, 0 50%, 25% 25%);
  box-shadow: none;
  z-index: 3;
}

.candle.on {
  filter: drop-shadow(0 0 11px rgba(216, 177, 93, 0.84)) drop-shadow(0 0 24px rgba(255, 138, 42, 0.40));
  animation: pixelCandleFloat 2s steps(2, end) infinite;
}

.candle.on .wax {
  background: #fff0d0;
  box-shadow:
    0 0 0 2px #5d4a32,
    4px 0 0 0 #fff9e8 inset,
    -4px 0 0 0 #b98455 inset,
    0 8px 0 0 rgba(216, 177, 93, 0.18) inset,
    0 28px 0 0 #201b18,
    0 0 20px 2px rgba(216, 177, 93, 0.22);
}

.candle.on .flame {
  opacity: 1;
  background: #ff8a2a;
  box-shadow:
    0 -4px 0 0 #fff3a6 inset,
    0 4px 0 0 #b43a16 inset,
    0 0 0 2px rgba(87, 45, 20, 0.65),
    0 0 18px 7px rgba(255, 138, 42, 0.48),
    0 0 42px 16px rgba(216, 177, 93, 0.20);
  animation: pixelFlicker 0.9s steps(2, end) infinite;
}

.candle.off { filter: grayscale(0.4) drop-shadow(0 10px 18px rgba(0,0,0,0.25)); }

@keyframes pixelCandleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
}

@keyframes pixelFlicker {
  0%, 100% { transform: translateX(0) scaleY(1); }
  50% { transform: translateX(1px) scaleY(0.88); }
}

.header-copy { min-width: 0; }

.chat-header h2 {
  margin: 0;
  color: var(--heading);
  font-size: 18px;
  letter-spacing: -0.01em;
}

.chat-header span {
  color: var(--muted);
  font-size: 13px;
}

.login-panel, .offline-panel {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-strong) 72%, transparent);
  position: relative;
  z-index: 1;
}

.offline-panel {
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.offline-panel strong { color: var(--heading); display: block; }
.offline-panel span { display: block; }
.offline-panel code { color: var(--accent); font-weight: 800; }

.login-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-row {
  display: flex;
  gap: 10px;
}

input, textarea, button { font: inherit; }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  border-radius: 15px;
  background: var(--input);
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }
input { padding: 14px 15px; }
textarea {
  min-height: 50px;
  max-height: 120px;
  resize: none;
  padding: 14px 15px;
}

input:focus, textarea:focus {
  border-color: rgba(70, 83, 146, 0.72);
  box-shadow: 0 0 0 4px rgba(37, 43, 85, 0.12);
  background: var(--panel-strong);
}

button {
  border: 0;
  border-radius: 15px;
  padding: 0 18px;
  min-height: 50px;
  color: #f8faff;
  cursor: pointer;
  font-weight: 800;
  background: var(--user);
  box-shadow: 0 12px 28px rgba(37, 43, 85, 0.24);
  transition: transform 160ms ease, filter 160ms ease, opacity 160ms ease;
}

button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.bubble {
  max-width: 84%;
  padding: 13px 15px;
  border-radius: 18px;
  white-space: pre-wrap;
  line-height: 1.65;
  font-size: 14px;
}

.bubble.bot {
  align-self: flex-start;
  background: var(--bot);
  color: var(--text);
  border: 1px solid var(--soft-line);
  border-bottom-left-radius: 6px;
}

.bubble.user {
  align-self: flex-end;
  background: var(--user);
  color: #f8faff;
  border-bottom-right-radius: 6px;
}

.bubble.answer {
  max-width: 94%;
  border: 1px solid rgba(70, 83, 146, 0.28);
  background: color-mix(in srgb, var(--bot) 82%, var(--panel-strong));
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 18px 22px 22px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-strong) 72%, transparent);
  position: relative;
  z-index: 1;
}

@media (max-width: 760px) {
  .page-shell { width: min(100% - 24px, 580px); padding: 20px 0; }
  .hero-card { grid-template-columns: 1fr; padding: 16px; }
  .theme-toggle { justify-self: stretch; }
  .brand-lockup { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 16px; }
  .brand-copy { display: grid; justify-items: center; }
  .brand-mark { width: 144px; min-height: 160px; }
  .brand-mark img { width: 104px; }
  .chat-card { min-height: 620px; max-height: none; }
  .login-row, .composer { grid-template-columns: 1fr; display: grid; }
  h1 { font-size: 31px; }
}
