/* top progress bar */
#topbar-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: var(--accent);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
}
#topbar-progress.active {
  opacity: 1;
  animation: topbar-indeterminate 1.4s ease infinite;
}
@keyframes topbar-indeterminate {
  0%   { width: 0%;  margin-left: 0%; }
  50%  { width: 40%; margin-left: 30%; }
  100% { width: 0%;  margin-left: 100%; }
}
#topbar-progress.done {
  width: 100% !important;
  margin-left: 0 !important;
  animation: none;
  opacity: 0;
  transition: opacity 0.3s ease 0.1s;
}

:root {
  --bg: #f6f8fa;
  --panel: #ffffff;
  --panel-border: #d0d7de;
  --text: #1f2328;
  --muted: #57606a;
  --line: #d0d7de;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --green: #1a7f37;
  --yellow: #9a6700;
  --red: #cf222e;
  --tag-bg: #f6f8fa;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --panel: #161b22;
    --panel-border: #21262d;
    --text: #e6edf3;
    --muted: #8b949e;
    --line: #21262d;
    --accent: #58a6ff;
    --accent-hover: #388bfd;
    --green: #3fb950;
    --yellow: #d29922;
    --red: #f85149;
    --tag-bg: #21262d;
  }
}

.dark {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-border: #21262d;
  --text: #e6edf3;
  --muted: #8b949e;
  --line: #21262d;
  --accent: #58a6ff;
  --accent-hover: #388bfd;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --tag-bg: #21262d;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 14px;
  background:
    radial-gradient(circle at top left, rgba(46, 155, 255, 0.12), transparent 30%),
    linear-gradient(180deg, #f7fafc 0%, var(--bg) 42%);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: 'SF Mono', Consolas, monospace; font-size: 13px; }
pre, textarea, select, input { font: inherit; }
h2 { margin: 0 0 4px; font-size: 20px; }
.hidden { display: none !important; }

/* Layout */
.app {
  display: flex;
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}
.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  z-index: 10;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.brand-mark {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  object-fit: cover;
  object-position: 58% 44%;
  transform: scale(1.28);
  transform-origin: center;
  border-radius: 10px;
}
.sidebar-brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; color: var(--text); line-height: 1.2; }
.brand-sub { font-size: 14px; color: var(--muted); }

/* About page */
.about-body { max-width: 520px; margin: 56px auto; padding: 0 24px; }
.about-brand-row { display: flex; align-items: center; gap: 4px; margin-bottom: 28px; }
.about-logo {
  width: 104px;
  height: 104px;
  flex-shrink: 0;
  object-fit: cover;
  object-position: 58% 44%;
  border-radius: 10px;
  filter: drop-shadow(0 4px 20px rgba(99,102,241,0.35));
}
.about-brand-text { display: flex; flex-direction: column; gap: 4px; }
.about-product { font-size: 36px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; background: linear-gradient(135deg, var(--text) 40%, var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.about-byline { font-size: 15px; color: var(--muted); }
.about-byline a { color: var(--accent); text-decoration: none; font-weight: 500; }
.about-byline a:hover { text-decoration: underline; }
.about-tagline { font-size: 17px; font-weight: 500; color: var(--text); margin: 0 0 32px; line-height: 1.5; letter-spacing: -0.01em; }
.about-divider { width: 100%; height: 1px; background: var(--line); margin: 0 0 20px; border: none; }
.about-copyright { font-size: 12px; color: var(--muted); opacity: 0.5; }
.sidebar-workspace {
  padding: 8px 0 4px;
}
.sidebar-workspace-header {
  padding-bottom: 4px;
}
.sidebar-workspace-item {
  padding: 7px 12px;
  margin: 1px 4px;
  border-radius: 6px;
  background: var(--tag-bg);
}
.brand-workspace-name {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  padding: 8px;
}
.sidebar-user-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  text-align: left;
}
.sidebar-user-btn:hover { background: var(--tag-bg); }
.user-avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--tag-bg);
  border: 1.5px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-chevron { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }

/* User dropdown - flies UP */
.user-menu-wrap { position: relative; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--tag-bg); color: var(--text); font-size: 12px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.user-avatar:hover { border-color: var(--accent); }
.user-dropdown { position: absolute; left: 0; right: 0; min-width: 210px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 -8px 24px rgba(0,0,0,0.12); z-index: 100; padding: 6px 0; }
.user-dropdown--up { bottom: calc(100% + 6px); top: auto; }
.user-dropdown-name { padding: 8px 14px 2px; font-size: 13px; font-weight: 600; color: var(--text); }
.user-dropdown-email { padding: 0 14px 8px; font-size: 12px; color: var(--muted); }
.user-dropdown-divider { height: 1px; background: var(--line); margin: 4px 0; }
.user-dropdown-item { display: block; padding: 7px 14px; font-size: 13px; color: var(--text); text-decoration: none; cursor: pointer; background: none; border: none; width: 100%; text-align: left; }
.user-dropdown-item:hover { background: var(--tag-bg); text-decoration: none; }

/* Mobile sidebar toggle */
.sidebar-mobile-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.sidebar-mobile-btn svg { width: 18px; height: 18px; }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9;
}
.sidebar-overlay.visible { display: block; }

