:root {
  --dirck-safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --dirck-safe-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
  --dirck-safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --dirck-safe-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
  --dirck-viewport-height: 100dvh;
}

html {
  min-width: 280px;
  min-height: 100%;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-width: 280px;
  min-height: 100%;
  min-height: var(--dirck-viewport-height);
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}

:where(button, [role="button"], input[type="button"], input[type="submit"], input[type="reset"], select) {
  min-block-size: var(--dirck-touch-target);
}

:where(input[type="text"], input[type="password"], input[type="email"], input[type="search"], input[type="number"], input[type="file"], textarea) {
  min-block-size: var(--dirck-touch-target);
  font-size: max(16px, 1em);
}

:where(.btn, .globalNavItem, .pageBack, .categoryModuleAction, .homeContinueCta, .homeToolLink, .homeEmptyAction, .homeRetryButton, .homeFocusLink) {
  min-block-size: var(--dirck-touch-target);
}

:where(button, a, input, select, textarea):focus-visible {
  outline: 3px solid var(--dirck-color-focus, var(--accent, #293c2c));
  outline-offset: 3px;
}

img,
video,
canvas,
svg {
  max-inline-size: 100%;
}

.app {
  min-height: 100svh;
  height: var(--dirck-viewport-height);
}

.sidebar {
  height: var(--dirck-viewport-height);
  max-height: none;
  padding-top: max(22px, var(--dirck-safe-top));
  padding-bottom: max(16px, var(--dirck-safe-bottom));
  padding-left: max(14px, var(--dirck-safe-left));
}

.main {
  scroll-padding-top: calc(var(--dirck-safe-top) + 16px);
  scroll-padding-bottom: calc(var(--dirck-safe-bottom) + 24px);
}

body #authOverlay,
body #onboardingOverlay,
body #hubOverlay {
  min-height: var(--dirck-viewport-height);
  max-width: 100%;
  overscroll-behavior: contain;
}

body #authOverlay,
body #onboardingOverlay {
  overflow-y: auto;
  padding-top: calc(16px + var(--dirck-safe-top));
  padding-right: calc(16px + var(--dirck-safe-right));
  padding-bottom: calc(16px + var(--dirck-safe-bottom));
  padding-left: calc(16px + var(--dirck-safe-left));
}

/* Mobile-first account entry. The legacy card used content-box sizing with a
   100% width, internal padding, and outer margins. On narrow iPhones that made
   the overlay wider than the viewport and encouraged Safari to zoom the page.
   Keep every auth measurement inside the safe viewport instead. */
body #authOverlay {
  --auth-surface: var(--dirck-color-auth-surface, #ffffff);
  --auth-surface-raised: var(--dirck-color-auth-surface-raised, #ffffff);
  --auth-border: var(--dirck-color-auth-border, rgba(14, 14, 12, 0.2));
  --auth-text: var(--dirck-color-auth-text, #0e0e0c);
  --auth-muted: var(--dirck-color-auth-muted, rgba(14, 14, 12, 0.68));
  --auth-accent: var(--dirck-color-auth-accent, #293c2c);
  --auth-focus: var(--dirck-color-auth-focus, #293c2c);
  box-sizing: border-box;
  inline-size: 100%;
  max-inline-size: 100vw;
  overflow-x: hidden;
  align-items: center;
  justify-content: center;
}

body #authOverlay *,
body #authOverlay *::before,
body #authOverlay *::after {
  box-sizing: border-box;
}

body #authOverlay .authBgVignette {
  background:
    linear-gradient(180deg, rgba(4, 15, 9, 0.25), rgba(4, 15, 9, 0.76)),
    radial-gradient(ellipse 80% 70% at 50% 38%, transparent 25%, rgba(0, 0, 0, 0.66) 100%);
}

body #authOverlay .authCard {
  inline-size: min(100%, 420px);
  max-inline-size: 420px;
  max-block-size: calc(var(--dirck-viewport-height) - var(--dirck-safe-top) - var(--dirck-safe-bottom) - 32px);
  margin: 0;
  padding: clamp(26px, 7vw, 42px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--auth-border);
  border-radius: var(--dirck-radius-xl, 28px);
  background:
    linear-gradient(145deg, rgba(36, 64, 43, 0.38), transparent 44%),
    var(--auth-surface);
  box-shadow: var(--dirck-shadow-lg, 0 28px 90px rgba(0, 0, 0, 0.56)), var(--dirck-inset-highlight, inset 0 1px rgba(255, 255, 255, 0.08));
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
  scrollbar-width: thin;
}

body #authOverlay .authLogo {
  margin: 0;
  color: rgba(216, 205, 168, 0.84);
  font-size: 11px;
  letter-spacing: 0.2em;
}

