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

/* Light theme (default) */
:root {
  --bg: #fafafa;
  --surface: #fff;
  --border: #ddd;
  --text: #1a1a1a;
  --text-secondary: #555;
  --accent: #0066cc;
  --accent-hover: #0052a3;
  --error-bg: #fef2f2;
  --error-text: #b91c1c;
  --success-bg: #f0fdf4;
  --success-text: #166534;
  --drop-bg: rgba(0, 102, 204, 0.08);
  --radius: 6px;
}

/* Dark theme values */
[data-theme="dark"] {
  --bg: #111;
  --surface: #1a1a1a;
  --border: #333;
  --text: #e5e5e5;
  --text-secondary: #999;
  --accent: #4da3ff;
  --accent-hover: #7dbdff;
  --error-bg: #2d1515;
  --error-text: #f87171;
  --success-bg: #052e16;
  --success-text: #4ade80;
  --drop-bg: rgba(77, 163, 255, 0.1);
}

/* System preference when no explicit choice */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --bg: #111;
    --surface: #1a1a1a;
    --border: #333;
    --text: #e5e5e5;
    --text-secondary: #999;
    --accent: #4da3ff;
    --accent-hover: #7dbdff;
    --error-bg: #2d1515;
    --error-text: #f87171;
    --success-bg: #052e16;
    --success-text: #4ade80;
    --drop-bg: rgba(77, 163, 255, 0.1);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

main {
  max-width: 700px;
  margin: 0 auto;
  padding: 3rem 1rem;
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

#theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-secondary);
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* Explainer */
.explainer {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.explainer p + p {
  margin-top: 0.5rem;
}

/* Options bar */
.options-bar {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
}

/* Panes */
.panes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pane {
  display: flex;
  flex-direction: column;
}

.pane-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.3rem;
}

.pane-header label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stats {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

textarea {
  width: 100%;
  min-height: 120px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", "Consolas", monospace;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  resize: vertical;
  line-height: 1.5;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

textarea[readonly] {
  background: var(--bg);
  cursor: default;
}

.pane-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.btn-secondary {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

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

/* Direction indicator */
.direction-indicator {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 0.2rem 0;
  min-height: 1.4em;
}

/* Drop zone overlay */
.drop-zone {
  position: fixed;
  inset: 0;
  background: var(--drop-bg);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border: 3px dashed var(--accent);
  margin: 1rem;
  border-radius: 12px;
}

.drop-zone p {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--accent);
}

/* File info */
.file-info {
  margin-top: 1rem;
  padding: 0.6rem 0.8rem;
  background: var(--success-bg);
  color: var(--success-text);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

/* Error */
#error {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* Footer */
footer {
  max-width: 700px;
  margin: 2rem auto 0;
  padding: 1rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 500px) {
  h1 {
    font-size: 1.4rem;
  }

  textarea {
    min-height: 100px;
  }
}
