@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;
}

.app-footer {
  text-align: center;
  padding: 1rem;
  color: #888;
  font-size: 0.8rem;
  background: rgba(0,0,0,0.2);
}

.bot-navigation {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
  overflow-x: auto;
}

.bot-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  color: #64748b;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.bot-tab:hover {
  background: rgba(15, 23, 42, 0.05);
  color: #0f172a;
}

.bot-tab.active {
  background: #0f172a;
  color: white;
}

/* Writing Tools Layout & Components */
.editor-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding-bottom: 2rem;
  display: flex;
  flex-direction: column;
}

.tools-header h1 {
  font-family: "Fraunces", serif;
  color: #fff; /* Default to white on dark background */
  font-size: 2rem;
  margin: 0;
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .main-content {
    display: grid;
    grid-template-columns: 1fr 280px 1fr;
    align-items: start;
    gap: 1.5rem;
  }
  
  .input-section {
    grid-column: 1;
  }
  
  .tool-panel {
    grid-column: 2;
  }
  
  .result-panel {
    grid-column: 3;
  }
}

/* Tool Panel */
.tool-panel {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  padding: 1.25rem;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.tool-panel h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text);
  font-weight: 600;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  padding-bottom: 0.5rem;
}

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

.tool-section:last-child {
  margin-bottom: 0;
}

.tool-section h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mode-selector select {
  width: 100%;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background-color: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

.tool-button {
  width: 100%;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.tool-button:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--accent-3);
  color: var(--accent-3);
}

.tool-button.primary {
  background: var(--accent-2);
  color: white;
  border: none;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(20, 184, 166, 0.2);
}

.tool-button.primary:hover:not(:disabled) {
  background: #0d9488;
  transform: translateY(-1px);
}

.button-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

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

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

