:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #020713;
  --panel: #06101f;
  --panel-strong: #081426;
  --line: #154365;
  --soft-line: #132b42;
  --text: #f3f7fb;
  --muted: #8998a8;
  --blue: #079fe1;
  --blue-light: #35b8ef;
  --danger: #ff9aaa;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: radial-gradient(circle at 50% 48%, #07152a 0%, #030a18 42%, #01050e 100%);
  color: var(--text);
}

main {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.login-card,
.chat-shell {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(7, 18, 35, .97), rgba(3, 10, 22, .98));
  box-shadow: 0 28px 90px rgba(0, 0, 0, .5), inset 0 1px rgba(96, 180, 230, .025);
}

.login-card {
  width: min(100%, 568px);
  padding: clamp(34px, 6vw, 58px);
  border-radius: 14px;
}

form { display: grid; }

label {
  margin: 0 0 12px;
  color: #eaf1f7;
  font-size: 1.06rem;
  letter-spacing: .01em;
}

input, textarea {
  width: 100%;
  border: 1px solid #21435d;
  border-radius: 8px;
  outline: none;
  background: #050d1b;
  color: var(--text);
  font: inherit;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input { height: 58px; padding: 0 16px; margin-bottom: 30px; }
textarea { resize: vertical; min-height: 106px; max-height: 280px; padding: 16px; line-height: 1.5; }

input:focus, textarea:focus {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(7, 159, 225, .12);
  background: #061122;
}

button { cursor: pointer; }
button { font: inherit; }
button:disabled { cursor: wait; opacity: .58; }

.primary-button {
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(105deg, #079fe1, #087fbe);
  color: white;
  font-weight: 700;
  letter-spacing: .11em;
  box-shadow: 0 12px 30px rgba(0, 119, 180, .2);
  transition: filter .16s ease, transform .16s ease;
}

.primary-button:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }
.primary-button:active:not(:disabled) { transform: translateY(0); }
.primary-button.compact { min-height: 44px; padding: 0 24px; letter-spacing: .03em; }

.form-message {
  min-height: 22px;
  margin: -12px 0 15px;
  color: var(--danger);
  font-size: .92rem;
}

.chat-shell {
  width: min(100%, 940px);
  min-height: min(780px, calc(100vh - 64px));
  max-height: calc(100vh - 64px);
  border-radius: 18px;
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto;
  overflow: hidden;
}

.minimal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid var(--soft-line);
}

.model-label { display: flex; align-items: center; gap: 9px; color: #aebdca; font-size: .86rem; }
.model-dot { width: 7px; height: 7px; border-radius: 50%; background: #4fd18b; box-shadow: 0 0 10px rgba(79, 209, 139, .55); }
.header-status { display: flex; align-items: center; gap: 18px; min-width: 0; }
.usage-label {
  border: 0;
  border-left: 1px solid var(--soft-line);
  background: transparent;
  color: #75899a;
  padding: 2px 0 2px 18px;
  font-size: .78rem;
  white-space: nowrap;
}
.usage-label:hover { color: #b9c8d4; }
.usage-value { font-weight: 650; }
.usage-value.low { color: #ff667a; }
.usage-value.medium { color: #f2c94c; }
.usage-value.high { color: #4fd18b; }

.text-button,
.secondary-button {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .035);
  color: #dcd5e1;
}

.text-button { border-color: transparent; background: transparent; padding: 10px 4px; color: #a9a0ae; font-size: .88rem; }
.text-button:hover { color: white; }
.secondary-button { min-height: 44px; padding: 0 15px; }
.secondary-button:hover { border-color: #245a7d; background: rgba(7, 159, 225, .07); }

.messages {
  overflow-y: auto;
  padding: 28px;
  scrollbar-color: rgba(7, 159, 225, .42) transparent;
}

.message { max-width: 78%; margin-bottom: 18px; animation: appear .18s ease-out; }
.message.user { margin-left: auto; }
.message.assistant { margin-right: auto; }
.bubble { padding: 14px 16px; border-radius: 14px; white-space: pre-wrap; line-height: 1.55; overflow-wrap: anywhere; }
.message.user .bubble { background: linear-gradient(130deg, #087fbe, #075c8b); border-bottom-right-radius: 4px; }
.message.assistant .bubble { background: #0a1728; border: 1px solid #182f46; border-bottom-left-radius: 4px; }
.composer { padding: 18px 22px 21px; border-top: 1px solid var(--soft-line); background: rgba(3, 9, 20, .72); }
.composer-footer { display: flex; align-items: center; justify-content: space-between; min-height: 48px; margin-top: 10px; gap: 16px; }
.composer-actions { display: flex; gap: 10px; margin-left: auto; }
#chat-status { color: var(--muted); font-size: .86rem; }

.hidden { display: none !important; }
.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; }

@keyframes appear { from { opacity: 0; transform: translateY(5px); } }

@media (max-width: 620px) {
  main { padding: 0; }
  .login-card { width: calc(100% - 32px); padding: 34px 25px; }
  .chat-shell { min-height: 100vh; max-height: 100vh; border: 0; border-radius: 0; }
  .minimal-header { padding: 0 16px; }
  .header-status { gap: 10px; }
  .usage-label { padding-left: 10px; font-size: .72rem; }
  .messages { padding: 20px 15px; }
  .message { max-width: 90%; }
  .composer { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