/* \u2500\u2500 Project sidebar \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.project-section { margin-top: 20px; }
.project-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px 6px;
}
.project-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
}
.btn-icon:hover { color: var(--text); background: var(--tag-bg); }

.new-project-form {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.new-project-form input { font-size: 12px; padding: 5px 8px; }
.new-project-actions { display: flex; gap: 6px; }

.project-list { display: flex; flex-direction: column; }
.project-item {
  padding: 7px 12px;
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.project-item:hover { background: var(--tag-bg); }
.project-item.active { background: var(--tag-bg); }
.project-item-main { flex: 1; min-width: 0; }
.project-item-name { font-size: 13px; color: var(--text); font-weight: 500; }
.project-item.active .project-item-name { color: var(--accent); }
.project-item-desc {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.project-item-menu-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 18px; line-height: 1;
  padding: 0 2px; border-radius: 4px; opacity: 0; flex-shrink: 0;
  transition: opacity 0.1s;
}
.project-item:hover .project-item-menu-btn { opacity: 1; }
.project-item-menu-btn:hover { color: var(--text); background: var(--line); }

/* \u2500\u2500 Main \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.main { flex: 1; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; }

body.unauthenticated {
  background:
    radial-gradient(circle at top left, rgba(46, 155, 255, 0.12), transparent 28%),
    linear-gradient(180deg, #f8fbfe 0%, #edf3f9 100%);
}

body.unauthenticated .content {
  width: 100%;
}

body.unauthenticated .main {
  overflow: visible;
}

body.unauthenticated .sidebar,
body.unauthenticated .sidebar-mobile-btn,
body.unauthenticated .sidebar-overlay {
  display: none !important;
}

.view { display: flex; flex-direction: column; padding: 24px; flex: 1; min-height: 0; }
.view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.run-detail-header {
  align-items: flex-start;
  gap: 10px;
}
.header-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
#refreshRunBtn { margin-left: 8px; padding: 6px 8px; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; }

/* \u2500\u2500 Buttons \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--tag-bg); border-color: var(--muted); }
.btn.btn-primary { background: var(--accent); color: #ffffff; border-color: var(--accent); font-weight: 600; }
.btn.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: rgba(248,81,73,0.12); }
.btn-back { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0; }
.btn-back:hover { color: var(--text); }

/* \u2500\u2500 Search \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.search {
  padding: 6px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: var(--tag-bg);
  color: var(--text);
  font-size: 13px;
  width: 220px;
}
.search:focus { outline: none; border-color: var(--accent); }

/* \u2500\u2500 Table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 8px 12px; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-row { cursor: pointer; }
.table-row:hover td { background: var(--panel); }
.goal-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* \u2500\u2500 Tags / status badges \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  background: var(--tag-bg);
  color: var(--muted);
}
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--tag-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}
.status-badge.running, .tag.running { background: rgba(63,185,80,0.15); color: var(--green); }
.status-badge.complete, .status-badge.completed, .tag.complete { background: rgba(88,166,255,0.12); color: var(--accent); }
.status-badge.finalized, .tag.finalized { background: rgba(88,166,255,0.2); color: var(--accent); }
.status-badge.incomplete, .tag.incomplete { background: rgba(248,81,73,0.12); color: var(--red); }

/* \u2500\u2500 Run detail \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.run-detail-summary {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.run-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.run-meta-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.run-meta-value {
  font-size: 14px;
  color: var(--text);
  line-height: 1.3;
}
.run-meta-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}
.run-meta-status.running { background: rgba(63,185,80,0.15); color: var(--green); }
.run-meta-status.complete, .run-meta-status.completed { background: rgba(88,166,255,0.12); color: var(--accent); }
.run-meta-status.finalized { background: rgba(88,166,255,0.2); color: var(--accent); }
.run-meta-status.incomplete { background: rgba(248,81,73,0.12); color: var(--red); }
.run-meta-help {
  position: relative;
  display: flex;
  align-items: center;
}
.run-meta-help-btn {
  height: 20px;
  width: 20px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.run-meta-help-btn:hover { color: var(--text); background: var(--tag-bg); border-color: var(--line); }
.run-meta-help-btn:focus-visible { outline: none; border-color: var(--panel-border); background: var(--tag-bg); }
.run-meta-help-icon { width: 15px; height: 15px; display: block; flex-shrink: 0; }
.run-meta-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 280px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(0,0,0,0.10);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  display: none;
  z-index: 20;
}
.run-meta-help.open .run-meta-tooltip,
.run-meta-help:focus-within .run-meta-tooltip { display: block; }
.run-meta-grid {
  display: grid;
  grid-template-columns: 62px 1fr;
  column-gap: 8px;
  row-gap: 6px;
  align-items: center;
}
.run-meta-k {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.run-meta-v {
  color: var(--text);
  min-width: 0;
  word-break: break-word;
}
.run-meta-runid-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.run-meta-copy-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 11px;
  cursor: pointer;
}
.run-meta-copy-btn:hover { color: var(--text); background: var(--tag-bg); border-color: var(--panel-border); }
.detail-goal {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  padding: 0;
  line-height: 1.35;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail-goal-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.detail-goal-link:hover { text-decoration: underline; }
.detail-goal-current { color: var(--text); }
.detail-goal:empty { display: none; }
.detail-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.detail-split {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* file tree */
.file-tree-pane {
  width: 220px;
  min-width: 120px;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
}
.file-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  flex-shrink: 0;
}
.file-filter-pill {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.file-filter-pill:hover { color: var(--text); background: var(--tag-bg); border-color: var(--panel-border); }
.file-filter-pill.active {
  color: var(--accent);
  border-color: rgba(88,166,255,0.4);
  background: rgba(88,166,255,0.12);
}
.file-filter-count {
  opacity: 0.8;
  font-weight: 600;
}
.file-filter-status {
  margin-left: auto;
  align-self: center;
}
.file-tree {
  border-right: none;
  overflow-y: auto;
  padding: 8px 0;
  flex: 1;
  min-height: 0;
}
.file-tree-resizer {
  width: 1px;
  flex-shrink: 0;
  cursor: col-resize;
  background: var(--line);
  transition: background 0.2s;
  position: relative;
}
.file-tree-resizer::after {
  content: '';
  position: absolute;
  inset: 0 -2px;
}
.file-tree-resizer:hover { background: var(--line); }
.file-tree-resizer.dragging { background: var(--accent); }
.tree-group { margin-bottom: 4px; }
.tree-children { display: block; }
.tree-group.collapsed .tree-children { display: none; }
.tree-dir {
  padding: 4px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 5px;
}
.tree-dir::before {
  content: '▶';
  font-size: 9px;
  transition: transform 0.15s;
  transform: rotate(90deg);
}
.tree-group.collapsed .tree-dir::before { transform: rotate(0deg); }
.tree-dir:hover { color: var(--text); }
.tree-file {
  padding: 5px 12px 5px 20px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-file:hover { background: var(--tag-bg); color: var(--text); }
.tree-file.selected { background: rgba(88,166,255,0.12); color: var(--accent); }

/* file panel */
.file-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.file-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--tag-bg);
}
.file-panel-title { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.file-panel-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.file-panel-actions .btn.small {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
}
.icon-btn { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 5px; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 3px 7px; flex-shrink: 0; transition: color 0.15s, border-color 0.15s, background 0.15s; }
#fileBackBtn { margin-right: 8px; }
.btn:disabled { opacity: 0.38; cursor: default; pointer-events: none; }
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--line); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
/* segmented control */
.segmented { display: flex; border: 1px solid var(--panel-border); border-radius: 6px; overflow: hidden; }
.file-panel-actions .segmented {
  height: 28px;
  background: var(--panel);
}
.seg-btn {
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  background: var(--panel);
  color: var(--muted);
  border: none;
  cursor: pointer;
  line-height: 1;
  height: 100%;
  display: inline-flex;
  align-items: center;
  transition: background 0.12s, color 0.12s;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--panel-border); }
