/* Phone presentation only. Desktop stages and the shared backend stay intact. */
@media (max-width: 767px), (max-width: 1000px) and (max-height: 600px) and (pointer: coarse) {
  body, body.workspace-page {
    --phone-gutter: clamp(20px, 5.6vw, 24px);
    --page-gutter: var(--phone-gutter);
    --header-height: calc(68px + env(safe-area-inset-top));
    --frame-width: calc(100% - 2 * var(--phone-gutter));
    --copy-size: 14px;
    --phone-nav-surface: rgb(255 244 207 / .72);
    overflow-x: clip;
  }
  /* Blur the header on its own surface so the drawer can also blur the page
     behind it. Every route shares the index sky tint. */
  html body.workspace-page > .site-header,
  html.phone-index body.section3-preview > .site-header {
    position: fixed;
    inset: 0 0 auto;
    height: var(--header-height);
    gap: 16px;
    padding: env(safe-area-inset-top) var(--phone-gutter) 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  html body.workspace-page > .site-header::before,
  html.phone-index body.section3-preview > .site-header::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: var(--phone-nav-surface);
    -webkit-backdrop-filter: blur(20px) saturate(115%);
    backdrop-filter: blur(20px) saturate(115%);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .2);
  }
  html body.workspace-page > .site-header .wordmark {
    display: inline-flex; align-items: center; min-height: 44px;
    max-width: calc(100% - 60px); font-size: 26px;
    white-space: nowrap; overflow-wrap: normal;
  }
  html body.workspace-page > .site-header .desktop-nav { display: none; }
  html body.workspace-page > .site-header .menu-toggle { display: flex; width: 46px; height: 46px; }
  html body.workspace-page > .site-header .mobile-nav,
  html.phone-index body.section3-preview > .site-header .mobile-nav {
    inset-inline: 0; top: 100%;
    max-height: calc(100dvh - var(--header-height));
    padding: 10px var(--phone-gutter) max(16px, env(safe-area-inset-bottom));
    gap: 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
    background: var(--phone-nav-surface);
    -webkit-backdrop-filter: blur(20px) saturate(115%);
    backdrop-filter: blur(20px) saturate(115%);
    box-shadow: 0 16px 24px #29292908;
  }
  html body.workspace-page > .site-header .mobile-nav:not([hidden]) { display: flex; }
  html body.workspace-page > .site-header .mobile-nav a {
    display: flex; align-items: center; min-height: 50px;
    padding-block: 10px; font-size: 15px; line-height: 1.4;
  }

  /* Reading and account pages share the same title, gutters and natural flow. */
  body.workspace-page .workspace-shell.page-composed {
    display: block; width: var(--frame-width); height: auto; min-height: calc(100svh - 140px);
    margin-inline: auto; padding: calc(var(--header-height) + 28px) 0 24px; overflow: visible;
  }
  body.workspace-page .page-composed > .page-composition {
    --copy-size: 14px; --workspace-gap: 18px; --header-height: calc(68px + env(safe-area-inset-top));
    position: static; display: block; width: 100%; min-height: 0;
    margin: 0; padding: 0; transform: none;
  }
  body.workspace-page .page-composition .workspace-heading { margin: 0 0 36px; }
  body.workspace-page .page-composition .workspace-heading h1 {
    font-size: clamp(32px, 9vw, 38px); line-height: 1.04; letter-spacing: -.045em; text-wrap: balance;
  }
  body.workspace-page .page-composition .workspace-heading p { margin-top: 14px; font-size: 14px; line-height: 1.55; }
  body.workspace-page > .contact-footer {
    display: flex; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0;
    width: var(--frame-width); block-size: auto; min-height: 0; margin: 12px auto 0;
    padding: 10px 0 max(10px, env(safe-area-inset-bottom)); font-size: 12px;
  }
  body.workspace-page .footer-brand { min-height: 44px; max-width: none; }
  body.workspace-page .linkedin-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: auto; }
  html.phone-index body.section3-preview main#main-content .contact-footer {
    gap: 0;
    padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  }
  body.workspace-page .contact-footer .footer-links,
  html.phone-index body.section3-preview main#main-content .footer-links { display: none; }

  body.workspace-page.policy-page .policy-section { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-block: 28px; }
  body.workspace-page.policy-page .policy-section h3,
  body.workspace-page.policy-page .faq-section > h2 { max-width: none; font-size: 25px; line-height: 1.15; scroll-margin-top: calc(var(--header-height) + 22px); }
  body.workspace-page.policy-page .policy-copy p,
  body.workspace-page.policy-page .testimonial blockquote p { font-size: 14px; line-height: 1.65; }
  body.workspace-page.policy-page .policy-copy p + p { margin-top: 16px; }
  body.workspace-page.policy-page .faq-item summary { gap: 18px; padding-block: 18px; font-size: 14px; line-height: 1.5; }
  body.workspace-page.policy-page .faq-item:first-child summary { padding-top: 0; }
  body.workspace-page.policy-page .faq-answer > p:last-child { padding-bottom: 20px; }
  body.workspace-page.policy-page .testimonials-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  body.workspace-page.policy-page .testimonial { padding-block: 28px; gap: 20px; }
  body.workspace-page.policy-page .testimonial figcaption { font-size: 13px; }

  body.workspace-page.course-page .page-composition { --course-space: 48px; --course-gap: 24px; }
  body.workspace-page.course-page .page-composition :is(p, li, dd) { font-size: 14px; line-height: 1.65; }
  body.workspace-page.course-page .page-composition h2 { font-size: 29px; line-height: 1.12; letter-spacing: -.035em; }
  body.workspace-page.course-page :is(.course-intro, .course-section-header, .course-included, .course-update, .course-enrol) { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  body.workspace-page.course-page .course-story h2 { margin-bottom: 20px; }
  body.workspace-page.course-page .course-story p + p { margin-top: 16px; }
  body.workspace-page.course-page .course-summary { padding: 24px; border-radius: 22px; }
  body.workspace-page.course-page .course-summary h3 { font-size: 27px; margin-bottom: 18px; }
  body.workspace-page.course-page .course-price strong { font-size: 32px; }
  body.workspace-page.course-page .course-section { margin-top: 48px; padding-top: 32px; scroll-margin-top: calc(var(--header-height) + 20px); }
  body.workspace-page.course-page .course-section-header { margin-bottom: 26px; }
  body.workspace-page.course-page .course-skill-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 20px; }
  body.workspace-page.course-page .course-skill-grid article { padding-top: 18px; }
  body.workspace-page.course-page .course-skill-grid h3 { font-size: 23px; margin-bottom: 12px; }
  body.workspace-page.course-page .course-included-list dt { font-size: 15px; }
  body.workspace-page.course-page .course-update { padding: 24px; }
  body.workspace-page.course-page .course-enrol-action { width: 100%; max-width: none; justify-self: stretch; }
  body.workspace-page.course-page .course-primary { min-height: 48px; padding: 14px 18px; font-size: 14px; }

  /* Minimal email/code and admin sign-in, centered below the page heading. */
  body.student-portal-page .portal-workspace,
  body.student-portal-page .portal-view { min-height: 0; }
  body.workspace-page .portal-shell:has(.portal-login) > .page-composition,
  body.workspace-page .admin-shell:is([data-admin-screen="login"], [data-admin-screen="checking"]) > .page-composition {
    display: flex; flex-direction: column;
    min-height: calc(100svh - var(--header-height) - 208px);
  }
  body.student-portal-page .portal-workspace:has(.portal-login),
  body.admin-page .admin-shell:is([data-admin-screen="login"], [data-admin-screen="checking"]) .admin-workspace { flex: 1; min-height: 280px; justify-content: center; }
  body.student-portal-page .portal-login { --copy-size: 16px; }
  body.student-portal-page .portal-login h2 { font-size: clamp(25px, 7vw, 29px); line-height: 1.05; min-height: 2.1em; }
  body.student-portal-page .portal-login h2 span { white-space: normal; }
  body.student-portal-page .portal-login-form { margin-top: 12px; }
  body.student-portal-page .portal-login-form input { font-size: 16px; min-height: 48px; }
  body.student-portal-page .portal-login-button { min-height: 48px; margin-top: 6px; font-size: 14px; }
  body.student-portal-page .portal-status { font-size: 13px; overflow-wrap: anywhere; }
  body.student-portal-page .portal-dashboard-heading { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 20px; }
  body.student-portal-page .portal-dashboard-heading h2 { font-size: 29px; }
  body.student-portal-page .portal-dashboard-actions { gap: 24px; }
  body.student-portal-page .portal-dashboard-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  body.student-portal-page .portal-tabs { gap: 22px; }
  body.student-portal-page .portal-tabs button { font-size: 14px; min-height: 48px; }
  body.student-portal-page .portal-lessons-list { height: auto; max-height: 480px; padding-right: 6px; }
  body.student-portal-page .portal-lesson { grid-template-columns: 38px minmax(0, 1fr); gap: 10px 14px; padding-block: 18px; }
  body.student-portal-page .portal-lesson-info h3 { font-size: 14px; }
  body.student-portal-page .portal-lesson-info p { font-size: 13px; }
  body.student-portal-page .portal-lesson-info small { display: inline-block; }
  body.student-portal-page .portal-lesson-actions { grid-column: 2; flex-wrap: wrap; gap: 16px; }
  body.student-portal-page .portal-lesson-actions :is(button, a) { min-height: 44px; }
  body.student-portal-page .portal-account-summary { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; padding: 20px; }
  body.student-portal-page .portal-account-label { font-size: 11px; margin-bottom: 12px; }
  body.student-portal-page .portal-subscription { font-size: 14px; }
  body.student-portal-page .portal-credit { font-size: 34px; }
  body.student-portal-page .portal-yki { padding: 22px; }
  body.student-portal-page .portal-yki h3 { font-size: 27px; }
  body.student-portal-page .portal-yki p { font-size: 14px; }
  body.student-portal-page .portal-success { padding-block: 34px; }
  body.student-portal-page .portal-success h2 { font-size: 32px; }
  body.student-portal-page .portal-success p { font-size: 14px; margin-block: 20px; }
  body.student-portal-page .portal-calendar { min-height: 0; gap: 18px; }
  body.student-portal-page .portal-calendar .calendar-heading { flex-direction: column; align-items: stretch; gap: 18px; }
  body.student-portal-page .portal-calendar .calendar-heading h2 { font-size: 28px; }
  body.student-portal-page .portal-calendar .calendar-heading p { margin-top: 10px; font-size: 14px; }
  body.student-portal-page .portal-calendar .calendar-grid { flex: none; grid-template-columns: 32px repeat(7, minmax(0, 1fr)); grid-template-rows: 44px repeat(14, 28px); min-height: 0; gap: 4px; padding: 0; }
  body.student-portal-page .portal-calendar .calendar-date { grid-column: auto; margin: 0; padding: 0 0 6px; gap: 3px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
  body.student-portal-page .calendar-date span { font-size: 11px; }
  body.student-portal-page .calendar-date strong { font-size: 16px; }
  body.student-portal-page :is(.calendar-corner, .calendar-hour, .calendar-slot) { display: block; }
  body.student-portal-page .calendar-hour { font-size: 11px; }
  body.student-portal-page .calendar-slot { grid-column: auto; min-height: 28px; border-radius: 999px; }
  body.student-portal-page .slot-mark { margin: 0; font-size: 12px; }
  body.student-portal-page .portal-calendar .calendar-actions { min-height: 156px; flex-direction: column; align-items: stretch; gap: 12px; padding-top: 12px; }
  body.student-portal-page .calendar-selection { flex: 1; font-size: 13px; line-height: 1.5; }
  body:is(.student-portal-page, .admin-page) .week-navigation { width: 100%; justify-content: space-between; gap: 10px; }
  body:is(.student-portal-page, .admin-page) .week-navigation button { width: 44px; height: 44px; flex-shrink: 0; }
  body:is(.student-portal-page, .admin-page) .week-navigation > span { font-size: 12px; }
  body:is(.student-portal-page, .admin-page) .booking-primary { min-width: 0; min-height: 48px; padding: 13px 16px; gap: 16px; font-size: 14px; }

  /* Direct Admin access stays usable, but never appears in phone navigation. */
  html:has(body.admin-page), body.admin-page { overflow-y: auto; }
  body.admin-page .admin-login { padding-bottom: 16px; }
  body.admin-page .admin-login h2 { font-size: 29px; margin-bottom: 22px; }
  body.admin-page .admin-login .admin-form { gap: 16px; }
  body.admin-page .admin-form :is(input, select, textarea),
  body.admin-page :is(.admin-search, .admin-filter, .admin-monthly-row select) { font-size: 16px; min-height: 44px; }
  body.admin-page .admin-topbar { flex-direction: column; align-items: stretch; gap: 12px; padding-bottom: 20px; }
  body.admin-page .admin-topbar h2 { font-size: 29px; }
  body.admin-page .admin-actions { gap: 12px 20px; }
  body.admin-page .admin-text-button { min-height: 44px; }
  body.admin-page .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; padding-block: 22px; }
  body.admin-page .admin-stats strong { font-size: 30px; margin-bottom: 5px; }
  body.admin-page .admin-stats span { font-size: 13px; }
  body.admin-page .admin-monthly-row { flex-direction: column; align-items: stretch; gap: 12px; }
  body.admin-page .admin-monthly-values { gap: 12px 24px; flex-wrap: wrap; }
  body.admin-page .admin-monthly-note { margin-bottom: 24px; font-size: 11px; }
  body.admin-page .admin-teaching { margin-bottom: 28px; padding-bottom: 24px; }
  body.admin-page .admin-teaching-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  body.admin-page .admin-teaching-metric > strong { font-size: 30px; }
  body.admin-page .admin-teaching-metric > p { margin-bottom: 12px; }
  body.admin-page .admin-teaching-actions { flex-wrap: wrap; gap: 12px; }
  body.admin-page .admin-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; scroll-margin-top: calc(var(--header-height) + 20px); }
  body.admin-page .admin-tabs button { min-height: 48px; font-size: 14px; padding-block: 12px; }
  body.admin-page .admin-panel-heading { flex-direction: column; align-items: stretch; gap: 16px; margin-bottom: 22px; }
  body.admin-page .admin-panel-heading h3 { font-size: 26px; }
  body.admin-page .admin-tools { flex-direction: column; align-items: stretch; gap: 14px; }
  body.admin-page .admin-tools .admin-search, body.admin-page .admin-filter { width: 100%; }
  /* A local horizontal canvas preserves readable appointment names and all
     seven days. The page itself never scrolls sideways. */
  body.admin-page .admin-week-grid { grid-template-columns: 38px repeat(7, 88px); gap: 4px; overflow-x: auto; overscroll-behavior-x: contain; padding-bottom: 12px; scrollbar-width: thin; }
  body.admin-page .admin-hour { position: sticky; left: 0; z-index: 1; background: #f4b1a0; font-size: 11px; }
  body.admin-page .admin-day { padding-bottom: 12px; margin-bottom: 3px; }
  body.admin-page .admin-day strong { font-size: 21px; }
  body.admin-page .admin-cell :is(button, .admin-preview, .admin-external) { font-size: 12px; padding: 8px 6px; overflow-wrap: anywhere; }
  body.admin-page .admin-cell small { font-size: 10px; }
  body.admin-page .admin-legend { gap: 12px 18px; font-size: 11px; }
  body.admin-page .admin-reschedule-banner { flex-direction: column; align-items: stretch; padding: 18px; }
  body.admin-page .admin-lesson-row { grid-template-columns: 38px minmax(0, 1fr); gap: 12px; padding: 16px; }
  body.admin-page .admin-lesson-row > .admin-actions, body.admin-page .admin-outcomes { grid-column: 1 / -1; justify-content: flex-start; }
  body.admin-page .admin-lesson-row h4 { font-size: 14px; }
  body.admin-page .admin-lesson-row p { font-size: 13px; }
  body.admin-page .admin-outcomes button { min-height: 44px; }
  body.admin-page .admin-student-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  body.admin-page .admin-student-card { padding: 18px; }
  body.admin-page .admin-student-card h4 { font-size: 25px; }
  body.admin-page .admin-student-details { gap: 16px; margin-block: 18px; }
  body.admin-page .admin-student-details dd { font-size: 14px; }
  body:is(.student-portal-page, .admin-page) :is(h2, h3, h4, p, dd) { overflow-wrap: anywhere; }
  body.admin-page :is(.admin-lesson-row > div, .admin-student-top > div) { min-width: 0; }
  body:is(.student-portal-page, .admin-page) :is(.portal-dialog, .admin-dialog) { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 22px; margin: auto; }
  body:is(.student-portal-page, .admin-page) :is(.portal-dialog, .admin-dialog) h2 { font-size: 28px; }
  body:is(.student-portal-page, .admin-page) :is(.portal-dialog, .admin-dialog) p { font-size: 14px; }
  body:is(.student-portal-page, .admin-page) :is(.portal-dialog-actions, .admin-dialog-actions) { flex-wrap: wrap; gap: 12px; }
  body.student-portal-page .portal-profile-form { gap: 16px; margin-top: 20px; }
  body.student-portal-page .portal-profile-form input { font-size: 16px; min-height: 44px; }
  body.admin-page .admin-form-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  body.admin-page .admin-subscription-fields { padding: 14px; gap: 16px; }
  body.admin-page .admin-slot-pair { gap: 12px; }
}
@media (max-width: 350px) {
  body.student-portal-page .portal-account-summary { grid-template-columns: minmax(0, 1fr); }
  body.admin-page .admin-student-details { grid-template-columns: minmax(0, 1fr); }
}
/* Phone-only glass; kept outside the foundation copied into tablet styles. */
@media (max-width: 767px), (max-width: 1000px) and (max-height: 600px) and (pointer: coarse) {
  html:not(.tablet-portrait) body:is(.workspace-page, .section3-preview) > .site-header {
    --phone-nav-surface: rgb(255 255 255 / .2);
  }
  html:not(.tablet-portrait) body:is(.workspace-page, .section3-preview) > .site-header::before,
  html:not(.tablet-portrait) body:is(.workspace-page, .section3-preview) > .site-header .mobile-nav {
    -webkit-backdrop-filter: blur(14px) saturate(115%);
    backdrop-filter: blur(14px) saturate(115%);
  }
}
@media (prefers-reduced-motion: reduce) {
  html body.workspace-page > .site-header::before, html body.workspace-page > .site-header .mobile-nav,
  html.phone-index body.section3-preview > .site-header::before, html.phone-index body.section3-preview > .site-header .mobile-nav { transition: none; }
}
