:root {
  /* --- Auto-generated Complete DRY variables --- */
  --c-rgba-25-25-35-a04: rgba(25, 25, 35, 0.4);
  --hex-00bcd4: #00bcd4;
  --c-black-a03: rgba(0, 0, 0, 0.3);
  --c-white-a01: rgba(255, 255, 255, 0.1);
  --hex-00e676: #00e676;
  --hex-b794f4: #b794f4;
  --hex-fff: #fff;
  --c-white-a003: rgba(255, 255, 255, 0.03);
  --c-white-a005: rgba(255, 255, 255, 0.05);
  --c-rgba-10-10-15-a04: rgba(10, 10, 15, 0.4);
  --c-white-a03: rgba(255, 255, 255, 0.3);
  --c-rgba-20-20-30-a06: rgba(20, 20, 30, 0.6);
  --c-rgba-0-230-118-a01: rgba(0, 230, 118, 0.1);
  --c-rgba-0-230-118-a03: rgba(0, 230, 118, 0.3);
  --user_chat_glow: rgba(255, 64, 129, 0.2);
  --c-black-a02: rgba(0, 0, 0, 0.2);
  --c-rgba-125-42-232-a06: rgba(125, 42, 232, 0.6);
  --c-rgba-125-42-232-a02: rgba(125, 42, 232, 0.2);
  --c-white-a02: rgba(255, 255, 255, 0.2);
  --hex-8e44f2: #8e44f2;
  --c-rgba-10-10-15-a08: rgba(10, 10, 15, 0.8);
  --c-black-a05: rgba(0, 0, 0, 0.5);
  --hex-ff3366: #ff3366;
  --c-rgba-40-20-60-a095: rgba(40, 20, 60, 0.95);
  --c-rgba-125-42-232-a05: rgba(125, 42, 232, 0.5);
  --hex-ff3333: #ff3333;
  --c-white-a015: rgba(255, 255, 255, 0.15);
  --c-white-a025: rgba(255, 255, 255, 0.25);
  --c-black-a06: rgba(0, 0, 0, 0.6);
  --c-white-a008: rgba(255, 255, 255, 0.08);
  --hex-00e5ff: #00e5ff;
  --c-rgba-0-229-255-a02: rgba(0, 229, 255, 0.2);
  --c-white-a05: rgba(255, 255, 255, 0.5);
  --c-rgba-20-20-25-a03: rgba(20, 20, 25, 0.3);
  --c-rgba-35-15-20-a04: rgba(35, 15, 20, 0.4);
  --c-rgba-125-42-232-a03: rgba(125, 42, 232, 0.3);
  --c-rgba-125-42-232-a01: rgba(125, 42, 232, 0.1);
  --hex-ffcc00: #ffcc00;
  --hex-1a1a20: #1a1a20;
  --hex-ff4757: #ff4757;
  --c-white-a04: rgba(255, 255, 255, 0.4);
  --c-black-a01: rgba(0, 0, 0, 0.1);
  --c-rgba-30-30-40-a085: rgba(30, 30, 40, 0.85);
  --c-rgba-125-42-232-a04: rgba(125, 42, 232, 0.4);
  --hex-7d2ae8: #7d2ae8;
  --hex-6b24c6: #6b24c6;
  --c-rgba-183-148-244-a05: rgba(183, 148, 244, 0.5);
  --c-black-a005: rgba(0, 0, 0, 0.05);
  --c-white-a: rgba(255, 255, 255, ...);

  /* DARK THEME (Default) */
  --bg-app: #0f0c29;
  --bg-gradient: none; /* Атмосферные круги делают фон */
  --glass-bg: rgba(25, 25, 35, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text-main: #f0f0f5;
  --text-muted: #a0a0b5;

  --scrollbar-track: var(--c-rgba-25-25-35-a04);
  --scrollbar-thumb: var(--accent-primary);
  --scrollbar-thumb-hover: var(--accent-pink);

  --accent-primary: #7d2ae8;
  --accent-glow: rgba(125, 42, 232, 0.4);
  --accent-pink: #ff4081;
  --accent-red: #ff3366;
  --accent-yellow: #ffc107;

  --chat-user-bg: linear-gradient(135deg, #7d2ae8, #ff4081);
  --chat-gemini-bg: rgba(40, 40, 55, 0.8);

  --input-bg: rgba(10, 10, 15, 0.4);
  --input-border: rgba(255, 255, 255, 0.1);

  --modal-bg: rgba(20, 20, 25, 0.95);
  --calendar-bg: rgba(15, 15, 20, 0.65);
  --dropdown-bg: rgba(30, 30, 30, 0.95);

  --slider-track: rgba(255, 255, 255, 0.1);
  --sidebar-item-hover: rgba(255, 255, 255, 0.05);

  --user_chat_glow: rgba(255, 64, 129, 0.2);

  --prime-btn: #7d2ae8;
  --prime-btn-hover: #8e44f2;

  --slider-1: rgba(68, 117, 232, 0.6);
  --slider-2: rgba(64, 220, 255, 0.6);
  --slider-3: rgba(248, 90, 166, 0.6);
  --slider-4: rgba(168, 7, 255, 0.6);
  --slide-border: rgba(255, 255, 255, 0.3);

  --english_text-chat: #ffc107;
  --chat-font-size: 16px;
  --topseparator: linear-gradient(0deg, transparent, #0f0c29);
}

body.light-theme {
  /* LIGHT THEME (Glassmorphism) */
  --bg-app: #f5f7fa;
  --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.8);
  --text-main: #2c3e50;
  --text-muted: #64748b;

  --accent-primary: #ffffff; /* Чуть темнее для контраста */
  --accent-glow: rgba(186, 210, 254, 0.2);
  --accent-pink: #40dcff;
  --accent-red: #ffdd33;
  --accent-yellow: #ffc107;

  /* Освежающий голубой градиент для пользователя в светлой теме */
  --chat-user-bg: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --chat-gemini-bg: rgba(255, 255, 255, 0.6);

  --input-bg: rgba(255, 255, 255, 0.6);
  --input-border: rgba(0, 0, 0, 0.1);

  --modal-bg: rgba(245, 247, 250, 0.95);
  --calendar-bg: rgba(255, 255, 255, 0.75);
  --dropdown-bg: rgba(255, 255, 255, 0.95);

  --slider-track: rgba(0, 0, 0, 0.1);
  --sidebar-item-hover: rgba(0, 0, 0, 0.05);

  --user_chat_glow: rgba(34, 97, 131, 0.2);

  --prime-btn: #7d2ae8;
  --prime-btn-hover: #8e44f2;

  --slide-border: rgba(255, 255, 255, 0.886);

  --english_text-chat: #068fff;

  --topseparator: linear-gradient(0deg, transparent, #f7fafc);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family:
    "Outfit",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
}

/* Custom Scrollbar Global System */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

body {
  background: var(--bg-gradient, var(--bg-app));
  background-color: var(--bg-app);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

ol,
li {
  padding: 5px 0 5px 35px;
  margin-left: 0px;
}

ul {
  list-style: disc;
  padding: 0 0 0 20px;
  margin: 0;
}
ul li {
  padding: 0;
  margin: 0;
}
/* Background Atmosphere */
.background-decorations {
  position: absolute;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
}

.blur-circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.4;
  animation: drift 20s infinite alternate ease-in-out;
}

.blur-circle.purple {
  width: 600px;
  height: 600px;
  background: var(--accent-primary);
  top: -100px;
  left: -100px;
}

.blur-circle.blue {
  width: 500px;
  height: 500px;
  background: var(--hex-00bcd4);
  bottom: -50px;
  right: 10%;
  animation-delay: -5s;
}

.blur-circle.pink {
  width: 400px;
  height: 400px;
  background: var(--accent-pink);
  top: 30%;
  right: -50px;
  animation-delay: -10s;
}

@keyframes drift {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(100px, 50px) scale(1.1);
  }
}

/* Main Layout */
.app-container {
  width: 95vw;
  max-width: 1800px;
  height: 90vh;
  display: flex;
  gap: 24px;
  z-index: 10;
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 25px 50px var(--c-black-a03);
}

/* Sidebar RPG Settings */
.sidebar {
  width: 350px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  position: relative;
}

.sidebar-header {
  text-align: center;
  margin-bottom: 40px;
}

.avatar-wrapper {
  position: relative;
  width: 300px;
  height: 300px;
  margin: 40px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-container {
  position: relative;
  width: 300px;
  height: 300px;
  overflow: hidden;
  border: 3px solid var(--accent-primary);
  box-shadow:
    0 0 10px var(--accent-primary),
    0 0 15px var(--accent-glow),
    0 0 30px var(--accent-glow);
  border-radius: 50%;
  z-index: 20;
  transition:
    border-color 0.3s,
    box-shadow 0.3s;
}

.avatar-container.speaking {
  border-color: var(--accent-pink);
  box-shadow:
    0 0 20px var(--accent-pink),
    0 0 40px var(--accent-glow);
  animation: avatar-pulse 2s infinite ease-in-out;
}

@keyframes avatar-pulse {
  0% {
    transform: scale(1);
    box-shadow:
      0 0 20px var(--accent-pink),
      0 0 40px var(--accent-glow);
  }
  50% {
    transform: scale(1.02);
    box-shadow:
      0 0 30px var(--accent-pink),
      0 0 60px var(--accent-glow);
  }
  100% {
    transform: scale(1);
    box-shadow:
      0 0 20px var(--accent-pink),
      0 0 40px var(--accent-glow);
  }
}

.avatar-img {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  object-fit: cover;
  position: relative;
  z-index: 20;
  margin-top: -1px;
  margin-left: -2px;
}

#avatar-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  margin-top: -1px;
  margin-left: -2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease-in-out;
  z-index: 25; /* Higher than avatar-static */
}

#avatar-video.video-active {
  opacity: 1;
  transition: opacity 0.3s ease-in;
}

.visualizer-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 30; /* In front of avatar */
}

