:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --muted-dim: #9ca3af;
  --primary: #1a73e8;
  --primary-hover: #1664c1;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --code-bg: #f3f4f6;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.container-wide {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 32px 80px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.site-header .brand {
  font-weight: 600;
  color: var(--text);
  font-size: 16px;
}

.site-header nav {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: var(--muted);
}

.site-header nav a {
  color: var(--muted);
}

.site-header nav a:hover {
  color: var(--text);
  text-decoration: none;
}

h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 32px 0 12px;
}

p {
  margin: 0 0 16px;
  color: var(--text);
}

.muted {
  color: var(--muted);
}

.hero {
  margin-bottom: 48px;
}

.hero-tagline {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.card-compact {
  padding: 16px;
}

.form-row {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="number"],
select {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--code-bg);
  text-decoration: none;
}

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--border-strong);
}

.btn-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.token-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 8px;
}

.token-meta {
  min-width: 0;
}

.token-name {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
  word-break: break-word;
}

.token-times {
  font-size: 13px;
  color: var(--muted);
}

.token-times span + span::before {
  content: " · ";
  color: var(--muted-dim);
}

details.create-token {
  margin-top: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

details.create-token > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 20px;
  font-weight: 500;
  color: var(--text);
}

details.create-token > summary::-webkit-details-marker {
  display: none;
}

details.create-token > summary::before {
  content: "+ ";
  color: var(--muted);
  font-weight: 400;
}

details.create-token[open] > summary::before {
  content: "− ";
}

details.create-token[open] > summary {
  border-bottom: 1px solid var(--border);
}

details.create-token .panel {
  padding: 20px;
}

.empty {
  padding: 32px 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

pre.code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
  margin: 0 0 12px;
  white-space: pre;
}

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 13px;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.token-reveal {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
  margin: 0;
}

.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.flash-error {
  background: var(--danger-bg);
  border-color: #fecaca;
  color: var(--danger);
}

.warn {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 32px 0;
}

.copy-btn {
  font-size: 12px;
  padding: 5px 10px;
}

.inline-form {
  display: inline;
}

/* Version history page (/settings/sites/{slug}) — mirrors .token-list with
   a current-version badge and a monospace short id. */
.versions-header {
  margin-bottom: 16px;
}
.versions-header h1 {
  margin-bottom: 4px;
}
.versions-header a {
  font-size: 14px;
  word-break: break-all;
}

.version-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 8px;
}

.version-row.is-current {
  border-color: #c8e6c9;
  background: #f1f8e9;
}

.version-meta {
  min-width: 0;
}

