/* ==========================================================================
   Youranke · Application Shell, Navigation, Appearance, Setup & Legal Styles
   Strict CSP: zero inline styles. Uses design tokens from styles.css.
   ========================================================================== */

/* Header: a flat, full-width bar that stays put while the page scrolls. */
.mast {
  transition: border-color 0.16s ease;
}

.mast.is-scrolled {
  border-bottom-color: var(--line-strong);
}

.mast-slot {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.brand-version {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--quiet);
}

/* Mobile Hamburger & Fullscreen Blur Overlay (F-A-009) */
.nav-burger {
  display: none;
}

.burger-lines {
  display: grid;
  gap: 4px;
  width: 18px;
}

.burger-lines span {
  display: block;
  height: 1.75px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-burger[aria-expanded="true"] .burger-lines span:nth-child(1) {
  transform: translateY(5.75px) rotate(45deg);
}

.nav-burger[aria-expanded="true"] .burger-lines span:nth-child(2) {
  opacity: 0;
}

.nav-burger[aria-expanded="true"] .burger-lines span:nth-child(3) {
  transform: translateY(-5.75px) rotate(-45deg);
}

body.nav-drawer-open {
  overflow: hidden;
}

.mobile-nav-overlay {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  z-index: 45;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.25rem 2rem;
  overflow-y: auto;
}

.mobile-nav-inner {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100%;
  gap: 2rem;
}

.mobile-nav-links {
  display: grid;
  gap: 0.5rem;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--surface);
  animation: shell-fade-up 0.24s ease both;
}

.mobile-nav-link.delay-1 { animation-delay: 0.04s; }
.mobile-nav-link.delay-2 { animation-delay: 0.08s; }
.mobile-nav-link.delay-3 { animation-delay: 0.12s; }
.mobile-nav-link.delay-4 { animation-delay: 0.16s; }
.mobile-nav-link.delay-5 { animation-delay: 0.2s; }
.mobile-nav-link.delay-6 { animation-delay: 0.24s; }

.mobile-nav-cta {
  width: 100%;
  height: 2.75rem;
}

.mobile-nav-auth {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

@keyframes shell-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Preferences Popover (Language + Theme) & Header Auth/Balance Controls */
.prefs-menu {
  position: relative;
}

.prefs-popover {
  position: absolute;
  top: calc(100% + 0.45rem);
  inset-inline-end: 0;
  width: min(19rem, calc(100vw - 1.5rem));
  z-index: 60;
  padding: 0.8rem;
  display: grid;
  gap: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.prefs-popover[hidden] {
  display: none;
}

.prefs-sec {
  display: grid;
  gap: 0.4rem;
}

.prefs-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--quiet);
}

.prefs-lang-slot .locale-picker {
  display: block;
  width: 100%;
}

.prefs-lang-slot .locale-picker .select {
  width: 100%;
  max-width: none;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 0 1.9rem 0 0.7rem;
}

.mast-auth-actions:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.mast-login-link {
  display: inline-flex;
  align-items: center;
  height: 2.05rem;
  padding: 0 0.65rem;
  border-radius: var(--radius);
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--quiet);
  white-space: nowrap;
}

.mast-login-link:hover {
  color: var(--ink);
  background: var(--soft);
}

.mast-register-btn {
  height: 2.05rem;
  padding: 0 0.85rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

.mast-balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 2.05rem;
  padding: 0 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mast-balance-pill:hover {
  border-color: var(--line-strong);
  background: var(--soft);
}

.mast-balance-pill .icon {
  width: 0.9rem;
  height: 0.9rem;
  color: var(--quiet);
}

/* 3-State Theme Menu (F-A-019) */
.theme-menu {
  position: relative;
}

.theme-segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.25rem;
  background: var(--soft);
  padding: 0.25rem;
  border-radius: var(--radius);
}

.theme-segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--quiet);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

.theme-segmented button[aria-checked="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

/* Notification Bell & Popover (F-A-013..016, F-B-006) */
.notif-wrap {
  position: relative;
}

.notif-trigger {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: 0.1rem;
  inset-inline-end: 0.05rem;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.26rem;
  border-radius: 999px;
  background: var(--danger);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 650;
  line-height: 1.05rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.notif-popover {
  position: absolute;
  top: calc(100% + 0.45rem);
  inset-inline-end: 0;
  width: min(24rem, calc(100vw - 1.5rem));
  z-index: 60;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.notif-pop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem 0.65rem;
  border-bottom: 1px solid var(--line);
}

.notif-pop-head strong {
  display: block;
  font-size: 0.92rem;
}

.notif-pop-head small {
  display: block;
  font-size: 0.76rem;
  color: var(--quiet);
}

.notif-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.notif-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--quiet);
}

.notif-tabs button[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--brand);
  background: var(--surface);
}

.notif-body {
  max-height: 20rem;
  overflow-y: auto;
  padding: 0.85rem 1rem;
}

.notif-empty,
.notif-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 1.75rem 0.5rem;
  color: var(--quiet);
  font-size: 0.84rem;
}

