:root {
  --color-bg: #f0f2f5;
  --color-primary: #2f7d5a;
  --color-primary-dark: #245f45;
  --color-bubble-own: #d9f2e6;
  --color-bubble-other: #ffffff;
  --color-text: #1c1e21;
  --color-muted: #65676b;
  --color-error: #c0392b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
}

/* Login */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.login-card h1 {
  text-align: center;
  color: var(--color-primary-dark);
  margin-top: 0;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-card label {
  font-size: 14px;
  color: var(--color-muted);
  margin-top: 10px;
}

.login-card input {
  padding: 12px;
  border: 1px solid #ccd0d5;
  border-radius: 8px;
  font-size: 16px;
}

.login-card button {
  margin-top: 20px;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.login-card button:hover {
  background: var(--color-primary-dark);
}

.error {
  color: var(--color-error);
  font-size: 14px;
  margin: 0 0 12px;
}

/* Chat */
.chat-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-header {
  background: var(--color-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header h1 {
  font-size: 18px;
  margin: 0;
}

.logout-link {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  text-decoration: none;
  font-size: 14px;
}

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

.message {
  background: var(--color-bubble-other);
  border-radius: 10px;
  padding: 8px 12px;
  max-width: 75%;
  align-self: flex-start;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.message-own {
  background: var(--color-bubble-own);
  align-self: flex-end;
}

.message-sender {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary-dark);
}

.message-content {
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-time {
  font-size: 11px;
  color: var(--color-muted);
  text-align: right;
  margin-top: 2px;
}

.message-image {
  display: block;
  max-width: 100%;
  max-height: 260px;
  border-radius: 8px;
  cursor: zoom-in;
  object-fit: cover;
}

.icon-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: #f0f2f5;
  font-size: 20px;
  cursor: pointer;
}

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

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
  cursor: zoom-out;
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
}

.message-audio {
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-audio audio {
  max-width: 220px;
  height: 36px;
}

.audio-duration {
  font-size: 12px;
  color: var(--color-muted);
  white-space: nowrap;
}

.icon-btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.recording-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #fff;
  border-top: 1px solid #e4e6eb;
  flex-shrink: 0;
}

.recording-bar[hidden] {
  display: none;
}

.recording-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-error);
  animation: recording-pulse 1.2s ease-in-out infinite;
}

@keyframes recording-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#recording-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.recording-label {
  color: var(--color-muted);
  font-size: 14px;
  flex: 1;
}

.message-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #e4e6eb;
  flex-shrink: 0;
}

.message-form[hidden] {
  display: none;
}

.message-form input {
  flex: 1;
  padding: 12px;
  border: 1px solid #ccd0d5;
  border-radius: 20px;
  font-size: 16px;
}

.message-form button {
  padding: 0 18px;
  border: none;
  border-radius: 20px;
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
