/* App shell layout: header + canvas + floating hosts + overlays. */

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------------------------------------------------------------- Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 32px;
  padding: 0 var(--sp-3);
  border: var(--border);
  border-radius: var(--r-pill);
  background: var(--c-surface);
  color: var(--c-ink);
  font-size: var(--fs-normal);
  font-weight: var(--fw-medium);
  transition: background var(--t-base), border-color var(--t-base);
  white-space: nowrap;
}
.btn:hover { background: 
  var(--c-surface-hover); 
  /* color: var(--c-accent);  */
}
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-primary {
  background: var(--c-accent);
  color: var(--c-ink-inv);
  border-color: var(--c-accent);
}
.btn-primary:hover { background: var(--c-accent-hover); }

.btn-danger {
  background: var(--c-splash-red) !important;
  color: var(--c-ink-inv);
  border-color: var(--c-splash-red);
}
.btn-danger:hover { filter: brightness(0.95); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--c-surface-hover); }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  border-radius: var(--r-pill);
}

/* ---------------------------------------------------------------- Header */

.app-header {
  position: relative;
  flex: 0 0 var(--header-h);
  height: var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 var(--sp-3);
  border-bottom: var(--border);
  background: var(--c-surface);
  z-index: var(--z-header);
}

.app-header__left { justify-self: start; display: flex; align-items: center; gap: var(--sp-2); }
.app-header__center { justify-self: center; display: flex; align-items: center; gap: var(--sp-2); }
.app-header__right { justify-self: end; display: flex; align-items: center; gap: var(--sp-2); }

.base-switch {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 2px;
  border: var(--border);
  border-radius: var(--r-pill);
  background: var(--c-surface-2);
  box-shadow: inset 0 0 0 1px rgba(10, 10, 10, 0.02);
}
.base-switch__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--c-ink-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  cursor: pointer;
}
.base-switch__btn:hover {
  color: var(--c-ink);
  background: var(--c-surface-hover);
}
.base-switch__btn.is-active {
  background: var(--c-ink);
  color: var(--c-ink-inv);
  box-shadow: 0 1px 3px rgba(10, 10, 10, 0.14);
}
.base-switch__btn.is-active:hover {
  background: var(--c-ink);
  color: var(--c-ink-inv);
}
.base-switch__btn:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
}

.app-brand__logo {
  width: 36px;
  height: 36px;
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}
.app-brand__logo::before,
.app-brand__logo > span {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.4s ease, border-color 0.4s ease;
}
.app-brand__logo::before {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, #1A1A1A 60%, #0A0A0A 100%);
}
.app-brand__logo > span:nth-child(1) {
  width: 90%;
  height: 90%;
  z-index: 300;
  background: transparent;
  border: 3.5px solid #0a0a0a;
  transform: translate(calc(-50% + 0.93px), calc(-50% + 0.93px));
}
.app-brand__logo > span:nth-child(2) {
  width: 80%;
  height: 80%;
  background: radial-gradient(circle, #444444 55%, #1A1A1A 100%);
  transform: translate(calc(-50% + 1.87px), calc(-50% + 1.87px));
}
.app-brand__logo > span:nth-child(3) {
  width: 68%;
  height: 68%;
  background: radial-gradient(circle, #5A5A5A 55%, #444444 100%);
  transform: translate(calc(-50% + 2.8px), calc(-50% + 2.8px));
}
.app-brand__logo > span:nth-child(4) {
  width: 56%;
  height: 56%;
  background: radial-gradient(circle, #707070 55%, #5A5A5A 100%);
  transform: translate(calc(-50% + 3.73px), calc(-50% + 3.73px));
}
.app-brand__logo > span:nth-child(5) {
  width: 44%;
  height: 44%;
  background: radial-gradient(circle, #868686 55%, #707070 100%);
  transform: translate(calc(-50% + 4.67px), calc(-50% + 4.67px));
}
.app-brand__logo > span:nth-child(6) {
  width: 34%;
  height: 34%;
  background: radial-gradient(circle, #9B9B9B 55%, #868686 100%);
  transform: translate(calc(-50% + 5.6px), calc(-50% + 5.6px));
}
.app-brand__logo > span:nth-child(7) {
  width: 24%;
  height: 24%;
  background: #B5B5B5;
  transform: translate(calc(-50% + 6.53px), calc(-50% + 6.53px));
}

@keyframes wave-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.6); }
}

.app-brand__logo:hover::before,
.app-brand__logo:hover > span {
  animation: wave-pulse 1.4s ease-in-out infinite;
}

.app-brand__logo:hover > span:nth-child(7) { animation-delay: 0s; }
.app-brand__logo:hover > span:nth-child(6) { animation-delay: 0.1s; }
.app-brand__logo:hover > span:nth-child(5) { animation-delay: 0.2s; }
.app-brand__logo:hover > span:nth-child(4) { animation-delay: 0.3s; }
.app-brand__logo:hover > span:nth-child(3) { animation-delay: 0.4s; }
.app-brand__logo:hover > span:nth-child(2) { animation-delay: 0.5s; }
.app-brand__logo:hover > span:nth-child(1) { animation-delay: 0.6s; }
.app-brand__logo:hover::before { animation-delay: 0.7s; }

@keyframes intake-logo-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.94); }
}