body #authOverlay .authBrand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-block-end: 16px;
}

body #authOverlay .authBrandMark {
  inline-size: 36px;
  block-size: 36px;
  flex: 0 0 auto;
  border: 1px solid rgba(229, 221, 193, 0.2);
  border-radius: 10px;
  object-fit: cover;
  box-shadow: var(--dirck-shadow-sm, 0 7px 18px rgba(0, 0, 0, 0.24));
}

body #authOverlay .authLogoTitle {
  max-inline-size: 9em;
  margin: 0 0 10px;
  color: var(--auth-text);
  font-size: clamp(34px, 10vw, 46px);
  line-height: 0.98;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

body #authOverlay .authSub {
  margin-block-end: 26px;
  color: var(--auth-muted);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

body #authOverlay .authTabs {
  gap: 4px;
  margin-block-end: 24px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
}

body #authOverlay .authTab {
  min-block-size: 44px;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  color: rgba(248, 245, 235, 0.55);
  font-size: 13px;
  letter-spacing: 0.055em;
  text-transform: none;
}

body #authOverlay .authTab.active {
  border: 0;
  color: #142117;
  background: var(--auth-accent);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

body #authOverlay .authField {
  margin-block-end: 18px;
}

body #authOverlay .authFieldHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-block-end: 8px;
}

body #authOverlay .authFieldHead .authLabel {
  margin: 0;
}

body #authOverlay .authLabel {
  margin-block-end: 8px;
  color: rgba(236, 230, 210, 0.78);
  font-size: 11px;
  letter-spacing: 0.11em;
}

body #authOverlay .authInput {
  inline-size: 100%;
  min-block-size: 52px;
  padding: 13px 15px;
  border: 1px solid rgba(235, 229, 210, 0.16);
  border-radius: 14px;
  background: var(--auth-surface-raised);
  color: var(--auth-text);
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: 0;
  transition: border-color var(--dirck-duration-standard, 150ms) var(--dirck-ease-standard, ease), box-shadow var(--dirck-duration-standard, 150ms) var(--dirck-ease-standard, ease), background-color var(--dirck-duration-standard, 150ms) var(--dirck-ease-standard, ease);
}

body #authOverlay .authInput::placeholder {
  color: color-mix(in srgb, var(--auth-muted) 55%, transparent);
}

body #authOverlay .authInput:focus {
  border-color: var(--auth-focus);
  box-shadow: var(--dirck-auth-focus-ring, 0 0 0 4px rgba(41, 60, 44, 0.2));
}

body #authOverlay .authPasswordWrap {
  position: relative;
}

body #authOverlay .authPasswordWrap .authInput {
  padding-inline-end: 72px;
}

body #authOverlay .authPasswordToggle {
  position: absolute;
  z-index: 1;
  inset-block-start: 4px;
  inset-inline-end: 4px;
  min-inline-size: 58px;
  min-block-size: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(236, 230, 210, 0.7);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: color var(--dirck-duration-standard, 150ms) var(--dirck-ease-standard, ease), background-color var(--dirck-duration-standard, 150ms) var(--dirck-ease-standard, ease), transform var(--dirck-duration-fast, 120ms) var(--dirck-ease-standard, ease);
}

