/* ── Header ──────────────────────────────────────────────── */

.app-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}
.app-header::before {
  content: ""; display: block; height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 33%, var(--green) 33%, var(--green) 66%, var(--red) 66%, var(--red) 100%);
}
.app-header__row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
}
.app-header__row--base-url { padding-top: 0; padding-bottom: 10px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-md);
  background: transparent; border: 1px solid transparent; color: var(--text-secondary);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }

.sidebar-toggle { display: none; }

.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text-primary); }
.brand__mark { color: var(--accent); display: flex; }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: .2px; }
.brand__sub { font-size: 10.5px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 1.1px; }

.version-chip {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--accent-strong);
  background: var(--accent-bg); border: 1px solid transparent;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}

.header-search {
  flex: 1; max-width: 420px; margin-left: 8px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0 10px; height: 36px; box-shadow: var(--shadow-sm);
}
.header-search__icon { color: var(--text-tertiary); flex: none; }
.header-search input {
  flex: 1; border: 0; background: transparent; color: var(--text-primary);
  font-size: 13.5px; font-family: var(--font-body); outline: none; min-width: 0;
}
.header-search input::placeholder { color: var(--text-tertiary); }
.header-search__kbd {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary);
  border: 1px solid var(--border-strong); border-radius: 4px; padding: 1px 5px;
}

.header-actions { display: flex; align-items: center; gap: 4px; }

#theme-toggle .icon-moon { display: none; }
html[data-theme="light"] #theme-toggle .icon-sun { display: none; }
html[data-theme="light"] #theme-toggle .icon-moon { display: inline-flex; }

.base-url {
  display: flex; align-items: stretch; gap: 0; flex: 1; max-width: 640px;
  border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
  background: var(--bg-raised); box-shadow: var(--shadow-sm);
}
.base-url__label {
  display: flex; align-items: center; padding: 0 12px;
  font-size: 11px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .8px;
  font-family: var(--font-mono);
  border-right: 1px solid var(--border); flex: none; background: var(--surface);
}
.base-url select {
  border: 0; background: var(--surface); color: var(--text-secondary); font-size: 12.5px;
  padding: 0 8px; border-right: 1px solid var(--border); max-width: 120px; flex: none;
}
.base-url input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text-primary);
  font-family: var(--font-mono); font-size: 13px; padding: 0 12px; outline: none; height: 36px;
}
.base-url__reset {
  flex: none; width: 36px; border: 0; border-left: 1px solid var(--border);
  background: var(--surface); color: var(--text-tertiary); cursor: pointer; font-size: 15px;
  transition: color .15s, background .15s;
}
.base-url__reset:hover { color: var(--accent); background: var(--surface-hover); }
.base-url__hint { font-size: 11.5px; color: var(--text-tertiary); white-space: nowrap; flex-shrink: 0; }
.app-header__row--base-url { flex-wrap: wrap; }

/* ── Shell / Sidebar ─────────────────────────────────────── */

.app-shell { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky; top: var(--header-h);
  width: var(--sidebar-w); flex: none;
  height: calc(100vh - var(--header-h));
  border-right: 1px solid var(--border);
  background: var(--bg-raised);
  display: flex; flex-direction: column;
}
.sidebar__search {
  display: flex; align-items: center; gap: 7px;
  margin: 12px 14px 6px; padding: 0 9px; height: 32px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
  color: var(--text-tertiary);
}
.sidebar__search input {
  border: 0; background: transparent; outline: none; color: var(--text-primary);
  font-size: 13px; flex: 1; min-width: 0;
}
.sidebar__scroll { flex: 1; overflow-y: auto; padding: 6px 8px 14px; }
.sidebar__footer {
  border-top: 1px solid var(--border); padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--text-tertiary);
}
.sidebar__overview-link { color: var(--text-secondary); text-decoration: none; font-weight: 600; }
.sidebar__overview-link:hover { color: var(--accent); }
.sidebar__loading { padding: 20px 12px; color: var(--text-tertiary); font-size: 13px; }

.sidebar-scrim { display: none; }

/* ── Main content ────────────────────────────────────────── */

.main { flex: 1; min-width: 0; }
.content { max-width: 900px; margin: 0 auto; padding: 40px 32px 120px; }

.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 120px 20px; color: var(--text-tertiary);
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 980px) {
  .header-search { display: none; }
}

@media (max-width: 860px) {
  :root { --header-h: 151px; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; z-index: 60;
    height: auto; transform: translateX(-100%);
    transition: transform .18s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-scrim {
    display: none; position: fixed; inset: var(--header-h) 0 0 0; z-index: 55;
    background: rgba(0,0,0,.4);
  }
  .sidebar-scrim.is-open { display: block; }
  .content { padding: 28px 18px 100px; }
  .base-url__label { display: none; }
  .app-header__row--base-url { flex-direction: column; align-items: stretch; gap: 6px; }
  .base-url { flex-wrap: wrap; max-width: none; width: 100%; }
  .base-url select { flex: 0 1 auto; max-width: none; }
  .base-url input { flex: 1 1 100%; order: 3; border-top: 1px solid var(--border); height: 36px; }
  .base-url__reset { order: 2; }
  .base-url__hint { white-space: normal; }
}

@media (max-width: 560px) {
  .brand__sub { display: none; }
  .version-chip { display: none; }
}