.notif-notice-card {
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.notif-notice-card a,
.notif-tl-link {
  color: var(--link);
  text-decoration: underline;
}

.notif-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}

.notif-tl-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.notif-tl-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.notif-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-top: 0.4rem;
  flex: none;
  background: var(--brand);
}

.notif-dot.is-urgent { background: var(--danger); }
.notif-dot.is-warn { background: var(--warning); }
.notif-dot.is-ok { background: var(--success); }
.notif-dot.is-info { background: var(--info); }

.notif-tl-content {
  min-width: 0;
  display: grid;
  gap: 0.22rem;
}

.notif-tl-title {
  font-size: 0.85rem;
}

.notif-tl-text,
.notif-tl-extra {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink-2);
}

.notif-tl-extra {
  color: var(--quiet);
}

.notif-tl-time {
  font-size: 0.72rem;
  color: var(--faint);
}

.notif-pop-foot {
  display: flex;
  justify-content: flex-end;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

/* User Avatar Dropdown (F-A-012, F-B-008) */
.user-menu {
  position: relative;
}

.user-avatar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 2.1rem;
  padding: 0 0.5rem 0 0.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 500;
}

.user-avatar-btn:hover {
  border-color: var(--line-strong);
  background: var(--soft);
}

.user-avatar {
  display: inline-grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: var(--on-brand);
  font-size: 0.72rem;
  font-weight: 650;
  flex: none;
}

.user-avatar.lg {
  width: 2.25rem;
  height: 2.25rem;
  font-size: 0.88rem;
}

.user-name-short {
  max-width: 7.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-popover {
  position: absolute;
  top: calc(100% + 0.45rem);
  inset-inline-end: 0;
  width: 16.5rem;
  z-index: 60;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.user-pop-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}

.user-pop-meta {
  min-width: 0;
  display: grid;
  gap: 0.2rem;
}

.user-pop-meta strong {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-pop-meta small {
  font-size: 0.72rem;
  color: var(--quiet);
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-pop-links {
  display: grid;
  padding: 0.35rem;
}

.user-pop-links a,
.user-pop-action {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
}

.user-pop-links a:hover,
.user-pop-action:hover {
  background: var(--soft);
  color: var(--ink);
}

.user-pop-action.is-danger {
  color: var(--danger);
}

.user-pop-action.is-danger:hover {
  background: var(--danger-soft, var(--soft));
  color: var(--danger);
}

.user-pop-sep {
  height: 1px;
  background: var(--line);
  margin: 0.15rem 0;
}

.user-pop-workspace {
  padding: 0.25rem 0.35rem;
}

.user-pop-ws-label {
  display: block;
}

.user-pop-ws-select {
  width: 100%;
  height: 2rem;
  font-size: 0.8rem;
}

/* Collapsible & Drill-Down Console Sidebar (F-A-010..012, F-C-002) */

/* Kept inside the sidebar box: hanging past its edge made the sidebar,
   which scrolls vertically, grow a horizontal scrollbar too. */

.settings-cat-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.12rem;
}

/* Appearance Drawer & Live Layout Customization (F-A-020) */

/* Theme Presets & Tokens — derive harmonious tints in oklab */

/* Setup Wizard (F-A-025..028) */
.setup-shell {
  min-height: calc(100dvh - var(--header-h) - 6rem);
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.setup-card {
  width: min(42rem, 100%);
  padding: 2rem;
  display: grid;
  gap: 1.5rem;
}

.setup-head {
  display: grid;
  gap: 0.45rem;
  justify-items: center;
  text-align: center;
}

.setup-stepper {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.setup-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--quiet);
}

.setup-step-num {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: inline-grid;
  place-items: center;
  font-weight: 600;
  background: var(--paper);
}

.setup-step.is-active {
  color: var(--ink);
  font-weight: 600;
}

.setup-step.is-active .setup-step-num {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-brand);
}

.setup-step.is-done .setup-step-num {
  border-color: var(--success-border);
  background: var(--success-soft);
  color: var(--success);
}

.setup-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.setup-strength-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

.setup-strength-bar {
  flex: 1;
  height: 0.45rem;
  min-height: 0.45rem;
  border-radius: 999px;
  background: var(--soft-2);
  overflow: hidden;
}

.setup-strength-bar span {
  display: block;
  height: 0.45rem;
  width: 0;
  transition: width 0.15s ease;
}

.setup-strength-bar.is-weak span { width: 33%; background: var(--danger); }
.setup-strength-bar.is-med span { width: 66%; background: var(--warning); }
.setup-strength-bar.is-strong span { width: 100%; background: var(--success); }

.setup-match.is-ok { color: var(--success); }
.setup-match.is-err { color: var(--danger); }

.setup-mode-grid {
  display: grid;
  gap: 0.65rem;
}

.setup-mode-card {
  display: grid;
  gap: 0.25rem;
  text-align: left;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.setup-mode-card[aria-checked="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.setup-mode-card span {
  font-size: 0.82rem;
  color: var(--quiet);
}

.setup-foot {
  justify-content: space-between;
  margin-top: 0.5rem;
}

/* Legal, About & Error Landing Pages (F-A-049, F-A-050, F-A-074) */
.legal-page,
.error-landing {
  width: min(52rem, 100%);
  margin-inline: auto;
  padding-block: 2rem 3rem;
}

.legal-card,
.error-card {
  padding: 2rem;
}

.legal-brand-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.legal-prose {
  display: grid;
  gap: 0.75rem;
  line-height: 1.7;
  color: var(--ink-2);
}

.legal-prose h1,
.legal-prose h2,
.legal-prose h3 {
  color: var(--ink);
  margin-top: 0.5rem;
}

.legal-prose a {
  color: var(--link);
  text-decoration: underline;
}

.legal-pre {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-ink);
  overflow-x: auto;
}

.error-landing {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - var(--header-h) - 10rem);
}