body #authOverlay .authPasswordToggle:hover,
body #authOverlay .authPasswordToggle:focus-visible {
  background: rgba(255, 255, 255, 0.075);
  color: var(--auth-text);
}

body #authOverlay .authPasswordToggle:active {
  transform: scale(0.97);
}

body #authOverlay .authRecoveryLink {
  min-block-size: 44px;
  margin: -12px -8px -12px 0;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(216, 205, 168, 0.82);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: color var(--dirck-duration-standard, 150ms) var(--dirck-ease-standard, ease), background-color var(--dirck-duration-standard, 150ms) var(--dirck-ease-standard, ease);
}

body #authOverlay .authRecoveryLink:hover,
body #authOverlay .authRecoveryLink:focus-visible,
body #authOverlay .authRecoveryLink[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.065);
  color: var(--auth-text);
}

body #authOverlay .authSubmitBtn {
  min-block-size: 52px;
  margin-block-start: 2px;
  padding: 13px 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, #e2d8b7, #cfc29b);
  color: var(--dirck-color-auth-on-accent, #142117);
  font-size: 15px;
  letter-spacing: 0.045em;
  text-transform: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  transition: transform var(--dirck-duration-fast, 120ms) var(--dirck-ease-standard, ease), box-shadow var(--dirck-duration-standard, 150ms) var(--dirck-ease-standard, ease), opacity var(--dirck-duration-standard, 150ms) var(--dirck-ease-standard, ease);
}

body #authOverlay .authSubmitBtn:active {
  transform: translateY(1px);
}

body #authOverlay .authSubmitBtn[data-loading="true"] {
  cursor: wait;
  opacity: 0.78;
}

body #authOverlay .authSubmitBtn[data-loading="true"]::after {
  content: "";
  display: inline-block;
  inline-size: 0.78em;
  block-size: 0.78em;
  margin-inline-start: 9px;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  vertical-align: -0.08em;
  animation: dirck-auth-spin 700ms linear infinite;
}

@keyframes dirck-auth-spin {
  to { transform: rotate(1turn); }
}

body #authOverlay .authCodeToggle {
  min-block-size: 44px;
  margin-block-start: 14px;
  padding: 8px 2px;
  color: var(--auth-muted);
  font-size: 13px;
}

body #authOverlay .authError {
  margin-block-start: 14px;
  padding: 13px 14px;
  border-color: rgba(255, 137, 113, 0.42);
  border-radius: 14px;
  background: var(--dirck-color-auth-error-surface, rgba(99, 35, 24, 0.56));
  color: var(--dirck-color-auth-error-text, #ffb29f);
  font-size: 14px;
  line-height: 1.45;
}

body #authOverlay .authError strong,
body #authOverlay .authError span {
  display: block;
}

body #authOverlay .authError strong {
  color: #ffd0c4;
  font-size: 14px;
  line-height: 1.35;
}

body #authOverlay .authError span {
  margin-block-start: 3px;
}

body #authOverlay .authError[data-tone="success"] {
  border-color: rgba(111, 190, 134, 0.48);
  background: rgba(24, 77, 43, 0.66);
  color: #c8efd2;
}

body #authOverlay .authError[data-tone="success"] strong {
  color: #e0f7e5;
}

body #authOverlay .authInput[aria-invalid="true"],
body #authOverlay .authCheck input[aria-invalid="true"] {
  border-color: #ff9f88;
  outline: 2px solid rgba(255, 159, 136, 0.34);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  body #authOverlay .authSubmitBtn[data-loading="true"]::after {
    animation: none;
    border-inline-end-color: currentColor;
  }
}

body #authOverlay .authHelpText {
  margin: 0 0 14px;
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 1.5;
}

body #authOverlay .authRecoveryHelp {
  margin-block-start: 12px;
}