.seg-btn:hover { background: var(--tag-bg); color: var(--text); }
.seg-btn.active { background: var(--accent); color: #fff; }
.copy-btn { min-width: 52px; }
.copy-btn.copied { color: var(--green); border-color: var(--green); }
.json-highlighted { background: transparent; }
.json-key  { color: #7c3aed; }
.json-str  { color: #16a34a; }
.json-num  { color: #d97706; }
.json-bool { color: #2563eb; font-weight: 600; }
.json-null { color: var(--muted); font-style: italic; }
.file-content-md, .file-content-html, .file-content-raw { flex: 1; padding: 16px; overflow: auto; margin: 0; min-height: 0; }
.file-content-html { display: block; width: 100%; padding: 0; border: none; }
body.is-resizing-pane .file-content-html { pointer-events: none; }
.file-content-md { padding: 20px 28px; font-size: 14px; line-height: 1.7; }
.file-content-md h1 { font-size: 1.45em; font-weight: 700; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.file-content-md h2 { font-size: 1.2em; font-weight: 600; margin: 20px 0 8px; }
.file-content-md h3 { font-size: 1.05em; font-weight: 600; margin: 16px 0 6px; }
.file-content-md p { margin: 0 0 10px; }
.file-content-md ul, .file-content-md ol { margin: 0 0 8px 0; padding-left: 20px; }
.file-content-md ul ul, .file-content-md ul ol,
.file-content-md ol ul, .file-content-md ol ol { margin: 2px 0 2px 0; padding-left: 16px; }
.file-content-md li { margin-bottom: 3px; }
.file-content-md code { font-family: Consolas, Menlo, monospace; font-size: 12px; background: var(--tag-bg); padding: 1px 5px; border-radius: 3px; border: 1px solid var(--line); }
.file-content-md pre { background: var(--tag-bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; overflow-x: auto; margin: 0 0 12px; }
.file-content-md pre code { background: none; padding: 0; border: none; font-size: 12px; }
.file-content-md blockquote { border-left: 3px solid var(--accent); margin: 0 0 10px; padding: 4px 14px; color: var(--muted); background: rgba(9,105,218,0.04); }
.file-content-md a { color: var(--accent); text-decoration: none; cursor: pointer; }
.file-content-md a:hover { text-decoration: underline; }
.file-content-md table { border-collapse: collapse; width: 100%; margin-bottom: 12px; font-size: 13px; }
.file-content-md th { background: var(--tag-bg); padding: 6px 12px; border: 1px solid var(--line); font-weight: 600; text-align: left; }
.file-content-md td { padding: 6px 12px; border: 1px solid var(--line); }
.file-content-md hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.file-content-html { border: none; width: 100%; height: 100%; background: #fff; }
.file-content-raw { font-family: Consolas, Menlo, 'SF Mono', monospace; font-size: 12px; line-height: 1.55; white-space: pre-wrap; color: var(--text); background: transparent; border: none; }

.hw-root { padding: 18px 20px 24px; font-size: 13px; max-width: 720px; }
.hw-axis-desc { font-size: 11px; color: var(--muted); margin-bottom: 14px; }
.hw-teams-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; gap: 16px; }
.hw-tbl, .hw-tbr { display: flex; flex-direction: column; }
.hw-tbr { align-items: flex-end; text-align: right; }
.hw-bigpct { font-size: 36px; font-weight: 700; line-height: 1; }
.hw-bigpct-l { color: #dc2626; }
.hw-bigpct-r { color: #1d4ed8; }
.hw-bigmeta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.hw-bigmeta-r { text-align: right; }
.hw-bigname { font-size: 14px; font-weight: 600; margin-top: 3px; }
.hw-bigname-r { text-align: right; }
.hw-winbar { position: relative; display: flex; height: 30px; border-radius: 4px; overflow: hidden; margin-bottom: 5px; }
.hw-wb-l { background: #dc2626; flex-shrink: 0; }
.hw-wb-r { background: #1d4ed8; flex: 1; }
.hw-wb-label { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.hw-wb-label-l { left: 10px; }
.hw-wb-label-r { right: 10px; }
.hw-subrow { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.hw-edge-note { color: var(--accent); }
.hw-sec-title { font-size: 14px; font-weight: 600; margin: 0 0 2px; }
.hw-sec-note { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.hw-sec-sub { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.hw-sec-mt { margin-top: 18px; }
.hw-chart-wrap { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 4px 4px 2px; overflow: hidden; }
.hw-legend { display: flex; flex-wrap: wrap; gap: 5px 14px; margin: 8px 0 12px; }
.hw-legend-item { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.hw-legend-sw { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.hw-worlds-list { display: flex; flex-direction: column; gap: 10px; }
.hw-world-hdr { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.hw-wdot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.hw-wname { font-size: 13px; font-weight: 600; flex: 1; }
.hw-wfav { font-size: 11px; font-weight: 500; flex-shrink: 0; }
.hw-wbar-track { height: 22px; background: var(--tag-bg); border-radius: 4px; overflow: hidden; }
.hw-wbar-fill { height: 100%; display: flex; align-items: center; border-radius: 4px; min-width: 44px; transition: width 0.3s; }
.hw-wpct { font-size: 12px; font-weight: 700; color: #fff; padding: 0 8px; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.hw-footnote { font-size: 10px; color: var(--muted); margin: 4px 0 6px; font-style: italic; }
.hw-footer { margin-top: 18px; font-size: 10px; color: var(--muted); padding-top: 10px; border-top: 1px solid var(--line); }

.file-content-raw span[id] { display: block; }
.file-content-raw .line-highlight { background: #fef08a; color: #1a1a1a; border-left: 3px solid #eab308; padding-left: 13px; margin: 0 -16px; padding-right: 16px; }
.file-content-md sup { font-size: 0.75em; line-height: 1; margin: 0 1px; }
.file-content-md sup a { text-decoration: none; }
.file-content-md sup a:hover { text-decoration: underline; }
.log-drawer {
  position: sticky;
  bottom: 0;
  background: #0d1117;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  max-height: 220px;
}
.log-drawer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.log-drawer-title { font-size: 12px; font-weight: 600; color: var(--muted); flex: 1; }
.live-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  margin: 0;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
}

/* \u2500\u2500 Forms \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.form-body { display: flex; flex-direction: column; gap: 16px; max-width: 680px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.label-full { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.hint { font-size: 11px; color: var(--muted); font-weight: normal; }
input[type=text], input[type=date], input[type=number], select, textarea {
  padding: 7px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: var(--tag-bg);
  color: var(--text);
  font-size: 13px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }
.form-actions { display: flex; align-items: center; gap: 12px; padding-top: 4px; }
.field-hint { font-size: 12px; color: var(--muted); }

/* \u2500\u2500 Info / MCP sections \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.info-section { margin-bottom: 24px; max-width: 680px; }
.info-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 8px; }
.info-value { font-size: 14px; color: var(--text); margin-bottom: 16px; }
.copy-row { display: flex; align-items: center; gap: 10px; }
.copy-row code { font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); flex: 1; }
.tool-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.tool-list li { font-size: 13px; color: var(--muted); }
.tool-list code { color: var(--text); }
.code-block {
  margin: 0 0 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  color: var(--muted);
  overflow: auto;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
  max-width: 980px;
}
.settings-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 18px 16px;
}
.settings-card.full {
  grid-column: 1 / -1;
}
.settings-card-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
}
.settings-card-subtitle {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.settings-row-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.settings-row-value {
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
}
.settings-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.settings-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--tag-bg);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text);
}
.settings-empty {
  font-size: 13px;
  color: var(--muted);
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.settings-inline-note {
  font-size: 12px;
  color: var(--muted);
}
.settings-secret-actions {
  gap: 8px;
}
.settings-secret-input {
  min-width: 280px;
  flex: 1;
  max-width: 520px;
  height: 32px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: var(--tag-bg);
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
}
.settings-secret-input:focus {
  outline: none;
  border-color: var(--accent);
}
.settings-runtime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px 16px;
}
.settings-runtime-input {
  min-width: 0;
  max-width: none;
}
.settings-runtime-textarea {
  min-height: 110px;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--tag-bg);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: 'SF Mono', Consolas, monospace;
  line-height: 1.45;
}
.settings-runtime-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.settings-output {
  margin-top: 12px;
}
.settings-output code {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tag-bg);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}
.settings-members {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--tag-bg);
}
.settings-member-main {
  min-width: 0;
}
.settings-member-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.settings-member-email {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  word-break: break-word;
}
.settings-member-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.settings-member-role {
  font-size: 12px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
}
.settings-member-joined {
  font-size: 11px;
  color: var(--muted);
}
.settings-subsection {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.settings-subsection-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* \u2500\u2500 States \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
/* -- Unauthenticated screen ---------------------------------------- */
.unauth-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
}
.unauth-shell {
  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.unauth-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 36px 32px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(208, 215, 222, 0.95);
  border-radius: 20px;
  text-align: center;
  width: 100%;
  box-shadow: 0 18px 50px rgba(18, 38, 63, 0.10);
  backdrop-filter: blur(12px);
}
.unauth-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.unauth-brand:hover {
  text-decoration: none;
}
.unauth-brand-text { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.unauth-mark { width: 96px; height: 96px; flex-shrink: 0; }
.unauth-subtitle {
  font-size: 13px;
  color: var(--muted);
}
.unauth-title { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; color: var(--text); line-height: 1; }
.unauth-desc { margin: 0; font-size: 15px; color: var(--muted); line-height: 1.7; max-width: 28ch; }
.unauth-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}
.unauth-signin { padding: 10px 24px; font-size: 14px; text-align: center; }
.unauth-site-link {
  font-size: 13px;
  color: var(--accent);
  text-align: center;
}
.unauth-copyright {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.loading, .empty { color: var(--muted); font-size: 13px; padding: 24px 12px; }
.error { color: var(--red); font-size: 13px; padding: 24px 0; }

/* \u2500\u2500 Responsive \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
@media (max-width: 640px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .app.sidebar-open .sidebar-overlay { display: block; }
  .sidebar-mobile-btn { display: flex; }
  .detail-split { flex-direction: column; }
  .file-tree { width: 100% !important; max-height: 200px; border-right: none; border-bottom: 1px solid var(--line); }
  .file-tree-resizer { display: none; }
  .hw-teams-row { flex-direction: column; align-items: stretch; }
  .hw-tbr { align-items: flex-start; text-align: left; }
  .hw-bigmeta-r, .hw-bigname-r { text-align: left; }
  .unauth-screen { padding: 24px 16px; }
  .unauth-card { padding: 30px 24px; border-radius: 18px; }
  .unauth-signin { width: 100%; text-align: center; }
}

/* ── Project context menu ────────────────────────────── */
.project-ctx-menu {
  position: absolute; z-index: 200;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px; min-width: 140px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.project-ctx-menu button {
  display: block; width: 100%; text-align: left;
  padding: 7px 12px; border: none; background: none;
  color: var(--text); font-size: 13px; cursor: pointer; border-radius: 5px;
}
.project-ctx-menu button:hover { background: var(--tag-bg); }

/* ── Modals ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.45); display: flex;
  align-items: center; justify-content: center;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 24px; width: 380px; max-width: 94vw;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  display: flex; flex-direction: column; gap: 16px;
}
.modal-title { font-size: 16px; font-weight: 600; margin: 0; }
.modal-body-text { font-size: 14px; color: var(--muted); margin: 0; }
.modal .form-body { display: flex; flex-direction: column; gap: 8px; }
.modal .input { width: 100%; box-sizing: border-box;
  padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg); color: var(--text); font-size: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn-danger {
  background: #dc2626; color: #fff; border: none;
  padding: 7px 16px; border-radius: 7px; font-size: 13px; cursor: pointer;
}
.btn-danger:hover { background: #b91c1c; }
