/* ==========================================================================
   Plagiano Studio - Design System & Modern CSS
   ========================================================================== */

:root {
  /* Color Palette - Dark Mode Default */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.72);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-primary: #6366f1;       /* Indigo */
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #10b981;     /* Emerald */
  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-rose: #ef4444;

  --glass-bg: rgba(17, 24, 39, 0.65);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(241, 245, 249, 0.95);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.4);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(0, 0, 0, 0.06);
  --glass-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}

/* Base Resets */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Ambient Background Lights */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.15;
}

.bg-glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
  top: -100px;
  left: 10%;
}

.bg-glow-2 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, var(--accent-secondary) 0%, transparent 70%);
  top: 30%;
  right: 5%;
}

.bg-glow-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
  bottom: 5%;
  left: 20%;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-purple) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.logo-icon svg {
  width: 26px;
  height: 26px;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.engine-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.engine-badge:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.engine-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-secondary);
  box-shadow: 0 0 8px var(--accent-secondary);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* ==========================================================================
   Main Container & Hero Banner
   ========================================================================== */
.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  position: relative;
  z-index: 1;
}

.banner-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(16, 185, 129, 0.05) 100%), var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  backdrop-filter: blur(12px);
  box-shadow: var(--glass-shadow);
}

.banner-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  margin-bottom: 0.5rem;
}

.banner-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}

.banner-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 850px;
  line-height: 1.55;
}

.banner-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 240px;
}

.pill-btn {
  padding: 0.55rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.pill-btn:hover {
  border-color: var(--accent-primary);
  background: var(--bg-card-hover);
  transform: translateX(3px);
}

/* ==========================================================================
   Toolbar & Modes
   ========================================================================== */
.toolbar-section {
  margin-bottom: 1.25rem;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.mode-tab {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.mode-tab:hover {
  border-color: rgba(99, 102, 241, 0.4);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.mode-tab.active {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.05) 100%), var(--bg-secondary);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
}

.mode-tab.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}

.mode-icon {
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
}

.mode-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.mode-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

/* Length Retention & Volume Control Bar */
.length-options-bar {
  margin-top: 0.85rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  transition: var(--transition);
}

.length-control-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.length-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-primary);
  white-space: nowrap;
}

.length-icon {
  font-size: 1.05rem;
}

.length-select-wrapper {
  position: relative;
}

.length-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 2rem 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  transition: var(--transition);
}

.length-select:hover,
.length-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.length-info-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.badge-page {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
}

/* ==========================================================================
   Workspace Grid (Dual Panels)
   ========================================================================== */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.editor-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(14px);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  transition: var(--transition);
}

.editor-panel:focus-within {
  border-color: var(--border-focus);
}

.panel-header {
  padding: 0.85rem 1.25rem;
  background: rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
}

.badge-primary {
  background: rgba(99, 102, 241, 0.18);
  color: var(--accent-primary);
}

.badge-success {
  background: rgba(16, 185, 129, 0.18);
  color: var(--accent-secondary);
}

.badge-neutral {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.badge-outline {
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.badge-interactive {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  cursor: help;
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tool-btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.tool-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.tool-btn.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.tool-btn-primary {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.35);
  color: var(--accent-primary);
}

.tool-btn-primary:hover {
  background: var(--accent-primary);
  color: #fff;
}

/* Export Dropdown */
.export-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.btn-export-toggle {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(5, 150, 105, 0.12));
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--accent-secondary);
}

.btn-export-toggle:hover {
  background: var(--accent-secondary);
  color: #fff;
  border-color: var(--accent-secondary);
}

.export-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  min-width: 290px;
  z-index: 100;
  overflow: hidden;
  backdrop-filter: blur(16px);
  animation: fadeIn 0.18s ease-out;
}

.export-dropdown-menu.show {
  display: flex;
  flex-direction: column;
}

.export-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.export-menu-item:last-child {
  border-bottom: none;
}

.export-menu-item:hover {
  background: var(--bg-card-hover);
  color: var(--accent-primary);
}

.export-menu-item .menu-icon {
  font-size: 1.35rem;
  flex-shrink: 0;
}

.export-menu-item .menu-text-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.export-menu-item .menu-title {
  font-size: 0.85rem;
  font-weight: 700;
}

.export-menu-item .menu-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Drag & Drop Highlight */
.textarea-wrapper.drag-over {
  border: 2px dashed var(--accent-primary) !important;
  background: rgba(99, 102, 241, 0.08) !important;
}

/* Textarea & Rendered View Containers */
.textarea-wrapper {
  position: relative;
  min-height: 380px;
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

textarea {
  width: 100%;
  flex: 1;
  min-height: 380px;
  padding: 1.25rem;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-main);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
}

textarea::placeholder {
  color: var(--text-muted);
}

.output-rendered-view,
.output-diff-view {
  padding: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-primary);
  flex: 1;
  min-height: 380px;
  white-space: pre-wrap;
}

.placeholder-text {
  color: var(--text-muted);
  font-style: italic;
}

/* Interactive Sentence Styling in Output */
.sentence-interactive {
  display: inline;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.18s ease;
  position: relative;
}

.sentence-interactive:hover {
  background-color: rgba(99, 102, 241, 0.25);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4);
}

/* Diff Styling */
.diff-add {
  background-color: rgba(16, 185, 129, 0.22);
  color: #34d399;
  text-decoration: none;
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 500;
}