.app-brand__logo.is-loading {
  animation: intake-logo-breathe 1.6s ease-in-out infinite;
  transform-origin: center;
  cursor: default;
}

.app-brand__logo.is-loading > span:nth-child(1) {
  border-width: 7px;
}

.app-brand__logo.is-loading,
.app-brand__logo.is-loading::before,
.app-brand__logo.is-loading > span {
  animation: wave-pulse 1.6s ease-in-out infinite;
}

.app-brand__logo.is-loading:hover,
.app-brand__logo.is-loading:hover::before,
.app-brand__logo.is-loading:hover > span {
  animation: wave-pulse 1.6s ease-in-out infinite;
}

.app-brand__logo.is-loading::before,
.app-brand__logo.is-loading > span {
  animation-delay: 0s;
}

.app-brand__logo.is-loading > span:nth-child(7) { animation-delay: 0s; }
.app-brand__logo.is-loading > span:nth-child(6) { animation-delay: 0.1s; }
.app-brand__logo.is-loading > span:nth-child(5) { animation-delay: 0.2s; }
.app-brand__logo.is-loading > span:nth-child(4) { animation-delay: 0.3s; }
.app-brand__logo.is-loading > span:nth-child(3) { animation-delay: 0.4s; }
.app-brand__logo.is-loading > span:nth-child(2) { animation-delay: 0.5s; }
.app-brand__logo.is-loading > span:nth-child(1) { animation-delay: 0.6s; }
.app-brand__logo.is-loading::before { animation-delay: 0.7s; }

@media (prefers-reduced-motion: reduce) {
  .app-brand__logo.is-loading,
  .app-brand__logo.is-loading::before,
  .app-brand__logo.is-loading > span {
    animation: none;
  }
}

/* Context dropdown */
.ws-switcher { position: relative; }
.ws-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 32px;
  padding: 0 var(--sp-3);
  border: var(--border);
  border-radius: var(--r-pill);
  background: var(--c-surface);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  max-width: 260px;
}
.ws-switcher__btn:hover { background: var(--c-surface-hover); }
.ws-switcher__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }

.menu {
  position: absolute;
  top: calc(100% + 7px);
  min-width: 220px;
  background: var(--c-surface);
  border: 0;
  border-bottom: var(--border);
  border-left: var(--border);
  border-right: var(--border);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
      box-shadow: 2px 20px 16px 1px rgba(10, 10, 10, 0.10);
  padding: var(--sp-1);
  z-index: var(--z-menu);
}
.menu--left { left: 0; }
.menu--right { right: 0; }

.menu__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-xl);
  font-size: var(--fs-normal);
  text-align: left;
  color: var(--c-ink);
}
.menu__item:hover { background: var(--c-surface-hover); }
.menu__item.is-active { font-weight: var(--fw-semibold); }
.menu__sep { height: 1px; background: var(--c-line); margin: var(--sp-1) 0; }
.menu__label { padding: var(--sp-2) var(--sp-3) var(--sp-1); font-size: var(--fs-2xs); color: var(--c-ink-3); text-transform: uppercase; letter-spacing: 0.04em; }