body #authOverlay .authPolicyLinks {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 9px;
  margin-block-start: 18px;
  padding-block-start: 14px;
  border-block-start: 1px solid rgba(255, 255, 255, 0.075);
  color: rgba(236, 230, 210, 0.34);
  font-size: 12px;
}

body #authOverlay .authPolicyLinks a {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
  padding: 6px 3px;
  border-radius: 8px;
  color: var(--auth-muted);
  text-underline-offset: 3px;
  transition: color var(--dirck-duration-standard, 150ms) var(--dirck-ease-standard, ease), background-color var(--dirck-duration-standard, 150ms) var(--dirck-ease-standard, ease);
}

body #authOverlay .authPolicyLinks a:hover,
body #authOverlay .authPolicyLinks a:focus-visible {
  background: rgba(255, 255, 255, 0.055);
  color: var(--auth-text);
}

body #authOverlay .authConsent {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-block-size: 44px;
  margin: 10px 0 16px;
  color: var(--auth-text);
  font-size: 14px;
  line-height: 1.45;
}

body #authOverlay .authConsent input {
  inline-size: 20px;
  block-size: 20px;
  margin: 1px 0 0;
  accent-color: var(--auth-focus);
  flex: 0 0 auto;
}

body #authOverlay :where(button, input):focus-visible {
  outline-color: var(--auth-focus);
}

@media (prefers-reduced-motion: reduce) {
  body #authOverlay :where(.authInput, .authSubmitBtn, .authPasswordToggle, .authRecoveryLink, .authPolicyLinks a) {
    transition: none;
  }
}

.settingsDrawer {
  height: var(--dirck-viewport-height);
  padding-top: var(--dirck-safe-top);
  padding-right: var(--dirck-safe-right);
  padding-bottom: var(--dirck-safe-bottom);
}

/* The standalone drawer owns the device safe area. Once it is embedded in the
   Account view, .main already owns that inset; retaining both creates a second
   notch-sized spacer above the profile card on physical iPhones. */
.settingsDrawer.settingsInline {
  height: auto;
  padding: 0;
}

.settingsDrawerBody {
  overscroll-behavior: contain;
  scroll-padding-block: 16px;
}

.coachingPreviewDialog {
  max-height: calc(var(--dirck-viewport-height) - var(--dirck-safe-top) - var(--dirck-safe-bottom) - 20px);
}

#loginWrap {
  min-height: var(--dirck-viewport-height);
  padding-top: var(--dirck-safe-top);
  padding-right: var(--dirck-safe-right);
  padding-bottom: var(--dirck-safe-bottom);
  padding-left: var(--dirck-safe-left);
}

#dashboard {
  padding-top: max(28px, calc(16px + var(--dirck-safe-top)));
  padding-right: max(24px, calc(16px + var(--dirck-safe-right)));
  padding-bottom: max(60px, calc(28px + var(--dirck-safe-bottom)));
  padding-left: max(24px, calc(16px + var(--dirck-safe-left)));
}

