:root {
  --bg: hsl(240 10% 3.9%);
  --bg-card: hsl(240 10% 5.9%);
  --bg-input: hsl(240 10% 5.9%);
  --bg-hover: hsl(240 3.7% 10%);
  --border: hsl(240 3.7% 13%);
  --border-mid: hsl(240 3.7% 18%);
  --border-focus: hsl(142.1 70.6% 45.3%);
  --text: hsl(0 0% 95%);
  --text-muted: hsl(240 5% 55%);
  --text-dim: hsl(240 5% 35%);
  --accent: hsl(142.1 70.6% 45.3%);
  --accent-hover: hsl(142.1 70.6% 50%);
  --accent-fg: hsl(144.9 80.4% 8%);
  --accent-soft: hsl(142.1 70.6% 55%);
  --radius: 10px;
  --font-mono: "JetBrains Mono", monospace;
  --font-sans: "Geist", sans-serif;
}

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

html {
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  background-image:
    radial-gradient(
      ellipse 80% 50% at 50% -20%,
      hsla(142, 70%, 45%, 0.08),
      transparent
    ),
    radial-gradient(
      ellipse 60% 40% at 80% 80%,
      hsla(142, 70%, 45%, 0.04),
      transparent
    );
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  background: hsla(240, 10%, 3.9%, 0.85);
  backdrop-filter: blur(8px);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.nav-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-fg);
  font-size: 13px;
}

.nav-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.nav-title .accent {
  color: var(--accent-soft);
}

.nav-tagline {
  font-size: 12px;
  color: var(--text-muted);
}

/* Main */
.main {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 16px;
}

.page-header {
  margin-bottom: 28px;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}
.page-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* Form stack */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.field-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.divider {
  width: 1px;
  height: 16px;
  background: var(--border-mid);
}

/* Input */
.input-custom {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  color: var(--text);
  border-radius: 7px;
  padding: 5px 10px;
  width: 136px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.input-custom::placeholder {
  color: hsl(240 5% 38%);
}

.input-custom:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px hsla(142, 70%, 45%, 0.15);
}

/* Select */
.select-wrap {
  position: relative;
}

.select-custom {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  color: var(--text);
  border-radius: 7px;
  padding: 5px 28px 5px 10px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.select-custom:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px hsla(142, 70%, 45%, 0.15);
}

.select-custom option {
  background: hsl(240 10% 8%);
  color: var(--text);
}

.select-arrow {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Lang badge */
.lang-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
  background: hsl(240 3.7% 10%);
  border: 1px solid hsl(240 3.7% 20%);
  color: var(--accent-soft);
}

/* Char count */
.char-count {
  transition: color 0.2s;
  font-size: 12px;
}

/* Ghost button */
.btn-ghost {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-family: var(--font-sans);
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

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

/* Editor card */
.card-editor {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.card-editor:focus-within {
  border-color: hsl(240 3.7% 22%);
  box-shadow:
    0 0 0 1px hsla(142, 70%, 45%, 0.07),
    0 8px 40px hsla(0, 0%, 0%, 0.3);
}

.editor-titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

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

.dot-red {
  background: hsl(0 60% 45%);
}
.dot-yellow {
  background: hsl(40 60% 45%);
}
.dot-green {
  background: hsl(142 60% 40%);
}

.editor-filename {
  margin-left: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.editor-wrap {
  display: flex;
}

.line-numbers {
  padding: 16px 12px;
  text-align: right;
  user-select: none;
  min-width: 48px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 22px;
  border-right: 1px solid var(--border);
  white-space: pre;
  overflow: hidden;
}

.editor-textarea {
  flex: 1;
  resize: none;
  field-sizing: content;
  min-height: 320px;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 22px;
  background: transparent;
  color: var(--text);
  border: none;
  tab-size: 2;
  caret-color: var(--accent);
}

.editor-textarea::placeholder {
  color: hsl(240 5% 32%);
}
.editor-textarea:focus {
  outline: none;
}

/* Action row */
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}

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

/* Primary button */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background 0.15s,
    transform 0.15s,
    box-shadow 0.15s;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px hsla(142, 70%, 45%, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  animation: slide-in 0.2s ease;
}

.toast-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid;
  font-size: 13px;
  font-weight: 500;
  min-width: 260px;
  box-shadow: 0 8px 30px hsla(0, 0%, 0%, 0.4);
}

.toast-ok {
  background: hsl(240 10% 7%);
  border-color: hsl(142 40% 20%);
  color: hsl(142 60% 80%);
}
.toast-err {
  background: hsl(0 15% 7%);
  border-color: hsl(0 40% 20%);
  color: hsl(0 60% 80%);
}
.toast-ok i,
.toast-err i {
  font-size: 16px;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}

.toast.hide {
  animation: slide-out 0.2s ease forwards;
}

/* Spinner */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.spin {
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: hsl(240 3.7% 25%);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: hsl(240 3.7% 35%);
}
