:root {
  --bg-main: #0B0F19;
  --bg-card: #151D2F;
  --bg-card-hover: #1C273E;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(254, 204, 0, 0.35);
  --accent-yellow: #FECC00;
  --accent-yellow-glow: rgba(254, 204, 0, 0.25);
  --accent-blue: #0066B3;
  --accent-blue-light: #38BDF8;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  --danger: #EF4444;
  --success: #10B981;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 860px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 0%, #152238 0%, var(--bg-main) 65%);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  position: relative;
}

/* Top Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 15, 25, 0.85);
}

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

.logo-flag {
  font-size: 28px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

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

.pill-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.pill-btn.danger-hover:hover {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Topic Banner */
.topic-banner {
  padding: 16px 24px;
  background: linear-gradient(90deg, rgba(0, 102, 179, 0.12) 0%, rgba(254, 204, 0, 0.05) 100%);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topic-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent-yellow);
  display: block;
  margin-bottom: 4px;
}

.topic-banner h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.level-indicator {
  background: rgba(254, 204, 0, 0.15);
  color: var(--accent-yellow);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* Chat Stream */
.chat-container {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding-bottom: 180px; /* Space for voice footer */
}

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

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

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

.message-wrapper.tutor {
  align-self: flex-start;
}

.message-bubble {
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  font-size: 15px;
  line-height: 1.6;
  position: relative;
}

.message-wrapper.user .message-bubble {
  background: linear-gradient(135deg, #005293, #003866);
  color: #fff;
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-wrapper.tutor .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
  color: var(--text-main);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.sender-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-yellow);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.audio-player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.audio-play-btn {
  background: var(--accent-yellow);
  color: #000;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.audio-play-btn:hover {
  transform: scale(1.08);
}

.audio-play-btn svg {
  margin-left: 2px;
}

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

/* Grammar Coaching Drawer */
.coaching-card {
  margin-top: 10px;
  background: rgba(254, 204, 0, 0.06);
  border: 1px solid rgba(254, 204, 0, 0.2);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
}

.coaching-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-yellow);
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 12px;
}

.coaching-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.coaching-item {
  color: #E2E8F0;
  line-height: 1.4;
  padding-left: 12px;
  position: relative;
}

.coaching-item::before {
  content: "•";
  color: var(--accent-yellow);
  position: absolute;
  left: 0;
}

/* Suggested Answers */
.suggestions-box {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.suggestions-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.suggestion-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.suggestion-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.suggestion-pill:hover {
  background: rgba(254, 204, 0, 0.1);
  color: var(--text-main);
  border-color: rgba(254, 204, 0, 0.3);
}

/* Voice Footer */
.voice-footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 860px;
  background: linear-gradient(180deg, rgba(11, 15, 25, 0) 0%, rgba(11, 15, 25, 0.95) 30%, #0B0F19 100%);
  padding: 20px 24px 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 10;
}

.voice-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
}

/* Large Mic Button */
.mic-button {
  background: var(--bg-card);
  border: 2px solid var(--accent-yellow);
  color: var(--text-main);
  padding: 10px 24px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  box-shadow: 0 4px 24px var(--accent-yellow-glow);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.mic-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(254, 204, 0, 0.35);
  background: var(--bg-card-hover);
}

.mic-inner {
  width: 44px;
  height: 44px;
  background: var(--accent-yellow);
  color: #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.2s ease;
}

.mic-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

/* Recording State Animation */
.mic-button.recording {
  border-color: var(--danger);
  box-shadow: 0 0 35px rgba(239, 68, 68, 0.4);
}

.mic-button.recording .mic-inner {
  background: var(--danger);
  color: #fff;
  animation: pulse-danger 1.5s infinite;
}

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

.stop-icon {
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 3px;
}

.text-toggle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.text-toggle-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.audio-feedback {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.9);
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-size: 13px;
}

.volume-meter-container {
  width: 50px;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.volume-bar {
  width: 4px;
  height: 100%;
  background: #10B981;
  border-radius: 999px;
  transition: width 0.05s ease;
}

.cancel-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
}

.cancel-btn:hover {
  color: var(--danger);
}

/* Text Drawer */
.text-drawer {
  width: 100%;
}

.text-form {
  display: flex;
  gap: 8px;
  width: 100%;
}

.text-form input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  outline: none;
}

.text-form input:focus {
  border-color: var(--accent-yellow);
}

.send-btn {
  background: var(--accent-yellow);
  color: #000;
  border: none;
  padding: 0 20px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.send-btn:hover {
  transform: scale(1.05);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group select {
  background: #0B0F19;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}

.primary-btn {
  background: var(--accent-yellow);
  color: #000;
  font-weight: 700;
  border: none;
  padding: 12px 20px;
  border-radius: 999px;
  width: 100%;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.primary-btn:hover {
  opacity: 0.9;
}

.hidden {
  display: none !important;
}

/* Login Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 20%, #152238 0%, #0B0F19 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
}

.login-flag {
  font-size: 42px;
  margin-bottom: 8px;
}

.login-brand h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-brand p {
  font-size: 13px;
  color: var(--text-muted);
}

.login-input {
  background: #0B0F19;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

.login-input:focus {
  border-color: var(--accent-yellow);
}

.login-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #FCA5A5;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  text-align: center;
}

