/* Kirpi AI Studio shell and shared design tokens. Page-specific CSS stays independent. */
:root {
  --ks-bg: #080b14;
  --ks-bg-soft: #0c101c;
  --ks-surface: #101522;
  --ks-surface-2: #161c2b;
  --ks-surface-3: #1b2334;
  --ks-surface-glass: rgba(16, 21, 34, .84);
  --ks-line: rgba(255, 255, 255, .09);
  --ks-line-strong: rgba(255, 255, 255, .15);
  --ks-text: #f5f7ff;
  --ks-text-soft: #d9deeb;
  --ks-muted: #96a0b5;
  --ks-muted-2: #818ca2;
  --ks-accent: #8b5cf6;
  --ks-accent-strong: #7c3aed;
  --ks-accent-soft: rgba(139, 92, 246, .14);
  --ks-accent-2: #22d3ee;
  --ks-success: #34d399;
  --ks-warning: #fbbf24;
  --ks-danger: #fb7185;
  --ks-radius: 16px;
  --ks-radius-sm: 11px;
  --ks-rail: 74px;
  --ks-drawer: 302px;
  --ks-header: 78px;
  --ks-shadow: 0 20px 60px rgba(0, 0, 0, .34);
  --ks-focus: 0 0 0 3px rgba(34, 211, 238, .24);
  --ks-ease: cubic-bezier(.22, 1, .36, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--ks-bg);
  scroll-behavior: smooth;
}

body.studio-shell {
  min-width: 0;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% -10%, rgba(139, 92, 246, .16), transparent 31rem),
    radial-gradient(circle at 94% 8%, rgba(34, 211, 238, .08), transparent 28rem),
    var(--ks-bg);
  color: var(--ks-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.studio-shell::before {
  position: fixed;
  z-index: -2;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .46), transparent 75%);
  opacity: .5;
  content: "";
  pointer-events: none;
}

body.studio-shell::after {
  position: fixed;
  z-index: -1;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(2, 4, 10, .48));
  content: "";
  pointer-events: none;
}

body.studio-shell.menu-open {
  overflow: hidden;
}

.studio-shell a,
.studio-shell button,
.studio-shell input,
.studio-shell select,
.studio-shell textarea,
.studio-shell summary {
  -webkit-tap-highlight-color: transparent;
}

.studio-shell :focus-visible {
  outline: 2px solid var(--ks-accent-2);
  outline-offset: 3px;
}

.studio-shell .studio-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.studio-skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 88px;
  padding: 10px 14px;
  border: 1px solid rgba(34, 211, 238, .4);
  border-radius: 10px;
  background: var(--ks-surface-3);
  color: var(--ks-text);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform .18s ease;
}

.studio-skip-link:focus {
  transform: translateY(0);
}

.studio-shell .studio-icon {
  display: block;
  width: 21px;
  height: 21px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* App frame */
.studio-shell .studio-app,
.studio-shell .app {
  display: block;
  width: 100%;
  max-width: none;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
}

.studio-rail {
  position: fixed;
  z-index: 100;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--ks-rail);
  flex-direction: column;
  align-items: center;
  padding: 12px 8px 10px;
  border-right: 1px solid var(--ks-line);
  background: rgba(8, 11, 20, .9);
  box-shadow: 10px 0 30px rgba(0, 0, 0, .18);
  backdrop-filter: blur(22px) saturate(140%);
}

.studio-brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: transparent;
  box-shadow: none;
  color: #fff;
  font: 900 17px/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -.04em;
  overflow: visible;
  text-decoration: none;
}

.studio-brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: .96;
  filter:
    drop-shadow(0 0 4px rgba(34, 211, 238, .48))
    drop-shadow(0 0 13px rgba(124, 58, 237, .3))
    drop-shadow(0 5px 8px rgba(0, 0, 0, .38));
  transform: scale(.94);
  transition: filter .22s ease, opacity .18s ease, transform .22s var(--ks-ease);
}

@media (hover:hover) and (pointer:fine) {
  .studio-mobile-topbar .mobile-brand:hover .studio-brand-mark img,
  .studio-mobile-topbar .mobile-brand:focus-visible .studio-brand-mark img,
  .studio-drawer-header .brand:hover .studio-brand-mark img,
  .studio-drawer-header .brand:focus-visible .studio-brand-mark img {
    filter:
      drop-shadow(0 0 6px rgba(34, 211, 238, .66))
      drop-shadow(0 0 18px rgba(124, 58, 237, .44))
      drop-shadow(0 6px 9px rgba(0, 0, 0, .42));
    opacity: 1;
    transform: translateY(-1px) scale(1.045);
  }
}

