:root {
  --bg: #000;
  --bg-alt: #0a0a0a;
  --text: #fff;
  --text-dim: #999;
  --accent: #C8D82D;
  --accent-dark: #A8B825;
  --border: rgba(255,255,255,0.08);
  --error: #ff5c5c;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

#app {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen.active {
  display: flex;
}

.container {
  margin: auto;
  max-width: 480px;
  padding: 40px 24px;
  width: 100%;
  text-align: center;
}

.logo-img {
  width: 130px;
  height: 130px;
  display: block;
  margin: 0 auto 32px;
}

@media (max-width: 600px) {
  .logo-img { width: 100px; height: 100px; margin-bottom: 24px; }
}

h1 {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-dim);
  font-size: 16px;
  margin-bottom: 40px;
  line-height: 1.5;
}

.error {
  color: var(--error);
  font-size: 14px;
  margin-top: 16px;
  min-height: 20px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

input[type="text"] {
  width: 100%;
  padding: 18px 20px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 18px;
  font-family: inherit;
  font-weight: 600;
  text-align: center;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: border-color 0.2s;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  padding: 18px 24px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

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

button:active:not(:disabled) {
  transform: scale(0.98);
}

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

.check {
  font-size: 64px;
  color: var(--accent);
  margin-bottom: 24px;
  line-height: 1;
}

/* Chat screen */
.chat-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}

.chat-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-header-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.chat-header-status {
  font-size: 12px;
  color: var(--text-dim);
}

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

.message-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  animation: fadeIn 0.3s ease-out;
}

.message-row.user {
  justify-content: flex-end;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.message {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

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

.message.assistant {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message.user {
  background: var(--accent);
  color: #000;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.message-text {
  display: inline;
}

.message-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  float: right;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1;
  opacity: 0.7;
  user-select: none;
  white-space: nowrap;
}

.message.user .message-meta {
  color: rgba(0, 0, 0, 0.55);
}

.message.assistant .message-meta {
  color: var(--text-dim);
  float: none;
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.message-checks {
  display: inline-flex;
  align-items: center;
  transition: color 0.3s ease;
}

.message.user .message-checks.sent,
.message.user .message-checks.delivered {
  color: rgba(0, 0, 0, 0.5);
}

.message.assistant .message-checks.sent,
.message.assistant .message-checks.delivered {
  color: rgba(255, 255, 255, 0.35);
}

.message-checks.read {
  color: #0ea5e9;
}

.check-icon {
  display: block;
}

.message.typing {
  display: flex;
  gap: 6px;
  align-items: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
}

.message.typing span {
  width: 8px;
  height: 8px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.message.typing span:nth-child(2) { animation-delay: 0.2s; }
.message.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

#chat-form {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
}

textarea {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 22px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  line-height: 1.35;
  resize: none;
  transition: border-color 0.2s;
  max-height: 140px;
  overflow-y: auto;
}

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

#chat-submit {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chat-submit svg {
  transform: translateX(1px);
}

@media (max-width: 600px) {
  h1 { font-size: 26px; }
  .container { padding: 32px 20px; }
  #messages { padding: 16px 12px; gap: 10px; }
  .chat-header { padding: 12px 16px; }
  .message { max-width: 85%; font-size: 15px; }
}