/* Blueprint switcher: item label grows + truncates, with a trailing badge. */
.menu__item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu__item-badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-ink-3);
  background: var(--c-surface-2);
  border: var(--bw) solid var(--c-line-2);
  border-radius: var(--r-xs);
  padding: 0 4px;
}
.menu__item-badge--shared {
  color: var(--c-accent);
  background: var(--c-surface-hover);
  border-color: var(--c-accent);
}
/* Nested "New blueprint" template list. */
.menu__sub {
  display: flex;
  flex-direction: column;
  margin: 2px 0 0 var(--sp-3);
  padding-left: var(--sp-2);
  border-left: var(--border);
}

/* Blueprint folders: a folder header (icon + name + count + actions) above a
   nested list of its blueprints. The "Unsorted" header omits the actions. */
.menu__folder-group + .menu__folder-group { margin-top: var(--sp-1); }
.menu__folder-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  color: var(--c-ink-3);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.menu__folder-header-label {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu__folder-count {
  font-size: 9px;
  color: var(--c-ink-3);
  background: var(--c-surface-2);
  border: var(--bw) solid var(--c-line-2);
  border-radius: var(--r-xs);
  padding: 0 4px;
  text-transform: none;
  letter-spacing: 0;
}
.menu__folder-items {
  display: flex;
  flex-direction: column;
  margin: 0 0 var(--sp-1) var(--sp-3);
  padding-left: var(--sp-2);
  border-left: var(--border);
}

/* Row with an item that grows + trailing action buttons (board switcher). */
.menu__item-row { display: flex; align-items: center; gap: 2px; }
.menu__item-row .menu__item--grow { flex: 1; min-width: 0; }
.menu__item-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--c-ink-3);
  cursor: pointer;
}
.menu__item-action:hover { background: var(--c-surface-hover); color: var(--c-ink); }

.org-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 32px;
  padding: 0 var(--sp-2) 0 var(--sp-1);
  border: var(--border);
  border-radius: var(--r-pill);
  font-size: var(--fs-normal);
}
.org-avatar {
  width: 22px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--c-accent);
  color: var(--c-ink-inv);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  overflow: hidden;
  flex: 0 0 auto;
}
.org-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* ---------------------------------------------------------------- Stage */

.app-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: var(--canvas-bg);
}

/* ---------------------------------------------------------------- Auth gate */