@media (prefers-reduced-motion:reduce) {
  .studio-brand-mark img {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}

.studio-rail-nav,
.studio-rail-bottom {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.studio-rail-nav {
  flex: 1;
}

.studio-rail-admin {
  display: flex;
  width: 100%;
  flex-shrink: 0;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(251, 191, 36, .24);
}

.studio-rail-admin .studio-rail-section-label {
  color: #fbbf24;
  font-size: 8px;
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.studio-rail-nav:has(.studio-rail-admin) {
  gap: 3px;
}

.studio-rail-nav:has(.studio-rail-admin) .studio-rail-link {
  min-height: 42px;
  gap: 3px;
  padding-top: 3px;
  padding-bottom: 3px;
}

/* The expanded admin rail stays usable in shorter desktop windows. */
@media (min-width: 901px) and (max-height: 800px) {
  .studio-rail-nav:has(.studio-rail-admin) {
    min-height: 0;
    padding: 2px 8px;
    width: calc(100% + 16px);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: none;
  }

  .studio-rail-nav:has(.studio-rail-admin)::-webkit-scrollbar {
    display: none;
  }

  .studio-rail-nav:has(.studio-rail-admin) .studio-rail-link {
    flex-shrink: 0;
  }

  .studio-rail-nav:has(.studio-rail-admin) .studio-rail-link::before {
    left: -7px;
  }

  .studio-rail-nav:has(.studio-rail-admin) .studio-rail-link[data-tooltip]::after {
    display: none;
  }
}

.studio-rail-bottom {
  padding-top: 8px;
  border-top: 1px solid var(--ks-line);
}

.studio-rail-link {
  position: relative;
  display: flex;
  width: 57px;
  min-width: 0;
  min-height: 52px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 3px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ks-muted);
  font: inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: color .17s ease, background .17s ease, border-color .17s ease, transform .17s ease;
}

.studio-rail-link > span {
  display: block;
  width: 100%;
  overflow: hidden;
  font-size: 9px;
  font-weight: 760;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-rail-lock {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 7px;
  height: 6px;
  border: 1.5px solid var(--ks-warning);
  border-radius: 2px;
  opacity: .82;
}

.studio-rail-lock::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 5px;
  height: 5px;
  border: 1.5px solid var(--ks-warning);
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  transform: translateX(-50%);
}

.studio-rail-link.is-locked { color: color-mix(in srgb, var(--ks-muted) 68%, transparent); }

.studio-rail-link:hover {
  border-color: rgba(255, 255, 255, .07);
  background: rgba(255, 255, 255, .045);
  color: var(--ks-text);
  transform: translateY(-1px);
}

.studio-rail-link.active,
.studio-rail-link[aria-current="page"] {
  border-color: rgba(139, 92, 246, .25);
  background: linear-gradient(145deg, rgba(139, 92, 246, .2), rgba(34, 211, 238, .06));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 8px 22px rgba(0, 0, 0, .15);
  color: #ddd2ff;
}

.studio-rail-link.active::before,
.studio-rail-link[aria-current="page"]::before {
  position: absolute;
  left: -9px;
  width: 3px;
  height: 22px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(var(--ks-accent-2), var(--ks-accent));
  box-shadow: 0 0 12px rgba(139, 92, 246, .55);
  content: "";
}

.studio-rail-admin .studio-rail-link {
  background: rgba(245, 158, 11, .035);
  color: #d8bc8c;
}

.studio-rail-admin .studio-rail-link:hover {
  border-color: rgba(251, 191, 36, .22);
  background: rgba(245, 158, 11, .1);
  color: #fde68a;
}

.studio-rail-admin .studio-rail-link.active,
.studio-rail-admin .studio-rail-link[aria-current="page"] {
  border-color: rgba(251, 191, 36, .38);
  background: linear-gradient(145deg, rgba(245, 158, 11, .24), rgba(251, 191, 36, .08));
  box-shadow: inset 0 1px 0 rgba(255, 235, 180, .08), 0 8px 22px rgba(0, 0, 0, .15);
  color: #fff2c6;
}

.studio-rail-admin .studio-rail-link.active::before,
.studio-rail-admin .studio-rail-link[aria-current="page"]::before {
  background: linear-gradient(#fbbf24, #f59e0b);
  box-shadow: 0 0 12px rgba(245, 158, 11, .5);
}

.studio-rail-link[data-tooltip]::after {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: calc(100% + 12px);
  width: max-content;
  max-width: 220px;
  padding: 7px 9px;
  border: 1px solid var(--ks-line-strong);
  border-radius: 8px;
  background: #191f2d;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .3);
  color: var(--ks-text-soft);
  content: attr(data-tooltip);
  font-size: 11px;
  font-weight: 750;
  pointer-events: none;
  opacity: 0;
  transform: translate(5px, -50%);
  transition: opacity .14s ease, transform .14s ease;
}

.studio-rail-link[data-tooltip]:hover::after,
.studio-rail-link[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(0, -50%);
}

.studio-account-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 1px solid rgba(139, 92, 246, .3);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(139, 92, 246, .2), rgba(34, 211, 238, .09));
  color: #e8e1ff;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  overflow: hidden;
  isolation: isolate;
  margin: 9px;
}

.studio-account-avatar img {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform .24s var(--ks-ease), filter .2s ease;
}

.studio-avatar-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(139, 92, 246, .2), rgba(34, 211, 238, .09));
  color: #e8e1ff;
  font: 900 13px/1 ui-sans-serif, system-ui, sans-serif;
}