@media (max-width: 720px) {
  html,
  body {
    min-height: var(--dirck-viewport-height);
  }

  /* Keep scrolled page copy from passing visibly behind an iPhone notch or
     Dynamic Island. This covers only the system status-bar inset; it is not an
     application header and does not consume space on devices without an inset. */
  .app::before {
    content: "";
    position: fixed;
    z-index: 35;
    inset: 0 0 auto;
    height: var(--dirck-safe-top);
    background: var(--dirck-color-bg);
    pointer-events: none;
  }

  body {
    padding-bottom: calc(64px + var(--dirck-safe-bottom));
  }

  .app {
    min-height: var(--dirck-viewport-height);
    height: auto;
  }

  .mobileTopbar {
    top: 0;
    min-height: calc(56px + var(--dirck-safe-top));
    padding-top: calc(9px + var(--dirck-safe-top));
    padding-right: max(14px, calc(10px + var(--dirck-safe-right)));
    padding-left: max(14px, calc(10px + var(--dirck-safe-left)));
  }

  .mobileBottomNav {
    min-height: calc(64px + var(--dirck-safe-bottom));
    padding-right: var(--dirck-safe-right);
    padding-bottom: var(--dirck-safe-bottom);
    padding-left: var(--dirck-safe-left);
    transition: transform 160ms ease, visibility 160ms ease;
  }

  .mobileBottomNav .globalNavItem {
    min-height: 64px;
  }

  .main {
    padding-top: max(22px, calc(16px + var(--dirck-safe-top)));
    padding-right: max(15px, calc(10px + var(--dirck-safe-right)));
    padding-bottom: 28px;
    padding-left: max(15px, calc(10px + var(--dirck-safe-left)));
    overflow-wrap: anywhere;
  }

  .coachingPreviewDialog {
    width: calc(100vw - var(--dirck-safe-left) - var(--dirck-safe-right));
    max-height: calc(var(--dirck-viewport-height) - var(--dirck-safe-top));
    margin-bottom: var(--dirck-safe-bottom);
  }

  #dashboard {
    padding-top: max(20px, calc(12px + var(--dirck-safe-top)));
    padding-right: max(14px, calc(10px + var(--dirck-safe-right)));
    padding-bottom: max(44px, calc(24px + var(--dirck-safe-bottom)));
    padding-left: max(14px, calc(10px + var(--dirck-safe-left)));
  }

  #dashboard .section {
    max-width: 100%;
    overflow-x: auto;
  }

  #dashboard .topBar > div {
    max-width: 100%;
    flex-wrap: wrap;
  }

  .authCard,
  #loginWrap .card {
    margin-right: 0;
    margin-left: 0;
  }

  body #authOverlay {
    align-items: flex-start;
    padding-top: max(12px, var(--dirck-safe-top));
    padding-right: max(12px, var(--dirck-safe-right));
    padding-bottom: max(12px, var(--dirck-safe-bottom));
    padding-left: max(12px, var(--dirck-safe-left));
  }

  body #authOverlay .authBgFilmBorder {
    display: none;
  }

  body #authOverlay .authCard {
    inline-size: 100%;
    min-block-size: calc(var(--dirck-viewport-height) - var(--dirck-safe-top) - var(--dirck-safe-bottom) - 24px);
    max-block-size: calc(var(--dirck-viewport-height) - var(--dirck-safe-top) - var(--dirck-safe-bottom) - 24px);
    padding: clamp(24px, 7vw, 34px);
    border-radius: 24px;
  }

  body #authOverlay .authLogoTitle {
    font-size: clamp(34px, 11vw, 44px);
  }

  html[data-dirck-keyboard="open"] body {
    padding-bottom: var(--dirck-safe-bottom);
  }

  html[data-dirck-keyboard="open"] body #authOverlay {
    padding-top: max(8px, var(--dirck-safe-top));
    padding-bottom: max(8px, var(--dirck-safe-bottom));
  }

  html[data-dirck-keyboard="open"] body #authOverlay .authCard {
    min-block-size: 0;
    max-block-size: calc(var(--dirck-viewport-height) - var(--dirck-safe-top) - var(--dirck-safe-bottom) - 16px);
    padding-block: 22px;
  }

  html[data-dirck-keyboard="open"] .mobileBottomNav {
    visibility: hidden;
    transform: translateY(110%);
    pointer-events: none;
  }
}

@media (max-width: 720px) and (orientation: landscape) and (max-height: 500px) {
  .mobileTopbar {
    min-height: calc(48px + var(--dirck-safe-top));
    padding-top: calc(5px + var(--dirck-safe-top));
    padding-bottom: 5px;
  }

  .mobileBottomNav {
    min-height: calc(54px + var(--dirck-safe-bottom));
  }

  .mobileBottomNav .globalNavItem {
    min-height: 54px;
  }

  body {
    padding-bottom: calc(54px + var(--dirck-safe-bottom));
  }

  body #authOverlay,
  body #onboardingOverlay {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobileBottomNav {
    transition: none;
  }
}
