/* ─── Design tokens ─────────────────────────────────────────────── */
:root {
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ─── Light mode (default) ──────────────────────────────────────── */
:root,
[data-theme="light"] {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f0f1f4;
  --text: #111827;
  --muted: #6b7280;
  --line: rgba(0, 0, 0, 0.09);
  --accent: #0ea5a0;
  --accent-2: #6366f1;
  --danger: #dc2626;
}

/* ─── Dark mode ─────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --panel: #161b22;
    --panel-2: #1c2333;
    --text: #e6edf3;
    --muted: #7d8590;
    --line: rgba(255, 255, 255, 0.08);
    --accent: #3dd6cc;
    --accent-2: #818cf8;
    --danger: #f87171;
    --shadow: 0 1px 4px rgba(0,0,0,0.3), 0 4px 24px rgba(0,0,0,0.2);
  }
}

[data-theme="dark"] {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2333;
  --text: #e6edf3;
  --muted: #7d8590;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #3dd6cc;
  --accent-2: #818cf8;
  --danger: #f87171;
  --shadow: 0 1px 4px rgba(0,0,0,0.3), 0 4px 24px rgba(0,0,0,0.2);
}

/* ─── Reset & base ──────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: 32px 20px;
}

/* ─── Layout ────────────────────────────────────────────────────── */
.page {
  max-width: 880px;
  margin: 0 auto;
}

.hero {
  margin-bottom: 24px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 3.5vw, 32px);
  line-height: 1.1;
  letter-spacing: -0.025em;
  font-weight: 700;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 640px;
  font-size: 13px;
}

/* ─── Card ──────────────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ─── Form ──────────────────────────────────────────────────────── */
form {
  display: grid;
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 5px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-2);
  background: var(--panel);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

/* ─── Buttons ───────────────────────────────────────────────────── */
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

button {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transition: opacity 0.15s ease, transform 0.12s ease;
}

button:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.danger-button {
  border: 1px solid rgba(220, 38, 38, 0.28);
  background: rgba(220, 38, 38, 0.07);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.danger-button:hover {
  background: rgba(220, 38, 38, 0.13);
}

.danger-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Utility text ──────────────────────────────────────────────── */
.note {
  color: var(--muted);
  font-size: 12px;
}

.status {
  font-size: 12px;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.small-status {
  font-size: 11px;
  color: var(--muted);
}

/* ─── Pre / code ────────────────────────────────────────────────── */
pre {
  margin: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 12px 14px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  font-size: 12px;
  color: var(--text);
}

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

/* ─── List items ────────────────────────────────────────────────── */
.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.list-item-link {
  display: grid;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.list-item-link:hover {
  transform: translateY(-1px);
  border-color: rgba(99, 102, 241, 0.25);
  background: var(--panel-2);
}

.list-item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.list-item-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.list-item-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

/* ─── Meta grid ─────────────────────────────────────────────────── */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  font-size: 12px;
  color: var(--muted);
}

/* ─── Pills ─────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}

/* ─── Button link ───────────────────────────────────────────────── */
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.button-link:hover {
  transform: translateY(-1px);
  border-color: rgba(99, 102, 241, 0.3);
  background: var(--panel-2);
}

/* ─── Detail blocks ─────────────────────────────────────────────── */
.detail-block {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.detail-block h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.detail-text {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--panel-2);
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
  word-break: break-word;
}

/* ─── Code card ─────────────────────────────────────────────────── */
.code-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: var(--panel-2);
}

/* ─── Empty / error states ──────────────────────────────────────── */
.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.error-state {
  color: var(--danger);
  font-size: 13px;
}

/* ─── Checkboxes ────────────────────────────────────────────────── */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.checkbox-item input {
  width: auto;
  margin: 0;
}

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 640px) {
  body {
    padding: 20px 14px;
  }

  .card {
    padding: 14px 16px;
  }

  .grid,
  .meta-grid,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }
}