.studio-account-button:hover .studio-account-avatar img,
.studio-mobile-account:hover .studio-account-avatar img {
  transform: scale(1.045);
}

/* Full navigation drawer */
.studio-shell .studio-drawer,
.studio-shell .sidebar {
  position: fixed;
  z-index: 92;
  inset: 0 auto 0 var(--ks-rail);
  display: grid;
  width: var(--ks-drawer);
  height: 100dvh;
  max-height: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--ks-line);
  border-radius: 0;
  background: rgba(12, 16, 28, .96);
  box-shadow: 22px 0 60px rgba(0, 0, 0, .32);
  backdrop-filter: blur(24px) saturate(135%);
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(-100% - 12px));
  transition: transform .28s var(--ks-ease), opacity .2s ease;
}

.studio-shell .studio-drawer::before,
.studio-shell .sidebar::before {
  display: none;
}

body.studio-drawer-open .studio-drawer {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.studio-shell .studio-drawer-header,
.studio-shell .sidebar-header {
  display: flex;
  min-height: 75px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--ks-line);
  background: transparent;
}

.studio-drawer-header .brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.studio-drawer-header .studio-brand-mark {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
  border-radius: 12px;
  font-size: 16px;
}

.studio-drawer-header .brand-text {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.studio-drawer-header .brand-title {
  overflow: hidden;
  color: var(--ks-text);
  font-size: 14px;
  font-weight: 880;
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-drawer-header .brand-sub {
  overflow: hidden;
  color: var(--ks-muted);
  font-size: 10px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-shell .studio-drawer .nav {
  display: block;
  min-height: 0;
  overflow: auto;
  padding: 10px 10px 18px;
  scrollbar-color: rgba(139, 92, 246, .28) transparent;
  scrollbar-width: thin;
}

.studio-shell .studio-drawer .nav::-webkit-scrollbar {
  width: 5px;
}

.studio-shell .studio-drawer .nav::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(139, 92, 246, .26);
}

.studio-shell .nav-group {
  display: block;
  margin: 5px 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
}

.studio-shell .nav-group[open] {
  border-color: rgba(255, 255, 255, .055);
  background: rgba(255, 255, 255, .018);
}

.studio-shell .nav-group[hidden] {
  display: none !important;
}

.studio-shell .nav-group.studio-drawer-mobile-only {
  display: none;
}

.studio-shell .nav-link.nav-mobile-only {
  display: none;
}

.studio-shell .nav-group summary {
  position: relative;
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 32px 8px 10px;
  color: var(--ks-muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .055em;
  text-transform: uppercase;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.studio-shell .nav-group summary::-webkit-details-marker {
  display: none;
}

.studio-shell .nav-group summary::after {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  transform: translateY(-65%) rotate(45deg);
  transition: transform .18s ease;
}

.studio-shell .nav-group[open] summary::after {
  transform: translateY(-28%) rotate(225deg);
}

.studio-shell .nav-group summary:hover {
  color: var(--ks-text-soft);
}

.studio-shell .nav-group .hint {
  padding: 3px 6px;
  border: 1px solid var(--ks-line);
  border-radius: 99px;
  background: rgba(255, 255, 255, .025);
  color: var(--ks-muted-2);
  font-size: 8px;
  letter-spacing: .04em;
}

.studio-shell .nav-items {
  display: grid;
  gap: 3px;
  padding: 0 5px 6px;
}

.studio-shell .nav-link {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 52px;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--ks-text-soft);
  text-decoration: none;
  transition: color .16s ease, background .16s ease, border-color .16s ease, transform .16s ease;
}

.studio-shell .nav-link::before {
  position: absolute;
  inset: 10px auto 10px -6px;
  width: 3px;
  border-radius: 4px;
  background: linear-gradient(var(--ks-accent-2), var(--ks-accent));
  content: "";
  opacity: 0;
  transform: scaleY(.3);
  transition: opacity .16s ease, transform .2s var(--ks-ease);
}

.studio-shell .nav-link:hover {
  border-color: rgba(255, 255, 255, .055);
  background: rgba(255, 255, 255, .035);
  color: #fff;
  transform: translateX(1px);
}

.studio-shell .nav-link.active,
.studio-shell .nav-link[aria-current="page"] {
  border-color: rgba(139, 92, 246, .2);
  background: linear-gradient(110deg, rgba(139, 92, 246, .16), rgba(34, 211, 238, .035));
  color: #fff;
}

.studio-shell .nav-link.active::before,
.studio-shell .nav-link[aria-current="page"]::before {
  opacity: 1;
  transform: scaleY(1);
}

.studio-shell .nav-left {
  display: contents;
}

.studio-shell .nav-emoji {
  display: grid;
  width: 36px;
  height: 36px;
  min-width: 36px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 10px;
  background: rgba(255, 255, 255, .035);
  box-shadow: none;
  color: var(--ks-muted);
}

.studio-shell .nav-link:hover .nav-emoji,
.studio-shell .nav-link.active .nav-emoji,
.studio-shell .nav-link[aria-current="page"] .nav-emoji {
  border-color: rgba(139, 92, 246, .25);
  background: rgba(139, 92, 246, .12);
  color: #c8b6ff;
}

.studio-shell .nav-emoji .studio-icon {
  width: 18px;
  height: 18px;
}

.studio-shell .nav-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.studio-shell .nav-title {
  overflow: hidden;
  color: inherit;
  font-size: 12px;
  font-weight: 790;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-shell .nav-note {
  overflow: hidden;
  color: var(--ks-muted-2);
  font-size: 9.5px;
  font-weight: 590;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-shell .nav-link.nav-locked {
  opacity: .72;
}

.studio-shell .nav-link.nav-locked:hover {
  opacity: 1;
}

.studio-shell .nav-lock {
  padding: 3px 5px;
  border: 1px solid rgba(251, 191, 36, .22);
  border-radius: 6px;
  background: rgba(251, 191, 36, .07);
  color: #fcd779;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.studio-shell .nav-group-admin[open] {
  border-color: rgba(251, 113, 133, .12);
}

.studio-shell .nav-group-admin summary {
  color: #fda4af;
}

/* Main content and header */
.studio-shell .studio-main,
.studio-shell .main {
  display: block;
  width: auto;
  min-width: 0;
  min-height: 100dvh;
  margin: 0 0 0 var(--ks-rail);
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transition: margin-left .28s var(--ks-ease);
}

.studio-shell .studio-main-header,
.studio-shell .main-header {
  position: sticky;
  z-index: 60;
  top: 0;
  display: flex;
  min-height: var(--ks-header);
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 11px clamp(20px, 2.4vw, 38px);
  border: 0;
  border-bottom: 1px solid transparent;
  background: linear-gradient(
    180deg,
    rgba(8, 11, 20, .86) 0%,
    rgba(8, 11, 20, .62) 52%,
    rgba(8, 11, 20, .24) 82%,
    rgba(8, 11, 20, 0) 100%
  );
  box-shadow: none;
  backdrop-filter: blur(22px) saturate(130%);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.studio-shell .studio-main-header.is-scrolled {
  border-bottom-color: var(--ks-line);
  background: rgba(8, 11, 20, .92);
  box-shadow: 0 10px 32px rgba(0, 0, 0, .18);
}

.studio-page-heading {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.studio-shell .main-title {
  margin: 0;
  overflow: hidden;
  color: var(--ks-text);
  font-size: clamp(20px, 1.7vw, 27px);
  font-weight: 840;
  line-height: 1.08;
  letter-spacing: -.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-shell .main-sub {
  max-width: min(70vw, 820px);
  margin: 0;
  overflow: hidden;
  color: var(--ks-muted);
  font-size: 11px;
  font-weight: 570;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-header-actions,
.studio-shell .user-panel {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.studio-status-copy,
.studio-account-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.studio-status-copy b,
.studio-account-copy b {
  overflow: hidden;
  color: var(--ks-text-soft);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-status-copy small,
.studio-status-copy span,
.studio-account-copy span,
.studio-account-copy small {
  overflow: hidden;
  color: var(--ks-muted-2);
  font-size: 8.5px;
  font-weight: 620;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-account-wrap {
  position: relative;
}

.studio-shell .studio-account-button,
.studio-shell .user-badge.studio-account-button {
  display: grid;
  min-width: 225px;
  min-height: 48px;
  grid-template-columns: 54px minmax(0, 1fr) auto 14px;
  align-items: center;
  gap: 9px;
  padding: 5px 8px 5px 6px;
  border: 1px solid var(--ks-line);
  border-radius: 13px;
  background: rgba(255, 255, 255, .035);
  box-shadow: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .17s ease, background .17s ease;
}

.studio-shell .studio-account-button:hover,
.studio-shell .studio-account-button[aria-expanded="true"] {
  border-color: rgba(139, 92, 246, .28);
  background: rgba(139, 92, 246, .08);
}

.studio-account-chevron {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--ks-muted);
  stroke-width: 1.5;
  transition: transform .18s ease;
}

.studio-account-button[aria-expanded="true"] .studio-account-chevron {
  transform: rotate(180deg);
}

.studio-plan {
  display: inline-flex;
  min-height: 21px;
  align-items: center;
  justify-content: center;
  padding: 3px 7px;
  border: 1px solid rgba(139, 92, 246, .22);
  border-radius: 7px;
  background: rgba(139, 92, 246, .09);
  color: #cbbcff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .035em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.studio-plan-premium,
.studio-plan-admin {
  border-color: rgba(251, 191, 36, .24);
  background: rgba(251, 191, 36, .08);
  color: #fcd779;
}

.studio-plan-free {
  border-color: var(--ks-line);
  background: rgba(255, 255, 255, .035);
  color: var(--ks-muted);
}

.studio-account-menu {
  position: absolute;
  z-index: 120;
  top: calc(100% + 9px);
  right: 0;
  width: min(300px, calc(100vw - 24px));
  padding: 7px;
  border: 1px solid var(--ks-line-strong);
  border-radius: 15px;
  background: rgba(18, 23, 36, .98);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .42);
  backdrop-filter: blur(24px);
  transform-origin: top right;
  animation: studio-pop .18s var(--ks-ease) both;
}

.studio-account-menu[hidden] {
  display: none !important;
}

.studio-account-menu-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
  padding: 7px 8px 11px;
  border-bottom: 1px solid var(--ks-line);
}

.studio-account-menu-head > span:last-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.studio-account-menu-head b,
.studio-account-menu-head small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-account-menu-head b {
  color: var(--ks-text);
  font-size: 12px;
}

.studio-account-menu-head small {
  color: var(--ks-muted);
  font-size: 9px;
}

.studio-account-menu > a {
  display: grid;
  min-height: 51px;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--ks-muted);
  text-decoration: none;
}

.studio-account-menu > a:hover {
  border-color: var(--ks-line);
  background: rgba(255, 255, 255, .035);
  color: var(--ks-text);
}

.studio-account-menu > a .studio-icon {
  width: 18px;
  height: 18px;
  margin: auto;
}

.studio-account-menu > a > span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.studio-account-menu > a b {
  color: var(--ks-text-soft);
  font-size: 11px;
}

.studio-account-menu > a small {
  color: var(--ks-muted-2);
  font-size: 9px;
}

.studio-account-menu > a.studio-account-menu-logout {
  margin-top: 4px;
  border-top: 1px solid rgba(251, 113, 133, .09);
  color: #fda4af;
}

.studio-account-menu > a.studio-account-menu-logout b {
  color: #fecdd3;
}

.studio-impersonation,
.studio-shell .impersonation-badge.studio-impersonation {
  display: flex;
  max-width: 260px;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 10px;
  border: 1px solid rgba(251, 191, 36, .22);
  border-radius: 12px;
  background: rgba(251, 191, 36, .07);
  color: #fde68a;
}

.studio-impersonation > div {
  display: grid;
  min-width: 0;
  font-size: 8px;
}

.studio-impersonation b {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-shell .studio-main-body,
.studio-shell .main-body {
  width: 100%;
  min-width: 0;
  padding: clamp(16px, 2vw, 32px) clamp(16px, 2.5vw, 40px) 52px;
}

.studio-shell .main-body > .tw-page,
.studio-shell .main-body > [class*="-page"] {
  width: 100%;
  max-width: 1680px;
  margin-inline: auto;
}

@media (min-width: 1100px) {
  body.studio-drawer-open .studio-main {
    margin-left: calc(var(--ks-rail) + var(--ks-drawer));
  }
}

/* Shared surface and form language for existing pages. */
.studio-shell .main-body .tw-card,
.studio-shell .main-body .studio-card {
  border-color: var(--ks-line);
  border-radius: var(--ks-radius);
  background: linear-gradient(165deg, rgba(22, 28, 43, .9), rgba(13, 17, 28, .88));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035), 0 16px 42px rgba(0, 0, 0, .15);
}

.studio-shell .main-body .tw-btn,
.studio-shell .main-body button.tw-btn,
.studio-shell .studio-impersonation .tw-btn {
  border-radius: 10px;
  font-weight: 780;
  transition: border-color .17s ease, background .17s ease, color .17s ease, transform .17s ease, box-shadow .17s ease;
}

.studio-shell .main-body .tw-btn:hover,
.studio-shell .studio-impersonation .tw-btn:hover {
  transform: translateY(-1px);
}

.studio-shell .main-body .tw-btn-primary {
  border-color: rgba(139, 92, 246, .55);
  background: linear-gradient(135deg, var(--ks-accent), #6d43df);
  box-shadow: 0 10px 24px rgba(124, 58, 237, .2);
  color: #fff;
}

.studio-shell .main-body .tw-btn-primary:hover {
  box-shadow: 0 13px 30px rgba(124, 58, 237, .3);
}

.studio-shell .main-body :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]) {
  border-color: var(--ks-line);
  border-radius: 10px;
  background: rgba(6, 9, 17, .5);
  color: var(--ks-text-soft);
}

.studio-shell .main-body :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):focus {
  border-color: rgba(34, 211, 238, .42);
  box-shadow: var(--ks-focus);
}

.studio-shell .main-body :is(input, textarea)::placeholder {
  color: var(--ks-muted-2);
}

.studio-shell .studio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 14px;
}

.studio-shell .studio-stack {
  display: grid;
  gap: 14px;
}

.studio-shell .studio-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--ks-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .035);
  color: var(--ks-muted);
  font-size: 10px;
  font-weight: 780;
}

.studio-shell .studio-empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--ks-line-strong);
  border-radius: var(--ks-radius);
  color: var(--ks-muted);
  text-align: center;
}

/* Mobile chrome */
.studio-shell .studio-mobile-topbar,
.studio-shell .mobile-topbar,
.studio-mobile-nav {
  display: none;
}

.studio-shell .sidebar-overlay {
  position: fixed;
  z-index: 88;
  inset: 0;
  display: block;
  background: rgba(1, 3, 9, .68);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

/* Toasts */
.studio-toast-container,
.studio-shell .tw-toast-container {
  position: fixed;
  z-index: 1000;
  top: 18px;
  right: 18px;
  display: grid;
  width: min(370px, calc(100vw - 28px));
  gap: 9px;
  pointer-events: none;
}

.studio-shell .tw-toast {
  position: relative;
  min-height: 68px;
  overflow: hidden;
  padding: 13px 42px 13px 15px;
  border: 1px solid var(--ks-line-strong);
  border-radius: 14px;
  background: rgba(18, 23, 36, .97);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .38);
  color: var(--ks-text-soft);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-10px) scale(.98);
  transition: opacity .2s ease, transform .24s var(--ks-ease);
}

.studio-shell .tw-toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.studio-shell .tw-toast::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--ks-accent-2);
  content: "";
}

