:root {
  --ink: #0f172a;
  --ink-soft: #64748b;
  --paper: #ffffff;
  --surface: #f8fafc;
  --surface-2: #f1f5f9;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #0e7490;
  --accent-soft: #ecfeff;
  --accent-ring: #a5f3fc;
  --ready: #047857;
  --ready-bg: #ecfdf5;
  --soon: #64748b;
  --soon-bg: #f1f5f9;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --sidebar-w: 272px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--surface);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", "Hiragino Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

#suite-bar-root {
  flex-shrink: 0;
}

#suite-bar-root[hidden] {
  display: none !important;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1;
  min-height: 0;
  height: auto;
}

.sidebar {
  background: var(--paper);
  color: var(--ink);
  padding: 1.35rem 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow: auto;
  border-right: 1px solid var(--line);
}

.brand {
  padding: 0.15rem 0.55rem 0.35rem;
}

.brand-mark {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
}

.brand-sub {
  margin-top: 0.15rem;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.sidebar-note {
  margin: 0 0.55rem 0.35rem;
  font-size: 0.75rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.nav-group-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 600;
  margin: 0 0 0.3rem 0.55rem;
}

.nav-link {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  transition: background 0.12s ease, color 0.12s ease;
  border-left: 2px solid transparent;
}

.nav-link:hover {
  background: var(--surface);
}

.nav-link.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--ink);
}

.nav-link-title {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.nav-link-meta {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.22rem;
}

.pill {
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: var(--soon-bg);
  color: var(--soon);
  font-weight: 600;
}

.pill.ready {
  color: var(--ready);
  background: var(--ready-bg);
}

.sidebar-foot {
  font-size: 0.68rem;
  color: #94a3b8;
  padding: 0.85rem 0.55rem 0.35rem;
  border-top: 1px solid var(--line);
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.app-version {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  color: #94a3b8;
  user-select: all;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.topbar {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1.15rem 1.5rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.role-bar {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  min-width: 12rem;
}

.context-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  justify-content: flex-end;
  align-items: flex-end;
}

.role-user {
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.role-switch {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: flex-end;
}

.role-switch-label {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 700;
}

.role-switch select {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  min-width: 9.5rem;
  cursor: pointer;
}

.menu-btn {
  display: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

.topbar-text h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.topbar-summary {
  margin: 0.3rem 0 0;
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.45;
  max-width: 52rem;
}

.frame-wrap {
  flex: 1;
  min-height: 0;
  padding: 1rem 1.25rem 1.25rem;
  position: relative;
}

#screen-frame {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 7rem);
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.screen-denied {
  min-height: calc(100vh - 7rem);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.screen-denied[hidden] {
  display: none;
}

.denied-card {
  max-width: 28rem;
  text-align: center;
}

.denied-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  color: var(--ink);
}

.denied-card p {
  margin: 0.4rem 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.5;
}

.denied-card code {
  font-size: 0.85em;
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.denied-card .auth-gate-retry {
  margin-top: 1rem;
}

@media (max-width: 860px) {
  .role-bar {
    margin-left: 0;
    align-items: stretch;
    width: 100%;
  }
  .context-switches {
    justify-content: stretch;
    flex-direction: column;
    align-items: stretch;
  }
  .role-switch {
    align-items: stretch;
  }
  .role-switch select {
    width: 100%;
    min-width: 0;
  }
  .topbar {
    flex-wrap: wrap;
  }
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, var(--sidebar-w));
    z-index: 20;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 10% -10%, #ecfeff 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f0f9ff 0%, transparent 50%),
    var(--surface);
  padding: 1.5rem;
}

.auth-gate[hidden] {
  display: none !important;
}

.app[hidden] {
  display: none !important;
}

.auth-gate-card {
  width: min(420px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.75rem 1.5rem;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}

.auth-gate-card .brand-mark {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-gate-card .brand-sub {
  color: var(--accent);
  font-weight: 600;
  margin-top: 0.15rem;
}

.auth-gate-status {
  margin: 1.25rem 0 0.35rem;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
}

.auth-gate-hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.auth-gate-retry {
  margin-top: 1rem;
  border: 1px solid var(--line-strong);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