.status-indicator {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--hex-00e676);
  border: 3px solid var(--bg-dark);
  box-shadow: 0 0 10px var(--hex-00e676);
}

.sidebar-header h2 {
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 4px;
  background: linear-gradient(to right, var(--hex-fff), var(--hex-b794f4));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.section-title {
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-weight: 500;
}

.settings-container {
  flex: 1;
}

.slider-group {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--c-white-a003);
  border-radius: 14px;
  border: 1px solid var(--c-white-a005);
  transition:
    transform 0.2s,
    background 0.2s;
  display: flex;
  flex-direction: column;
}

.slider-group:hover {
  background: var(--c-white-a005);
}

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

.slider-header label {
  font-weight: 500;
  font-size: 0.95rem;
}

.slider-value {
  background: var(--c-white-a01);
  padding: 2px 8px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--text-main);
  min-width: 34px;
  text-align: center;
}

/* Personality (RPG) sliders grouped card */
.personality-group {
  gap: 12px;
}

.personality-title {
  margin-bottom: 0;
}

.personality-title label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.55;
}

.personality-slider .slider-header {
  margin-bottom: 6px;
}

/* Custom Text Input for Settings */
.custom-input {
  height: 40px;
  width: 100%;
  background: var(--c-rgba-10-10-15-a04);
  border: 1px solid var(--c-white-a01);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 1rem;
  outline: none;
  transition: all 0.3s ease;
  margin-top: 4px;
}

.custom-input::placeholder {
  color: var(--c-white-a03);
}

.custom-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-glow);
  background: var(--c-rgba-20-20-30-a06);
}

/* Custom Range Slider */
.custom-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: var(--slider-track);
  outline: none;
  transition: opacity 0.2s;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--slider-1);
  cursor: pointer;
  box-shadow: 0 0 10px var(--slider-1);
  transition: transform 0.1s;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1px solid var(--slide-border);
}

.custom-slider.accent-pink::-webkit-slider-thumb {
  background: var(--slider-2);
  box-shadow: 0 0 10px var(--slider-2);
}
.custom-slider.accent-red::-webkit-slider-thumb {
  background: var(--slider-3);
  box-shadow: 0 0 10px var(--slider-3);
}
.custom-slider.accent-yellow::-webkit-slider-thumb {
  background: var(--slider-4);
  box-shadow: 0 0 10px var(--slider-4);
}

.custom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.memory-badge {
  margin-top: 20px;
  padding: 12px;
  background: var(--c-rgba-0-230-118-a01);
  border: 1px solid var(--c-rgba-0-230-118-a03);
  border-radius: 12px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--hex-00e676);
  font-weight: 500;
}