.studio-shell .tw-toast-success::before { background: var(--ks-success); }
.studio-shell .tw-toast-error::before { background: var(--ks-danger); }
.studio-shell .tw-toast-warning::before { background: var(--ks-warning); }

.studio-shell .tw-toast-title {
  margin-bottom: 3px;
  color: var(--ks-text);
  font-size: 12px;
  font-weight: 850;
}

.studio-shell .tw-toast-text {
  color: var(--ks-muted);
  font-size: 11px;
  line-height: 1.45;
}

.studio-shell .tw-toast-close {
  position: absolute;
  top: 10px;
  right: 9px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ks-muted);
  font-size: 18px;
  cursor: pointer;
}

.studio-shell .tw-toast-close:hover {
  background: rgba(255, 255, 255, .055);
  color: #fff;
}

.studio-shell .tw-toast-progress {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: linear-gradient(90deg, var(--ks-accent), var(--ks-accent-2));
  transform-origin: left;
  animation: studio-toast-progress 4s linear both;
}

.studio-shell .tw-toast-glow {
  display: none;
}

@keyframes studio-pop {
  from { opacity: 0; transform: translateY(-5px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes studio-toast-progress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (max-width: 1180px) {
  .studio-shell .studio-account-button,
  .studio-shell .user-badge.studio-account-button {
    min-width: 196px;
  }
}

@media (max-width: 900px) {
  :root {
    --ks-mobile-top: 64px;
    --ks-mobile-bottom: 70px;
  }

  body.studio-shell {
    padding: 0;
  }

  .studio-rail {
    display: none;
  }

  .studio-shell .studio-mobile-topbar,
  .studio-shell .mobile-topbar {
    position: fixed;
    z-index: 95;
    inset: 0 0 auto;
    display: grid;
    width: 100%;
    height: var(--ks-mobile-top);
    grid-template-columns: minmax(34px, 1fr) minmax(0, 300px);
    align-items: center;
    gap: 8px;
    padding: 8px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
    border: 0;
    border-bottom: 1px solid var(--ks-line);
    border-radius: 0;
    background: rgba(8, 11, 20, .97);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .2);
    backdrop-filter: blur(14px) saturate(120%);
  }

  .studio-mobile-topbar .mobile-brand {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    justify-self: start;
    gap: 9px;
    background: none;
    color: var(--ks-text);
    font-size: 13px;
    font-weight: 720;
    text-decoration: none;
    -webkit-text-fill-color: currentColor;
  }

  .studio-mobile-topbar .mobile-brand .studio-brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: 10px;
    font-size: 13px;
  }

  .studio-mobile-topbar .mobile-brand b {
    background: linear-gradient(90deg, #67e8f9 0%, #38bdf8 48%, #818cf8 100%);
    background-clip: text;
    color: transparent;
    font-weight: 900;
    text-shadow: 0 0 12px rgba(56, 189, 248, .22);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .studio-mobile-account {
    display: grid;
    width: 100%;
    min-width: 0;
    min-height: 48px;
    grid-template-columns: 42px minmax(0, 1fr) auto 14px;
    align-items: center;
    gap: 8px;
    justify-self: end;
    padding: 2px 8px 2px 6px;
    border: 1px solid var(--ks-line);
    border-radius: 13px;
    background: rgba(255, 255, 255, .035);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .17s ease, background .17s ease;
  }

  .studio-mobile-account .studio-account-avatar {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
    margin: 7px;
  }

  .studio-mobile-account:hover,
  .studio-mobile-account[aria-expanded="true"] {
    border-color: rgba(139, 92, 246, .28);
    background: rgba(139, 92, 246, .08);
  }

  .studio-mobile-account[aria-expanded="true"] .studio-account-chevron {
    transform: rotate(180deg);
  }

  .studio-mobile-account .studio-account-copy b {
    font-size: 11px;
  }

  .studio-mobile-account .studio-account-copy span {
    font-size: 9px;
  }

  .studio-shell .studio-drawer,
  .studio-shell .sidebar {
    z-index: 110;
    inset: 0 auto 0 0;
    width: min(var(--ks-drawer), calc(100vw - 34px));
    border-right: 1px solid var(--ks-line-strong);
    box-shadow: 28px 0 70px rgba(0, 0, 0, .5);
    transform: translateX(calc(-100% - 12px));
  }

  .studio-shell .nav-group.studio-drawer-mobile-only {
    display: block;
  }

  .studio-shell .nav-link.nav-mobile-only {
    display: grid;
  }

  body.studio-drawer-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .studio-shell .studio-main,
  .studio-shell .main {
    width: 100%;
    min-height: 100dvh;
    margin: 0;
    padding-top: var(--ks-mobile-top);
  }

  .studio-shell .studio-main-header,
  .studio-shell .main-header {
    position: static;
    z-index: auto;
    top: auto;
    min-height: 70px;
    gap: 12px;
    padding: 12px 14px 11px;
    border-bottom: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .studio-shell .studio-main-header.is-scrolled {
    border-bottom-color: transparent;
    background: transparent;
    box-shadow: none;
  }

  .studio-shell .main-title {
    font-size: clamp(18px, 5.4vw, 23px);
  }

  .studio-shell .main-sub {
    max-width: calc(100vw - 28px);
    font-size: 12px;
  }

  .studio-shell .studio-account-button,
  .studio-shell .user-badge.studio-account-button {
    display: none;
  }

  .studio-account-menu {
    position: fixed;
    z-index: 125;
    top: calc(var(--ks-mobile-top) + 8px);
    right: 10px;
  }

  .studio-impersonation {
    display: none !important;
  }

  .studio-shell .studio-main-body,
  .studio-shell .main-body {
    padding: 14px 12px calc(var(--ks-mobile-bottom) + 22px + env(safe-area-inset-bottom));
  }

  .studio-mobile-nav {
    position: fixed;
    z-index: 90;
    inset: auto 0 0;
    display: flex;
    width: 100%;
    min-height: var(--ks-mobile-bottom);
    align-items: flex-start;
    justify-content: space-around;
    gap: 1px;
    padding: 7px max(5px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(5px, env(safe-area-inset-left));
    border-top: 1px solid var(--ks-line);
    background: #0a0e19;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, .22);
    backdrop-filter: none;
  }

  .studio-mobile-nav .studio-rail-link {
    width: min(19vw, 74px);
    min-height: 53px;
    padding: 5px 2px;
    border-radius: 11px;
  }

  .studio-mobile-nav .studio-rail-link .studio-icon {
    width: 20px;
    height: 20px;
  }

  .studio-mobile-nav .studio-rail-link > span {
    font-size: 10px;
  }

  .studio-mobile-nav .studio-rail-link.active::before,
  .studio-mobile-nav .studio-rail-link[aria-current="page"]::before {
    inset: auto auto -8px 50%;
    width: 20px;
    height: 3px;
    border-radius: 4px 4px 0 0;
    transform: translateX(-50%);
  }

  .studio-mobile-nav .studio-rail-link[data-tooltip]::after {
    display: none;
  }

  .studio-toast-container,
  .studio-shell .tw-toast-container {
    top: calc(var(--ks-mobile-top) + 8px);
    right: 7px;
    width: calc(100vw - 14px);
  }

  .studio-shell .main-body :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]) {
    font-size: 16px;
  }
}

@media (max-width: 560px) {
  .studio-mobile-topbar .mobile-brand > span:last-child {
    display: none;
  }

  .studio-shell .main-sub {
    max-width: calc(100vw - 38px);
  }

  .studio-shell .studio-main-header,
  .studio-shell .main-header {
    min-height: 70px;
  }

  .studio-shell .main-body > .tw-page,
  .studio-shell .main-body > [class*="-page"] {
    max-width: 100%;
  }

}

@media (max-width: 360px) {
  .studio-shell .studio-mobile-topbar,
  .studio-shell .mobile-topbar {
    gap: 6px;
    padding-right: max(8px, env(safe-area-inset-right));
    padding-left: max(8px, env(safe-area-inset-left));
  }

  .studio-mobile-account {
    gap: 6px;
    padding-right: 6px;
  }

  .studio-mobile-account .studio-plan {
    padding-right: 5px;
    padding-left: 5px;
    font-size: 9px;
  }
}

.studio-plan-viewer {
  border-color: rgba(34, 211, 238, .24);
  background: rgba(34, 211, 238, .08);
  color: #a5f3fc;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .studio-shell *,
  .studio-shell *::before,
  .studio-shell *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }

  .studio-shell :is(.studio-rail-link, .nav-link, .tw-btn):hover,
  .studio-shell :is(.studio-account-button, .studio-mobile-account):hover img {
    transform: none !important;
  }
}

@media (pointer: coarse) {
  .studio-shell :is(button, summary, .ks-btn, .nav-link) {
    min-height: 44px;
  }

  .studio-shell .studio-mobile-account {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (prefers-contrast: more) {
  :root {
    --ks-line: rgba(255, 255, 255, .2);
    --ks-line-strong: rgba(255, 255, 255, .34);
    --ks-muted: #b5bed0;
    --ks-muted-2: #9ca7ba;
  }
}
