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

:root {
  --bg: #0f0f0f;
  --card: #1a1a1a;
  --card-hover: #202020;
  --border: #2a2a2a;
  --text: #e0e0e0;
  --text-muted: #888;
  --blue: #3b82f6;
  --blue-hover: #2563eb;
  --blue-dim: rgba(59, 130, 246, 0.15);
  --output-bg: #141414;
  --error-bg: rgba(239, 68, 68, 0.1);
  --error-border: rgba(239, 68, 68, 0.4);
  --error-text: #f87171;
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.18s ease;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Mono', 'Cascadia Code', 'Consolas', monospace;
}

html {
  font-size: 16px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.5rem 1rem 4rem;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 900px;
}

/* ── Header ───────────────────────────────────────────────── */
.header {
  text-align: center;
  margin-bottom: 2rem;
}

.title {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: #fff;
  margin-bottom: 0.35rem;
}

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

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (max-width: 600px) {
  .card {
    padding: 1.25rem 1rem;
  }
}

/* ── Mode Selector ────────────────────────────────────────── */
.mode-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mode-btn {
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.mode-btn:hover {
  border-color: var(--blue);
  color: var(--text);
}

.mode-btn.active {
  background: var(--blue-dim);
  border-color: var(--blue);
  color: var(--blue);
}

/* ── Input Group ──────────────────────────────────────────── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.textarea {
  width: 100%;
  background: #111;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-family: var(--font);
  line-height: 1.6;
  resize: vertical;
  min-height: 150px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.textarea::placeholder {
  color: #444;
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

.char-count.over-limit {
  color: var(--error-text);
}

/* ── Fix Button ───────────────────────────────────────────── */
.fix-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  position: relative;
  min-height: 48px;
}

.fix-btn:hover:not(:disabled) {
  background: var(--blue-hover);
}

.fix-btn:active:not(:disabled) {
  transform: scale(0.99);
}

.fix-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Spinner */
.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.fix-btn.loading .btn-label {
  opacity: 0.7;
}

.fix-btn.loading .btn-spinner {
  display: block;
}

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

/* ── Error Box ────────────────────────────────────────────── */
.error-box {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--error-text);
  font-size: 0.9rem;
  line-height: 1.5;
  animation: fadeIn 0.2s ease;
}

/* ── Output Section ───────────────────────────────────────── */
.output-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  animation: fadeIn 0.25s ease;
}

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

.output-box {
  background: var(--output-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.92rem;
  font-family: var(--font-mono);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  min-height: 60px;
}

/* ── Copy Button ──────────────────────────────────────────── */
.copy-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.copy-btn:hover {
  color: var(--text);
  border-color: #555;
  background: rgba(255, 255, 255, 0.04);
}

.copy-btn.copied {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.4);
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
