@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  font-family: "Space Grotesk", system-ui, sans-serif;
  line-height: 1.5;
  font-weight: 400;
  color: #0f172a;
  background-color: #0f172a;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  --bg-1: #0f172a;
  --bg-2: #0b3b4c;
  --bg-3: #0a2a2f;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #f59e0b;
  --accent-2: #14b8a6;
  --accent-3: #0ea5e9;
  --ring: rgba(20, 184, 166, 0.35);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.25);
  --shadow-md: 0 14px 28px rgba(15, 23, 42, 0.18);
  --shadow-sm: 0 6px 16px rgba(15, 23, 42, 0.12);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh; /* Use dynamic viewport height for mobile */
  background: radial-gradient(circle at 20% 20%, rgba(20, 184, 166, 0.2), transparent 50%),
    radial-gradient(circle at 80% 10%, rgba(245, 158, 11, 0.25), transparent 45%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
  /* Prevent horizontal scroll */
  overflow-x: hidden;
  /* Improve touch scrolling */
  -webkit-overflow-scrolling: touch;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font-family: inherit;
}
* {
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(140deg, rgba(15, 23, 42, 0.98), rgba(8, 47, 73, 0.98));
  overflow: hidden;
  width: 100%;
  position: relative;
}

.app::before,
.app::after {
  content: '';
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(0px);
  opacity: 0.3;
  z-index: 0;
}

.app::before {
  background: radial-gradient(circle, rgba(20, 184, 166, 0.35), transparent 65%);
  top: -200px;
  right: -120px;
}

.app::after {
  background: radial-gradient(circle, rgba(245, 158, 11, 0.35), transparent 65%);
  bottom: -240px;
  left: -120px;
}

@media (max-width: 768px) {
  .app {
    height: 100dvh; /* Use dynamic viewport height on mobile */
    min-height: 100dvh;
  }
}

.app-header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  padding: 1rem 1.75rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
}

.logo {
  text-align: left;
}

.logo h1 {
  font-family: "Fraunces", serif;
  font-size: clamp(1.4rem, 3vw, 2.1rem);
  color: var(--text);
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.logo .subtitle {
  font-size: clamp(0.75rem, 1.8vw, 0.95rem);
  color: var(--accent-2);
  font-weight: 600;
  display: block;
  margin-top: 0.35rem;
}

.app-main {
  flex: 1;
  padding: 1.25rem;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  z-index: 1;
  -webkit-overflow-scrolling: touch;
}

.editor-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  flex: 1;
  min-height: 0;
  height: 100%;
}

@media (min-width: 768px) {
  .app-main {
    padding: 1.5rem;
  }

  .editor-container {
    padding: 2rem;
  }
}

@media (min-width: 1024px) {
  .app-main {
    padding: 2rem;
  }

  .editor-container {
    grid-template-columns: 1fr auto 1fr;
  }
}

/* Large tablet and small desktop */
@media (min-width: 1024px) and (max-width: 1279px) {
  .editor-container {
    grid-template-columns: 1fr auto 1fr;
    gap: 2rem;
  }

  .tool-panel {
    min-width: 260px;
    max-width: 300px;
  }
}

.input-section,
.result-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.input-section h2,
.result-header h2,
.input-panel h2,
.result-panel-full h2 {
  font-family: "Fraunces", serif;
  font-size: clamp(1.2rem, 2.8vw, 1.7rem);
  color: var(--text);
  margin-bottom: 1rem;
  line-height: 1.25;
}

.feature-container h2 {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  line-height: 1.3;
}

.feature-container h3 {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  line-height: 1.3;
}

.text-editor,
.result-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.text-area {
  width: 100%;
  max-width: 100%;
  padding: 0.95rem 1rem;
  border: 1.5px solid rgba(15, 23, 42, 0.15);
  border-radius: var(--radius-md);
  font-size: 0.98rem;
  line-height: 1.65;
  resize: none;
  font-family: inherit;
  transition: border-color 0.3s;
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

@media (min-width: 768px) {
  .text-area {
    padding: 1rem;
    font-size: 1rem;
  }
}

.text-area:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px var(--ring);
}

.text-area::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.text-area.result {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.86));
  color: #f8fafc;
  font-weight: 500;
}

.editor-info {
  margin-top: 0.5rem;
  text-align: right;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.tool-panel {
  width: 100%;
  border: none;
  border-top: 1px solid rgba(15, 23, 42, 0.1);
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
  padding: 1.5rem 0;
  overflow-y: visible;
  max-height: none;
}

@media (min-width: 1024px) {
  .tool-panel {
    min-width: 280px;
    max-width: 320px;
    border: none;
    border-left: 1px solid rgba(15, 23, 42, 0.1);
    border-right: 1px solid rgba(15, 23, 42, 0.1);
    padding: 0 1.5rem;
    overflow-y: auto;
    max-height: 700px;
  }
}

.tool-panel h3 {
  font-family: "Fraunces", serif;
  font-size: 1.3rem;
  color: var(--text);
  margin-bottom: 1.5rem;
  text-align: center;
}

.tool-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.tool-section:last-child {
  border-bottom: none;
}

.tool-section h4 {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.mode-selector {
  margin-bottom: 0.75rem;
}

.mode-selector select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid rgba(15, 23, 42, 0.18);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.3s;
}

.mode-selector select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--ring);
}

.tool-button {
  width: 100%;
  padding: 0.8rem 1rem;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 10px 20px rgba(14, 165, 233, 0.22);
}

.tool-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 24px rgba(14, 165, 233, 0.28);
}

.tool-button:focus {
  outline: 3px solid rgba(14, 165, 233, 0.6);
  outline-offset: 2px;
}

.tool-button:disabled {
  background: #999;
  color: #fff;
  cursor: not-allowed;
  opacity: 0.7;
  pointer-events: none;
}

