:root {
  --bg: #0f1115;
  --surface: #161a22;
  --surface-2: #1d222c;
  --surface-3: #242a36;
  --border: #2a313d;
  --border-2: #3a4252;
  --text: #e6e9ef;
  --text-dim: #9aa3b2;
  --text-faint: #6b7385;
  --accent: #5b8def;
  --accent-hover: #7aa3ff;
  --success: #4ade80;
  --warning: #facc15;
  --danger: #f87171;
  --radius: 8px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; }

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

/* --- Layout --- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; color: var(--text); }
.app-nav a { margin-left: 1rem; color: var(--text-dim); }
.app-nav a.active, .app-nav a:hover { color: var(--text); }

.app-main { max-width: 960px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.app-footer { text-align: center; color: var(--text-dim); padding: 1rem; border-top: 1px solid var(--border); }

h1, h2, h3 { margin-top: 0; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; margin-top: 1.5rem; }
h3 { font-size: 1.05rem; margin-top: 1.25rem; color: var(--text-dim); }
p { margin: 0.5rem 0; }
small { color: var(--text-dim); }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); font-size: 0.88rem; }

/* --- Home page cards --- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.card {
  display: block; padding: 1rem 1.1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.card h3 { margin: 0 0 0.4rem; font-size: 1.05rem; color: var(--text); }
.card p { margin: 0 0 0.6rem; color: var(--text-dim); font-size: 0.92rem; }
.card small { color: var(--text-faint); font-size: 0.8rem; }
.card .tag {
  display: inline-block; font-size: 0.7rem; padding: 0.1rem 0.45rem; margin-left: 0.4rem;
  border-radius: 99px; border: 1px solid var(--border-2); color: var(--text-dim);
}
.card .tag.stub { color: var(--warning); border-color: rgba(250, 204, 21, 0.4); }
.card .tag.ready { color: var(--success); border-color: rgba(74, 222, 128, 0.4); }

/* --- Tool page panel --- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem; margin-bottom: 1rem;
}
.panel-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.panel-title { font-weight: 600; font-size: 1rem; }
.panel-subtitle { color: var(--text-dim); font-size: 0.88rem; }

/* --- Forms --- */
.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.field label { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-dim); }
.field-hint { font-size: 0.78rem; color: var(--text-faint); margin-top: 0.25rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="number"], input[type="date"], input[type="time"], select, textarea {
  width: 100%; padding: 0.55rem 0.75rem;
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius);
  color: var(--text); font: inherit; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { font-family: var(--mono); font-size: 0.85rem; resize: vertical; min-height: 6rem; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.15); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

.check-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0; cursor: pointer; user-select: none; font-size: 0.9rem; }
.check-row input[type="checkbox"] { accent-color: var(--accent); width: 1rem; height: 1rem; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius);
  background: var(--accent); color: #fff; border: 0;
  font: inherit; font-weight: 600; cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-secondary { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-2); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border-2); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); background: transparent; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #fca5a5; }

.button-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-top: 0.5rem; }

/* --- Status messages --- */
.status {
  padding: 0.6rem 0.85rem; border-radius: var(--radius);
  font-size: 0.88rem; line-height: 1.45; margin-top: 0.75rem;
  border: 1px solid var(--border-2); background: var(--surface-2);
  display: none;
}
.status.visible { display: block; }
.status.info    { color: var(--accent);  border-color: rgba(91, 141, 239, 0.4);  background: rgba(91, 141, 239, 0.08); }
.status.success { color: var(--success); border-color: rgba(74, 222, 128, 0.4);  background: rgba(74, 222, 128, 0.06); }
.status.warning { color: var(--warning); border-color: rgba(250, 204, 21, 0.4);  background: rgba(250, 204, 21, 0.06); }
.status.error   { color: var(--danger);  border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.06); }
.status.loading { color: var(--text-dim); }

.spinner {
  display: inline-block; width: 0.9rem; height: 0.9rem;
  border: 2px solid var(--border-2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: -2px; margin-right: 0.35rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Tables --- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.55rem 0.8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--surface-2); }

/* --- Result rows (compact card list) --- */
.result-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.75rem; }
.result-row {
  display: flex; gap: 0.75rem; align-items: flex-start;
  padding: 0.65rem 0.85rem; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
}
.result-row.success { border-left: 3px solid var(--success); }
.result-row.error   { border-left: 3px solid var(--danger); }
.result-row.warning { border-left: 3px solid var(--warning); }
.result-icon { font-size: 1rem; flex-shrink: 0; line-height: 1.4; }
.result-body { flex: 1; min-width: 0; }
.result-title { font-weight: 500; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-msg { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.15rem; }

/* --- Code blocks --- */
code, pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; font-family: var(--mono); }
code { padding: 0.1rem 0.35rem; font-size: 0.86em; }
pre { padding: 0.75rem 1rem; overflow-x: auto; font-size: 0.82rem; max-height: 24rem; }

/* --- Tabs --- */
.tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1rem;
}
.tab {
  padding: 0.55rem 1rem; border: 0; background: transparent; color: var(--text-dim);
  font: inherit; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* --- Misc --- */
.toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.toolbar .field { margin-bottom: 0; min-width: 10rem; flex: 1; }
.toolbar .btn { align-self: flex-end; }

.divider { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.kbd { font-family: var(--mono); font-size: 0.82rem; background: var(--surface-3); border: 1px solid var(--border-2); border-radius: 4px; padding: 0.05rem 0.4rem; }
.pill { display: inline-block; font-size: 0.78rem; padding: 0.1rem 0.55rem; border-radius: 99px; border: 1px solid var(--border-2); color: var(--text-dim); }
.pill.ok    { color: var(--success); border-color: rgba(74, 222, 128, 0.4); }
.pill.warn  { color: var(--warning); border-color: rgba(250, 204, 21, 0.4); }
.pill.error { color: var(--danger);  border-color: rgba(248, 113, 113, 0.4); }