/* Main Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.chat-header {
  padding: 15px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.translate {
  opacity: 0.4;
  font-style: italic;
  font-size: 12px;
  display: block;
  padding: 15px 5px;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0.7;
}

.icon-btn:hover {
  text-shadow: 0 0 10px var(--accent-primary);
  transform: scale(1.1);
  opacity: 1;
}

.voice-toggle-icon {
  filter: invert(1); /* White in Dark mode */
  transition: filter 0.3s ease;
}

body.light-theme .voice-toggle-icon {
  filter: none; /* Dark in Light mode */
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.3);
    opacity: 1;
  }
}

.chat-messages {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
  position: relative;
}

.topseparator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;

  height: 80px;
  background: var(--topseparator);
  z-index: 1;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: fadeIn 0.3s ease-out forwards;
  opacity: 0;
  transform: translateY(10px);
}

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

.model-switcher {
  display: flex;
  gap: 8px;
}

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

.message.gemini-msg {
  align-self: flex-start;
}

.message.system-msg {
  align-self: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 100%;
}

.msg-content {
  padding: 14px 20px;
  border-radius: 18px;
  font-size: var(--chat-font-size, 1.1rem);
  line-height: 1.5;
  word-wrap: break-word;
  max-width: 100%;
}

.message-attached-image {
  width: 100%;
  max-width: 130px;
  border-radius: 8px;
  margin-bottom: 8px;
  display: block;
}

.msg-text-container {
  word-wrap: break-word;
}

.date-separator {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 15px 0;
  display: block;
  user-select: none;
}
.date-separator span {
  background: var(--glass-bg);
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
}

.user-msg .msg-content {
  background: var(--chat-user-bg);
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px var(--user_chat_glow);
}

.gemini-msg .msg-content {
  background: var(--chat-gemini-bg);
  border: 1px solid var(--c-white-a005);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 15px var(--c-black-a02);
}

.msg-content p {
  margin-bottom: 8px;
}
.msg-content p:last-child {
  margin-bottom: 0;
}

/* Chat Input */
.chat-input-container {
  padding: 20px 30px;
  border-top: 1px solid var(--input-border);
  background: var(--input-bg);
}

.input-form {
  display: flex;
  gap: 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 20px;
  padding: 8px;
  align-items: flex-end;
  transition:
    border-color 0.3s,
    box-shadow 0.3s;
}

.input-form:focus-within {
  border-color: var(--c-rgba-125-42-232-a06);
  box-shadow: 0 0 20px var(--c-rgba-125-42-232-a02);
}

#user-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 1rem;
  padding: 10px 16px;
  resize: none;
  height: 44px;
  max-height: 200px;
  line-height: 1.5;
  overflow-y: hidden;
  font-family: inherit;
}

#user-input::placeholder {
  color: var(--text-muted);
}

.send-btn,
.mic-btn {
  background: var(--prime-btn);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition:
    transform 0.2s,
    background 0.2s,
    box-shadow 0.2s;
  flex-shrink: 0;
}

.mic-btn {
  background: var(--c-white-a01);
  border: 1px solid var(--c-white-a02);
}

.mic-btn:hover {
  background: var(--prime-btn-hover);
  transform: scale(1.05);
}

.mic-btn:active {
  transform: scale(0.95);
}

.send-btn svg {
  width: 20px;
  height: 20px;
  transform: translateX(-1px);
}

.send-btn:hover {
  background: var(--hex-8e44f2);
  transform: scale(1.05);
}

.send-btn:active {
  transform: scale(0.95);
}

/* Typing Indicator */
.typing-indicator {
  padding: 16px 20px;
  background: var(--chat-gemini-bg);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  align-self: flex-start;
  animation: fadeIn 0.3s;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 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 typingBounce {
  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Modal UI */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--c-rgba-10-10-15-a08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: var(--modal-bg);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  width: 90%;
  max-width: 600px;
  padding: 32px;
  box-shadow: 0 25px 50px var(--c-black-a05);
  transform: translateY(-20px) scale(0.95);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

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

.modal-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  background: linear-gradient(to right, var(--hex-fff), var(--hex-b794f4));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close-btn:hover {
  color: var(--hex-ff3366);
}

.modal-body p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.full-textarea {
  width: 100%;
  height: 250px;
  resize: vertical;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 16px;
}

.modal-footer {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--prime-btn);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.2s;
}

.btn-primary:hover {
  background: var(--prime-btn-hover);
  transform: translateY(-2px);
}

/* Quick Access Nav Tiles (premium glass buttons under portrait) */
.nav-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.nav-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  padding: 12px 4px;
  border-radius: 14px;
  cursor: pointer;
  color: var(--text-main);
  background: linear-gradient(160deg, var(--c-white-a01), var(--c-white-a005));
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--c-white-a01);
  overflow: hidden;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition:
    transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.25s,
    border-color 0.25s,
    background 0.25s;
}

/* radial sheen revealed on hover */
.nav-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    120% 80% at 50% -20%,
    var(--accent-glow),
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.nav-tile svg {
  color: var(--text-muted);
  transition:
    color 0.25s,
    transform 0.25s,
    filter 0.25s;
}

.nav-tile span {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.15;
  text-align: center;
  color: var(--text-muted);
  transition: color 0.25s;
}

.nav-tile:hover {
  transform: translateY(-3px);
  border-color: var(--accent-primary);
  background: linear-gradient(
    160deg,
    var(--c-rgba-125-42-232-a02),
    var(--c-white-a005)
  );
  box-shadow:
    0 8px 24px var(--accent-glow),
    inset 0 1px 0 var(--c-white-a01);
}

.nav-tile:hover::before {
  opacity: 1;
}