.tool-button.primary {
  background: linear-gradient(135deg, var(--accent), #f97316);
  box-shadow: 0 12px 24px rgba(245, 158, 11, 0.3);
}

.tool-button.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 16px 28px rgba(245, 158, 11, 0.35);
}

.tool-button.small {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

.button-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

@media (min-width: 480px) {
  .button-group {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .button-group {
    grid-template-columns: repeat(3, 1fr);
  }
}

.button-group-vertical {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

@media (min-width: 480px) {
  .button-group-vertical {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .button-group-vertical {
    display: flex;
    flex-direction: column;
  }
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.result-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-button {
  padding: 0.55rem;
  background: rgba(15, 23, 42, 0.9);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  box-shadow: var(--shadow-sm);
}

.icon-button:hover {
  transform: translateY(-2px);
  background: rgba(15, 23, 42, 1);
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
  flex: 1;
  min-height: 200px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(15, 23, 42, 0.08);
  border-top: 4px solid var(--accent-2);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
  flex: 1;
  min-height: 200px;
}

.empty-state p {
  margin: 0.5rem 0;
  font-size: 1rem;
  font-weight: 500;
}

.empty-state .hint {
  font-size: 0.9rem;
  color: #94a3b8;
}

.app-footer {
  background: rgba(255, 255, 255, 0.9);
  padding: 0.875rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: clamp(0.75rem, 2vw, 0.9rem);
  line-height: 1.5;
  margin-top: auto;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(10px);
}

@media (min-width: 768px) {
  .app-footer {
    padding: 1rem 2rem;
  }
}

/* Additional responsive utilities */
@media (max-width: 479px) {
  .tool-button.small {
    padding: 0.625rem;
    font-size: 0.8rem;
  }

  .result-actions {
    gap: 0.375rem;
  }

  .icon-button {
    min-width: 44px;
  }

  .tool-panel h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
  }

  .tool-section {
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
  }

  .tool-section h4 {
    font-size: 0.95rem;
    margin-bottom: 0.625rem;
  }

  .mode-selector select {
    padding: 0.625rem;
    font-size: 0.875rem;
  }
}

/* Better spacing for small screens */
@media (max-width: 640px) {
  .app-main {
    padding: 0.75rem;
  }

  .editor-container {
    padding: 1rem;
    gap: 1rem;
    border-radius: 8px;
  }

  .result-header h2,
  .input-section h2 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
  }

  .text-area {
    font-size: 1rem;
    line-height: 1.65;
    padding: 0.875rem;
    border-radius: 6px;
  }

  .editor-info {
    font-size: 0.875rem;
    margin-top: 0.625rem;
  }

  .feature-container h2,
  .chat-container h2,
  .translator-container h2,
  .citation-container h2 {
    font-size: 1.25rem;
    line-height: 1.3;
  }

  .feature-container h3,
  .chat-container h3,
  .translator-container h3,
  .citation-container h3 {
    font-size: 1.1rem;
    line-height: 1.4;
  }
}

/* Bot Navigation */
.bot-navigation {
  background: rgba(255, 255, 255, 0.88);
  padding: 0.85rem 0.75rem;
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  overflow-y: hidden;
  box-shadow: var(--shadow-sm);
  flex-wrap: nowrap;
  justify-content: flex-start;
  position: sticky;
  top: 68px;
  z-index: 90;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-2) rgba(15, 23, 42, 0.08);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(12px);
}

.bot-navigation::-webkit-scrollbar {
  height: 6px;
}

.bot-navigation::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.08);
  border-radius: 3px;
}

.bot-navigation::-webkit-scrollbar-thumb {
  background: var(--accent-2);
  border-radius: 3px;
}

.bot-navigation::-webkit-scrollbar-thumb:hover {
  background: #0d9488;
}

.bot-tab {
  padding: 0.75rem 1.1rem;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid rgba(15, 23, 42, 0.14);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: fit-content;
}

.bot-tab:focus {
  outline: 3px solid rgba(20, 184, 166, 0.6);
  outline-offset: 2px;
}

.bot-tab span {
  display: none;
}

.bot-tab svg {
  font-size: 1.25rem;
}

.bot-tab:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.bot-tab.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
  color: white;
  border-color: transparent;
  box-shadow: 0 10px 20px rgba(14, 165, 233, 0.3);
}

@media (max-width: 480px) {
  .bot-navigation {
    padding: 0.75rem 0.625rem;
    gap: 0.5rem;
    top: auto;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05), 0 2px 10px rgba(0, 0, 0, 0.05);
  }

  .bot-tab {
    padding: 0.75rem 1rem;
    min-width: 52px;
    min-height: 52px;
    border-width: 2px;
  }

  .bot-tab svg {
    font-size: 1.375rem;
  }

  /* Add scroll indicator for bot navigation */
  .bot-navigation::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.95), transparent);
    pointer-events: none;
  }
}

@media (min-width: 481px) and (max-width: 639px) {
  .bot-navigation {
    top: 68px;
  }
}

@media (min-width: 640px) {
  .bot-navigation {
    padding: 1rem 1rem;
    gap: 0.5rem;
  }

  .bot-tab {
    font-size: 0.875rem;
    padding: 0.75rem 1.125rem;
  }

  .bot-tab span {
    display: inline;
  }
}

@media (min-width: 1024px) {
  .bot-navigation {
    padding: 1rem 2rem;
    flex-wrap: wrap;
    justify-content: center;
    overflow-x: visible;
  }

  .bot-tab {
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
  }
}

/* Coming Soon Section */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-muted);
  flex: 1;
  min-height: 300px;
}

.coming-soon svg {
  color: var(--accent-2);
  margin-bottom: 1.5rem;
  opacity: 0.6;
}

.coming-soon h2 {
  color: var(--text);
  margin-bottom: 1rem;
  font-size: 2rem;
}

.coming-soon p {
  color: #94a3b8;
  font-size: 1.1rem;
  max-width: 500px;
}