.error-card {
  width: min(34rem, 100%);
  text-align: center;
  justify-items: center;
}

.error-code {
  font-size: 3rem;
  font-weight: 650;
  line-height: 1;
  color: var(--brand);
}

.error-detail {
  font-size: 0.78rem;
  color: var(--quiet);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background: var(--soft);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.error-actions {
  justify-content: center;
  margin-top: 0.5rem;
}

/* Step-Up Modal (F-A-060) */
.stepup-shell {
  display: grid;
  gap: 1rem;
}

.stepup-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Compliance Gate Banner (F-C-007) */
.compliance-lock {
  border-color: var(--warning-border);
  background: var(--warning-soft);
}

.compliance-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--warning);
}

.compliance-ok {
  border-color: var(--success-border);
  background: var(--success-soft);
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Multi-Row / Demo / Custom Footer (F-A-023, F-A-024) */

.footer-custom-card {
  margin-block: 0.75rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}

.footer-custom-right {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.field-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  cursor: pointer;
}

.shell-guard-loading {
  min-height: 40dvh;
  display: grid;
  place-items: center;
}

/* Responsive Breakpoints */

@media (max-width: 760px) {
  .mast-inner {
    width: calc(100% - 1.25rem);
    gap: 0.45rem;
  }

  .mast .nav,
  #mast-notif-mount,
  .mast-search-text,
  .mast-search kbd,
  .user-name-short,
  .mast-login-link {
    display: none;
  }

  .mast-search {
    flex: 0 0 auto;
    width: 2.1rem;
    min-width: 0;
    margin-inline: 0;
    margin-left: auto;
    padding: 0;
    justify-content: center;
  }

  .nav-burger {
    display: inline-grid;
  }

  .user-avatar-btn {
    padding: 0.2rem;
    border-color: transparent;
  }

  .setup-stepper {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Console frame
   No sidebar. A console area's sections are one row of text tabs that sticks
   under the header, and its pages share the site's centred column.
   ========================================================================== */
:root {
  --tabs-h: 2.75rem;
  --sticky-top: var(--header-h);
}

body[data-layout="console"] {
  --sticky-top: calc(var(--header-h) + var(--tabs-h));
}

/* Header and tab row read as one block: only the tab row draws the line. */
body[data-layout="console"] .mast,
body[data-layout="console"] .mast.is-scrolled {
  border-bottom-color: transparent;
}

.console {
  min-height: calc(100dvh - var(--header-h));
}

.console-tabs {
  position: sticky;
  top: var(--header-h);
  z-index: 29;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}

.console-tabs-inner {
  display: flex;
  align-items: stretch;
  gap: 1.25rem;
  width: min(100% - 3rem, var(--page-w));
  height: var(--tabs-h);
  margin-inline: auto;
}

.console-tabs-scope {
  align-self: center;
  flex: none;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--quiet);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
}

.console-tabs-list {
  display: flex;
  flex: 1;
  gap: 1.5rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.console-tabs-list::-webkit-scrollbar {
  display: none;
}

.console-tabs-list a {
  display: inline-flex;
  flex: none;
  align-items: center;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--quiet);
  font-size: 0.88rem;
  white-space: nowrap;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.console-tabs-list a:hover {
  color: var(--ink);
}

.console-tabs-list a[aria-current="page"] {
  border-bottom-color: var(--ink);
  color: var(--ink);
  font-weight: 500;
}

.console-tabs-across {
  display: inline-flex;
  flex: none;
  align-items: center;
  align-self: center;
  gap: 0.3rem;
  color: var(--quiet);
  font-size: 0.82rem;
  white-space: nowrap;
}

.console-tabs-across:hover {
  color: var(--ink);
}

.console-tabs-across .icon {
  width: 0.85rem;
  height: 0.85rem;
}

.console-main {
  width: min(100% - 3rem, var(--page-w));
  min-width: 0;
  margin-inline: auto;
  padding: 1.75rem 0 4rem;
}

@media (max-width: 760px) {
  .console-tabs-inner {
    gap: 0.9rem;
    width: calc(100% - 1.5rem);
  }

  .console-tabs-list {
    gap: 1.15rem;
  }

  .console-main {
    width: calc(100% - 1.5rem);
    padding-top: 1.25rem;
  }
}