.nav-tile:hover svg {
  color: #fff;
  transform: scale(1.08);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.nav-tile:hover span {
  color: var(--text-main);
}

.nav-tile:active {
  transform: translateY(-1px) scale(0.98);
}

/* English Tutor Mode card + toggle switch */
.tutor-group {
  border-color: var(--accent-glow);
  background: linear-gradient(
    160deg,
    var(--c-rgba-125-42-232-a02),
    var(--c-white-a003)
  );
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--c-white-a01);
  border: 1px solid var(--glass-border);
  border-radius: 26px;
  transition:
    background 0.25s,
    box-shadow 0.25s;
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.25s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.switch input:checked + .switch-slider {
  background: var(--prime-btn);
  box-shadow: 0 0 12px var(--accent-glow);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

/* "Разбор" corrections block inside chat replies */
/* Premium "Разбор" (corrections) card */
.tutor-review {
  display: block;
  margin-top: 14px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(
    160deg,
    rgba(125, 42, 232, 0.16),
    rgba(255, 255, 255, 0.02)
  );
  border: 1px solid var(--accent-glow);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 var(--c-white-a01);
  font-size: 0.92em;
}

.tr-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(125, 42, 232, 0.28);
  border-bottom: 1px solid var(--accent-glow);
}

.tr-row {
  display: flex;
  gap: 10px;
  padding: 11px 16px;
  align-items: flex-start;
  line-height: 1.55;
  border-bottom: 1px solid var(--c-white-a005);
}

.tr-row:last-child {
  border-bottom: none;
}

.tr-icon {
  flex-shrink: 0;
  font-size: 1.05em;
  line-height: 1.4;
}

.tr-wrong {
  background: rgba(255, 51, 102, 0.1);
}

.tr-right {
  background: rgba(34, 197, 94, 0.1);
}

.tr-new {
  flex-direction: column;
  gap: 4px;
}

.tr-new ul {
  margin: 4px 0 0;
  padding-left: 20px;
}

.tr-new li {
  margin: 3px 0;
}

/* Settings Modal Tabs */
.settings-tab-btn:hover {
  background: var(--c-white-a005) !important;
}
.settings-tab-btn.active {
  background: var(--c-rgba-125-42-232-a02) !important;
  border-left: 3px solid var(--prime-btn) !important;
  color: var(--hex-b794f4) !important;
}
.settings-tab-pane {
  display: none;
}
.settings-tab-pane.active {
  display: flex !important;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 100002;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--c-rgba-40-20-60-a095);
  backdrop-filter: blur(10px);
  border: 1px solid var(--c-rgba-125-42-232-a05);
  box-shadow:
    0 4px 15px var(--c-black-a05),
    0 0 20px var(--c-rgba-125-42-232-a02);
  color: white;
  padding: 15px 20px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-icon {
  font-size: 1.2rem;
}

.toast-content {
  display: flex;
  flex-direction: column;
}

.toast-message {
  font-size: 0.95rem;
  font-weight: 500;
}

/* File Upload Attachment Styles */
.chat-input-container {
  position: relative;
  display: flex;
  flex-direction: column;
}

.attachments-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  align-self: flex-start;
  animation: fadeIn 0.3s;
}

.attachment-chip {
  position: relative;
  width: 80px;
  height: 80px;
  background: var(--bg-light);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 4px 15px var(--c-black-a02);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.attachment-chip:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
}

.attachment-chip img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
}

/* Model-generated images (e.g. Gemini Image Preview via OpenRouter) */
.generated-image-wrapper {
  display: inline-block;
  position: relative;
  margin: 10px 0 4px 0;
  animation: fadeInUp 0.4s ease;
}

.download-image-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 0.2s ease,
    background 0.2s ease;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.generated-image-wrapper:hover .download-image-btn {
  opacity: 1;
}

.download-image-btn:hover {
  background: rgba(0, 0, 0, 0.85);
}

.generated-image {
  max-width: 100%;
  max-height: 480px;
  width: auto;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  cursor: zoom-in;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  display: block;
}

.generated-image:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.attachment-chip .file-icon {
  font-size: 2rem;
}

.remove-attachment-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ff4d4f;
  color: white;
  border: none;
  font-size: 14px;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  z-index: 10;
  transition: background 0.2s;
}

.remove-attachment-btn:hover {
  background: #ff7875;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 5px var(--c-black-a03);
  transition: all 0.2s;
  z-index: 10;
}

.remove-image-btn:hover {
  transform: scale(1.1);
  background: var(--hex-ff3333);
}

.attach-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.attach-btn:hover {
  background: var(--c-white-a01);
  color: var(--text-main);
}

/* Стили для выпадающего меню */
.theme-dropdown-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
  z-index: 100;
}

.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--dropdown-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  display: none;
  min-width: 150px;
  z-index: 1100;
  padding: 8px;
  box-shadow: 0 10px 30px var(--c-black-a05);
}

.theme-menu.show {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px;
}

.theme-option {
  background: transparent;
  border: none;
  color: var(--text-main) !important;
  font-size: 0.95rem;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  width: 100%;
  display: block;
}
.theme-option:hover {
  background: var(--c-white-a015) !important;
}

/* Header Buttons cleanup */
.header-action-btn {
  background: var(--c-white-a01);
  border: 1px solid var(--c-white-a02);
  color: white;
  padding: 6px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
}

.header-action-btn:hover {
  background: var(--c-white-a025);
}

/* RAG File Attachment UI */
.file-attachment {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--c-white-a01);
  border: 1px solid var(--c-white-a02);
  border-radius: 12px;
  padding: 12px 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  max-width: 300px;
  box-shadow: 0 4px 15px var(--c-black-a02);
}

.file-attachment-icon {
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--c-white-a015);
  border-radius: 8px;
}

.file-attachment-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.file-attachment-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-attachment-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.loading-pulse {
  animation: pulse 1.5s infinite ease-in-out;
  color: var(--accent-light);
}

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

/* Calendar Modal UI */
/* NOTEBOOK STYLES */
.notebook-layout {
  display: flex;
  flex-direction: column;
  width: 90vw;
  height: 90vh;
  max-width: 1200px;
  padding: 0;
  overflow: hidden;
}

.notebook-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 25px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-panel);
}

.notebook-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.notebook-sidebar {
  width: 300px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
}

.notebook-sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
}

