/* PachBae Studi-OS — TopBar + Sidebar */

/* ─── TopBar ─────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 18px;
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--bg-rail) 90%, oklch(0.22 0.008 65)),
    var(--bg-rail));
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
}
html[data-theme="light"] .topbar {
  background: linear-gradient(180deg, var(--surface), var(--bg-rail));
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent) 30%, var(--accent) 70%, transparent);
  opacity: 0.22;
  filter: blur(0.5px);
}

/* ─── Brand mark ─────────────────────────────────────────────────────── */
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: linear-gradient(180deg, oklch(0.32 0.012 60), oklch(0.16 0.008 60));
  border: 1px solid var(--border-strong);
  display: grid; place-items: center;
  box-shadow:
    inset 0 1px 0 oklch(0.45 0.014 60),
    inset 0 -1px 0 oklch(0.10 0.008 60),
    0 1px 3px rgba(0,0,0,0.5);
  position: relative;
  overflow: hidden;
}
.brand-mark-led {
  width: 9px; height: 9px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, oklch(0.95 0.08 80), var(--accent) 60%);
  box-shadow:
    0 0 10px var(--accent),
    0 0 2px var(--accent),
    inset 0 0 4px oklch(0.50 0.10 60);
  position: relative; z-index: 2;
  animation: led-pulse 3.6s ease-in-out infinite;
}
@keyframes led-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}
.brand-mark-shine {
  position: absolute;
  top: 1px; left: 1px; right: 1px;
  height: 12px;
  border-radius: 6px 6px 50% 50% / 6px 6px 80% 80%;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), transparent);
  pointer-events: none;
}

.brand-wordmark {
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}
.brand-wordmark-accent {
  color: var(--accent);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.brand-tagline {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-top: 4px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.brand-tagline-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: oklch(0.78 0.14 145);
  box-shadow: 0 0 5px oklch(0.78 0.14 145);
}

.topbar-search {
  flex: 1;
  max-width: 520px;
  height: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  transition: border-color 0.15s, background 0.15s;
}
.topbar-search:focus-within {
  border-color: var(--accent);
  background: var(--surface-2);
}
.topbar-search input {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 13px;
  color: var(--text-primary);
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search { position: relative; }

.gs-clear {
  border: 0; background: transparent; color: var(--text-muted);
  font-size: 11px; cursor: pointer; padding: 2px 4px; border-radius: var(--radius-sm);
}
.gs-clear:hover { color: var(--text-primary); background: var(--surface-3); }

.gs-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 200;
  max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
}
.gs-group + .gs-group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); }
.gs-group-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); padding: 6px 8px 4px;
}
.gs-more { color: var(--text-faint); text-transform: none; letter-spacing: 0; }
.gs-item {
  display: flex; align-items: baseline; gap: 10px; width: 100%;
  border: 0; background: transparent; text-align: left; cursor: pointer;
  padding: 7px 8px; border-radius: var(--radius); color: var(--text-primary);
}
.gs-item.hi { background: var(--surface-3); }
.gs-item.hi .gs-item-label { color: var(--accent); }
.gs-item-label { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; min-width: 0; }
.gs-item-sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: auto; flex-shrink: 2; min-width: 0; }
.gs-empty { padding: 14px 10px; font-size: 13px; color: var(--text-muted); }
.gs-foot { font-size: 10px; color: var(--text-faint); padding: 8px 8px 4px; border-top: 1px solid var(--border); margin-top: 4px; }

.kbd-glyph { color: var(--text-muted); font-size: 14px; }

.kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 5px;
  letter-spacing: 0.05em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}
.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}
.icon-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius);
  display: grid; place-items: center;
  color: var(--text-secondary);
  position: relative;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.badge-dot {
  position: absolute; top: 7px; right: 7px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 2px var(--bg-rail);
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, oklch(0.45 0.08 60), oklch(0.30 0.06 60));
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  display: grid; place-items: center;
  letter-spacing: 0.02em;
}

/* Room selector chips */
.room-selector { display: flex; align-items: center; gap: 6px; }
.room-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: all 0.15s;
}
.room-chip .room-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--chip-color);
}
.room-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--surface);
}
.room-chip.active {
  border-color: var(--chip-color);
  background: color-mix(in oklab, var(--chip-color) 12%, var(--surface));
  color: var(--text-primary);
}
.room-chip.active .room-dot {
  box-shadow: 0 0 6px var(--chip-color);
}

