:root {
  --ground: #171719;
  --surface: #131217;
  --raised: #212023;
  --border: #222224;
  --rule: #1b1a1f;
  --control: #3a3a3e;
  --text: #ffffff;
  --muted: #8a8c92;
  --accent: #4a8ad6;
  --positive: #44a282;
  --negative: #e5566f;
  --warning: #d9a441;
  --pill-positive-bg: #1b2828;
  --pill-positive-ink: #5fc39c;
  --pill-negative-bg: #2c1a20;
  --pill-negative-ink: #e5566f;
  --pill-warning-bg: #2a2416;
  --pill-warning-ink: #d9a441;
  --pill-neutral-bg: #212023;
  --pill-neutral-ink: #bdbdc0;
  --radius-card: 4px;
  --radius-control: 4px;
  --sidebar-w: 260px;
}

@media (prefers-color-scheme: light) {
  :root {
    --ground: #f8f9fa;
    --surface: #ffffff;
    --raised: #f1f3f5;
    --border: #e2e8f0;
    --rule: #edf2f7;
    --control: #cbd5e1;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #1d5fbf;
    --positive: #059669;
    --negative: #dc2626;
    --warning: #d97706;
    --pill-positive-bg: #ecfdf5;
    --pill-positive-ink: #059669;
    --pill-negative-bg: #fef2f2;
    --pill-negative-ink: #dc2626;
    --pill-warning-bg: #fffbeb;
    --pill-warning-ink: #d97706;
    --pill-neutral-bg: #f1f5f9;
    --pill-neutral-ink: #475569;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  background-color: var(--ground);
  color: var(--text);
  line-height: 1.5;
  font-size: 13px;
}

/* Header */
.app-header {
  height: 48px;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.logo-area { display: flex; align-items: center; gap: 24px; }
.app-title { font-weight: 600; font-size: 14px; color: var(--text); text-decoration: none; letter-spacing: -0.2px; }
.nav-links { display: flex; gap: 16px; }
.nav-link { color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 400; padding: 4px 0; }
.nav-link:hover { color: var(--text); }
.btn-logout { background: none; border: 1px solid var(--border); color: var(--muted); padding: 4px 10px; border-radius: var(--radius-control); cursor: pointer; font-size: 12px; }
.btn-logout:hover { color: var(--negative); border-color: var(--negative); }

.main-content { min-height: calc(100vh - 48px); }

/* Dashboard */
.dashboard-container { max-width: 1040px; margin: 0 auto; padding: 32px 20px; }
.dashboard-header h2 { margin: 0 0 4px 0; font-size: 20px; font-weight: 500; }
.subtitle { color: var(--muted); margin: 0 0 24px 0; font-size: 13px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.card { background-color: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 18px; }
.card-wide { grid-column: span 2; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-header h3 { margin: 0; font-size: 14px; font-weight: 500; }
.stat-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-val { font-weight: 500; font-size: 13px; }
.stat-val-sm { color: var(--muted); font-size: 12px; }
.badge { background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); padding: 2px 8px; border-radius: var(--radius-control); font-size: 11px; }

/* Status Indicators */
.service-item { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--rule); }
.status-healthy { background: var(--pill-positive-bg); color: var(--pill-positive-ink); padding: 2px 8px; border-radius: var(--radius-control); font-size: 11px; font-weight: 500; }
.status-stale { background: var(--pill-warning-bg); color: var(--pill-warning-ink); padding: 2px 8px; border-radius: var(--radius-control); font-size: 11px; font-weight: 500; }
.status-unhealthy { background: var(--pill-negative-bg); color: var(--pill-negative-ink); padding: 2px 8px; border-radius: var(--radius-control); font-size: 11px; font-weight: 500; }
.status-unmonitored { background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); padding: 2px 8px; border-radius: var(--radius-control); font-size: 11px; }

/* Editor Layout */
.editor-layout { display: flex; height: calc(100vh - 48px); overflow: hidden; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar-header { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.sidebar-header h3 { margin: 0; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.5px; font-weight: 500; }
.btn-icon { background: none; border: 1px solid var(--border); color: var(--muted); cursor: pointer; font-size: 13px; border-radius: var(--radius-control); padding: 2px 6px; }
.btn-icon:hover { color: var(--text); border-color: var(--muted); }
.tree-container { flex: 1; overflow-y: auto; padding: 8px; font-size: 13px; }
.upload-dropzone { border: 1px dashed var(--border); margin: 8px; padding: 12px; text-align: center; border-radius: var(--radius-card); font-size: 12px; color: var(--muted); cursor: pointer; }
.upload-dropzone.dragover { border-color: var(--accent); color: var(--accent); }

.tree-list { list-style: none; padding: 0; margin: 0; }
.tree-sublist { list-style: none; padding-left: 14px; margin: 0; }
.tree-item-li { padding: 2px 0; }
.tree-item { cursor: pointer; padding: 4px 6px; border-radius: var(--radius-control); display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.tree-item:hover { background: var(--raised); color: var(--text); }
.folder-item { font-weight: 500; }
.doc-item { color: var(--text); }

.editor-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.editor-toolbar { height: 42px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; padding: 0 16px; background: var(--surface); }
.doc-meta-area { display: flex; align-items: center; gap: 10px; flex: 1; }
.dirty-indicator { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.dirty-indicator.dirty { background: var(--accent); }
.input-title { background: transparent; border: none; color: var(--text); font-size: 14px; font-weight: 500; outline: none; width: 60%; }
.editor-controls { display: flex; align-items: center; gap: 8px; }
.btn-sm { background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 4px 10px; border-radius: var(--radius-control); font-size: 12px; cursor: pointer; }
.btn-sm:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.btn-primary:hover { background: #3b7ac6; }

.editor-panes { flex: 1; display: flex; overflow: hidden; }
.editor-pane { flex: 1; height: 100%; border-right: 1px solid var(--border); overflow: auto; background: var(--ground); }
.preview-pane { flex: 1; height: 100%; display: flex; flex-direction: column; overflow: hidden; background: var(--ground); }
.preview-header { height: 32px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; padding: 0 12px; font-size: 12px; color: var(--muted); }
.preview-body { flex: 1; overflow-y: auto; padding: 24px; line-height: 1.6; }
.html-preview-frame { width: 100%; height: 100%; border: none; background: #fff; }

.editor-textarea {
  width: 100%;
  height: 100%;
  border: none;
  padding: 16px;
  background: transparent;
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; /* taste-skill-ignore */
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
}

/* Floating AI Drawer overlay */
.ai-drawer { position: fixed; right: 20px; bottom: 20px; width: 380px; height: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); display: flex; flex-direction: column; z-index: 100; overflow: hidden; }
.ai-drawer-header { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.ai-drawer-header h4 { margin: 0; font-size: 13px; font-weight: 500; }
.ai-shortcuts { display: flex; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.ai-btn-action { background: var(--raised); border: 1px solid var(--border); color: var(--text); padding: 3px 8px; border-radius: var(--radius-control); font-size: 11px; cursor: pointer; }
.ai-btn-action:hover { border-color: var(--accent); color: var(--accent); }
.ai-output-container { flex: 1; padding: 12px 14px; overflow-y: auto; font-size: 13px; line-height: 1.5; color: var(--text); }
.ai-actions-footer { padding: 8px 14px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Settings View */
.settings-container { max-width: 640px; margin: 0 auto; padding: 32px 20px; }
.settings-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--muted); }
.form-group small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.input-text { width: 100%; background: var(--ground); border: 1px solid var(--control); color: var(--text); padding: 6px 10px; border-radius: var(--radius-control); font-size: 13px; outline: none; }
.input-text:focus { border-color: var(--accent); }

/* Login */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--ground); }
.login-card { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 28px; }
.login-header h1 { margin: 0 0 4px 0; font-size: 18px; font-weight: 600; letter-spacing: -0.2px; }
.login-header p { margin: 0 0 20px 0; color: var(--muted); font-size: 13px; }
.btn-block { width: 100%; padding: 8px; font-size: 13px; margin-top: 12px; border-radius: var(--radius-control); }