.notebook-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.note-list-item {
  padding: 15px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 10px;
  background: var(--bg-panel);
  transition: all 0.2s;
  border: 1px solid transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.note-list-item-content {
  flex: 1;
  min-width: 0;
}

.notebook-delete-btn {
  display: none;
  background: rgba(255, 50, 50, 0.15);
  border: 1px solid rgba(255, 50, 50, 0.3);
  color: #ff4d4d;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  margin-left: 10px;
}

.notebook-delete-btn:hover {
  background: rgba(255, 50, 50, 0.8);
  color: white;
}

.note-list-item.active .notebook-delete-btn {
  display: flex;
  color: white;
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.note-list-item.active .notebook-delete-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.note-list-item:hover {
  background: var(--bg-panel-hover);
}

.note-list-item.active {
  background: var(--prime-btn);
  color: white;
  border-color: var(--accent-primary);
}

.note-item-title {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item-date {
  font-size: 11px;
  opacity: 0.6;
}

.note-group-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 15px 10px 5px 10px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 5px;
  margin-top: 5px;
}

.note-item-tags {
  font-size: 0.75rem;
  color: #fbbf24; /* yellow for tags */
  font-weight: 500;
  margin-top: 2px;
  margin-bottom: 2px;
}

/* Quill Editor Overrides */
.ql-toolbar.ql-snow {
  border: 1px solid var(--input-border) !important;
  border-radius: 8px 8px 0 0;
  background: var(--input-bg);
}

.ql-toolbar.ql-snow .ql-stroke {
  stroke: var(--text-main) !important;
}

.ql-toolbar.ql-snow .ql-fill {
  fill: var(--text-main) !important;
}

.ql-toolbar.ql-snow .ql-picker {
  color: var(--text-main) !important;
}

.ql-container.ql-snow {
  border: 1px solid var(--input-border) !important;
  border-top: none !important;
  border-radius: 0 0 8px 8px;
  background: var(--input-bg);
  font-family: inherit !important;
  font-size: 1.05rem !important;
  color: var(--text-main);
  display: flex !important;
  flex-direction: column;
  min-height: 0; /* allows shrinking */
}

.ql-editor {
  min-height: 200px;
  flex: 1;
  overflow-y: auto;
}

.notebook-editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 30px 30px 30px;
  background: var(--bg-app);
  overflow: hidden; /* constrain flex children */
}

.notebook-editor-header {
  display: flex;
  align-items: center;
}

@media (max-width: 768px) {
  .notebook-layout {
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    border-radius: 0;
  }
  .notebook-body {
    flex-direction: column;
  }
  .notebook-sidebar {
    width: 100%;
    height: 40%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .notebook-editor-area {
    height: 60%;
    padding: 15px;
  }
}

.calendar-modal-content {
  overflow: hidden;
  background: var(--calendar-bg);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--glass-border);
  border-top: 1px solid var(--c-white-a03);
  box-shadow:
    0 30px 60px var(--c-black-a06),
    inset 0 1px 0 var(--c-white-a01);
}

.calendar-toolbar {
  background: var(--c-black-a02) !important;
  border-bottom: 1px solid var(--c-white-a008) !important;
}

.glass-input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text-main);
  padding: 8px 12px;
  font-family: inherit;
  transition: all 0.2s;
  outline: none;
  color-scheme: dark;
}

.glass-input:focus {
  background: var(--c-white-a01);
  border-color: var(--c-rgba-125-42-232-a05);
  box-shadow: 0 0 15px var(--c-rgba-125-42-232-a02);
}

::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.7;
  cursor: pointer;
  transition: 0.2s;
}

::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* Custom Flatpickr Minimal Glassmorphism Overrides */
.flatpickr-calendar {
  background: var(--calendar-bg) !important;
  border: 1px solid var(--glass-border) !important;
  box-shadow: 0 10px 30px var(--c-black-a05) !important;
  border-radius: 16px !important;
  backdrop-filter: blur(30px) !important;
  -webkit-backdrop-filter: blur(30px) !important;
  color: var(--text-main) !important;
  padding: 10px !important;
  font-family: inherit !important;
  z-index: 10000 !important;
}

.flatpickr-calendar.arrowTop:before,
.flatpickr-calendar.arrowTop:after,
.flatpickr-calendar.arrowBottom:before,
.flatpickr-calendar.arrowBottom:after {
  display: none !important;
}

.flatpickr-months {
  background: transparent !important;
}

.flatpickr-month {
  color: var(--hex-fff) !important;
  height: 40px !important;
}

.flatpickr-current-month {
  padding-top: 5px !important;
  font-size: 1.1rem !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: transparent !important;
  color: var(--hex-fff) !important;
  border: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  outline: none !important;
  pointer-events: none !important; /* Disable dropdown */
  font-weight: 400 !important;
  font-size: 1.2rem !important;
  padding: 0 5px 0 0 !important;
  text-align: right !important;
}

.flatpickr-current-month input.cur-year {
  color: var(--hex-fff) !important;
  font-weight: 400 !important;
  font-size: 1.2rem !important;
  padding: 0 !important;
}

.numInputWrapper span.arrowUp,
.numInputWrapper span.arrowDown {
  display: none !important;
}

span.flatpickr-weekday {
  color: var(--hex-fff) !important;
  font-weight: 300 !important;
  font-size: 1rem !important;
}

.flatpickr-days {
  border: none !important;
}

.dayContainer {
  justify-content: space-around !important;
  min-width: unset !important;
  width: 100% !important;
}

.flatpickr-day {
  color: var(--hex-00e5ff) !important;
  background: transparent !important;
  border: none !important;
  font-weight: 400 !important;
  font-size: 1.1rem !important;
  transition: all 0.2s ease !important;
  border-radius: 50% !important;
  width: 38px !important;
  height: 38px !important;
  line-height: 38px !important;
  margin: 2px !important;
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
  color: var(--c-white-a03) !important;
}

.flatpickr-day:hover,
.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover,
.flatpickr-day:focus {
  background: var(--c-white-a01) !important;
  color: var(--hex-fff) !important;
}

.flatpickr-day.selected,
.flatpickr-day.selected:focus,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--c-rgba-0-229-255-a02) !important;
  border: 1px solid var(--hex-00e5ff) !important;
  color: var(--hex-00e5ff) !important;
  box-shadow: none !important;
  font-weight: 600 !important;
}

.flatpickr-day.today {
  border: 1px dashed var(--c-white-a05) !important;
}

.flatpickr-time {
  border-top: 1px solid var(--c-white-a01) !important;
  margin-top: 10px !important;
  background: transparent !important;
}

.flatpickr-time input {
  color: var(--hex-fff) !important;
  font-weight: 400 !important;
}

.flatpickr-time .flatpickr-time-separator {
  color: var(--c-white-a05) !important;
}

.flatpickr-time input:hover,
.flatpickr-time input:focus {
  background: var(--c-white-a005) !important;
}

.calendar-grid {
  display: flex;
  gap: 12px;
  height: 100%;
  min-height: 500px;
}