/* Tab Navigation (Legacy) */
.tab-nav {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.tab-button {
  padding: 0.75rem 1.5rem;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.tab-button:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
  transform: translateY(-2px);
}

.tab-button.active {
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent-3) 100%);
  color: white;
  border-color: var(--accent-2);
}

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

/* Feature Containers */
.feature-container {
  background: rgba(255, 255, 255, 0.96);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  max-width: 100%;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .feature-container {
    padding: 2rem;
  }
}

.feature-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 768px) {
  .feature-content {
    grid-template-columns: 1fr 1fr;
  }
}

.input-panel,
.result-panel-full {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.description {
  color: #1f2937;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
}

@media (min-width: 768px) {
  .description {
    font-size: 0.95rem;
  }
}

.action-button {
  margin-top: 1rem;
  padding: 1rem;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent-3) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.action-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.action-button:disabled {
  background: #999;
  color: #fff;
  cursor: not-allowed;
  opacity: 0.7;
}

/* Plagiarism & AI Detector Results */
.score-display {
  text-align: center;
  padding: 2rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
}

.score-display.risk-low {
  background: linear-gradient(135deg, #4caf50 0%, #81c784 100%);
  color: white;
}

.score-display.risk-medium {
  background: linear-gradient(135deg, #ff9800 0%, #ffb74d 100%);
  color: white;
}

.score-display.risk-high {
  background: linear-gradient(135deg, #f44336 0%, #e57373 100%);
  color: white;
}

.score-number {
  font-size: clamp(2.25rem, 8vw, 3rem);
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.score-label {
  font-size: clamp(1rem, 3.5vw, 1.2rem);
  font-weight: 600;
}

@media (max-width: 640px) {
  .score-display {
    padding: 1.5rem 1rem;
    margin-bottom: 1rem;
  }

  .analysis-section {
    margin-bottom: 1rem;
    padding: 0.875rem;
  }

  .analysis-section h3 {
    font-size: 1rem;
    margin-bottom: 0.625rem;
  }

  .analysis-section p,
  .analysis-section li {
    font-size: 0.875rem;
  }

  .segment-item {
    padding: 0.875rem;
    margin-bottom: 0.625rem;
  }

  .segment-text {
    font-size: 0.9rem;
  }

  .segment-reason {
    font-size: 0.85rem;
  }
}

.analysis-section {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #6c757d;
  border-radius: 8px;
  color: white;
}

.analysis-section h3 {
  color: white;
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

.analysis-section p {
  color: white;
  line-height: 1.7;
  font-size: 0.95rem;
}

.analysis-section ul {
  margin-left: 1.5rem;
}

.analysis-section li {
  margin-bottom: 0.5rem;
  color: white;
  font-size: 0.95rem;
  line-height: 1.6;
}

.segment-item {
  background: white;
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  border-left: 4px solid #ff9800;
}

.segment-text {
  font-style: italic;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.segment-reason {
  font-size: 0.9rem;
  color: #1f2937;
  line-height: 1.5;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.positive-indicator {
  color: #4caf50 !important;
}

.negative-indicator {
  color: #f44336 !important;
}

/* Chat Interface */
.chat-container {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

@media (min-width: 768px) {
  .chat-container {
    padding: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .chat-container {
    padding: 2rem;
  }
}

.chat-header {
  margin-bottom: 1rem;
  text-align: center;
}

@media (min-width: 768px) {
  .chat-header {
    margin-bottom: 1.5rem;
  }
}

.chat-header h2 {
  color: var(--text);
  margin-bottom: 0.5rem;
  font-size: clamp(1.25rem, 3vw, 1.5rem);
}

.chat-header p {
  color: var(--text-muted);
  font-size: clamp(0.85rem, 2vw, 0.95rem);
  line-height: 1.5;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  background: #6c757d;
  border-radius: 8px;
  margin-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
  color: white;
  /* Ensure messages scroll to bottom on mobile */
  scroll-behavior: smooth;
}

@media (min-width: 768px) {
  .chat-messages {
    padding: 1rem;
  }
}

/* Auto-scroll to bottom when new message arrives on mobile */
@media (max-width: 768px) {
  .chat-messages {
    padding-bottom: 1rem;
  }
}

.chat-welcome {
  text-align: center;
  padding: 1rem;
}

@media (min-width: 768px) {
  .chat-welcome {
    padding: 2rem;
  }
}

.chat-welcome h3 {
  color: white;
  margin-bottom: 1rem;
  font-size: clamp(1.1rem, 3vw, 1.25rem);
}

@media (min-width: 768px) {
  .chat-welcome h3 {
    margin-bottom: 1.5rem;
  }
}

.suggestion-chips {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (min-width: 640px) {
  .suggestion-chips {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

.suggestion-chips button {
  padding: 0.875rem;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 0.85rem;
  text-align: left;
}

@media (min-width: 768px) {
  .suggestion-chips button {
    padding: 1rem;
    font-size: 0.9rem;
  }
}

.suggestion-chips button:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
  transform: translateY(-2px);
}

.message {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  animation: fadeIn 0.3s;
}

@media (min-width: 768px) {
  .message {
    gap: 1rem;
    margin-bottom: 1.5rem;
  }
}

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

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent-3) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .message-avatar {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #4caf50 0%, #81c784 100%);
}

.message-content {
  flex: 1;
  background: white;
  padding: 0.75rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  min-width: 0;
  word-wrap: break-word;
}

@media (min-width: 768px) {
  .message-content {
    padding: 1rem;
  }
}

.message.user .message-content {
  background: #5c7cfa;
}

.message-text {
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
}

.message.user .message-content .message-text {
  color: white;
}

@media (min-width: 768px) {
  .message-text {
    font-size: 1rem;
  }
}

.message-time {
  font-size: 0.75rem;
  color: #999;
}

.message.user .message-content .message-time {
  color: rgba(255, 255, 255, 0.9);
}

@media (min-width: 768px) {
  .message-time {
    font-size: 0.8rem;
  }
}

.typing-indicator {
  display: flex;
  gap: 0.5rem;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--accent-2);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-10px); }
}

.chat-input-container {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: nowrap;
  position: sticky;
  bottom: 0;
  background: white;
  padding-top: 0.75rem;
  z-index: 10;
}

@media (min-width: 768px) {
  .chat-input-container {
    gap: 1rem;
    position: relative;
    padding-top: 0;
  }
}

.chat-input {
  flex: 1;
  padding: 0.875rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  transition: border-color 0.3s;
  min-width: 0;
  background: white;
  color: var(--text);
}

@media (min-width: 768px) {
  .chat-input {
    padding: 1rem;
    font-size: 1rem;
  }
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-send-button {
  padding: 0.875rem 1.5rem;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent-3) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .chat-send-button {
    padding: 1rem 2rem;
    font-size: 1rem;
  }
}

.chat-send-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.chat-send-button:disabled {
  background: #999;
  color: #fff;
  cursor: not-allowed;
  opacity: 0.7;
}

/* Translator */
.translator-container {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
  .translator-container {
    padding: 2rem;
  }
}

.translator-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .translator-controls {
    flex-direction: row;
    align-items: center;
  }
}

.language-selector {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.language-selector label {
  font-weight: 600;
  color: #555;
  font-size: 0.9rem;
}

.language-selector select {
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.3s;
}

@media (min-width: 768px) {
  .language-selector select {
    font-size: 1rem;
  }
}

.language-selector select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.swap-button {
  padding: 1rem;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
  transition: all 0.3s;
  margin-top: 0;
  align-self: center;
}

@media (min-width: 640px) {
  .swap-button {
    margin-top: 1.5rem;
    font-size: 1.5rem;
  }
}

.swap-button:hover:not(:disabled) {
  border-color: var(--accent-2);
  color: var(--accent-2);
  transform: rotate(180deg);
}

.swap-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.translator-panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .translator-panels {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
}

.translator-panel h3 {
  color: var(--text);
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

/* Citation Generator */
.citation-container {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
  .citation-container {
    padding: 2rem;
  }
}

.citation-form {
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .citation-form {
    margin-bottom: 2rem;
  }
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-weight: 600;
  color: #555;
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  .form-group label {
    font-size: 0.9rem;
  }
}

.form-group input,
.form-group select {
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.3s;
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .form-group input,
  .form-group select {
    font-size: 1rem;
  }
}

@media (max-width: 640px) {
  .form-group input,
  .form-group select {
    font-size: 16px;
    padding: 0.875rem;
  }
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.citation-results {
  border-top: 2px solid rgba(15, 23, 42, 0.08);
  padding-top: 2rem;
}

.citation-results h3 {
  color: var(--text);
  margin-bottom: 1.5rem;
}

.citation-box {
  background: #6c757d;
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  position: relative;
  color: white;
}

.citation-box h4 {
  color: white;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.citation-text {
  color: var(--text);
  line-height: 1.6;
  padding: 1rem;
  background: white;
  border-radius: 6px;
  font-family: 'Georgia', serif;
  margin-bottom: 1rem;
}

.copy-citation-btn {
  padding: 0.5rem 1rem;
  background: var(--accent-2);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
}

.copy-citation-btn:hover {
  background: #0ea5e9;
  transform: translateY(-2px);
}

.citation-notes {
  background: #fff3cd;
  padding: 1rem;
  border-radius: 8px;
  border-left: 4px solid #ffc107;
}

.citation-notes h4 {
  color: #856404;
  margin-bottom: 0.5rem;
}

.citation-notes p {
  color: #856404;
  font-size: 0.95rem;
}

/* Image & Video Generator */
.generated-image-container,
.generated-video-container {
  background: #6c757d;
  padding: 1rem;
  border-radius: 8px;
  margin: 1.5rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.generated-image {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.generated-video {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.image-actions,
.video-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.image-result h3,
.video-result h3 {
  color: var(--text);
  margin-bottom: 1rem;
}

.feature-examples {
  margin-top: 2rem;
  text-align: left;
}

.feature-examples h4 {
  color: #555;
  margin-bottom: 1rem;
}

.feature-examples ul {
  list-style: none;
  padding: 0;
}

.feature-examples li {
  padding: 0.75rem;
  background: #6c757d;
  margin-bottom: 0.5rem;
  border-radius: 6px;
  border-left: 3px solid var(--accent-2);
  color: white;
  font-size: 0.95rem;
  line-height: 1.5;
}

.info-box {
  background: #5c7cfa;
  padding: 1.5rem;
  border-radius: 8px;
  border-left: 4px solid #2196f3;
  color: white;
}

.info-box h4 {
  color: white;
  margin-bottom: 0.5rem;
}

.info-box p {
  color: white;
  font-size: 0.95rem;
  margin: 0;
  line-height: 1.6;
}

/* Mobile-specific adjustments */
@media (max-width: 767px) {
  .image-actions,
  .video-actions {
    flex-direction: column;
    gap: 0.75rem;
  }

  .action-button {
    width: 100%;
  }

  .citation-box {
    padding: 1rem;
  }

  .citation-text {
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  .info-box {
    padding: 1rem;
  }

  .feature-examples li {
    padding: 0.625rem;
    font-size: 0.9rem;
  }

  .feature-container {
    padding: 1.25rem;
  }

  .feature-content {
    gap: 1.5rem;
  }

  .chat-container {
    padding: 1.25rem;
  }

  .translator-container,
  .citation-container {
    padding: 1.25rem;
  }

  .form-group label {
    font-size: 0.85rem;
  }

  .form-group input,
  .form-group select {
    padding: 0.625rem;
    font-size: 0.9rem;
  }

  .chat-input {
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  .chat-send-button {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 1.125rem;
  }

  .message-content {
    padding: 0.625rem;
  }

  .message-text {
    font-size: 0.875rem;
  }

  .message-time {
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  .feature-container {
    padding: 1rem;
  }

  .translator-controls {
    gap: 0.75rem;
  }

  .swap-button {
    padding: 0.875rem;
    font-size: 1.125rem;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .bot-tab,
  .tool-button,
  .action-button,
  .icon-button,
  .chat-send-button,
  .subscribe-button,
  .logout-button,
  button {
    min-height: 44px;
    min-width: 44px;
  }

  .tool-button.small {
    min-height: 44px;
    padding: 0.75rem 1rem;
  }

  .icon-button {
    padding: 0.75rem;
    min-height: 44px;
    min-width: 44px;
  }

  /* Improve tap target spacing */
  .button-group {
    gap: 0.625rem;
  }

  /* Better text selection on mobile */
  .text-area,
  .chat-input {
    -webkit-user-select: text;
    user-select: text;
  }
}

/* Enhanced mobile button sizing */
@media (max-width: 640px) {
  .tool-button {
    padding: 0.875rem 1.125rem;
    font-size: 0.9375rem;
    min-height: 48px;
    font-weight: 600;
  }

  .tool-button.small {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    min-height: 48px;
  }

  .icon-button {
    padding: 0.75rem;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .action-button {
    padding: 1rem 1.25rem;
    font-size: 1rem;
    min-height: 50px;
    font-weight: 600;
  }

  .chat-send-button {
    min-height: 48px;
    padding: 0.875rem 1.5rem;
  }
}

/* Subscription Header Styles */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.subscribe-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent-3) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  white-space: nowrap;
}

.subscribe-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.subscribe-button:active {
  transform: translateY(0);
}

.subscription-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.crown-icon {
  color: #b8860b;
  font-size: 1.25rem;
  animation: shine 2s infinite;
}

@keyframes shine {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

.status-text {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.logout-button {
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.1);
  color: var(--text);
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-button:hover {
  background: rgba(0, 0, 0, 0.15);
}

/* Responsive header */
@media (max-width: 640px) {
  .app-header {
    padding: 0.75rem 0.875rem;
    gap: 0.625rem;
    min-height: auto;
    flex-wrap: nowrap;
  }

  .logo h1 {
    font-size: 1.125rem;
  }

  .logo .subtitle {
    font-size: 0.7rem;
    margin-top: 0.125rem;
  }

  .header-actions {
    gap: 0.5rem;
    flex-shrink: 0;
  }

  .subscribe-button {
    padding: 0.625rem 0.875rem;
    font-size: 0.8rem;
    gap: 0.375rem;
    min-height: 44px;
  }

  .subscribe-button span {
    display: inline;
  }

  .subscription-status {
    padding: 0.625rem 0.875rem;
    gap: 0.5rem;
  }

  .crown-icon {
    font-size: 1rem;
  }

  .status-text {
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .logout-button {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    min-height: 36px;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .app-header {
    flex-direction: row;
    align-items: center;
    padding: 0.75rem 0.875rem;
    gap: 0.5rem;
    flex-wrap: nowrap;
  }

  .logo {
    text-align: left;
    flex: 1;
    min-width: 0;
  }

  .logo h1 {
    font-size: 1.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .logo .subtitle {
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    flex-shrink: 0;
  }

  .subscribe-button,
  .subscription-status {
    min-height: 48px;
    font-size: 0.85rem;
    padding: 0.625rem 1rem;
  }

  .subscribe-button span {
    display: none;
  }

  .status-text {
    display: none;
  }

  .subscription-status {
    padding: 0.75rem;
  }
}
/* ===== TEXT CONTRAST AND COLOR RULES ===== */

/* Default text colors for white/light backgrounds */
.mode-selector select,
.feature-container,
.chat-container,
.translator-container,
.citation-container,
input:not([type="submit"]):not([type="button"]),
select,
textarea:not(.result),
.text-area:not(.result) {
  background: white;
  color: var(--text);
}

/* White background with dark text */
.segment-item,
.segment-text,
.segment-reason,
.citation-text,
.suggestion-chips button,
.message-content,
.swap-button {
  background: white;
  color: var(--text);
}

/* Dark/grey backgrounds with white text */
.text-area.result,
.analysis-section,
.analysis-section h3,
.analysis-section h4,
.analysis-section p,
.analysis-section ul,
.analysis-section li,
.chat-messages,
.citation-box,
.citation-box h4,
.citation-box p,
.generated-image-container,
.generated-video-container,
.feature-examples li,
.subscription-features,
.subscription-features h3,
.subscription-features ul,
.subscription-features li,
.message.user .message-content,
.message.user .message-content .message-text,
.message.user .message-content .message-time,
.info-box,
.info-box h4,
.info-box p {
  color: white;
}

/* Headings and labels */
.result-panel h2,
.input-section h2,
.tool-panel h3,
.tool-section h4,
label {
  color: var(--text);
}

/* Helper text and info */
.editor-info,
.description,
.hint,
.loading,
.empty-state,
.empty-state p,
.empty-state .hint {
  color: var(--text-muted);
}

/* Placeholder text */
.text-area::placeholder,
.chat-input::placeholder {
  color: #999;
}

/* Assistant messages should be readable */
.message:not(.user) .message-content {
  background: white;
  color: var(--text);
}

.message:not(.user) .message-text,
.message:not(.user) .message-time {
  color: var(--text);
}

/* Mobile overflow and scrolling improvements */
@media (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.1);
  }

  input,
  textarea,
  select {
    font-size: 16px !important;
  }

  .feature-container,
  .chat-container,
  .translator-container,
  .citation-container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .feature-content {
    width: 100%;
    overflow-x: hidden;
  }

  h1, h2, h3, h4, h5, h6 {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }

  p, li, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
}

/* Improve scrolling on mobile */
@media (max-width: 640px) {
  .app-main {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .chat-messages,
  .result-content {
    -webkit-overflow-scrolling: touch;
  }

  .bot-navigation {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  /* Ensure all interactive elements have proper touch targets */
  button,
  .bot-tab,
  .tool-button,
  .action-button,
  .icon-button,
  select {
    min-height: 44px;
    min-width: 44px;
  }

  /* Improve form control sizing */
  input[type="text"],
  input[type="email"],
  input[type="url"],
  textarea,
  select {
    font-size: 16px !important;
    min-height: 44px;
  }

  /* Better button spacing in groups */
  .button-group {
    gap: 0.75rem;
  }

  /* Prevent text from causing overflow */
  h1, h2, h3, h4, h5, h6,
  p, span, div, button {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }
}

/* Prevent horizontal scroll on very small screens */
@media (max-width: 400px) {
  html,
  body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
  }

  .app,
  .app-main,
  .editor-container,
  .feature-container,
  .chat-container {
    max-width: 100vw;
    overflow-x: hidden;
    width: 100%;
  }

  .subscription-modal {
    max-width: 100vw;
    padding: 1.25rem;
    border-radius: 16px 16px 0 0;
  }

  /* Make logo more compact on tiny screens */
  .logo h1 {
    font-size: 1rem;
  }

  .logo .subtitle {
    font-size: 0.65rem;
  }

  /* Adjust button padding for very small screens */
  .subscribe-button,
  .logout-button {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Ensure all containers respect viewport width */
  * {
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* Additional overflow prevention */
@media (max-width: 640px) {
  /* Prevent all containers from overflowing */
  .editor-container,
  .feature-container,
  .chat-container,
  .translator-container,
  .citation-container,
  .tool-panel,
  .input-section,
  .result-panel,
  .result-panel-full,
  .input-panel {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  /* Ensure content within containers doesn't overflow */
  .text-area,
  .chat-input,
  .translator-panels,
  .citation-form {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Fix table and pre elements that might overflow */
  table {
    width: 100%;
    overflow-x: auto;
    display: block;
  }

  pre, code {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
  }

  /* Ensure images don't overflow */
  img {
    max-width: 100%;
    height: auto;
    display: block;
  }

  /* Ensure all media elements are responsive */
  video,
  iframe,
  embed,
  object {
    max-width: 100%;
    height: auto;
  }

  /* Improve readability on mobile */
  .text-area,
  .message-text,
  .analysis-section p,
  .description,
  .citation-text {
    line-height: 1.7;
    font-size: 1rem;
  }

  /* Better spacing for mobile */
  .app-header,
  .bot-navigation,
  .app-footer {
    position: sticky;
  }

  /* Improve visibility on mobile */
  .tool-button,
  .action-button {
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  /* Better focus states for accessibility */
  button:focus,
  input:focus,
  textarea:focus,
  select:focus {
    outline: 3px solid var(--accent-2);
    outline-offset: 2px;
  }

  /* Prevent double-tap zoom on buttons */
  button,
  .bot-tab,
  .tool-button,
  .action-button {
    touch-action: manipulation;
  }

  /* Improve scrollable areas on iOS */
  .chat-messages,
  .result-content,
  .translator-container,
  .citation-container {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  /* Better label and form text */
  label,
  .form-group label {
    font-size: 0.9375rem;
    font-weight: 600;
  }

  /* Improve input field sizing */
  input,
  select,
  textarea {
    font-size: 1rem !important;
  }

  /* Better keyboard handling on mobile */
  input:focus,
  textarea:focus,
  select:focus {
    scroll-margin-top: 100px;
  }

  /* Improve scrolling when keyboard appears */
  .app-main {
    padding-bottom: env(safe-area-inset-bottom, 1rem);
  }
}

/* Tablet portrait optimizations */
@media (min-width: 481px) and (max-width: 1023px) and (orientation: portrait) {
  .editor-container {
    grid-template-columns: 1fr;
  }

  .tool-panel {
    order: 2;
    border-top: 1px solid rgba(15, 23, 42, 0.1);
    border-bottom: 1px solid rgba(15, 23, 42, 0.1);
    padding: 1.5rem 0;
  }

  .input-section {
    order: 1;
  }

  .result-panel {
    order: 3;
  }
}

/* Tablet landscape optimizations */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: landscape) {
  .editor-container {
    grid-template-columns: 1fr auto 1fr;
  }

  .tool-panel {
    min-width: 240px;
    max-width: 280px;
    border-left: 1px solid rgba(15, 23, 42, 0.1);
    border-right: 1px solid rgba(15, 23, 42, 0.1);
    border-top: none;
    border-bottom: none;
    padding: 0 1.25rem;
  }
}

/* Enhanced mobile layout for better UX */
@media (max-width: 480px) {
  /* Compact spacing on very small screens */
  .editor-container,
  .feature-container {
    gap: 1rem;
  }

  .tool-section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
  }

  /* Better button groups on tiny screens */
  .button-group {
    grid-template-columns: 1fr;
  }

  .button-group .tool-button {
    width: 100%;
  }

  /* Improve modal sizing on small screens */
  .subscription-modal {
    max-width: 100vw;
    padding: 1.25rem;
    border-radius: 16px 16px 0 0;
  }

  /* Better chat interface on mobile */
  .chat-input-container {
    flex-direction: column;
    gap: 0.5rem;
  }

  .chat-send-button {
    width: 100%;
  }

  /* Improve form layouts */
  .translator-controls,
  .citation-form .form-row {
    flex-direction: column;
  }

  /* Better footer on very small screens */
  .app-footer {
    padding: 0.75rem 0.75rem;
    font-size: 0.75rem;
  }

  /* Ensure inputs don't zoom on iOS */
  input[type="text"],
  input[type="email"],
  input[type="url"],
  input[type="number"],
  input[type="tel"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* Tablet-specific styles (between mobile and desktop) */
@media (min-width: 481px) and (max-width: 1023px) {
  .app-main {
    padding: 1.25rem;
  }

  .editor-container {
    padding: 1.5rem;
    gap: 1.5rem;
  }

  .bot-navigation {
    flex-wrap: wrap;
    justify-content: center;
    overflow-x: visible;
  }

  .bot-tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
  }

  .bot-tab span {
    display: inline;
  }

  .feature-content {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .tool-panel {
    border-top: 1px solid rgba(15, 23, 42, 0.1);
    border-bottom: 1px solid rgba(15, 23, 42, 0.1);
    border-left: none;
    border-right: none;
    padding: 1.5rem 0;
  }

  .button-group {
    grid-template-columns: repeat(2, 1fr);
  }

  .button-group-vertical {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Additional mobile-specific improvements */
@media (max-width: 768px) {
  /* Improve bot navigation scrolling */
  .bot-navigation {
    scroll-snap-type: x mandatory;
  }

  .bot-tab {
    scroll-snap-align: start;
  }

  /* Better container heights on mobile */
  .editor-container,
  .feature-container,
  .chat-container {
    max-height: calc(100dvh - 180px);
  }

  /* Improve chat message spacing */
  .message {
    margin-bottom: 1rem;
  }

  /* Better tool panel spacing */
  .tool-panel {
    padding: 1rem 0;
  }

  /* Improve result panel spacing */
  .result-panel {
    margin-top: 0.5rem;
  }

  /* Prevent body scroll when modal is open */
  body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }
}

/* Landscape mode optimizations for mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .app-main {
    padding: 0.5rem;
  }

  .editor-container,
  .feature-container,
  .chat-container {
    padding: 0.875rem;
    max-height: calc(100dvh - 120px);
  }

  .app-header {
    padding: 0.5rem 1rem;
    min-height: 56px;
  }

  .logo h1 {
    font-size: 1.1rem;
  }

  .logo .subtitle {
    font-size: 0.7rem;
  }

  .bot-navigation {
    padding: 0.5rem;
    top: 56px;
  }

  .bot-tab {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  .bot-tab span {
    display: none;
  }

  /* Reduce vertical spacing in landscape */
  .tool-panel {
    padding: 0.75rem 0;
  }

  .tool-section {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
  }

  /* Make text areas more compact */
  .text-area {
    min-height: 80px;
  }
}

/* Improve accessibility for mobile users */
@media (max-width: 768px) {
  /* Increase contrast on focus */
  *:focus-visible {
    outline: 3px solid var(--accent-2);
    outline-offset: 3px;
  }

  /* Better hover states converted to active states for touch */
  .tool-button:active,
  .action-button:active,
  .bot-tab:active {
    transform: scale(0.98);
  }

  /* Improve loading states visibility */
  .spinner {
    width: 60px;
    height: 60px;
    border-width: 5px;
  }

  /* Prevent text selection on buttons for better touch experience */
  button,
  .bot-tab {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(20, 184, 166, 0.2);
  }

  /* Improve scrolling performance */
  .app-main,
  .editor-container,
  .feature-container,
  .chat-container,
  .chat-messages,
  .result-content {
    will-change: scroll-position;
    transform: translateZ(0);
  }
}

/* Fix for notch and safe areas on mobile */
@supports (padding: max(0px)) {
  .app {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }

  .app-header {
    padding-left: max(1rem, calc(1rem + env(safe-area-inset-left)));
    padding-right: max(1rem, calc(1rem + env(safe-area-inset-right)));
    padding-top: max(1rem, calc(1rem + env(safe-area-inset-top)));
  }

  .bot-navigation {
    padding-left: max(0.5rem, calc(0.5rem + env(safe-area-inset-left)));
    padding-right: max(0.5rem, calc(0.5rem + env(safe-area-inset-right)));
  }

  .app-footer {
    padding-left: max(1rem, calc(1rem + env(safe-area-inset-left)));
    padding-right: max(1rem, calc(1rem + env(safe-area-inset-right)));
    padding-bottom: max(1rem, calc(1rem + env(safe-area-inset-bottom)));
  }

  .subscription-modal-overlay {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}
.trial-banner {
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.trial-info {
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent-3) 100%);
  color: white;
}

.trial-warning {
  background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
  color: white;
}

.trial-exceeded {
  background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
  color: white;
}

.admin-banner {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  color: var(--text);
}

.trial-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.trial-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.trial-text {
  flex: 1;
  min-width: 200px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.trial-text strong {
  font-weight: 700;
}

.trial-email-button,
.trial-subscribe-button {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid white;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.trial-email-button:hover,
.trial-subscribe-button:hover {
  background: white;
  color: var(--accent-2);
}

.trial-exceeded .trial-subscribe-button:hover {
  color: #f44336;
}

.trial-email-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.trial-email-input {
  padding: 0.5rem 0.75rem;
  border: 2px solid white;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 0.875rem;
  min-width: 200px;
}

.trial-email-input:focus {
  outline: none;
  background: white;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.trial-email-submit,
.trial-email-cancel {
  padding: 0.5rem 0.75rem;
  border: 2px solid white;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.trial-email-submit {
  background: white;
  color: var(--accent-2);
}

.trial-email-submit:hover {
  background: rgba(255, 255, 255, 0.9);
}

.trial-email-cancel {
  background: transparent;
  color: white;
}

.trial-email-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Responsive design */
@media (max-width: 640px) {
  .trial-banner {
    padding: 1rem;
    margin-bottom: 0.875rem;
    border-radius: 8px;
  }

  .trial-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.875rem;
  }

  .trial-icon {
    font-size: 1.375rem;
  }

  .trial-text {
    min-width: 0;
    width: 100%;
    font-size: 1rem;
    line-height: 1.6;
  }

  .trial-email-button,
  .trial-subscribe-button {
    width: 100%;
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    min-height: 48px;
  }

  .trial-email-form {
    width: 100%;
    gap: 0.625rem;
  }

  .trial-email-input {
    width: 100%;
    min-width: 0;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    min-height: 48px;
  }

  .trial-email-submit,
  .trial-email-cancel {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    min-height: 48px;
  }
}

@media (max-width: 480px) {
  .trial-banner {
    padding: 0.875rem;
  }

  .trial-content {
    gap: 0.75rem;
  }

  .trial-text {
    font-size: 0.9375rem;
  }
}
.ad-slideshow-container {
  width: 100%;
  max-width: 360px;
  margin: 18px auto;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 14px 26px rgba(15, 23, 42, 0.15);
  position: relative;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.ad-content {
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ad-image-container {
    width: 100%;
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.05), rgba(255, 255, 255, 0));
    overflow: hidden;
    padding: 12px;
}

.ad-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.4s ease;
}

.ad-content:hover .ad-image {
  transform: scale(1.04);
}

.ad-label {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(15, 23, 42, 0.8);
  color: white;
  padding: 4px 8px;
  font-size: 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ad-indicators {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.9);
}

.indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.2);
  cursor: pointer;
  transition: background-color 0.3s;
}

.indicator.active {
  background: #14b8a6;
}

@media (max-width: 768px) {
    .ad-slideshow-container {
        max-width: 100%;
        margin: 10px 0;
    }
    
    .ad-image-container {
        height: 150px;
    }
}

/* Tablet optimizations */
@media (min-width: 481px) and (max-width: 1023px) {
    .ad-slideshow-container {
        max-width: 100%;
        margin: 12px auto;
    }
    
    .ad-image-container {
        height: 180px;
    }
}

/* Ensure images are responsive */
.ad-image {
    width: 100%;
    height: auto;
    object-fit: contain;
}
.subscription-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease-in-out;
}

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

.subscription-modal {
  background: white;
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease-out;
}

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

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 5px 10px;
  transition: color 0.2s, transform 0.2s;
}

.modal-close:hover {
  color: var(--text);
  transform: scale(1.1);
}

.modal-header {
  text-align: center;
  margin-bottom: 30px;
}

.modal-header h2 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px 0;
}

.modal-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  margin: 0;
}

.subscription-features {
  background: #6c757d;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 25px;
  color: white;
}

.subscription-features h3 {
  font-size: 18px;
  font-weight: 600;
  color: white;
  margin: 0 0 15px 0;
}

.subscription-features ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.subscription-features li {
  font-size: 14px;
  color: white;
  line-height: 1.6;
}

.subscription-pricing {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent-3) 100%);
  border-radius: 12px;
  color: white;
}

.price-tag {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin-bottom: 10px;
}

.currency {
  font-size: 24px;
  font-weight: 600;
  margin-top: 5px;
}

.amount {
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
}

.period {
  font-size: 18px;
  font-weight: 500;
  align-self: flex-end;
  margin-left: 5px;
  margin-bottom: 8px;
}

.price-description {
  margin: 0;
  font-size: 14px;
  opacity: 0.95;
}

.payment-section {
  margin-bottom: 25px;
}

.paypal-button-container {
  position: relative;
}

.paypal-loading,
.payment-processing {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
}

.payment-error-box {
  background: #fee;
  border: 1px solid #fcc;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  color: #c33;
  text-align: center;
}

.payment-error-box p {
  margin: 0;
  font-size: 14px;
}

.payment-success {
  text-align: center;
  padding: 40px 20px;
}

.success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent-3) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: white;
  animation: successPulse 0.5s ease-out;
}

@keyframes successPulse {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.payment-success h2 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 15px 0;
}

.payment-success p {
  font-size: 16px;
  color: var(--text-muted);
  margin: 0;
}

.modal-footer {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.secure-payment {
  font-size: 14px;
  color: #555;
  font-weight: 500;
  margin: 0 0 10px 0;
}

.terms {
  font-size: 12px;
  color: #999;
  margin: 0;
  line-height: 1.5;
}

/* Responsive design */
@media (max-width: 640px) {
  .subscription-modal-overlay {
    padding: 0;
    align-items: flex-end;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .subscription-modal {
    padding: 25px 20px;
    max-height: 95vh;
    max-height: 95dvh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    width: 100%;
    margin: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-close {
    top: 12px;
    right: 12px;
    font-size: 30px;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

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

  .modal-header h2 {
    font-size: 24px;
    line-height: 1.3;
  }

  .modal-subtitle {
    font-size: 15px;
    line-height: 1.5;
  }

  .subscription-features {
    padding: 20px;
    margin-bottom: 20px;
  }

  .subscription-features h3 {
    font-size: 17px;
    margin-bottom: 12px;
  }

  .subscription-features ul {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .subscription-features li {
    font-size: 14px;
    line-height: 1.6;
  }

  .subscription-pricing {
    padding: 20px;
    margin-bottom: 20px;
  }

  .amount {
    font-size: 40px;
  }

  .currency {
    font-size: 22px;
  }

  .period {
    font-size: 17px;
  }

  .price-description {
    font-size: 14px;
  }

  .payment-section {
    margin-bottom: 20px;
  }

  .payment-success {
    padding: 30px 20px;
  }

  .success-icon {
    width: 75px;
    height: 75px;
    font-size: 42px;
    margin-bottom: 18px;
  }

  .payment-success h2 {
    font-size: 26px;
    margin-bottom: 14px;
  }

  .payment-success p {
    font-size: 15px;
    line-height: 1.5;
  }

  .modal-footer {
    padding-top: 18px;
  }

  .secure-payment {
    font-size: 14px;
  }

  .terms {
    font-size: 12px;
    line-height: 1.5;
  }
}

@media (max-width: 400px) {
  .subscription-modal {
    padding: 20px 15px;
  }

  .modal-header h2 {
    font-size: 20px;
  }

  .amount {
    font-size: 32px;
  }
}

/* Ensure no white-on-white text */
.subscription-modal * {
  color: inherit;
}

.subscription-modal {
  color: var(--text);
}

.paypal-button-container * {
  color: var(--text) !important;
}

/* Force white text on grey backgrounds in subscription modal */
.subscription-features {
  color: white !important;
}

.subscription-features h3,
.subscription-features ul,
.subscription-features li {
  color: white !important;
}
