/* Main app background and layout */
.stApp {
  background: radial-gradient(1100px 650px at 25% 18%, rgba(80, 170, 255, 0.55), rgba(255, 255, 255, 0) 62%),
              radial-gradient(950px 720px at 82% 18%, rgba(212, 120, 255, 0.42), rgba(255, 255, 255, 0) 58%),
              radial-gradient(900px 620px at 48% 92%, rgba(120, 220, 255, 0.30), rgba(255, 255, 255, 0) 58%),
              linear-gradient(105deg, #6bb8ff 0%, #9aa8ff 36%, #caa0ff 68%, #f2b6e9 100%);
  min-height: 100vh;
}

.stApp::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.30;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='320' viewBox='0 0 520 320'%3E%3Cg fill='none' stroke='white' stroke-opacity='0.35' stroke-width='2'%3E%3Cellipse cx='115' cy='90' rx='78' ry='26'/%3E%3Cellipse cx='115' cy='90' rx='78' ry='26' transform='rotate(60 115 90)'/%3E%3Cellipse cx='115' cy='90' rx='78' ry='26' transform='rotate(-60 115 90)'/%3E%3Ccircle cx='115' cy='90' r='4' fill='white' fill-opacity='0.35' stroke='none'/%3E%3Cpath d='M360 210c32-22 76-22 108 0'/%3E%3Cpath d='M346 246c40-26 102-26 142 0'/%3E%3Cpath d='M380 110c18 10 40 10 58 0'/%3E%3Cpath d='M50 250c50-38 110-38 160 0'/%3E%3Cpath d='M70 270c40-28 88-28 128 0'/%3E%3Cpath d='M240 60c28-18 64-18 92 0'/%3E%3Cpath d='M250 80c22-14 50-14 72 0'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 520px 320px;
  mix-blend-mode: overlay;
  z-index: 0;
}

.stApp::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(900px 520px at 50% 48%, rgba(255,255,255,0.25), rgba(255,255,255,0) 62%),
              radial-gradient(1200px 800px at 50% 110%, rgba(0,0,0,0.12), rgba(0,0,0,0) 55%);
  z-index: 0;
}

/* Layout and container styles */
.block-container {
  position: relative;
  z-index: 1;
  max-width: 980px;
  padding-top: 28px;
  padding-bottom: 40px;
}

/* Header and footer */
footer, #MainMenu {
  visibility: hidden;
}

header[data-testid="stHeader"] {
  background: transparent;
}

/* Animations */
@keyframes tutorFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Tutor hero section */
.tutor-hero {
  padding: 18px 22px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.40);
  box-shadow: 0 14px 38px rgba(31, 38, 135, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: tutorFadeUp 380ms ease-out both;
  width: 100%;
  max-width: 980px;
  margin: 0 auto 20px;
  box-sizing: border-box;
}

/* Branding */
.tutor-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.tutor-brand-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.tutor-badge {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(80, 140, 255, 0.9), rgba(180, 120, 255, 0.9));
  box-shadow: 0 10px 26px rgba(31, 38, 135, 0.18);
}

/* Navigation */
.tutor-nav {
  display: flex;
  gap: 16px;
  opacity: 0.85;
  font-size: 0.95rem;
}

.tutor-nav a {
  text-decoration: none;
  color: inherit;
}

.tutor-nav a:hover {
  text-decoration: underline;
}

/* Typography */
.tutor-title {
  font-size: 1.6rem;
  font-weight: 750;
  margin: 6px 0 2px 0;
}

.tutor-subtitle {
  opacity: 0.82;
  margin: 0 0 12px 0;
}

/* Form elements */
div[data-testid="stTextInput"] input {
  border-radius: 14px !important;
  padding: 14px 14px !important;
  background: rgba(255, 255, 255, 0.65) !important;
  border: 1px solid rgba(255, 255, 255, 0.55) !important;
}

div[data-testid="stTextInput"] input:focus {
  border: 1px solid rgba(120, 150, 255, 0.75) !important;
  box-shadow: 0 0 0 4px rgba(120, 150, 255, 0.18) !important;
}

