/* Signed-in Studio app shell */

body.is-app {
  background: #f0ebe3;
  height: 100vh;
  overflow: hidden;
}

body.is-app .app-shell {
  flex: 1;
  width: 100%;
  min-height: 0;
  height: 100vh;
}

body.is-app .top,
body.is-app .mode-rail,
body.is-app .marketing,
body.is-app .foot {
  display: none !important;
}

body.is-app .foot {
  margin-left: 0;
  border-left: 0;
}

body:not(.is-app) .app-sidebar,
body:not(.is-app) .app-topbar,
body:not(.is-app) .app-onboard {
  display: none !important;
}

/* Guest layout: flatten shell wrappers so intro + workspace match original page flow */
body:not(.is-app) .app-shell,
body:not(.is-app) .app-main {
  display: contents;
}

.app-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 100%;
}

.app-sidebar {
  --app-sidebar-w: 4.5rem;
  position: sticky;
  top: 0;
  z-index: 40;
  flex: 0 0 var(--app-sidebar-w);
  width: var(--app-sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.65rem 0 0.75rem;
  background: #faf7f1;
  border-right: 1px solid var(--rule);
}

.app-sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  padding: 0 0.2rem 0.85rem;
  color: var(--seal);
  text-decoration: none;
}

.app-sidebar-brand svg {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
}

.app-sidebar-mark {
  font-family: var(--font-display);
  font-size: 0.46rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.2;
  color: var(--seal-deep);
}

.app-topbar-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex-shrink: 0;
}

body.is-app .app-topbar-brand {
  gap: 0.65rem;
  min-width: 0;
}

body.is-app .app-topbar-brand .seal svg {
  width: 34px;
  height: 34px;
}

body.is-app .app-topbar-brand .brand-mark {
  font-size: 1.45rem;
  letter-spacing: 0.1em;
}

body.is-app .app-topbar-brand .brand-sub {
  font-size: 0.72rem;
  line-height: 1.2;
}

.app-topbar-user {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

body.is-app .app-nav-btn .mode-rail-icon {
  width: 2rem;
  height: 2rem;
  border-width: 1.5px;
}

body.is-app .app-nav-btn .mode-rail-icon svg {
  width: 16px;
  height: 16px;
}

.app-sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  flex: 1;
}

.app-nav-btn,
.app-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 3.15rem;
  min-height: 3.15rem;
  padding: 0.35rem 0.2rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.15;
  transition: background 0.15s ease, color 0.15s ease;
}

.app-nav-btn:hover,
.app-nav-link:hover {
  background: rgba(124, 47, 36, 0.08);
  color: var(--seal);
}

.app-nav-btn.is-active,
.app-nav-link.is-active {
  background: rgba(124, 47, 36, 0.12);
  color: var(--seal);
  box-shadow: inset 3px 0 0 var(--seal);
}

.app-nav-icon {
  display: grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
}

.app-nav-icon svg {
  display: block;
}

.app-sidebar-foot {
  margin-top: auto;
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--paper);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.55rem 1.15rem;
  background: rgba(251, 248, 242, 0.92);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(8px);
}

.app-welcome {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-plan-badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(124, 47, 36, 0.1);
  color: var(--seal-deep);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.app-plan-badge.is-pro {
  background: rgba(47, 93, 69, 0.12);
  color: var(--human);
}

.app-topbar-center {
  flex: 1;
  min-width: 10rem;
  max-width: 22rem;
}

.app-usage {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.app-usage-label {
  margin: 0;
  font-size: 0.68rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.app-usage-bar {
  height: 5px;
  background: rgba(28, 25, 22, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.app-usage-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--human), #4a8f6a);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.app-usage.is-warn .app-usage-bar span {
  background: linear-gradient(90deg, var(--gold), var(--seal));
}

.app-usage.is-unlimited .app-usage-label {
  color: var(--human);
  font-weight: 600;
}

.app-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.app-upgrade-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.32rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--seal) 35%, transparent);
  border-radius: 999px;
  background: #fff;
  color: var(--seal);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
}

.app-upgrade-btn:hover {
  border-color: var(--seal);
  background: rgba(124, 47, 36, 0.06);
}

.app-upgrade-btn[hidden] {
  display: none !important;
}

#appTopbarAuth {
  display: inline-flex;
  align-items: center;
  position: relative;
}

#appTopbarAuth .auth-profile-name {
  max-width: 6.5rem;
}

@media (max-width: 720px) {
  #appTopbarAuth .auth-profile-name {
    display: none;
  }
}

body.is-app .verify-banner {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0.45rem 1.15rem;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  border-bottom: 1px solid rgba(124, 47, 36, 0.18);
}

body.is-app .app-alerts {
  flex-shrink: 0;
}

body.is-app .app-alerts:not(:has(.app-onboard:not([hidden]), .verify-banner:not([hidden]))) {
  display: none;
}

body.is-app .app-onboard {
  margin: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  padding: 0.5rem 1.15rem;
}