/* ─── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-rail);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: width 0.18s ease;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px 8px;
}

.nav-section { margin-bottom: 16px; }
.nav-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 8px 6px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  letter-spacing: -0.005em;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface); color: var(--text-primary); }
.nav-item.active {
  background: color-mix(in oklab, var(--accent) 14%, var(--surface));
  color: var(--text-primary);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 6px var(--accent);
}
.nav-glyph {
  display: inline-block;
  width: 16px; text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.nav-item.active .nav-glyph { color: var(--accent); }
.nav-label { flex: 1; text-align: left; }

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-title {
  display: none;
}
.sidebar.collapsed .nav-item { justify-content: center; padding: 0; }

.sidebar-foot {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.studio-address { gap: 2px; font-size: 11px; line-height: 1.45; text-align: left; }
.studio-address-name { color: var(--text-primary); font-weight: 500; margin-bottom: 2px; }
.studio-address-line { color: var(--text-muted); overflow-wrap: anywhere; }
.studio-address.is-empty { cursor: pointer; border-style: dashed; background: transparent; font: inherit; font-size: 11px; }
.studio-address.is-empty:hover { border-color: var(--border-strong); }
.studio-address.is-empty:hover .studio-address-line { color: var(--accent); }
.site-switch { position: relative; }
.site-switch-btn { width: 100%; cursor: pointer; font: inherit; font-size: 11px; transition: border-color 0.12s; }
.site-switch-btn:hover:not(:disabled) { border-color: var(--border-strong); }
.site-switch-btn:disabled { cursor: progress; opacity: 0.7; }
.site-switch-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.site-switch-chevron { color: var(--text-muted); font-size: 10px; }
.site-switch-btn[aria-expanded="true"] .site-switch-chevron { color: var(--accent); }
/* Opens upward from the foot of the sidebar. */
.role-menu.site-menu { top: auto; bottom: calc(100% + 8px); left: 0; right: auto; width: 240px; }
.status-card-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  white-space: nowrap;
}
.status-card-label { color: var(--text-muted); letter-spacing: 0.01em; }
.status-card-value { color: var(--text-primary); font-family: var(--font-mono); font-feature-settings: "tnum" on; text-align: right; }
.status-card-value.warn { color: var(--red); }
.live-dot {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  box-shadow: 0 0 6px var(--accent);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.collapse-btn {
  height: 26px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}
.collapse-btn:hover { background: var(--surface); color: var(--text-primary); }


/* ─── Role preview ──────────────────────────────────────────────────── */
.role-switch { position: relative; }
.avatar-btn { cursor: pointer; position: relative; padding: 0; transition: box-shadow 0.15s; }
.avatar-btn:hover { box-shadow: 0 0 0 2px var(--surface-3); }
.avatar-btn.previewing { box-shadow: 0 0 0 2px var(--blue); }
.avatar-role {
  position: absolute; right: -4px; bottom: -4px;
  width: 15px; height: 15px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 8.5px; font-weight: 600;
  background: var(--blue); color: oklch(0.18 0.02 240);
  box-shadow: 0 0 0 2px var(--bg-rail);
}
.role-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 300;
  width: 300px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
}
.role-menu-head {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); padding: 6px 8px 4px;
}
.role-menu-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  border: 0; background: transparent; text-align: left; cursor: pointer;
  padding: 8px; border-radius: var(--radius); color: var(--text-primary);
}
.role-menu-item:hover { background: var(--surface-2); }
.role-menu-radio {
  flex-shrink: 0; margin-top: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid var(--border-strong);
}
.role-menu-item.on .role-menu-radio { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 3px, transparent 3.5px); }
.role-menu-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.role-menu-label { font-size: 13px; }
.role-menu-item.on .role-menu-label { color: var(--accent); }
.role-menu-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.35; }
.role-menu-foot {
  font-size: 11px; color: var(--text-faint);
  border-top: 1px solid var(--border); margin-top: 4px; padding: 8px 8px 4px;
}

.role-banner {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 7px 18px;
  font-size: 12.5px; color: var(--text-primary);
  background: color-mix(in oklab, var(--blue) 14%, var(--bg-rail));
  border-bottom: 1px solid color-mix(in oklab, var(--blue) 35%, var(--border));
}
.role-banner strong { color: var(--blue); font-weight: 600; }
.role-banner-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 8px var(--blue); }
.role-banner-meta { font-size: 10.5px; color: var(--text-muted); letter-spacing: 0.03em; }
.role-banner-exit {
  margin-left: auto;
  height: 26px; padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in oklab, var(--blue) 45%, var(--border));
  background: transparent; color: var(--text-primary);
  font-size: 12px; cursor: pointer;
}
.role-banner-exit:hover { background: color-mix(in oklab, var(--blue) 18%, transparent); }

.nav-viewonly {
  font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px;
}
.sidebar.collapsed .nav-viewonly { display: none; }

.viewonly-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 400;
  padding: 9px 16px; border-radius: var(--radius);
  background: var(--surface-3); border: 1px solid color-mix(in oklab, var(--blue) 45%, var(--border));
  color: var(--text-primary); font-size: 12.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  animation: viewonly-in 0.18s ease-out;
}
@keyframes viewonly-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ── Sign-in (backend mode) ─────────────────────────────────────────── */
.signin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg);
}
.signin-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.signin-brand {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.signin-title {
  margin: 4px 0 6px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}
.signin-sub {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.signin-card .st-input { width: 100%; }
.signin-error {
  font-size: 12.5px;
  color: oklch(0.72 0.17 25);
}
.signin-submit { margin-top: 6px; justify-content: center; }

/* ── Save problems (backend mode) ───────────────────────────────────── */
.sync-toast {
  display: flex; align-items: center; gap: 10px;
  border-color: color-mix(in oklab, var(--accent) 50%, var(--border));
}
.sync-toast.denied { border-color: color-mix(in oklab, oklch(0.70 0.18 25) 55%, var(--border)); }
.sync-toast .tb-btn { flex: none; }
@media (max-width: 600px) {
  .sync-toast { left: 16px; right: 16px; transform: none; flex-wrap: wrap; animation: none; }
}