/* ===== CSS for HTML Frontend (Vercel deployment) ===== */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: radial-gradient(1100px 650px at 25% 18%, rgba(80, 170, 255, 0.55), rgba(255, 255, 255, 0) 62%),
              radial-gradient(950px 720px at 82% 18%, rgba(212, 120, 255, 0.42), rgba(255, 255, 255, 0) 58%),
              radial-gradient(900px 620px at 48% 92%, rgba(120, 220, 255, 0.30), rgba(255, 255, 255, 0) 58%),
              linear-gradient(105deg, #6bb8ff 0%, #9aa8ff 36%, #caa0ff 68%, #f2b6e9 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.30;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='320' viewBox='0 0 520 320'%3E%3Cg fill='none' stroke='white' stroke-opacity='0.35' stroke-width='2'%3E%3Cellipse cx='115' cy='90' rx='78' ry='26'/%3E%3Cellipse cx='115' cy='90' rx='78' ry='26' transform='rotate(60 115 90)'/%3E%3Cellipse cx='115' cy='90' rx='78' ry='26' transform='rotate(-60 115 90)'/%3E%3Ccircle cx='115' cy='90' r='4' fill='white' fill-opacity='0.35' stroke='none'/%3E%3Cpath d='M360 210c32-22 76-22 108 0'/%3E%3Cpath d='M346 246c40-26 102-26 142 0'/%3E%3Cpath d='M380 110c18 10 40 10 58 0'/%3E%3Cpath d='M50 250c50-38 110-38 160 0'/%3E%3Cpath d='M70 270c40-28 88-28 128 0'/%3E%3Cpath d='M240 60c28-18 64-18 92 0'/%3E%3Cpath d='M250 80c22-14 50-14 72 0'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 520px 320px;
  mix-blend-mode: overlay;
  z-index: 0;
}

.main-container {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 0 40px;
}

/* Input Section */
.input-section {
  margin-top: 20px;
}

#voice-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-bottom: 10px;
}

#voice-mic {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  transition: all 0.2s;
  font-family: inherit;
}

#voice-mic:hover {
  background: rgba(255, 255, 255, 0.9);
}

#voice-mic.listening {
  background: #ff4b4b !important;
  color: white !important;
}

#voice-mic:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#voice-status {
  font-size: 0.8em;
  min-height: 1.2em;
  color: #666;
  margin-top: 5px;
}

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

#question-input {
  flex: 1;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.65);
  font-size: 16px;
  font-family: inherit;
  backdrop-filter: blur(8px);
}

#question-input:focus {
  outline: none;
  border: 1px solid rgba(120, 150, 255, 0.75);
  box-shadow: 0 0 0 4px rgba(120, 150, 255, 0.18);
}

.submit-btn {
  padding: 14px 24px;
  background: linear-gradient(135deg, #6bb8ff, #9aa8ff);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(107, 184, 255, 0.4);
}

.submit-btn:active {
  transform: translateY(0);
}

.tts-controls-row {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.auto-speak-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #555;
  cursor: pointer;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 20px;
}

.auto-speak-toggle input {
  cursor: pointer;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 30px 0;
  font-size: 16px;
  color: #555;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.5);
  border-top-color: #6bb8ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.hidden {
  display: none !important;
}

/* Error */
.error {
  background: #ffebee;
  border: 1px solid #ef5350;
  color: #c62828;
  padding: 14px 18px;
  border-radius: 12px;
  margin: 20px 0;
}

/* Answer Section */
.answer-section {
  margin-top: 30px;
}

.card {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.08);
  backdrop-filter: blur(12px);
}

.card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: #444;
}

.card-content {
  line-height: 1.7;
}

.card-content h4 {
  font-size: 1.1rem;
  margin: 16px 0 10px;
  color: #555;
}

.card-content ul, .card-content ol {
  margin-left: 20px;
  margin-bottom: 12px;
}

.card-content li {
  margin-bottom: 8px;
}

/* TTS Buttons */
.tts-buttons {
  display: flex;
  gap: 10px;
  margin: 20px 0;
}

.tts-btn {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.speak-btn {
  background: #0d6efd;
  color: white;
}

.speak-btn:hover {
  background: #0b5ed7;
}

.stop-btn {
  background: #dc3545;
  color: white;
}

.stop-btn:hover {
  background: #c82333;
}

.tts-speaking {
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Grounded Section */
.grounded-section {
  margin-top: 20px;
}

.grounded-section details {
  background: rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  padding: 16px;
}

.grounded-section summary {
  cursor: pointer;
  font-weight: 600;
  color: #555;
}

.grounded-content {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 14px;
  line-height: 1.6;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 12px;
  }
  
  .tutor-title {
    font-size: 1.3rem;
  }
  
  .input-row {
    flex-direction: column;
  }
  
  .submit-btn {
    width: 100%;
  }
}

