:root {
  --bg0: #0c1412;
  --bg1: #13201c;
  --bg2: #1a2c26;
  --line: rgba(180, 220, 200, 0.14);
  --text: #e8f3ee;
  --muted: #93a8a0;
  --accent: #3dcaa0;
  --accent-2: #f0b429;
  --danger: #ff6b6b;
  --ok: #4ade80;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 202, 160, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(240, 180, 41, 0.12), transparent 50%),
    linear-gradient(160deg, var(--bg0), var(--bg1) 45%, #0f1a17);
}

body {
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand:hover { text-decoration: none; }

.brand-mark {
  width: 34px;
  height: 34px;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 0 10px rgba(61, 202, 160, 0.25));
  animation: markPulse 3.2s ease-in-out infinite;
}

.brand-text span { color: var(--accent); }

@keyframes markPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.04); opacity: 0.92; }
}

.nav {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav form { display: inline; margin: 0; }

.btn, button.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--accent);
  color: #042018;
  font-weight: 700;
  font-family: inherit;
  border-radius: 999px;
  padding: 0.75rem 1.2rem;
  cursor: pointer;
  transition: transform .15s ease, filter .15s ease, background .15s ease;
}

.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.warn { background: var(--accent-2); color: #2a1d00; }
.btn.danger { background: transparent; border-color: rgba(255,107,107,.45); color: var(--danger); }

.auth-wrap {
  min-height: calc(100vh - 2rem);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: min(440px, 100%);
  padding: 2rem;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(26, 44, 38, 0.92), rgba(12, 20, 18, 0.92));
  box-shadow: var(--shadow);
  border-radius: 1.4rem;
  animation: rise .55s ease both;
}

.auth-card h1 {
  margin: 0 0 .35rem;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.3rem);
  letter-spacing: -0.03em;
}

.auth-card p.lead {
  margin: 0 0 1.4rem;
  color: var(--muted);
  line-height: 1.5;
}

label {
  display: block;
  margin: 0.85rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
  font: inherit;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: rgba(61, 202, 160, 0.65);
  box-shadow: 0 0 0 3px rgba(61, 202, 160, 0.15);
}

textarea { min-height: 140px; resize: vertical; }

.form-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.alert {
  margin: 0 0 1rem;
  padding: .8rem 1rem;
  border-radius: .8rem;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: #ffd0d0;
}

.alert.ok {
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.35);
  color: #c8ffd8;
}

.chat-layout {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: calc(100vh - 5rem);
  gap: 1rem;
  padding-bottom: 1.5rem;
}

.chat-header h1 {
  margin: .4rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.03em;
}

.chat-header p {
  margin: .4rem 0 0;
  color: var(--muted);
}

.panel {
  border: 1px solid var(--line);
  background: rgba(19, 32, 28, 0.72);
  border-radius: 1.25rem;
  padding: 1rem;
  box-shadow: var(--shadow);
}

#messages {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  min-height: 42vh;
  max-height: 52vh;
  padding: .4rem;
}

.bubble {
  max-width: min(720px, 92%);
  padding: .85rem 1rem;
  border-radius: 1rem;
  line-height: 1.45;
  animation: rise .35s ease both;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: rgba(61, 202, 160, 0.18);
  border: 1px solid rgba(61, 202, 160, 0.28);
}

.bubble.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.composer {
  display: grid;
  grid-template-columns: 180px 1fr auto auto;
  gap: .7rem;
  align-items: end;
}

.composer-input { min-width: 0; }

.lang-switch {
  display: inline-flex;
  margin: 0;
}

.lang-switch select {
  width: auto;
  min-width: 8.5rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  font-size: 0.88rem;
  background: rgba(0, 0, 0, 0.28);
}

.mic-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.25);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
}

.mic-btn.listening {
  background: rgba(255, 107, 107, 0.2);
  border-color: rgba(255, 107, 107, 0.55);
  box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.12);
  animation: pulse 1.2s ease infinite;
}

.status-line {
  min-height: 1.25rem;
  color: var(--muted);
  font-size: .9rem;
}

.chat-controls {
  margin-top: .8rem;
  display: flex;
  gap: .85rem;
  align-items: center;
  flex-wrap: wrap;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.admin-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  padding-bottom: 2rem;
}

.side {
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  padding: 1rem;
  background: rgba(19, 32, 28, 0.7);
  height: fit-content;
}

.side a {
  display: block;
  padding: .65rem .75rem;
  border-radius: .7rem;
  color: var(--text);
  text-decoration: none;
  margin-bottom: .25rem;
}

.side a:hover, .side a.active {
  background: rgba(61, 202, 160, 0.14);
  text-decoration: none;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  text-align: left;
  padding: .75rem .5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table th { color: var(--muted); font-weight: 600; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .8rem;
  margin-bottom: 1rem;
}

.stat {
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.2);
}

.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.7rem;
  margin-top: .2rem;
}

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@media (max-width: 860px) {
  .composer { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  #messages { max-height: 48vh; }
}
