:root {
  --bg: #0b0f14;
  --panel: #111823;
  --panel-2: #16202e;
  --border: #223044;
  --text: #e6edf3;
  --muted: #8b9bb0;
  --accent: #4f8cff;
  --accent-hover: #3d78e6;
  --user: #1d4ed8;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial,
    sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 960px;
  margin: 0 auto;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.brand .dot.off {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

select,
button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

select:hover,
button:hover {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

button.ghost {
  background: transparent;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 100%;
}

.msg .avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.msg.user .avatar {
  background: var(--user);
  border-color: var(--user);
}

.msg .bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.msg.user .bubble {
  background: #14243f;
  border-color: #23406e;
}

.msg .bubble p:first-child {
  margin-top: 0;
}

.msg .bubble p:last-child {
  margin-bottom: 0;
}

.bubble pre {
  background: #0a0e13;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
}

.bubble code {
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 13px;
}

.bubble :not(pre) > code {
  background: #0a0e13;
  padding: 1px 5px;
  border-radius: 5px;
}

.bubble table {
  border-collapse: collapse;
}

.bubble th,
.bubble td {
  border: 1px solid var(--border);
  padding: 4px 8px;
}

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 480px;
  padding: 20px;
}

.empty h2 {
  color: var(--text);
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.cursor::after {
  content: "▍";
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

.composer {
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 12px 16px 16px;
}

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

textarea {
  flex: 1;
  resize: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  max-height: 200px;
  min-height: 44px;
}

textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

.status-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

.error {
  color: var(--danger);
}

/* login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.card h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.card p {
  color: var(--muted);
  margin-top: 0;
}

.card input {
  width: 100%;
  padding: 11px 13px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 14px 0;
}

.card input:focus {
  outline: none;
  border-color: var(--accent);
}

.card button {
  width: 100%;
}

#login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}