.auth-gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--c-bg-sunken);
  z-index: var(--z-overlay);
}
.auth-card {
  width: 360px;
  max-width: calc(100vw - var(--sp-8));
  background: var(--c-surface);
  border: var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.auth-card__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.auth-card__logo {
  width: 200px;
  height: 200px;
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  margin-bottom: 10px;
      transform: translateX(-10px);
}
.auth-card__logo::before,
.auth-card__logo > span {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.4s ease, border-color 0.4s ease;
}
.auth-card__logo::before {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, #1A1A1A 60%, #0A0A0A 100%);
}
.auth-card__logo > span:nth-child(1) {
  width: 90%;
  height: 90%;
  z-index: 300;
  background: transparent;
  border: 20px solid #0a0a0a;
  transform: translate(calc(-50% + 6.67px), calc(-50% + 6.67px));
}
.auth-card__logo > span:nth-child(2) {
  width: 80%;
  height: 80%;
  background: radial-gradient(circle, #444444 55%, #1A1A1A 100%);
  transform: translate(calc(-50% + 13.33px), calc(-50% + 13.33px));
}
.auth-card__logo > span:nth-child(3) {
  width: 68%;
  height: 68%;
  background: radial-gradient(circle, #5A5A5A 55%, #444444 100%);
  transform: translate(calc(-50% + 20px), calc(-50% + 20px));
}
.auth-card__logo > span:nth-child(4) {
  width: 56%;
  height: 56%;
  background: radial-gradient(circle, #707070 55%, #5A5A5A 100%);
  transform: translate(calc(-50% + 26.67px), calc(-50% + 26.67px));
}
.auth-card__logo > span:nth-child(5) {
  width: 44%;
  height: 44%;
  background: radial-gradient(circle, #868686 55%, #707070 100%);
  transform: translate(calc(-50% + 33.33px), calc(-50% + 33.33px));
}
.auth-card__logo > span:nth-child(6) {
  width: 34%;
  height: 34%;
  background: radial-gradient(circle, #9B9B9B 55%, #868686 100%);
  transform: translate(calc(-50% + 40px), calc(-50% + 40px));
}
.auth-card__logo > span:nth-child(7) {
  width: 24%;
  height: 24%;
  background: radial-gradient(circle, #B5B5B5 55%, #9B9B9B 100%);
  transform: translate(calc(-50% + 46.67px), calc(-50% + 46.67px));
}

.auth-card__logo:hover::before,
.auth-card__logo:hover > span {
  animation: wave-pulse 1.4s ease-in-out infinite;
}

.auth-card__logo:hover > span:nth-child(7) { animation-delay: 0s; }
.auth-card__logo:hover > span:nth-child(6) { animation-delay: 0.1s; }
.auth-card__logo:hover > span:nth-child(5) { animation-delay: 0.2s; }
.auth-card__logo:hover > span:nth-child(4) { animation-delay: 0.3s; }
.auth-card__logo:hover > span:nth-child(3) { animation-delay: 0.4s; }
.auth-card__logo:hover > span:nth-child(2) { animation-delay: 0.5s; }
.auth-card__logo:hover > span:nth-child(1) { animation-delay: 0.6s; }
.auth-card__logo:hover::before { animation-delay: 0.7s; }
.auth-card__title { font-size: var(--fs-3xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; line-height: 1.2;}
.auth-card__slogan { font-style: italic; font-size: var(--fs-lg); color: var(--c-ink-3); }
.auth-field { display: flex; flex-direction: column; gap: var(--sp-1); }
.auth-field label { font-size: var(--fs-xs); color: var(--c-ink-2); }
.input {
  height: 38px;
  padding: 0 var(--sp-3);
  border: var(--border-2);
  border-radius: var(--r-pill);
  background: var(--c-surface);
  font-size: var(--fs-normal);
}
.input:focus { outline: none; border-color: var(--c-line-strong); }
.auth-divider { display: flex; align-items: center; gap: var(--sp-3); color: var(--c-ink-3); font-size: var(--fs-xs); }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--c-line); }
.auth-toggle { font-size: var(--fs-normal); color: var(--c-ink-2); text-align: center; }
.auth-toggle button { color: var(--c-accent); font-weight: var(--fw-medium); text-decoration: underline; }
.auth-error {
  font-size: var(--fs-normal);
  color: var(--c-splash-red);
  background: var(--c-error-soft);
  border: 1px solid var(--c-error-line);
  border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3);
}
.btn-block { width: 100%; height: 38px; justify-content: center; }

/* ---------------------------------------------------------------- Overlays */

.overlay {
  position: absolute;
  inset: 0;
  background: var(--c-bg);
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.overlay__header {
  display: flex;
  height: 48px;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-6);
  border-bottom: var(--border);
}
.overlay__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.overlay__body { padding: var(--sp-6); }

/* ---------------------------------------------------------------- Empty states */

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  color: var(--c-ink-3);
  text-align: center;
}
.empty__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--c-ink-2); }

.app-loading .app-brand__logo {
  width: 80px;
  height: 80px;
  cursor: default;
}
.app-loading__text {
  font-size: var(--fs-md);
  color: var(--c-ink-3);
  letter-spacing: 0.01em;
}

/* ---------------------------------------------------------------- Toasts */

.toast-host {
  position: fixed;
  bottom: var(--sp-4);
  right: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: var(--z-toast);
}
.toast {
  background: var(--c-accent);
  color: var(--c-ink-inv);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-normal);
}
.toast.is-error { background: var(--c-splash-red); }

.muted { color: var(--c-ink-3); }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