body.is-app .workspace {
  flex: 1;
  min-height: 0;
  max-width: none;
  margin: 0;
  border-left: 0;
  border-right: 0;
  border-top: 1px solid var(--rule);
  overflow: hidden;
}

body.is-app .composer,
body.is-app .results-pane {
  height: 100%;
  max-height: 100%;
}

body.is-app .app-topbar {
  flex-shrink: 0;
}

/* Compact mode headline for signed-in Studio — keep “In every scan” panel */
body.is-app .studio-intro {
  flex-shrink: 0;
  max-width: none;
  margin: 0;
  padding: 0.65rem 1.15rem 0.7rem;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(165deg, #f8f3eb 0%, #f5efe4 100%);
}

body.is-app .studio-intro::after {
  display: none;
}

body.is-app .studio-intro-inner {
  grid-template-columns: minmax(12rem, 1fr) minmax(17rem, 1.05fr);
  gap: 0.75rem 1.15rem;
  align-items: stretch;
}

body.is-app .studio-intro-main {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.1rem 0;
  justify-content: center;
}

body.is-app .studio-intro-eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.62rem;
}

body.is-app .studio-intro-tagline {
  margin: 0;
  max-width: 15em;
  font-size: clamp(1rem, 1.4vw, 1.18rem);
  line-height: 1.22;
}

body.is-app .studio-intro-tagline em {
  display: inline;
}

body.is-app .studio-intro-meta {
  display: block;
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
}

body.is-app .studio-intro-panel {
  padding: 0.55rem 0.65rem 0.6rem;
  border: 1px solid rgba(160, 120, 56, 0.42);
  background: linear-gradient(145deg, rgba(255, 252, 247, 0.92) 0%, rgba(248, 240, 228, 0.78) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

body.is-app .studio-intro-panel-head {
  margin: 0 0 0.4rem;
  padding: 0 0 0.35rem;
  border-bottom: 1px solid rgba(160, 120, 56, 0.28);
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

body.is-app .studio-intro-points-label {
  display: block;
  font-size: 0.6rem;
}

body.is-app .studio-intro-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
}

body.is-app .studio-intro-features li span {
  font-size: 0.68rem;
  padding: 0.32rem 0.4rem;
}

body.is-app .studio-intro-status {
  margin: 0;
  flex-shrink: 0;
}

body.is-app .intro-status-item {
  font-size: 0.58rem;
  padding: 0.15rem 0.35rem;
}

@media (max-width: 900px) {
  body.is-app .studio-intro-inner {
    grid-template-columns: 1fr;
  }

  body.is-app .studio-intro-features {
    grid-template-columns: 1fr 1fr;
  }
}

body.is-app .composer-head {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  margin-bottom: 0.85rem;
}

body.is-app .composer-pane-label {
  display: block;
}

body:not(.is-app) .composer-pane-label {
  display: none;
}

body.is-app .results-empty-kicker {
  display: flex;
  flex-shrink: 0;
  padding: 0.85rem 1.5rem 0;
  margin: 0;
  border-bottom: 1px solid var(--rule);
}

body.is-app .results-empty {
  min-height: 0;
  flex: 1;
}

body.is-app .results-pane {
  display: flex;
  flex-direction: column;
}

body:not(.is-app) .results-empty-kicker {
  display: none;
}

.app-onboard {
  margin: 0.65rem 1.15rem 0;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(47, 93, 69, 0.08), rgba(160, 120, 56, 0.1));
  border: 1px solid rgba(47, 93, 69, 0.22);
  border-radius: 8px;
}

.app-onboard p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink);
  line-height: 1.45;
}

.app-onboard strong {
  color: var(--human);
}

.app-onboard-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.app-onboard-dismiss {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
}

.results-empty .ship-gate-hint {
  margin: 0.5rem 0 0;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  color: var(--human);
  background: rgba(47, 93, 69, 0.08);
  border-left: 2px solid var(--human);
  max-width: 20rem;
  line-height: 1.4;
}

@media (max-width: 960px) {
  body.is-app .foot {
    margin-left: 0;
    border-left: 0;
  }

  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    position: static;
    flex-direction: row;
    width: 100%;
    min-height: auto;
    padding: 0.4rem 0.5rem;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .app-sidebar-brand {
    margin: 0 0.25rem 0 0;
  }

  .app-sidebar-nav {
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.2rem;
  }

  .app-sidebar-foot {
    flex-direction: row;
    margin-top: 0;
    margin-left: auto;
    padding-top: 0;
  }

  .app-nav-btn,
  .app-nav-link {
    width: auto;
    min-height: auto;
    flex-direction: row;
    padding: 0.35rem 0.5rem;
    font-size: 0.62rem;
  }

  .app-nav-btn.is-active,
  .app-nav-link.is-active {
    box-shadow: inset 0 -2px 0 var(--seal);
  }

  .app-topbar-center {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
}
