:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --danger: #f85149;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
    sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    monospace;
}

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── Landing page ──────────────────────────────────────────────── */

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
}

.landing h1 {
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
}

.landing h1 span {
  color: var(--accent);
}

.landing p.tagline {
  color: var(--text-muted);
  font-size: 1.15rem;
  margin-bottom: 2.5rem;
  max-width: 480px;
}

.input-group {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  max-width: 560px;
}

.input-group input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: var(--font-mono);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
}

.input-group input::placeholder {
  color: var(--text-muted);
}

.input-group input:focus {
  border-color: var(--accent);
}

.input-group button {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.input-group button:hover {
  background: var(--accent-hover);
}

.hint {
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hint code {
  font-family: var(--font-mono);
  background: var(--surface);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ── Preview page ──────────────────────────────────────────────── */

.preview {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbar .logo {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  text-decoration: none;
}

.toolbar .gist-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar .gist-link:hover {
  color: var(--accent);
}

.toolbar .file-tabs {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
  overflow-x: auto;
}

.toolbar .file-tab {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.toolbar .file-tab:hover {
  color: var(--text);
  background: var(--bg);
}

.toolbar .file-tab.active {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
}

.preview iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

/* ── Loading / Error states ────────────────────────────────────── */

.state-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.state-message.error h2 {
  color: var(--danger);
}

.state-message p {
  color: var(--text-muted);
  max-width: 420px;
}

.state-message a {
  color: var(--accent);
  text-decoration: none;
}

.state-message a:hover {
  text-decoration: underline;
}

/* ── Responsive ────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .landing h1 {
    font-size: 2rem;
  }

  .input-group {
    flex-direction: column;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar .file-tabs {
    margin-left: 0;
    width: 100%;
  }
}
