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

:root {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #eaebf0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-sub: #334155;
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  
  --green: #16a34a;
  --green-bg: #dcfce7;
  --orange: #d97706;
  --orange-bg: #fef3c7;
  --blue: #2563eb;
  --blue-bg: #dbeafe;
  
  --item-bg: #fafafa;
  --item-border: #f1f5f9;
}

:root[data-theme="dark"] {
  --bg: #0f172a;
  --card-bg: #1e293b;
  --card-border: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #cbd5e1;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  
  --green: #4ade80;
  --green-bg: rgba(74, 222, 128, 0.15);
  --orange: #fbbf24;
  --orange-bg: rgba(251, 191, 36, 0.15);
  --blue: #60a5fa;
  --blue-bg: rgba(96, 165, 250, 0.15);
  
  --item-bg: #182234;
  --item-border: #2c3b52;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* NAVBAR */
.navbar {
  width: 100%;
  border-bottom: 1px solid var(--card-border);
  background: var(--card-bg);
}

.nav-container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--item-bg);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--card-border);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: flex; align-items: center; justify-content: center; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: flex; align-items: center; justify-content: center; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* MAIN CONTENT */
.main-content {
  max-width: 1180px;
  width: 100%;
  margin: 36px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* PAGE HEADER */
.page-header {
  text-align: center;
}

.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.badge-dot {
  font-size: 10px;
  opacity: 0.7;
}

.main-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 10px;
}

.main-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.5;
}

/* GRID LAYOUT */
.revision-grid {
  display: flex;
  flex-direction: column;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  gap: 24px;
}

.revision-grid.active {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 1180px;
  align-items: start;
}

/* CARDS COMMON */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

/* INPUT CARD */
.input-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.word-counter {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.cefr-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cefr-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.cefr-pills {
  display: flex;
  gap: 8px;
}

.cefr-pill {
  flex: 1;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--item-bg);
  border: 1px solid var(--item-border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.cefr-pill:hover {
  background: var(--card-border);
  color: var(--text);
}

.cefr-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.textarea-container textarea {
  width: 100%;
  min-height: 240px;
  padding: 16px;
  border-radius: 12px;
  background: var(--item-bg);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s ease;
}

.textarea-container textarea:focus {
  border-color: var(--primary);
}

.input-actions {
  display: flex;
  gap: 12px;
}

.btn-primary {
  flex: 1;
  height: 44px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s ease;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.sparkle-icon {
  font-size: 14px;
}

.btn-secondary {
  height: 44px;
  padding: 0 18px;
  background: var(--item-bg);
  border: 1px solid var(--card-border);
  color: var(--text-sub);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--card-border);
  color: var(--text);
}

.privacy-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* OUTPUT CARD & TABS */
.output-card {
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.output-card.active {
  display: flex;
}

.tabs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--card-border);
  padding: 0 20px;
}

.tab-buttons {
  display: flex;
  gap: 20px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 16px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

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

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.level-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
}

.tab-content {
  padding: 20px;
  min-height: 200px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.response-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-sub);
  white-space: pre-wrap;
}

.pane-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.btn-copy {
  background: var(--item-bg);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-copy:hover {
  color: var(--text);
  background: var(--card-border);
}

/* CHANGES LIST */
.changes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.change-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--item-bg);
  border: 1px solid var(--item-border);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-sub);
}

.change-num {
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}

/* PREVIEW SECTION BELOW TABS */
.preview-section {
  padding: 20px;
  border-top: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--card-bg);
}

.preview-card {
  background: var(--item-bg);
  border: 1px solid var(--item-border);
  border-radius: 12px;
  padding: 16px;
}

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

.preview-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.sub-muted {
  font-weight: 400;
  color: var(--text-muted);
}

.preview-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s ease;
}

.preview-link:hover {
  opacity: 0.8;
}

.preview-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.preview-item:hover {
  transform: translateX(3px);
}

.badge-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.badge-icon.green { background: var(--green-bg); color: var(--green); }
.badge-icon.blue { background: var(--blue-bg); color: var(--blue); }
.badge-icon.orange { background: var(--orange-bg); color: var(--orange); }

.preview-text {
  color: var(--text-sub);
  font-size: 13px;
}

.preview-text strong {
  color: var(--text);
  font-weight: 600;
}

.item-arrow {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 16px;
}

.model-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.model-preview-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.model-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.model-preview-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.model-preview-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-outline {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* SPINNER & LOADING */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* MODAL STYLING */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.modal-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  max-width: 520px;
  width: 90%;
  padding: 24px 28px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  transform: translateY(12px);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s ease;
}

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

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.step-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.step-desc {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

.btn-modal-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-modal-primary:hover {
  background: var(--primary-hover);
}

@media (max-width: 900px) {
  .revision-grid { grid-template-columns: 1fr; }
  .model-preview { flex-direction: column; align-items: flex-start; gap: 12px; }
}