/* Overlay chrome: menus, modals, and routed dialog surfaces. */
.topbar-menu-root {
  position: fixed;
  inset: 0;
  z-index: var(--z-menu);
  pointer-events: none;
}

.topbar-menu-root.open {
  pointer-events: auto;
}

.topbar-menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.topbar-menu {
  position: absolute;
  top: 82px;
  right: 16px;
  width: min(340px, calc(100vw - 32px));
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.topbar-menu-title {
  font-size: var(--font-size-md);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--muted);
}

.topbar-menu-actions {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}


.context-menu-root {
  position: fixed;
  inset: 0;
  z-index: var(--z-context-menu);
  pointer-events: none;
}

.context-menu-root.open {
  pointer-events: auto;
}

.context-menu-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
}

.context-menu {
  position: absolute;
  width: 240px;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.context-menu-item {
  width: 100%;
  justify-content: flex-start;
}

.planner-wizard-root {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal-base) + 20);
  pointer-events: none;
}

.planner-wizard-root.open {
  pointer-events: auto;
}

.planner-wizard-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.planner-wizard {
  position: absolute;
  inset: 0;
  margin: 72px auto;
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 96px);
  padding: var(--space-7);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  overflow: hidden;
}

.planner-wizard-header {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
  justify-content: space-between;
}

.planner-wizard-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
}

.planner-wizard-subtitle {
  color: var(--muted);
  font-size: var(--font-size-md);
  margin-top: var(--space-1);
}

.planner-wizard-body {
  display: flex;
  gap: var(--space-7);
  flex: 1 1 auto;
  min-height: 0;
}

.planner-wizard-options {
  flex: 0 0 360px;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

.planner-wizard-preview {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.planner-wizard-preview-canvas {
  width: 100%;
  max-width: 760px;
  height: auto;
  border-radius: var(--radius-lg);
  background: #050a18;
  box-shadow: var(--shadow-floating);
}

.planner-wizard-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.planner-wizard-section-title {
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--muted);
}

.planner-wizard-field {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  width: 100%;
}

.planner-wizard-field-label {
  min-width: 90px;
  color: var(--muted);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.planner-wizard-footer {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-3);
}

.template-gallery-root {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-base);
  pointer-events: none;
}

.template-gallery-root.open {
  pointer-events: auto;
}

.template-gallery-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.project-hub-root {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-base);
  pointer-events: none;
}

.project-hub-root.open {
  pointer-events: auto;
}

.project-hub-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.project-hub {
  position: absolute;
  inset: 0;
  margin: 48px auto;
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: var(--space-7);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  overflow: hidden;
}

.project-hub-header {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
  justify-content: space-between;
}

.project-hub-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
}

.project-hub-subtitle {
  color: var(--muted);
  font-size: var(--font-size-md);
  margin-top: var(--space-1);
}

.project-hub-body {
  display: flex;
  gap: var(--space-7);
  flex: 1 1 auto;
  min-height: 0;
}

.project-hub-nav {
  flex: 0 0 180px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.project-hub-content {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius-xl);
  border: var(--border-w) solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.project-hub-scroll {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-7);
}

.project-hub-document {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.about-modal-root {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal-base) + 10);
  pointer-events: none;
}

.about-modal-root.open {
  pointer-events: auto;
}

.about-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.about-modal {
  position: absolute;
  inset: 0;
  margin: 120px auto;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 160px);
  padding: var(--space-7);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  overflow: hidden;
}

.about-modal-header {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
  justify-content: space-between;
}

.about-modal-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
}

.about-modal-subtitle {
  color: var(--muted);
  font-size: var(--font-size-md);
  margin-top: var(--space-1);
}

.about-modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.about-modal-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.about-modal-section-title {
  font-size: var(--font-size-md);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--muted);
}

.autosave-modal-root {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal-base) + 15);
  pointer-events: none;
}

.autosave-modal-root.open {
  pointer-events: auto;
}

.autosave-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}

.autosave-modal {
  position: absolute;
  inset: 0;
  margin: 140px auto;
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100vh - 180px);
  padding: var(--space-7);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  overflow: hidden;
}

.autosave-modal-header {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
  justify-content: space-between;
}

.autosave-modal-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
}

.autosave-modal-subtitle {
  color: var(--muted);
  font-size: var(--font-size-md);
  margin-top: var(--space-1);
}

.autosave-modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.autosave-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.command-palette-root {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal-base) + 12);
  pointer-events: none;
}

.command-palette-root.open {
  pointer-events: auto;
}

.command-palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 12, 24, 0.62);
}

.command-palette {
  position: absolute;
  inset: 0;
  margin: 120px auto;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 200px);
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overflow: hidden;
}

.command-palette-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.command-palette-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
}

.command-palette-input {
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: rgba(8, 12, 20, 0.6);
  color: var(--text);
  font-size: var(--font-size-md);
}

.command-palette-input:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset-tight);
}

.command-palette-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow-y: auto;
  padding-right: 6px;
}

.command-palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border: var(--border-w) solid transparent;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.command-palette-item.active {
  border-color: rgba(34, 211, 238, 0.6);
  background: rgba(34, 211, 238, 0.12);
}

.command-palette-item.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.command-palette-item-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.command-palette-item-label {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
}

.command-palette-item-meta {
  font-size: var(--font-size-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.template-gallery {
  position: absolute;
  inset: 0;
  margin: 96px auto;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 128px);
  padding: var(--space-7);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  overflow: hidden;
}

.template-gallery-header {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
  justify-content: space-between;
}

.template-gallery-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
}

.template-gallery-subtitle {
  color: var(--muted);
  font-size: var(--font-size-md);
  margin-top: var(--space-1);
}

.template-gallery-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

.template-gallery-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.template-gallery-section-title {
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--muted);
}

.template-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-5);
}

.template-gallery-tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  text-align: left;
  width: 100%;
}

.template-gallery-tile-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
}

.template-gallery-tile-desc {
  font-size: var(--font-size-sm);
  color: var(--muted);
  line-height: 1.3;
}

.template-gallery-hint {
  width: fit-content;
}

@media (max-width: 980px) {
  .planner-wizard {
    margin: 40px auto;
    max-height: calc(100vh - 80px);
  }

  .planner-wizard-body {
    flex-direction: column;
  }

  .planner-wizard-options {
    flex: 0 0 auto;
  }

  .planner-wizard-preview-canvas {
    max-width: 100%;
  }

  .template-gallery {
    margin: 40px auto;
    max-height: calc(100vh - 80px);
  }

  .template-gallery-grid {
    grid-template-columns: 1fr;
  }

  .project-hub {
    margin: 40px auto;
    max-height: calc(100vh - 80px);
  }

  .project-hub-body {
    flex-direction: column;
  }

  .project-hub-nav {
    flex-direction: row;
    flex: 0 0 auto;
    overflow-x: auto;
    overflow-y: hidden;
  }
}