.diff-del {
  background-color: rgba(239, 68, 68, 0.22);
  color: #f87171;
  text-decoration: line-through;
  padding: 0 2px;
  border-radius: 3px;
  opacity: 0.75;
}

/* Panel Footer */
.panel-footer {
  padding: 0.85rem 1.25rem;
  background: rgba(0, 0, 0, 0.1);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.counter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.separator {
  color: var(--text-muted);
}

.primary-action-btn {
  padding: 0.65rem 1.35rem;
  font-size: 0.88rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-purple) 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  transition: var(--transition);
}

.primary-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.primary-action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.secondary-action-btn {
  padding: 0.55rem 1.15rem;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.secondary-action-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

/* ==========================================================================
   Radar & Metrics Boxes
   ========================================================================== */
.radar-box {
  padding: 1.25rem;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.15);
}

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

.radar-header h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.score-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
}

.score-neutral {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.score-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.score-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.score-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-secondary);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.radar-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-val {
  font-size: 1.1rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.text-success {
  color: var(--accent-secondary);
}

.stat-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.35rem;
}

.stat-bar-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.fill-success {
  background: var(--accent-secondary);
}

.fill-danger {
  background: var(--accent-rose);
}

.fill-warning {
  background: var(--accent-amber);
}

/* Rhythm Visualizer */
.rhythm-wrapper {
  margin-top: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
}

.rhythm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.65rem;
}

.rhythm-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.rhythm-bar {
  width: 14px;
  min-width: 14px;
  background: var(--accent-primary);
  border-radius: 3px 3px 0 0;
  position: relative;
  transition: height 0.3s ease;
  cursor: pointer;
}

.rhythm-bar:hover::after {
  content: attr(data-words) ' kata';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  margin-bottom: 4px;
}

.rhythm-bar.output-bar {
  background: var(--accent-secondary);
}

/* Diagnosis List */
.diagnosis-items {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.diagnosis-item {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.diagnosis-item.danger {
  background: rgba(239, 68, 68, 0.1);
  border-left: 3px solid var(--accent-rose);
}

.diagnosis-item.warning {
  background: rgba(245, 158, 11, 0.1);
  border-left: 3px solid var(--accent-amber);
}

.diagnosis-item.info {
  background: rgba(99, 102, 241, 0.1);
  border-left: 3px solid var(--accent-primary);
}

.diagnosis-item strong {
  font-weight: 700;
}

/* ==========================================================================
   Modals & Drawers
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 620px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
}

.close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Form inputs in Modals */
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.setting-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.form-select,
.form-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.form-select:focus,
.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.setting-alert {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  color: var(--accent-secondary);
  line-height: 1.5;
}

/* Sentence Options in Modal */
.sentence-current-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.box-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 0.35rem;
  display: block;
}

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

.sentence-option-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sentence-option-card:hover {
  border-color: var(--accent-primary);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.option-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  align-self: flex-start;
}

.option-text {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-primary);
}

/* History List */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-item:hover {
  border-color: var(--accent-primary);
  background: var(--bg-card-hover);
}

.history-snippet {
  font-size: 0.85rem;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1e1b4b;
  color: #fff;
  border: 1px solid var(--accent-primary);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transform: translateY(100px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 200;
}

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

/* Animation */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
  .banner-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .radar-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Academic Manuscript Generator Styles
   ========================================================================== */

.primary-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #ffffff;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  transition: var(--transition);
}

.primary-nav-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.pill-btn-primary {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(139, 92, 246, 0.25) 100%);
  border: 1px solid rgba(99, 102, 241, 0.5);
  color: var(--text-primary);
  font-weight: 700;
}

.pill-btn-primary:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.45) 0%, rgba(139, 92, 246, 0.45) 100%);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.modal-card-lg {
  max-width: 720px;
  width: 92%;
}

.modal-card-md {
  max-width: 540px;
  width: 90%;
}

.modal-title-with-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.badge-accent {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.gen-input-mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  background: var(--bg-tertiary);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.gen-mode-tab {
  flex: 1;
  text-align: center;
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: none;
  outline: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
}

.gen-mode-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.gen-mode-tab.active {
  background: var(--accent-primary);
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.form-textarea-topic {
  width: 100%;
  background: var(--bg-primary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.95rem;
  line-height: 1.55;
  resize: vertical;
  min-height: 90px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.form-textarea-topic::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.form-textarea-topic:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background: var(--bg-secondary);
}

.required-star {
  color: var(--accent-rose);
}

.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.gen-features-box {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 1rem;
}

.gen-feature-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.gen-feature-item strong {
  color: var(--text-primary);
  display: inline;
  margin-right: 0.35rem;
}

.gen-feature-icon {
  font-size: 1.15rem;
  line-height: 1.2;
}

/* Stepped Progress Bar */
.stepped-progress-container {
  margin: 1.25rem 0 1rem 0;
}

.progress-bar-track {
  width: 100%;
  height: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill-animated {
  height: 100%;
  background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 50%, #10b981 100%);
  background-size: 200% 100%;
  animation: shimmerProgress 2s linear infinite;
  border-radius: 999px;
  transition: width 0.4s ease-in-out;
}

@keyframes shimmerProgress {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.progress-percent-label {
  display: flex;
  justify-content: flex-end;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-top: 0.4rem;
}

.generator-active-log {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.log-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text-primary);
}

.log-spinner {
  display: inline-block;
  animation: spin 1.2s linear infinite;
}

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

.progress-note-box {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