/* Text Editor & Result Panel */
.text-editor, .result-panel {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  padding: 1.5rem;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

.text-area {
  width: 100%;
  flex: 1;
  min-height: 300px;
  padding: 1rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.6;
  resize: vertical;
  font-family: inherit;
}

.text-area:focus {
  outline: none;
  border-color: var(--accent-2);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

.result-header h2 {
  font-size: 1.25rem;
  color: var(--text);
  margin: 0;
}

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

.editor-info {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-button:hover {
  background: var(--surface-3);
  color: var(--text);
}

.icon-button.copied {
  background: var(--accent-2);
  color: white;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
  border: 2px dashed rgba(15, 23, 42, 0.1);
  border-radius: 12px;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(20, 184, 166, 0.2);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

/* History Toggle Button */
.history-toggle-btn {
  font-weight: 500;
  transition: all 0.2s;
}

.history-toggle-btn:hover {
  background: #f1f5f9 !important;
}

.history-toggle-btn.active {
  background: #e0f2fe !important;
  color: #0284c7 !important;
  border-color: #0284c7 !important;
}

/* Dark Mode Support */
body.dark-mode {
  --text: #e0e0e0;
  --bg-color: #121212;
  --card-bg: #1e1e1e;
  --border-color: #333;
}

body.dark-mode .app {
  background: linear-gradient(140deg, rgba(0, 0, 0, 0.98), rgba(20, 20, 20, 0.98));
}

body.dark-mode .app-header {
  background: rgba(30, 30, 30, 0.95);
  border-bottom-color: #333;
}

body.dark-mode .app-header h1 {
  color: #fff;
}

body.dark-mode .bot-navigation {
  background: #1e1e1e;
  border-right-color: #333;
}

body.dark-mode .bot-tab {
  color: #aaa;
}

body.dark-mode .bot-tab:hover {
  background: #2d2d2d;
}

body.dark-mode .bot-tab.active {
  background: #2d2d2d;
  color: #fff;
}

body.dark-mode .editor-container,
body.dark-mode .tool-panel,
body.dark-mode .result-panel,
body.dark-mode .text-editor {
  background: #1e1e1e;
  color: #e0e0e0;
  border-color: #333;
}

body.dark-mode .text-editor textarea,
body.dark-mode .text-area {
  background: #2d2d2d;
  color: #fff;
  border-color: #444;
}

body.dark-mode .text-area:focus {
  border-color: var(--accent-2);
  background: #333;
}

body.dark-mode .tool-button {
  background: #2d2d2d;
  color: #e0e0e0;
  border-color: #444;
}

body.dark-mode .tool-button:hover:not(:disabled) {
  background: #383838;
}

body.dark-mode .mode-selector select {
  background: #2d2d2d;
  color: #fff;
  border-color: #444;
}

body.dark-mode .history-panel {
  background: #1e1e1e;
  border-left-color: #333;
}

body.dark-mode .history-header {
  border-bottom-color: #333;
}

body.dark-mode .history-header h3 {
  color: #fff;
}

body.dark-mode .history-item {
  background: #2d2d2d;
  border-color: #333;
}

body.dark-mode .history-item:hover {
  background: #383838;
}

body.dark-mode .item-text {
  color: #ccc;
}

body.dark-mode .history-panel.empty {
  color: #666;
}
/* Shared Feature Layouts */
.feature-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.feature-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .feature-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 2rem;
  }
  
  /* Full width for single column layouts */
  .feature-content.single-column {
    display: block;
    max-width: 800px;
    margin: 0 auto;
  }
}

.input-panel,
.result-panel-full {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  padding: 1.5rem;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-panel h2,
.result-panel-full h2 {
  font-family: "Fraunces", serif;
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.description {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  line-height: 1.6;
}

.action-button {
  background: var(--accent-2);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  align-self: flex-start;
  margin-top: 0.5rem;
}

.action-button:hover:not(:disabled) {
  background: #0d9488;
  transform: translateY(-1px);
}

.action-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Analysis Results */
.score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--surface-2);
  border-radius: 12px;
  margin-bottom: 1.5rem;
  text-align: center;
}

.score-number {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.5rem;
}

/* Result Items (Citations, Slides, etc.) */
.citation-box {
  background: white;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  margin-bottom: 1rem;
  transition: all 0.2s;
}

.citation-box:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

body.dark-mode .citation-box {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.citation-box h4 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  color: var(--text);
  font-weight: 600;
}

.citation-text {
  font-family: monospace;
  background: var(--surface-2);
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

body.dark-mode .citation-text {
  background: rgba(0, 0, 0, 0.2);
}

.copy-citation-btn {
  background: transparent;
  color: var(--accent-2);
  border: 1px solid var(--accent-2);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-citation-btn:hover {
  background: var(--accent-2);
  color: white;
}

.score-label {
  font-weight: 600;
  letter-spacing: 0.5px;
  font-size: 0.9rem;
}

.risk-high { color: #ef4444; background: rgba(239, 68, 68, 0.1); }
.risk-medium { color: #f59e0b; background: rgba(245, 158, 11, 0.1); }
.risk-low { color: #10b981; background: rgba(16, 185, 129, 0.1); }

.analysis-section {
  margin-top: 1.5rem;
}

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

.analysis-section ul {
  list-style: none;
  padding: 0;
}

.analysis-section li {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

.positive-indicator { color: #10b981; }
.negative-indicator { color: #ef4444; }

/* AI Chat Layout */
.chat-container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.chat-header {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.5);
}

.chat-header h2 {
  font-size: 1.25rem;
  margin: 0 0 0.25rem 0;
}

.chat-header p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.message {
  display: flex;
  gap: 1rem;
  max-width: 85%;
}

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
}

.message-content {
  background: var(--surface-2);
  padding: 1rem;
  border-radius: 12px;
  border-top-left-radius: 2px;
  position: relative;
}

.message.user .message-content {
  background: var(--accent-3);
  color: white;
  border-radius: 12px;
  border-top-right-radius: 2px;
}

.message-text {
  line-height: 1.5;
}

.message-time {
  font-size: 0.7rem;
  margin-top: 0.5rem;
  opacity: 0.7;
  text-align: right;
}

.chat-input-container {
  padding: 1.25rem;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.5);
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: var(--surface);
  resize: none;
  font-family: inherit;
  line-height: 1.5;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-3);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.chat-send-button {
  padding: 0.75rem 1.25rem;
  background: var(--accent-3);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  height: 48px;
}

.chat-send-button:hover:not(:disabled) {
  background: #0284c7;
}

.chat-send-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-welcome {
  text-align: center;
  margin: auto;
  max-width: 500px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.suggestion-chips button {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
  transition: all 0.2s;
}

.suggestion-chips button:hover {
  background: var(--surface-2);
  border-color: var(--accent-3);
}

.typing-indicator span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  margin: 0 2px;
  animation: typing 1.4s infinite ease-in-out both;
}

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

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

/* Dark Mode Overrides */
body.dark-mode .input-panel,
body.dark-mode .result-panel-full,
body.dark-mode .chat-container {
  background: #1e1e1e;
  border-color: #333;
}

body.dark-mode .input-panel h2,
body.dark-mode .result-panel-full h2,
body.dark-mode .chat-header h2 {
  color: #fff;
}

body.dark-mode .description,
body.dark-mode .chat-header p {
  color: #aaa;
}

body.dark-mode .score-display {
  background: #2d2d2d;
}

body.dark-mode .chat-header,
body.dark-mode .chat-input-container {
  background: #1e1e1e;
  border-color: #333;
}

body.dark-mode .chat-input {
  background: #2d2d2d;
  color: #fff;
  border-color: #444;
}

body.dark-mode .message-content {
  background: #2d2d2d;
  color: #e0e0e0;
}

body.dark-mode .message.user .message-content {
  background: var(--accent-3);
  color: white;
}

body.dark-mode .suggestion-chips button {
  background: #2d2d2d;
  border-color: #444;
  color: #e0e0e0;
}

body.dark-mode .suggestion-chips button:hover {
  background: #383838;
}

body.dark-mode .analysis-section h3 {
  color: #fff;
}

body.dark-mode .form-input,
body.dark-mode .form-select,
body.dark-mode .text-area {
  background: #2d2d2d;
  border-color: #444;
  color: #fff;
}

body.dark-mode .form-input:focus,
body.dark-mode .form-select:focus,
body.dark-mode .text-area:focus {
  border-color: var(--accent-2);
  background: #333;
}

body.dark-mode .form-group label {
  color: #e0e0e0;
}
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none; /* Allow clicking through container */
}

.toast {
  pointer-events: auto; /* Re-enable clicks on toasts */
  display: flex;
  align-items: center;
  background: white;
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 300px;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-left: 4px solid transparent;
  animation: slideIn 0.3s ease-out forwards;
  transition: all 0.3s ease;
}

.toast-success {
  border-left-color: #10b981;
}

.toast-error {
  border-left-color: #ef4444;
}

.toast-info {
  border-left-color: #3b82f6;
}

.toast-icon {
  margin-right: 12px;
  display: flex;
  align-items: center;
  font-size: 1.2rem;
}

.toast-success .toast-icon { color: #10b981; }
.toast-error .toast-icon { color: #ef4444; }
.toast-info .toast-icon { color: #3b82f6; }

.toast-message {
  flex: 1;
  font-size: 0.95rem;
  color: #1f2937;
  font-weight: 500;
}

.toast-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px;
  margin-left: 8px;
  transition: color 0.2s;
  display: flex;
  align-items: center;
}

.toast-close:hover {
  color: #4b5563;
}

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

/* Dark mode support */
body.dark-mode .toast {
  background: #1e1e1e;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .toast-message {
  color: #e5e7eb;
}

body.dark-mode .toast-close {
  color: #6b7280;
}

body.dark-mode .toast-close:hover {
  color: #9ca3af;
}
.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: 200px;
    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;
}
/* Writing Tools Layout */
.tools-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

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

@media (min-width: 1024px) {
  .tools-layout.with-history {
    display: grid;
    grid-template-columns: 1fr 320px;
    align-items: start;
    gap: 1.5rem;
  }

  .main-content {
    display: grid;
    grid-template-columns: 1fr 280px 1fr;
    align-items: start;
    gap: 1.5rem;
  }
 
  .input-section {
    grid-column: 1;
  }
  
  .tool-panel {
    grid-column: 2;
  }
  
  .result-panel {
    grid-column: 3;
  }
}

.history-sidebar {
  width: 100%;
  height: calc(100vh - 200px);
  max-height: 800px;
  position: sticky;
  top: 20px;
  border: 1px solid #eee;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface, #fff);
}

/* Tools Header */
.tools-header {
  margin-bottom: 1.5rem;
}

.tools-header h1 {
  font-family: "Fraunces", serif;
  color: #ffffff;
  font-size: 2rem;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Tool Panel */
.tool-panel {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  padding: 1.25rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  color: #0f172a; /* Force dark text */
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tool-panel h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: #0f172a;
  font-weight: 700;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  padding-bottom: 0.5rem;
}

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

.tool-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

/* Buttons & Inputs */
.mode-selector select {
  width: 100%;
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
  color: #0f172a;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
}

.mode-selector select:focus {
  border-color: #14b8a6;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.tool-button {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #334155;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.tool-button:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.tool-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tool-button.primary {
  background: #14b8a6; /* Teal 500 */
  color: white;
  border: none;
  box-shadow: 0 4px 6px -1px rgba(20, 184, 166, 0.3);
}

.tool-button.primary:hover:not(:disabled) {
  background: #0d9488; /* Teal 600 */
  box-shadow: 0 6px 8px -1px rgba(20, 184, 166, 0.4);
}

.button-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

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

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

/* Text Editor & Result Panel */
.text-editor, .result-panel {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  padding: 1.5rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  min-height: 500px;
  color: #0f172a;
}

.text-area {
  width: 100%;
  flex: 1;
  min-height: 400px;
  padding: 1.25rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 1.05rem;
  line-height: 1.7;
  resize: vertical;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}

.text-area:focus {
  border-color: #14b8a6;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.result-header h2 {
  font-size: 1.25rem;
  color: #0f172a;
  margin: 0;
  font-weight: 700;
}

/* History Toggle */
.history-toggle-btn {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
}

.history-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2) !important;
}

.history-toggle-btn.active {
  background: #e0f2fe !important;
  color: #0284c7 !important;
}

/* Dark Mode Overrides */
body.dark-mode .tool-panel,
body.dark-mode .text-editor,
body.dark-mode .result-panel {
  background: #1e293b; /* Slate 800 */
  border-color: #334155;
  color: #f1f5f9;
}

body.dark-mode .text-area {
  background: #0f172a; /* Slate 900 */
  border-color: #334155;
  color: #f1f5f9;
}

body.dark-mode .text-area:focus {
  border-color: #14b8a6;
}

body.dark-mode .tool-button {
  background: #334155;
  border-color: #475569;
  color: #f1f5f9;
}

body.dark-mode .tool-button:hover:not(:disabled) {
  background: #475569;
}

body.dark-mode .tool-panel h3,
body.dark-mode .result-header h2,
body.dark-mode .tool-section h4 {
  color: #f1f5f9;
  border-color: #334155;
}

body.dark-mode .mode-selector select {
  background: #334155;
  border-color: #475569;
  color: #f1f5f9;
}
.history-panel {
  background: white;
  border-left: 1px solid #e0e0e0;
  padding: 1rem;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.history-panel.empty {
  align-items: center;
  justify-content: center;
  color: #888;
}

.empty-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
}

.history-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #333;
}

.clear-btn {
  background: none;
  border: none;
  color: #ff4d4f;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.clear-btn:hover {
  background: #fff1f0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  padding: 0.75rem;
  background: #f9f9f9;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.history-item:hover {
  background: #fff;
  border-color: #4caf50;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
}

.badge {
  padding: 0.15rem 0.4rem;
  border-radius: 12px;
  text-transform: capitalize;
  font-weight: 500;
  background: #e0e0e0;
  color: #555;
}

.badge-paraphrase { background: #e3f2fd; color: #1976d2; }
.badge-grammar { background: #e8f5e9; color: #2e7d32; }
.badge-summarize { background: #fff3e0; color: #ef6c00; }
.badge-humanize { background: #f3e5f5; color: #7b1fa2; }

.timestamp {
  color: #999;
}

.item-text {
  margin: 0;
  font-size: 0.85rem;
  color: #444;
  line-height: 1.4;
}