.version-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.version-id {
  background: var(--surface-alt, #f6f6f6);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--text);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-current {
  background: #2e7d32;
  color: #fff;
}

.version-times {
  font-size: 13px;
  color: var(--muted);
}

.version-times span + span::before {
  content: " · ";
  color: var(--muted-dim);
}

@media (max-width: 640px) {
  .container {
    padding: 32px 16px 56px;
  }
  .token-row,
  .version-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  h1 {
    font-size: 24px;
  }
}

/* Agent-comments note: shown under the versions list once per slug. */
.agent-comments-note { margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--border); }
.agent-comments-note h2 { font-size: 18px; margin: 0 0 8px; }
.agent-comments-note p { color: var(--muted); font-size: 14px; line-height: 1.55; }
.agent-comments-note code { background: var(--code-bg, #f3f4f6); padding: 1px 6px; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* Trusted apex feedback handling surface */
.feedback-surface { max-width: 680px; }
.feedback-back { display: inline-block; margin-bottom: 24px; font-size: 14px; }
.feedback-quote { margin: 24px 0 16px; padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 17px; }
.feedback-body { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); white-space: pre-wrap; word-break: break-word; }
.feedback-disclosure { margin-top: 20px; color: var(--muted); font-size: 14px; }
.feedback-action-form { margin-top: 20px; }
.badge-open { background: #1a73e8; color: #fff; }
.badge-claimed { background: #8a5a00; color: #fff; }
.badge-resolved { background: #2e7d32; color: #fff; }

/* Status badges */
.badge-active { background: #2e7d32; color: #fff; }
.badge-pending { background: #f57f17; color: #fff; }
.badge-expired { background: var(--muted-dim); color: #fff; }

/* Site table */
.site-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 14px;
}

.site-table thead {
  background: var(--code-bg);
  border-bottom: 2px solid var(--border-strong);
}

.site-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.site-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.site-table th.sortable:hover {
  color: var(--text);
}

.site-table th.sort-asc,
.site-table th.sort-desc {
  color: var(--primary);
}

.site-table .sort-icon {
  font-size: 11px;
}

.site-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.site-table tbody tr:last-child td {
  border-bottom: none;
}

.site-table tbody tr:hover {
  background: rgba(26, 115, 232, 0.03);
}

.site-table .site-name a {
  font-weight: 500;
  color: var(--text);
}

.site-table .site-name a:hover {
  color: var(--primary);
  text-decoration: none;
}

.site-table .site-times {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.site-table .site-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

/* Drop zone for file upload */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 16px;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(26, 115, 232, 0.04);
}

.drop-zone p { margin: 0; color: var(--muted); }
.drop-zone .btn { margin-top: 12px; }

.file-list { list-style: none; padding: 0; margin: 0 0 16px; }
.file-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 4px; font-size: 14px;
}
.file-list li button {
  background: none; border: none; color: var(--danger); cursor: pointer; font-size: 13px;
}

.publish-result {
  padding: 16px; background: #e8f5e9; border: 1px solid #c8e6c9;
  border-radius: var(--radius-sm); margin-bottom: 16px;
}
.publish-result a { font-weight: 600; }

/* Sites search bar */
.sites-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.sites-search {
  position: relative;
  flex: 1;
  max-width: 360px;
}

.sites-search input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sites-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.sites-search input::placeholder {
  color: var(--muted-dim);
}

.sites-search::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted-dim);
  border-radius: 50%;
  pointer-events: none;
}

.sites-search::after {
  content: "";
  position: absolute;
  left: 26px;
  top: 60%;
  width: 2px;
  height: 6px;
  background: var(--muted-dim);
  border-radius: 1px;
  transform: rotate(-45deg);
  pointer-events: none;
}

.sites-count {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.site-table tr.hidden-by-search {
  display: none;
}

@media (max-width: 640px) {
  .container-wide {
    padding: 32px 16px 56px;
  }
  .site-table {
    font-size: 13px;
  }
  .site-table th,
  .site-table td {
    padding: 8px 10px;
  }
  .site-table .site-actions {
    flex-direction: column;
    gap: 4px;
  }
  .sites-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .sites-search {
    max-width: none;
  }
}

/* Site detail — pages in the current version (VOT-2384) */
.site-files { margin-top: 32px; }
.site-files h2 { font-size: 16px; font-weight: 600; }
.file-list { list-style: none; margin: 12px 0 0; padding: 0; border: 1px solid var(--border, #e2e8f0); border-radius: 8px; overflow: hidden; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border, #edf2f7); }
.file-row:last-child { border-bottom: none; }
.file-row .file-path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: #2d3748; }
.file-row.is-page .file-path { font-weight: 600; }

/* Sites list — Linear-style page sub-tree under the site name (site-file-tree-nav) */
.site-table .site-name { vertical-align: top; }

/* Disclosure wrapping the slug + indented page list. */
.page-tree { display: block; }
.page-tree-summary {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-radius: 6px;
  margin: -2px -6px;
  padding: 2px 6px;
}
.page-tree-summary:hover { background: var(--hover, #f1f5f9); }
.page-tree-summary::-webkit-details-marker { display: none; }

/* Chevron rotates ▸ → ▾ on open, matching the served-page nav + Linear. */
.page-tree-chevron {
  flex: none;
  width: 12px;
  color: var(--muted, #94a3b8);
  font-size: 10px;
  line-height: 1;
  transition: transform 0.12s ease;
}
.page-tree-chevron::before { content: "▶"; }
.page-tree[open] > .page-tree-summary .page-tree-chevron { transform: rotate(90deg); }

.page-tree-name { font-weight: 600; color: var(--text, #1a202c); }
.page-tree-count { font-size: 12px; color: var(--muted, #94a3b8); }

/* Indented children with a vertical connector line (Linear sub-issue look). */
.page-tree-list {
  list-style: none;
  margin: 4px 0 2px 5px;
  padding: 2px 0 2px 14px;
  border-left: 1px solid var(--border, #e2e8f0);
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 60vh;
  overflow-y: auto;
}
.page-tree-list li { position: relative; }
.page-tree-list li::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 0.7em;
  width: 10px;
  height: 1px;
  background: var(--border, #e2e8f0);
}
.page-tree-list li a {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--primary, #1a73e8);
  text-decoration: none;
  white-space: nowrap;
}
.page-tree-list li a:hover { text-decoration: underline; }
