:root {
  --bg: #14121b;
  --bg-2: #191527;
  --panel: #1e1930;
  --panel-2: #241f3a;
  --line: #332e42;
  --line-strong: #40395a;
  --text: #f3f1f8;
  --text-secondary: #b6b1c4;
  --muted: #8a8597;
  --accent: #7b2ff7;
  --accent-bright: #a892e0;
  --accent-deep: #4a1d96;
  --danger: #f87171;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input {
  font: inherit;
}

button {
  appearance: none;
  border: 0;
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--line);
}

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

.brand-name {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.brand-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.session {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.account-box,
.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session input {
  width: 160px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
}

.session input:focus {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px rgba(123, 47, 247, 0.22);
}

.chip-btn {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.chip-btn:hover {
  border-color: var(--accent-bright);
}

.user-box {
  color: var(--text-secondary);
  font-size: 13px;
}

.user-box a {
  color: var(--accent-bright);
  text-decoration: none;
  font-weight: 600;
}

.chat {
  overflow-y: auto;
  padding: 24px 4px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty {
  margin: auto;
  max-width: 460px;
  text-align: center;
}

.empty-art {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 0 8px rgba(123, 47, 247, 0.12);
}

.empty-title {
  margin: 22px 0 8px;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.empty-text {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.chips button {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-secondary);
  font-size: 13px;
}

.chips button:hover {
  border-color: var(--accent-bright);
  color: var(--text);
}

.message {
  max-width: 84%;
  padding: 12px 14px;
  border-radius: var(--radius);
  line-height: 1.55;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: slideUp 0.2s ease-out;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #ffffff;
}

.message.assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
}

.message.error {
  align-self: flex-start;
  background: #2a1518;
  border: 1px solid #5b2830;
  color: #ffd7d9;
}

.message.typing {
  color: var(--muted);
}

.cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 2px;
  border-radius: 2px;
  background: var(--accent-bright);
  vertical-align: -2px;
  animation: blink 1s steps(2, start) infinite;
}

.composer {
  padding: 12px 0 16px;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.composer textarea {
  flex: 1;
  min-height: 48px;
  max-height: 150px;
  resize: none;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.composer textarea:focus {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px rgba(123, 47, 247, 0.22);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: var(--radius);
  color: #ffffff;
}

.send-btn {
  background: var(--accent);
}

.voice-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-secondary);
}

.icon-btn:hover:not(:disabled) {
  filter: brightness(1.12);
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.voice-btn.recording {
  border-color: var(--danger);
  color: #ffffff;
  background: #7f1d1d;
  animation: pulse 1.4s ease-out infinite;
}

.status-line {
  min-height: 18px;
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

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

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.45);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(248, 113, 113, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(248, 113, 113, 0);
  }
}

@media (max-width: 560px) {
  .session {
    display: none;
  }
  .message {
    max-width: 92%;
  }
  .empty-art {
    width: 92px;
    height: 92px;
  }
}

.admin-shell {
  max-width: 1200px;
}

.admin-main {
  padding: 24px 4px 40px;
}

.notice {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 12px;
}

.admin-stats {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text-secondary);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

#adminTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#adminTable th,
#adminTable td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

#adminTable th {
  color: var(--muted);
  font-weight: 600;
  background: var(--panel-2);
}

#adminTable tbody tr:hover {
  background: var(--bg-2);
}