.calendar-col {
  display: flex;
  flex: 1;
  flex-direction: column;
  background: var(--c-rgba-20-20-25-a03);
  border-radius: 12px;
  overflow: hidden;
  min-width: 0;
}

.weekend-col .calendar-day-header {
  background: #591a28bd !important;
  border-bottom: 1px solid rgba(255, 0, 24, 0.69) !important;
  color: #fff !important;
}

.calendar-day-header {
  padding: 12px;
  text-align: center;
  background: var(--c-white-a003);
  border-bottom: 1px solid var(--c-white-a005);
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.95em;
  letter-spacing: 0.5px;
}

.calendar-day-header.today {
  background: linear-gradient(
    135deg,
    var(--c-rgba-125-42-232-a03),
    var(--c-rgba-125-42-232-a01)
  );
  color: var(--hex-fff);
  border-bottom: 1px solid var(--c-rgba-125-42-232-a05);
  text-shadow: 0 0 10px var(--c-rgba-125-42-232-a05);
  box-shadow: inset 0 0 15px var(--c-rgba-125-42-232-a02);
}

.calendar-day-body {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-card {
  border-radius: 12px;
  padding: 12px;
  position: relative;
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}

.task-card:hover {
  transform: translateY(-2px);
}

.task-yellow {
  background: var(--hex-ffcc00);
  color: var(--hex-1a1a20);
}
.task-purple {
  background: var(--hex-b794f4);
  color: var(--hex-fff);
}
.task-pink {
  background: var(--hex-ff4757);
  color: var(--hex-fff);
}

.task-card.completed {
  opacity: 0.5;
  background: var(--c-white-a01);
  color: var(--text-muted);
}

.task-card.completed .task-title {
  text-decoration: line-through;
}

.task-title {
  font-size: 0.95em;
  font-weight: 600;
  margin-bottom: 25px; /* space for actions */
  word-wrap: break-word;
  line-height: 1.3;
}

.task-time {
  font-size: 0.85em;
  font-weight: 700;
  margin-bottom: 4px;
  opacity: 0.9;
}

.task-actions {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
}

.task-btn {
  background: transparent;
  border: 1px solid var(--c-white-a04);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.task-yellow .task-btn {
  border-color: var(--c-black-a02);
}

.task-btn:hover {
  background: var(--c-white-a03);
  transform: scale(1.1);
}

.task-yellow .task-btn:hover {
  background: var(--c-black-a01);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100002;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.secretary-toast {
  background: var(--c-rgba-30-30-40-a085);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid var(--c-rgba-125-42-232-a04);
  border-radius: 12px;
  padding: 24px 28px;
  color: white;
  box-shadow: 0 10px 30px var(--c-black-a03);
  display: flex;
  align-items: center;
  gap: 20px;
  animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-ok-btn {
  background: var(--hex-7d2ae8);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
}

.toast-ok-btn:hover {
  background: var(--hex-6b24c6);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Memory Pruning Visual Divider */
.memory-pruned-divider {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: center;
  margin: 30px 0;
  width: 100%;
}

.memory-pruned-divider::before,
.memory-pruned-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    var(--c-rgba-183-148-244-a05),
    transparent
  );
}

.memory-pruned-divider-text {
  color: var(--hex-b794f4);
  font-size: 0.8rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0 15px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* =========================================
   ГЛОБАЛЬНАЯ ПРИВЯЗКА ПЕРЕМЕННЫХ К ЭЛЕМЕНТАМ
   ========================================= */
/* 1. Обновляем переменные для Светлой Темы (добавляем недостающие) */
/* 1. Обновляем переменные для Светлой Темы (добавляем недостающие) */
body.light-theme {
  --chat-user-bg: linear-gradient(
    135deg,
    rgba(161, 196, 253, 0.6) 0%,
    rgba(194, 233, 251, 0.6) 100%
  ) !important; /* Мягкий нежный glassmorphism голубой */
  --modal-bg: rgba(245, 247, 250, 0.85);
  --calendar-bg: rgba(255, 255, 255, 0.75);
  --input-bg: rgba(255, 255, 255, 0.6);
  --input-border: rgba(0, 0, 0, 0.1);
  --slider-track: rgba(0, 0, 0, 0.15);
  --sidebar-item-hover: rgba(0, 0, 0, 0.05);

  --scrollbar-track: rgba(0, 0, 0, 0.05);
  --scrollbar-thumb: rgba(0, 0, 0, 0.2);
  --scrollbar-thumb-hover: var(--accent-primary);
}

/* 2. Модальные окна (Настройки и Календарь) */
.modal-content,
.calendar-modal-content {
  background: var(--modal-bg, rgba(20, 20, 25, 0.95)) !important;
  border: 1px solid var(--glass-border) !important;
  color: var(--text-main) !important;
}

/* 3. Инпуты и Выпадающие списки (Dropdowns) */
.custom-input,
.glass-input {
  height: 40px;
  background: var(--input-bg, rgba(10, 10, 15, 0.4)) !important;
  border: 1px solid var(--input-border, rgba(255, 255, 255, 0.1)) !important;
  color: var(--text-main) !important;
}
.custom-input option {
  background: var(--dropdown-bg, rgba(30, 30, 30, 0.95)) !important;
  color: var(--text-main) !important;
}

/* 4. Ползунки (чтобы трек ползунка был виден на любом фоне) */
.custom-slider {
  background: var(--slider-track, rgba(255, 255, 255, 0.1)) !important;
}

/* 5. Элементы Календаря (Убиваем серые цвета) */
.calendar-col {
  background: var(--sidebar-item-hover, rgba(20, 20, 25, 0.3)) !important;
}
.calendar-toolbar {
  background: transparent !important;
  border-bottom: 1px solid var(--glass-border) !important;
}
.flatpickr-calendar {
  background: var(--calendar-bg, rgba(30, 30, 40, 0.95)) !important;
  color: var(--text-main) !important;
}

/* 6. Сообщения пользователя и отыгрыш действий (em) */
body.light-theme .user-msg .msg-content {
  background: var(--chat-user-bg) !important;
  color: var(
    --text-main
  ) !important; /* Тёмный текст для читаемости на мягком фоне */
}

/* Действия (курсив) внутри сообщений для светлой темы */
body.light-theme .msg-content em {
  color: var(--text-main);
  opacity: 0.8;
  font-weight: 500;
}
/* =========================================
   СВЕТЛАЯ ТЕМА: ТОЧЕЧНЫЕ ФИКСЫ (Иконки, Оверлеи, Календарь)
   ========================================= */

/* Затенение под модалками в светлой теме должно быть светлым, а не траурно-черным */
body.light-theme .modal-overlay,
body.light-theme .calendar-modal-overlay {
  background: var(--c-white-a04);
}

/* Кнопка микрофона выделяется цветом, чтобы не сливаться с белым фоном */
body.light-theme .mic-btn {
  background: var(--c-rgba-125-42-232-a01) !important;
  color: var(--prime-btn) !important;
  border: 1px solid var(--prime-btn) !important;
}

body.light-theme .mic-btn:hover {
  background: var(--prime-btn-hover) !important;
  color: var(--accent-primary) !important;
}

/* Иконки в шапке (Язык, Тема, Разраб) должны быть темными в светлой теме */
body.light-theme .header-action-btn,
body.light-theme .icon-btn {
  color: var(--text-main) !important;
  border-color: var(--c-black-a01) !important;
}

body.light-theme .header-action-btn:hover,
body.light-theme .icon-btn:hover {
  background: var(--c-black-a005) !important;
}

/* Заголовок календаря (Месяц и Год) - убираем белый текст */
body.light-theme .flatpickr-current-month,
body.light-theme .flatpickr-month,
body.light-theme .flatpickr-current-month .flatpickr-monthDropdown-months,
body.light-theme .flatpickr-current-month input.cur-year {
  color: var(--text-main) !important;
}

/* Дни недели в календаре (Пн, Вт, Ср...) */
body.light-theme span.flatpickr-weekday {
  color: var(--text-muted) !important;
}

/* Сами дни в календаре (числа) */
body.light-theme .flatpickr-day {
  color: var(--text-main) !important;
}

/* Неактивные дни (из других месяцев) */
body.light-theme .flatpickr-day.prevMonthDay,
body.light-theme .flatpickr-day.nextMonthDay {
  color: var(--text-muted) !important;
  opacity: 0.5;
}

/* Ховер на дни в календаре */
body.light-theme .flatpickr-day:hover,
body.light-theme .flatpickr-day.prevMonthDay:hover,
body.light-theme .flatpickr-day.nextMonthDay:hover,
body.light-theme .flatpickr-day:focus {
  background: var(--c-black-a005) !important;
  border-color: var(--c-black-a005) !important;
}

/* Инпуты времени в календаре */
body.light-theme .flatpickr-time input,
body.light-theme .flatpickr-time .flatpickr-time-separator {
  color: var(--text-main) !important;
}

body.light-theme .flatpickr-time input:hover,
body.light-theme .flatpickr-time input:focus {
  background: var(--c-black-a005) !important;
}

/* =========================================
   СВЕТЛАЯ ТЕМА: ИСПРАВЛЕНИЯ МОДАЛОК И ИНЛАЙН СТИЛЕЙ
   ========================================= */

/* Заголовки модалок (были бело-фиолетовым градиентом) */
body.light-theme .modal-header h2 {
  background: linear-gradient(
    to right,
    var(--text-main),
    var(--accent-primary)
  ) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

/* Панель инструментов календаря и диапазон дат */
body.light-theme .calendar-toolbar {
  border-bottom-color: var(--c-black-a01) !important;
}
body.light-theme #cal-current-range {
  color: var(--text-main) !important;
}

/* Иконки календаря и глобальных настроек в шапке */
body.light-theme .lang-btn {
  color: var(--text-main) !important;
}

/* =========================================
   VOCABULARY MODAL
   ========================================= */
.vocab-layout {
  display: flex;
  flex-direction: column;
  width: 90vw;
  height: 90vh;
  padding: 0;
  overflow: hidden;
  background: var(--bg-app); /* Use light background for the list */
}

.vocab-item {
  display: flex;
  align-items: center;
  gap: 15px;
  background: var(--bg-panel);
  padding: 12px 20px;
  border-radius: 8px;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  box-shadow: 0 2px 4px var(--c-black-a01);
  position: relative;
}

.vocab-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--c-black-a01);
}

/* allow example line to wrap onto its own row */
.vocab-item {
  flex-wrap: wrap;
}

.vocab-speak-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  margin-left: 8px;
  opacity: 0.65;
  transition:
    opacity 0.2s,
    transform 0.2s;
}

.vocab-speak-btn:hover {
  opacity: 1;
  transform: scale(1.18);
}

.vocab-example {
  width: 100%;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 6px;
  opacity: 0.85;
}

/* Voice preview ("Listen") button in TTS settings */
.voice-preview-btn {
  align-self: flex-start;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
  background: var(--c-white-a01);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.15s;
}

.voice-preview-btn:hover {
  background: var(--c-rgba-125-42-232-a02);
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

.voice-preview-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.vocab-text-eng {
  flex: 1;
  font-weight: 500;
  color: var(--text-main);
  font-size: 1.05rem;
}

.vocab-divider {
  width: 20px;
  height: 1px;
  background: var(--border-color);
}

.vocab-text-rus {
  flex: 1;
  color: var(--text-main);
  font-size: 1.05rem;
}

.vocab-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 5px;
  opacity: 0;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vocab-item:hover .vocab-delete-btn {
  opacity: 1;
}

.vocab-delete-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}
body.light-theme .lang-btn:hover {
  background: var(--c-black-a005) !important;
}

/* Боковое меню вкладок в настройках */
body.light-theme .settings-tab-btn {
  color: var(--text-muted) !important;
}
body.light-theme .settings-tab-btn.active {
  color: var(--prime-btn) !important;
  background: var(--c-rgba-125-42-232-a01) !important;
}

/* Переопределение инлайн-стилей (style="color: var(--c-white-a)") внутри модалок настроек */
body.light-theme .settings-tab-pane p,
body.light-theme .settings-tab-pane h3,
body.light-theme .settings-tab-pane label,
body.light-theme .slider-header label,
body.light-theme .memory-badge,
body.light-theme .memory-badge span {
  color: var(--text-main) !important;
}

/* Нижние границы для заголовков H3 в настройках */
body.light-theme .settings-tab-pane h3 {
  border-bottom-color: var(--c-black-a01) !important;
}

/* Иконки глаз (для паролей) в настройках */
body.light-theme .password-toggle {
  color: var(--text-muted) !important;
}

/* =========================================
   КНОПКА АУДИО ВОСПРОИЗВЕДЕНИЯ (Replay/Play)
   ========================================= */
.replay-btn {
  border: 1px solid var(--c-rgba-125-42-232-a06);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 0 10px var(--c-rgba-125-42-232-a03);
  transition: all 0.2s ease;
  background: var(--c-rgba-125-42-232-a01);
  transform: scale(1);
  color: var(--hex-fff); /* SVG inherits this via currentColor */
}

.replay-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 15px var(--c-rgba-125-42-232-a06);
}

