:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #263449;
  --accent: #2dd4bf;
  --accent-dark: #14b8a6;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --border: #334155;
  --danger: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.brand-name { font-weight: 700; font-size: 18px; }
.brand-sub { font-size: 12px; color: var(--text-dim); }

h1 { font-size: 20px; margin: 0 0 20px; }

label { display: block; font-size: 13px; color: var(--text-dim); margin: 14px 0 6px; }

input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
}
input:focus { outline: none; border-color: var(--accent); }

.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-row img {
  height: 42px;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

button.primary {
  width: 100%;
  margin-top: 22px;
  padding: 11px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #04211d;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
button.primary:hover { background: var(--accent-dark); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--danger);
  font-size: 13px;
  display: none;
}
.error-msg.show { display: block; }

.hint { font-size: 12px; color: var(--text-dim); margin-top: 16px; text-align: center; }

/* chat page */
body.chat-body {
  align-items: stretch;
  padding: 0;
}
.chat-shell {
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.chat-header .who { font-size: 13px; color: var(--text-dim); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.usage { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.logout-btn:hover { color: var(--text); border-color: var(--text-dim); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}
.msg { max-width: 78%; padding: 12px 16px; border-radius: 12px; line-height: 1.5; font-size: 15px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #04211d; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); }
.msg.assistant table { border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.msg.assistant th, .msg.assistant td { border: 1px solid var(--border); padding: 6px 10px; }
.msg.pending { align-self: flex-start; color: var(--text-dim); font-style: italic; }

.composer {
  border-top: 1px solid var(--border);
  padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
  background: var(--panel);
}
.composer form {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
}
.composer input {
  flex: 1;
  padding: 12px 14px;
  font-size: 15px;
}
.composer button {
  padding: 0 20px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #04211d;
  font-weight: 600;
  cursor: pointer;
}
.composer button:disabled { opacity: 0.5; cursor: not-allowed; }
