:root {
  --bg-main: #090d16;
  --bg-surface: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #273549;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-light: rgba(139, 92, 246, 0.15);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --user-bubble: linear-gradient(135deg, #6366f1, #4f46e5);
  --assistant-bubble: #1e293b;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* App Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-surface);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-container {
  position: relative;
  width: 44px;
  height: 44px;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.35);
}

.status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background-color: var(--success);
  border: 2px solid var(--bg-surface);
  border-radius: 50%;
}

.header-info h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.header-status {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-indicator {
  display: inline-block;
  width: 7px;
  height: 7px;
  background-color: var(--success);
  border-radius: 50%;
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

.btn-icon.active {
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.1);
}

.badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  border: 2px solid var(--bg-surface);
}

.spinning svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: fadeIn 0.25s ease-out;
}

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

.message-row.user {
  align-self: flex-end;
}

.message-row.assistant {
  align-self: flex-start;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.message-row.user .message-bubble {
  background: var(--user-bubble);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-row.assistant .message-bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.message-time {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 4px;
  padding: 0 4px;
}

.message-row.user .message-time {
  text-align: right;
}

.message-text p {
  margin-bottom: 8px;
}
.message-text p:last-child {
  margin-bottom: 0;
}
.message-text strong {
  font-weight: 600;
  color: #ffffff;
}

/* TTS Speaker Button in Assistant Message */
.message-footer {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.btn-tts {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-tts:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: #fff;
}

.btn-tts.speaking {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  animation: pulse-tts 1.2s infinite;
}

@keyframes pulse-tts {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

/* Email Card Alert */
.email-alert-card {
  background: linear-gradient(145deg, #1e293b, #192437);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 14px;
  padding: 14px;
  margin-top: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.email-alert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
}

.email-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--accent-light);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.email-sender {
  font-size: 12px;
  color: var(--text-muted);
}

.email-subject {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
}

.email-deadline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  font-size: 11.5px;
  padding: 4px 8px;
  border-radius: 6px;
  margin-top: 8px;
}

/* Audio Player */
.audio-player-wrapper {
  margin-top: 6px;
}
audio {
  width: 100%;
  max-width: 250px;
  height: 38px;
  border-radius: 20px;
  outline: none;
}

/* Image Attachment */
.image-attachment-wrapper {
  margin-top: 6px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 260px;
}
.image-attachment-wrapper img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  cursor: pointer;
}

/* Input Area */
.chat-input-area {
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}

.attachment-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.attachment-preview-content {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-remove-att {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
}

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

.input-actions-left {
  display: flex;
  gap: 6px;
}

.chat-textarea {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text-main);
  font-size: 14.5px;
  font-family: inherit;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s;
}

.chat-textarea:focus {
  border-color: var(--accent);
}

.btn-send, .btn-mic {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: white;
}

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

.btn-mic {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-mic .icon-stop {
  display: none;
}

.btn-mic.recording {
  background: var(--danger);
  border-color: var(--danger);
  animation: pulse-red 1.2s infinite;
}

.btn-mic.recording .icon-mic {
  display: none;
}
.btn-mic.recording .icon-stop {
  display: block;
}

@keyframes pulse-red {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Modals & Drawers */
.drawer-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  max-height: 75%;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 60;
  overflow: hidden;
}

.drawer.active {
  transform: translateY(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.drawer-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-title-box h2 {
  font-size: 16px;
  font-weight: 600;
}

.drawer-content {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px 10px;
  color: var(--text-dim);
  font-size: 13.5px;
}

.reminder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-card);
  border-radius: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
  transition: all 0.2s;
}

.reminder-item.completed {
  opacity: 0.5;
  text-decoration: line-through;
}

.reminder-info {
  flex: 1;
  margin-right: 12px;
}

.reminder-date {
  font-size: 11px;
  color: var(--warning);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.reminder-text {
  font-size: 13.5px;
  margin-top: 3px;
  color: var(--text-main);
}

.btn-check {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-check.active {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  margin-bottom: 6px;
}

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

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
