/* Shared application shell for migrated editor tools. */
:root {
  --app-sidebar-width: 252px;
  --app-topbar-height: 72px;
  --app-content-max: 1240px;
}

body.app-shell-enabled {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(230px, auto) 1fr;
  align-items: center;
  min-height: var(--app-topbar-height);
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 20, 25, 0.96);
  backdrop-filter: blur(16px);
}

.app-brand-wrap,
.app-topbar-actions,
.app-account-slot {
  display: flex;
  align-items: center;
}

.app-brand-wrap { gap: 12px; }

.app-brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.app-brand {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 760;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.app-topbar-actions {
  justify-content: flex-end;
  gap: 12px;
}

.app-account-slot .account { gap: 12px; }
.app-account-slot .account-info { gap: 12px; }
.app-account-slot .email { display: none; }

.app-mobile-menu {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.app-shell-layout {
  display: grid;
  grid-template-columns: var(--app-sidebar-width) minmax(0, 1fr);
  min-height: calc(100vh - var(--app-topbar-height));
  min-height: calc(100dvh - var(--app-topbar-height));
}

.app-sidebar {
  position: sticky;
  top: var(--app-topbar-height);
  z-index: 40;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--app-topbar-height));
  height: calc(100dvh - var(--app-topbar-height));
  padding: 26px 18px 20px;
  border-right: 1px solid var(--border);
  background: #111318;
}

.app-sidebar-label {
  margin: 0 12px 10px;
  color: var(--muted-2);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.app-tool-nav {
  display: grid;
  gap: 6px;
}

.app-tool-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 630;
  line-height: 1.25;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.app-tool-nav a:hover {
  border-color: var(--border);
  background: var(--panel);
  color: var(--text);
}

.app-tool-nav a[aria-current="page"] {
  border-color: rgba(138, 170, 255, 0.2);
  background: var(--accent-soft);
  color: #c8d7ff;
}

.app-nav-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 22px;
  height: 22px;
}

.app-nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.app-sidebar-bottom {
  display: grid;
  gap: 4px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

.app-sidebar-bottom a {
  min-height: 42px;
  color: var(--muted);
}

.app-main {
  min-width: 0;
  background:
    radial-gradient(80% 42% at 50% -10%, rgba(91, 135, 255, 0.08), transparent 65%),
    var(--bg);
}

.app-main-inner {
  width: min(100%, var(--app-content-max));
  margin: 0 auto;
  padding: 42px 36px 72px;
}

.app-sidebar-scrim { display: none; }

@media (max-width: 1100px) {
  :root { --app-sidebar-width: 82px; }

  .app-sidebar { padding-right: 12px; padding-left: 12px; }
  .app-sidebar-label { text-align: center; margin-inline: 0; }
  .app-tool-nav a { justify-content: center; padding-inline: 8px; }
  .app-tool-nav .app-nav-text { display: none; }
  .app-sidebar-bottom { align-items: center; }
}

@media (max-width: 767px) {
  :root { --app-topbar-height: 64px; }

  .app-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 0 14px;
  }

  .app-mobile-menu {
    display: inline-grid;
    place-items: center;
    margin-right: 10px;
  }

  .app-brand-wrap { gap: 8px; }
  .app-brand-mark { width: 30px; height: 30px; }
  .app-brand { font-size: 0.92rem; }
  .app-topbar-actions { grid-column: 2; }
  .app-account-slot .email { display: none; }
  .app-account-slot .account-info { gap: 8px; }
  .app-account-slot .balance {
    min-width: 0;
    padding: 4px 8px;
    font-size: 0.72rem;
  }
  .app-account-slot #redeem-toggle {
    max-width: 58px;
    font-size: 0.72rem;
    line-height: 1.15;
  }
  .app-account-slot #logout-btn { display: none; }
  .app-account-slot .btn-signin { padding: 8px 13px; }

  .app-shell-layout { display: block; }

  .app-sidebar {
    position: fixed;
    top: var(--app-topbar-height);
    bottom: 0;
    left: 0;
    width: min(292px, 84vw);
    height: auto;
    padding: 22px 16px 18px;
    box-shadow: 20px 0 48px rgba(0, 0, 0, 0.45);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.app-menu-open { overflow: hidden; }
  body.app-menu-open .app-sidebar { transform: translateX(0); }

  .app-sidebar-label { margin: 0 12px 10px; text-align: left; }
  .app-tool-nav a { justify-content: flex-start; padding-inline: 12px; }
  .app-tool-nav .app-nav-text { display: inline; }

  .app-sidebar-scrim {
    position: fixed;
    inset: var(--app-topbar-height) 0 0;
    z-index: 35;
    display: block;
    border: 0;
    background: rgba(3, 5, 9, 0.68);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.app-menu-open .app-sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .app-main-inner { padding: 30px 16px 56px; }

  .app-account-slot .login-form,
  .app-account-slot .redeem-panel {
    position: fixed;
    top: calc(var(--app-topbar-height) + 8px);
    right: 12px;
    left: 12px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar,
  .app-sidebar-scrim,
  .app-tool-nav a { transition: none; }
}
