:root {
  --shell-surface: #fff;
  --shell-border: #e9e5f2;
  --shell-text: #29213e;
  --shell-muted: #817993;
  --shell-soft: #f5f2ff;
  --shell-shadow: 0 22px 52px #24134322;
}

.app-header { position: relative; z-index: 40; }
.header-theme-toggle { margin-left: auto; }
.profile-menu { position: relative; }
.header-theme-toggle,
.profile-trigger {
  display: grid;
  place-items: center;
  width: 41px;
  height: 41px;
  border: 1px solid var(--shell-border);
  border-radius: 14px;
  background: var(--shell-surface);
  box-shadow: 0 4px 15px #2818540b;
  color: var(--shell-text);
  cursor: pointer;
}
.header-theme-toggle .ti,
.profile-trigger .ti { font-size: 23px; }
.header-theme-toggle:hover { background: var(--shell-soft); }
.header-theme-toggle:active { background: var(--shell-soft); }
.profile-trigger[aria-expanded="true"] { border-color: #bba8fb; color: #6236ff; box-shadow: 0 0 0 4px #6236ff14; }
.profile-trigger:active { background: var(--shell-soft); }
.header-theme-toggle:focus-visible,
.profile-trigger:focus-visible,
.profile-menu-action:focus-visible,
.theme-options button:focus-visible,
.client-bottom-nav a:focus-visible { outline: 2px solid #875fff; outline-offset: 3px; }
.profile-menu-panel {
  position: absolute;
  z-index: 50;
  top: calc(100% + 10px);
  right: 0;
  width: min(294px, calc(100vw - 28px));
  padding: 8px;
  border: 1px solid var(--shell-border);
  border-radius: 20px;
  background: var(--shell-surface);
  box-shadow: var(--shell-shadow);
  color: var(--shell-text);
}
.profile-menu-panel[hidden],
.profile-menu-actions[hidden] { display: none !important; }
.profile-menu-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 11px;
  border-radius: 14px;
  background: var(--shell-soft);
}
.profile-menu-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #6236ff;
  color: #fff;
  font: 800 15px Manrope,sans-serif;
}
.profile-menu-head > span:last-child { min-width: 0; }
.profile-menu-head strong,
.profile-menu-head small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-menu-head strong { font-size: 13px; }
.profile-menu-head small { margin-top: 2px; color: var(--shell-muted); font-size: 10px; }
.profile-menu-actions { padding: 6px 2px; }
.profile-menu-action {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--shell-text);
  font: 700 12px 'DM Sans',sans-serif;
  text-align: left;
  cursor: pointer;
}
.profile-menu-action:hover { background: var(--shell-soft); color: #6236ff; }
.profile-menu-action:active { background: var(--shell-soft); }
.profile-menu-action > .ti:first-child { color: #7251d5; font-size: 17px; }
.profile-menu-action > .ti:last-child { margin-left: auto; color: #aaa2bc; font-size: 14px; }
.profile-theme { padding: 12px 8px 7px; border-top: 1px solid var(--shell-border); }
.profile-theme > span { display: block; margin: 0 3px 9px; color: var(--shell-muted); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.theme-options { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border-radius: 12px; background: var(--shell-soft); }
.theme-options button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 33px; border: 0; border-radius: 9px; background: transparent; color: var(--shell-muted); font-size: 11px; font-weight: 800; cursor: pointer; }
.theme-options button[aria-pressed="true"] { background: var(--shell-surface); box-shadow: 0 2px 8px #25154213; color: #6139d6; }
.theme-options .ti { font-size: 15px; }

.client-bottom-nav { display: none; }

@media (max-width: 700px) {
  .app-body { padding-bottom: calc(91px + env(safe-area-inset-bottom)); }
  .app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    isolation: isolate;
    padding: 11px 1px 12px;
    background: transparent;
  }
  .app-header::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset-block: 0;
    left: 50%;
    width: 100vw;
    transform: translateX(-50%);
    pointer-events: none;
  }
  .app-header.is-scrolled::before {
    background: color-mix(in srgb, #f5f5fa 94%, transparent);
    box-shadow: 0 1px 0 #e9e5f2;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  .app-header .brand { font-size: 20px; }
  .app-header .brand-mark,
  .app-header .brand-mark img { width: 34px; height: 34px; }
  .header-theme-toggle,
  .profile-trigger { width: 39px; height: 39px; border-radius: 13px; flex: none; }
  .profile-menu-panel { top: calc(100% + 9px); }
  .client-bottom-nav {
    position: fixed;
    z-index: 35;
    left: 50%;
    bottom: calc(10px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: 1fr;
    width: min(160px, calc(100% - 24px));
    min-height: 65px;
    padding: 6px;
    border: 1px solid var(--shell-border);
    border-radius: 21px;
    background: color-mix(in srgb, var(--shell-surface) 94%, transparent);
    box-shadow: 0 13px 38px #24134330, 0 2px 8px #2413430d;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
  .client-bottom-nav.is-authenticated {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(430px, calc(100% - 24px));
  }
  .client-bottom-nav a[hidden] { display: none !important; }
  .client-bottom-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    border-radius: 15px;
    color: var(--shell-muted);
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
  }
  .bottom-nav-icon { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 11px; }
  .bottom-nav-icon .ti { font-size: 20px; }
  .client-bottom-nav a[aria-current="page"] { color: #5630c8; }
  .client-bottom-nav a[aria-current="page"] .bottom-nav-icon { background: #6236ff; color: #fff; box-shadow: 0 5px 12px #6236ff38; }
  .client-bottom-nav a:not([aria-current="page"]):hover { background: var(--shell-soft); }
  .client-bottom-nav a:active { background: var(--shell-soft); }
}

@media (max-width: 500px) {
  .app-header .header-links { display: none; }
  .app-header { gap: 10px; }
}

@media (max-width: 350px) {
  .client-bottom-nav.is-authenticated { width: calc(100% - 16px); }
  .client-bottom-nav a { font-size: 9px; }
}

@media print {
  .client-bottom-nav,
  .header-theme-toggle,
  .profile-menu { display: none !important; }
  .app-body { padding-bottom: 0 !important; }
}