.replay-btn.playing {
  background: var(--c-rgba-125-42-232-a04);
}

body.light-theme .replay-btn {
  color: var(--accent-primary) !important;
  border-color: var(--c-rgba-125-42-232-a02) !important;
  box-shadow: 0 0 5px var(--c-rgba-125-42-232-a02);
}

body.light-theme .replay-btn:hover {
  box-shadow: 0 0 10px var(--c-rgba-125-42-232-a04);
}

/* =========================================
   SPECIAL CODE WINDOW STYLES (GITHUB THEME)
   ========================================= */
pre {
  background: #0d1117; /* GitHub Dark default */
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 40px 16px 16px 16px;
  margin: 15px 0;
  overflow-x: auto;
  position: relative;
  box-shadow: 0 10px 40px 0 rgba(0, 0, 0, 0.4);
}

/* Semi-transparent background for dark mode to keep glass look */
body:not(.light-theme) pre {
  background: rgba(13, 17, 23, 0.85);
}

pre::before {
  content: "Code Window";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  padding-left: 15px;
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

pre code.hljs {
  font-family: "JetBrains Mono", "Fira Code", "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  background: none;
  padding: 0;
  border-radius: 0;
  display: block;
}

/* Scrollbar for code blocks handled by global system */
pre {
  overflow-x: auto;
}

/* Inline code styling */
:not(pre) > code {
  background: rgba(125, 42, 232, 0.15);
  color: #d1adff;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9em;
}

/* LIGHT THEME (GITHUB LIGHT) */
body.light-theme pre {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

body.light-theme pre::before {
  background: rgba(0, 0, 0, 0.03);
  color: rgba(0, 0, 0, 0.4);
  border-bottom-color: rgba(0, 0, 0, 0.05);
}

body.light-theme pre code.hljs {
  background: #ffffff;
}

body.light-theme :not(pre) > code {
  background: rgba(125, 42, 232, 0.08);
  color: #7d2ae8;
}

/* --- Copy Code Button --- */
pre {
  position: relative;
}

.copy-code-btn {
  position: absolute;
  top: 3px;
  right: 4px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: white;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 4px;
  transition:
    opacity 0.2s,
    background 0.2s;
  z-index: 10;
  opacity: 0.3;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

pre:hover .copy-code-btn {
  opacity: 1;
}

.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.copy-code-btn.copied {
  border-color: #00e676;
  color: #00e676;
}

@media screen and (min-width: 769px) {
  .mobileonly {
    display: none !important;
  }
}

/* --- Mobile Responsiveness --- */
@media screen and (max-width: 768px) {
  .app-container {
    width: 100dvw;
    height: 100dvh;
    border-radius: 0;
    gap: 0;
    padding: 0;
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    padding: 0;
    border-radius: 0;
  }

  .header-top-actions {
    position: absolute;
    flex-direction: column;
    width: auto;
    height: 100%;
    z-index: 999;
  }
  .header-top-actions div {
    flex-direction: column;
  }

  .sidebar-header {
    margin-bottom: 0;
  }

  .settings-container,
  .deskonly {
    display: none !important;
  }

  #clear-ui-btn {
    display: none;
  }
  .avatar-wrapper {
    margin: 0 auto;
  }

  .chat-area {
    border-radius: 0;
  }

  .chat-header {
    display: none;
  }

  .chat-header-mobile {
    display: flex;
    padding: 10px;
    position: absolute;
    z-index: 9999;
    top: 0;
    background: var(--bg-app);
    right: 0;
    border-radius: 50%;
    margin: 10px;
  }

  .avatar-container,
  .avatar-img,
  #avatar-video {
    width: 100vw;
    height: 100vw;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
  .avatar-wrapper {
    border-radius: 0;
    width: 100vw;
    height: 75vw;
    padding-top: 50px;
  }

  .visualizer-canvas {
    display: none;
  }

  .chat-messages {
    gap: 8px;
    padding: 15px;
  }
  .message {
    max-width: 100%;
  }

  .msg-content {
    padding: 5px 10px;
  }

  .chat-input-container {
    padding: 0px;
  }

  .input-form {
    display: flex;
    gap: 8px;
    border: none;
    border-radius: 0;
    padding: 5px;
    align-items: flex-start;
  }

  #user-input {
    height: 65px !important;
    max-height: 300px !important;
  }

  .modal-content {
    width: 100dvw !important;
    height: 100dvh !important;
    max-width: 100dvw !important;
    max-height: 100dvh !important;
    border-radius: 0;
    padding: 0;
    margin: 0;
  }

  .modal-header {
    margin-bottom: 0;
    padding: 20px;
  }

  .modal-body {
    flex-direction: column !important;
  }
  .settings-sidebar {
    width: 100dvw !important;
    border-right: 0;
    padding: 10px 0;
    display: flex;
    flex-direction: row !important;
    overflow: auto !important;
  }

  .chat-area.glass-panel {
    border: none !important;
  }

  .topchat {
    --corner-size: 100px;
    --corner-radius: 100px;
    position: absolute;
    width: 100%;
    height: 100px;
    overflow: hidden;
    z-index: 999;
    bottom: -2px;
  }

  .corner {
    position: absolute;
    bottom: 0;
    width: var(--corner-size);
    height: var(--corner-size);
    background-color: transparent;
  }

  .corner--bottom-left {
    left: 0;
    background: radial-gradient(
      circle at 100% 0%,
      transparent var(--corner-radius),
      var(--glass-bg) var(--corner-radius)
    );
  }

  .corner--bottom-right {
    right: 0;
    background: radial-gradient(
      circle at 0% 0%,
      transparent var(--corner-radius),
      var(--glass-bg) var(--corner-radius)
    );
  }
}
