/* ===== CSS Variables ===== */
:root {
  --bg-primary: #0c0e12;
  --bg-secondary: #12151c;
  --bg-tertiary: #1a1e28;
  --bg-elevated: #222733;
  --border: #2a3040;
  --border-subtle: #1e2430;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-muted: rgba(99, 102, 241, 0.15);
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --input-dot: #6366f1;
  --output-dot: #22c55e;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --transition: 0.18s ease;
}

[data-theme="light"] {
  --bg-primary: #f4f5f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f1f3;
  --bg-elevated: #e8eaed;
  --border: #d1d5db;
  --border-subtle: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --accent: #4f46e5;
  --accent-hover: #6366f1;
  --accent-muted: rgba(79, 70, 229, 0.1);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

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

html {
  height: 100%;
  font-size: 15px;
}

body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ===== App Layout ===== */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100dvh;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
}

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

.logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  border-radius: 8px;
  letter-spacing: -0.02em;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.tool-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.brand {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

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

.icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon,
:root:not([data-theme]) .icon-moon { display: none; }
[data-theme="light"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun,
:root:not([data-theme]) .icon-sun { display: block; }

/* ===== Main ===== */
.main {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ===== Options Panel ===== */
.options-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
}

.panel-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

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

.option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
}

.option:hover {
  background: var(--bg-tertiary);
}

.option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkmark {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--bg-tertiary);
  position: relative;
  transition: all var(--transition);
}

.option input:checked + .checkmark {
  background: var(--accent);
  border-color: var(--accent);
}

.option input:checked + .checkmark::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.option-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.option-text strong {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.option-text small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 550;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  gap: 0.35rem;
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--accent-muted);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.privacy-note svg {
  flex-shrink: 0;
  color: var(--accent);
}

/* ===== Editors ===== */
.editors {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
  background: var(--border);
  overflow: hidden;
}

.editor-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  min-height: 0;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.editor-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--text-secondary);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.input-dot { background: var(--input-dot); }
.output-dot { background: var(--output-dot); }

.editor-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 70px;
  text-align: right;
}

.editor-body {
  flex: 1;
  position: relative;
  min-height: 0;
}

.code-editor {
  width: 100%;
  height: 100%;
  padding: 1rem 1.1rem;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-primary);
  caret-color: var(--accent);
}

.code-editor::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.code-editor:read-only {
  color: var(--text-secondary);
}

/* Drop zone */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(99, 102, 241, 0.08);
  border: 2px dashed var(--accent);
  border-radius: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}

.drop-overlay.active {
  display: flex;
}

.drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
  font-weight: 500;
  font-size: 0.9rem;
}

/* ===== Status Bar ===== */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  padding: 0 1.25rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 0.75rem;
}

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

.status-text.success { color: var(--success); }
.status-text.error { color: var(--error); }
.status-text.working { color: var(--warning); }

.developer {
  color: var(--text-muted);
  font-size: 0.7rem;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .main {
    flex-direction: column;
  }

  .options-panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    gap: 1rem;
    max-height: 42vh;
  }

  .options-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
  }

  .panel-actions {
    flex-direction: row;
    margin-top: 0;
  }

  .panel-actions .btn {
    flex: 1;
  }

  .editors {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .header {
    padding: 0 0.85rem;
  }

  .logo-text .brand {
    display: none;
  }

  .options-list {
    grid-template-columns: 1fr;
  }

  .editor-header {
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
  }

  .char-count {
    min-width: auto;
  }

  .status-bar {
    padding: 0 0.85rem;
  }

  .developer {
    display: none;
  }
}

/* Subtle focus ring */
.code-editor:focus {
  outline: none;
}

/* Scrollbar styling */
.code-editor::-webkit-scrollbar,
.options-panel::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.code-editor::-webkit-scrollbar-track,
.options-panel::-webkit-scrollbar-track {
  background: transparent;
}

.code-editor::-webkit-scrollbar-thumb,
.options-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.code-editor::-webkit-scrollbar-thumb:hover,
.options-panel::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
