/* Studio Coach visual layer. Screen styling stays separate from the printable sheet. */
@media screen {
  :root {
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    --ink: #211e36;
    --muted: #59576f;
    --navy: #201b39;
    --green: #4941a4;
    --green-dark: #362c87;
    --wash: #f5f5fa;
    --line: #e0dfed;
    --paper: #fff;
    --radius: 18px;
    --studio-purple: #5944bd;
    --studio-purple-deep: #483697;
    --studio-purple-soft: #efebff;
    --studio-teal-soft: #e0f7f2;
    --studio-shadow: 0 1px 2px #2420390a, 0 12px 30px -24px #342b6360;
    --studio-side-width: 220px;
    --studio-header-height: 68px;
    --studio-gutter: clamp(16px, 2.6vw, 36px);
  }

  body.studio-page {
    min-height: 100dvh;
    background: radial-gradient(ellipse at 90% -6%, #ede8ff 0, transparent 520px), var(--wash);
  }

  h1 {
    font-size: clamp(1.9rem, 3.7vw, 2.85rem);
    font-weight: 760;
    letter-spacing: -.052em;
    text-wrap: balance;
  }
  h2 { font-weight: 740; letter-spacing: -.025em; }
  :focus-visible { outline: 3px solid #7155d7; outline-offset: 3px; }

  .coach-header {
    background: #fff;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
  }
  .coach-header .studio-header-inner {
    min-width: 0;
    min-height: var(--studio-header-height);
    max-width: 1520px;
    padding: 10px var(--studio-gutter);
  }
  .studio-brand { min-width: 0; gap: 11px; }
  .studio-brand-copy { min-width: 0; }
  .studio-brand strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1.04rem;
    font-weight: 770;
    letter-spacing: -.025em;
  }
  .coach-header .studio-kicker { color: var(--muted); font-size: .63rem; letter-spacing: .1em; }
  .studio-mark, .coach-logo {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 13px;
  }
  .studio-mark {
    background: linear-gradient(145deg, #dcd3ff, #ab9af6);
    color: #261958;
    box-shadow: 0 2px 5px #3f318230;
    font-size: .95rem;
    letter-spacing: -.05em;
  }
  .coach-header-context {
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 650;
  }
  .coach-header-context::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #8670db;
  }
  .coach-account { justify-content: flex-end; min-width: 0; }
  #studio-account {
    min-width: 0;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
  }
  .coach-account .studio-button {
    color: #45405d;
    border-color: var(--line);
    min-height: 34px;
    padding: 6px 10px;
    font-size: .78rem;
  }
  .coach-account .studio-button:hover:not(:disabled) { background: #f2effb; border-color: #cfc6ed; }

  .coach-nav {
    padding: 5px var(--studio-gutter) 10px;
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px;
    max-width: 100%;
  }
  #studio-nav .studio-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 3px;
    min-height: 46px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: #4d4867;
    text-align: center;
    font-size: .8rem;
    font-weight: 680;
    line-height: 1.16;
  }
  #studio-nav .studio-button:hover:not(:disabled) { background: #f4f1fc; color: #382c79; }
  #studio-nav .studio-button[aria-current="page"] {
    color: var(--studio-purple-deep);
    background: var(--studio-purple-soft);
    border-color: #e6ddff;
    font-weight: 760;
  }
  .coach-nav-icon { width: 19px; height: 19px; flex: 0 0 19px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
  .coach-nav-label { min-width: 0; overflow-wrap: anywhere; }

  .studio-shell, .studio-shell.studio-client-area, .coach-global { max-width: 1520px; padding-inline: var(--studio-gutter); }
  .studio-shell { padding-block: clamp(17px, 3vw, 33px) 45px; }
  .coach-signin { max-width: 700px; }
  .coach-page, .studio-workspace { gap: 19px; }
  .studio-shell.studio-client-area { gap: 19px; }
  .studio-sidebar, .studio-panel, .studio-stat { box-shadow: var(--studio-shadow); }
  .studio-panel { padding: clamp(15px, 2.2vw, 25px); }
  .studio-panel > :is(h2, h3) { margin-bottom: 15px; }
  .studio-sidebar { padding: 20px; }
  .studio-sidebar-note { color: var(--muted); }

  .coach-banner, .studio-hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-width: 0;
    padding: clamp(19px, 3vw, 36px);
    border: 1px solid #e1dbf6;
    border-radius: 23px;
    background: linear-gradient(119deg, #fff 12%, #f5f0ff 62%, #eae4ff 100%);
    box-shadow: var(--studio-shadow);
  }
  .coach-banner::after, .studio-hero::after {
    content: "";
    position: absolute;
    z-index: -1;
    inset: -95px -55px auto auto;
    width: 290px;
    aspect-ratio: 1;
    border: 42px solid #d9cdf844;
    border-radius: 50%;
    box-shadow: 0 0 0 24px #eee7ff70;
    pointer-events: none;
  }
  .coach-banner > p:last-child, .studio-hero p:not(.studio-kicker) {
    max-width: 69ch;
    color: var(--muted);
  }
  .coach-grid { gap: clamp(9px, 1.4vw, 17px); }
  .coach-stat {
    --stat-color: #513ba9;
    --stat-bg: #f1ecff;
    position: relative;
    align-content: start;
    min-height: 138px;
    padding: 16px;
    border-radius: 18px;
    box-shadow: var(--studio-shadow);
    transition: border-color .16s ease, box-shadow .16s ease;
  }
  .coach-stat:nth-child(2) { --stat-color: #206258; --stat-bg: var(--studio-teal-soft); }
  .coach-stat:nth-child(3) { --stat-color: #33518f; --stat-bg: #e8efff; }
  .coach-stat:nth-child(4) { --stat-color: #853e6b; --stat-bg: #fceaf6; }
  .coach-stat strong {
    display: inline-grid;
    justify-self: start;
    min-width: 43px;
    min-height: 43px;
    place-items: center;
    padding-inline: 9px;
    margin-bottom: 4px;
    border-radius: 12px;
    background: var(--stat-bg);
    color: var(--stat-color);
    font-size: 1.66rem;
    font-variant-numeric: tabular-nums;
  }
  .coach-stat:hover { border-color: #aa9be1; box-shadow: 0 8px 22px -18px #5944bd90; }
  .studio-stat { padding: clamp(11px, 1.65vw, 18px); }
  .studio-stat:nth-child(1) { border-top: 3px solid #a18bea; }
  .studio-stat:nth-child(2) { border-top: 3px solid #74c8b7; }
  .studio-stat:nth-child(3) { border-top: 3px solid #9baee2; }

  .studio-button {
    border-radius: 11px;
    border-color: #d8d0f2;
    background: #efebff;
    color: #413477;
    font-weight: 690;
    transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
  }
  .studio-button:hover:not(:disabled) { background: #e6ddfb; border-color: #c9bceb; }
  .studio-button.quiet { background: #fff; border-color: var(--line); color: #4d4666; }
  .studio-button.quiet:hover:not(:disabled) { background: #f4f1fb; border-color: #d7cef0; }
  .studio-button.primary {
    background: var(--coach-accent);
    border-color: var(--coach-accent);
    color: var(--coach-on-accent);
    box-shadow: 0 2px 5px #201b391b;
  }
  .studio-button.primary:hover:not(:disabled) {
    background: var(--coach-accent);
    border-color: var(--coach-accent);
    color: var(--coach-on-accent);
  }
  .studio-button.danger { border-color: #f0ced7; color: #862e49; }
  .studio-button.danger:hover:not(:disabled) { background: #fceef3; border-color: #e7b8ca; }
  input:not([type="checkbox"],[type="radio"]), select, textarea {
    border-color: #d6d2e5;
    border-radius: 11px;
    background: #fff;
  }
  input::placeholder, textarea::placeholder { color: #6f6a81; }
  input:read-only:not([type]), textarea:read-only { background: #f6f5fa; }
  .studio-exercise, #studio-client-log fieldset { border-radius: 14px; background: #f9f8fd; }
  .studio-plan-list button[aria-current="true"], .studio-volume-bar[aria-pressed="true"] {
    background: #eee8ff;
    border-color: #c9bcec;
    color: #413477;
  }
  .studio-volume li, .coach-list li, .coach-answers > div { background: #f6f4fb; }
  .coach-list a, .coach-answers a, .coach-text-link { color: #493aa0; }
  .coach-chat { background: #f4f2fa; }
  .coach-chat li[data-from="trainer"] { background: #eeebff; }
  .studio-status { background: #ede9fa; color: #332957; }
  .studio-status[data-kind="success"] { background: #def6eb; color: #15553d; }
  .studio-status[data-kind="error"] { background: #fceaf1; color: #822943; }

  .coach-ai-trigger.studio-button, .coach-ai-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid #5e48bd;
    border-radius: 11px;
    background: linear-gradient(130deg, #684dcc, #5039ad);
    color: #fff;
    box-shadow: 0 5px 14px #593cb82e;
    font-weight: 750;
  }
  .coach-ai-trigger.studio-button:hover:not(:disabled), .coach-ai-trigger:hover:not(:disabled) {
    background: linear-gradient(130deg, #5b41bf, #432a9d);
    border-color: #4931aa;
    color: #fff;
  }
  .coach-ai-trigger svg { width: 18px; height: 18px; flex: 0 0 18px; }
  .coach-ai-panel {
    max-width: 100%;
    border: 1px solid #ded4fb;
    border-radius: 20px;
    background: linear-gradient(138deg, #fff 45%, #f5efff 100%);
    color: var(--ink);
    box-shadow: 0 10px 32px -24px #42358288;
  }
  dialog.coach-ai-panel {
    max-width: min(720px, calc(100vw - 28px));
    max-height: calc(100dvh - 28px);
    overflow: auto;
  }
  dialog.coach-ai-panel::backdrop { background: #21183477; }
  .coach-ai-panel-header, .coach-ai-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
  .coach-ai-panel-header { justify-content: space-between; }

  @media (min-width: 980px) {
    body.studio-page:has(.coach-nav:not([hidden])) { padding-inline-start: var(--studio-side-width); }
    .studio-page:has(.coach-nav:not([hidden])) .coach-header {
      position: sticky;
      z-index: 10;
      top: 0;
      background: #fffffff7;
    }
    .studio-page:has(.coach-nav:not([hidden])) .studio-brand {
      position: fixed;
      z-index: 2;
      top: 0;
      left: 0;
      width: var(--studio-side-width);
      min-height: 82px;
      padding: 12px 16px;
      color: #fff;
      border-bottom: 1px solid #ffffff18;
    }
    .studio-page:has(.coach-nav:not([hidden])) .studio-brand .studio-kicker { color: #c8bdf0; }
    .studio-page:has(.coach-nav:not([hidden])) .coach-header-context { display: inline-flex; }
    .coach-nav {
      position: fixed;
      z-index: 1;
      inset: 0 auto 0 0;
      width: var(--studio-side-width);
      overflow: auto;
      overscroll-behavior: contain;
      align-content: start;
      grid-template-columns: minmax(0, 1fr);
      gap: 6px;
      padding: 103px 12px 18px;
      background: linear-gradient(176deg, #221c3c, #19162c 78%);
      border-right: 1px solid #332951;
    }
    #studio-nav .studio-button {
      justify-content: flex-start;
      gap: 11px;
      min-height: 46px;
      padding: 8px 11px;
      color: #ddd6f0;
      text-align: left;
      font-size: .86rem;
    }
    #studio-nav .studio-button:hover:not(:disabled) { background: #ffffff11; color: #fff; }
    #studio-nav .studio-button[aria-current="page"] { background: #dcd2ff; border-color: #dcd2ff; color: #2e205f; }
    #studio-nav .studio-button:focus-visible { outline-color: #cab8ff; outline-offset: 1px; }
    .studio-page:has(.coach-nav:not([hidden])) .studio-sidebar {
      position: sticky;
      top: calc(var(--studio-header-height) + 18px);
      max-height: calc(100dvh - var(--studio-header-height) - 38px);
      overflow: auto;
    }
    #plan-area { grid-template-columns: minmax(205px, 250px) minmax(0, 1fr); }
  }

  @media (min-width: 980px) and (max-width: 1179px) {
    :root { --studio-side-width: 70px; }
    .studio-page:has(.coach-nav:not([hidden])) .studio-brand { justify-content: center; padding-inline: 8px; }
    .studio-page:has(.coach-nav:not([hidden])) .studio-brand-copy,
    .coach-nav-label {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }
    .coach-nav { padding-inline: 8px; }
    #studio-nav .studio-button { justify-content: center; padding-inline: 3px; }
  }

  @media (min-width: 1370px) {
    .studio-hero { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
    .studio-hero > .studio-actions { justify-content: flex-end; }
  }

  @media (max-width: 979px) {
    #plan-area { grid-template-columns: minmax(0, 1fr); }
    #plan-area .studio-sidebar { order: 1; }
  }

  @media (max-width: 760px) {
    .coach-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    #studio-nav .studio-button { flex-direction: column; gap: 4px; min-height: 47px; }
    .coach-nav-icon { width: 17px; height: 17px; flex-basis: 17px; }
    .coach-stat { min-height: 124px; padding: 12px; }
    .coach-banner::after, .studio-hero::after { right: -150px; }
  }

  @media (max-width: 540px) {
    .coach-header .studio-header-inner { flex-direction: row; align-items: center; gap: 7px; min-height: 58px; }
    .studio-mark, .coach-logo { width: 34px; height: 34px; flex-basis: 34px; border-radius: 10px; }
    .studio-brand { gap: 7px; }
    .studio-brand strong { font-size: .93rem; }
    .coach-header .studio-kicker { display: none; }
    .coach-account { gap: 4px; }
    .coach-account .studio-button { padding-inline: 7px; min-height: 32px; }
    #studio-account { max-width: 92px; font-size: .75rem; }
    .studio-hero, .coach-banner { border-radius: 17px; }
    .studio-panel, .studio-sidebar { border-radius: 15px; }
  }

  @media (prefers-reduced-motion: reduce) {
    .studio-button, .coach-stat { transition: none; }
  }
  #plan-area { grid-template-columns: minmax(0, 1fr); }
  .studio-page:has(.coach-nav:not([hidden])) #plan-area .studio-sidebar {
    position: static;
    max-height: none;
  }
  #plan-area .studio-sidebar-actions, .coach-manage-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: .75rem;
  }
  #plan-area .studio-plan-list .studio-button {
    justify-content: space-between;
    text-align: left;
  }
  #plan-area [data-catalog-resources]:empty { display: none; }
  .coach-manage-filters label:first-child { flex: 1 1 14rem; }
  #coach-manage-roster .coach-list li { justify-content: space-between; }
  #coach-manage-roster small, #help-area .coach-list small { display: block; margin: .25rem 0 0; }
}

@media screen {
  .studio-comparison > summary {
    width: fit-content;
    color: var(--studio-purple-deep);
    font-size: 1.05rem;
    font-weight: 750;
    cursor: pointer;
  }
  .studio-comparison[open] > summary { margin-bottom: 13px; }
  #program-comparison-content { display: grid; gap: 12px; }
  .studio-comparison-tools, .studio-comparison-pages {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: end;
  }
  .studio-comparison-tools { justify-content: space-between; }
  .studio-comparison-tools > label { flex: 1 1 190px; max-width: 360px; }
  .studio-comparison-pages { align-items: center; color: var(--muted); font-size: .82rem; }
  .studio-comparison-scroll {
    max-width: 100%;
    max-height: min(60dvh, 710px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
  }
  .studio-comparison-scroll table {
    min-width: 100%;
    width: max-content;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
  }
  .studio-comparison-scroll :is(th, td) {
    min-width: 108px;
    max-width: 195px;
    padding: 8px 9px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    overflow-wrap: anywhere;
  }
  .studio-comparison-scroll tr > :last-child { border-right: 0; }
  .studio-comparison-scroll tbody tr:last-child > * { border-bottom: 0; }
  .studio-comparison-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f5f1ff;
  }
  .studio-comparison-scroll tr > :first-child {
    position: sticky;
    left: 0;
    min-width: 145px;
    max-width: 220px;
    background: #fbfaff;
  }
  .studio-comparison-scroll thead tr > :first-child { z-index: 3; background: #f5f1ff; }
  .studio-comparison-scroll tbody th { z-index: 1; font-size: .9rem; }
  .studio-comparison-scroll strong, .studio-comparison-scroll small { display: block; }
  .studio-comparison-scroll small { margin-top: 3px; color: var(--muted); }
  .studio-comparison-scroll .studio-button {
    min-height: 34px;
    width: 100%;
    padding: 4px 9px;
  }
  .studio-comparison-scroll .studio-button[aria-pressed="true"] { background: #ded5ff; border-color: #b4a2ed; }
  .studio-comparison-different { background: #f0eaff; }
  .studio-comparison-scroll .studio-comparison-change {
    width: fit-content;
    padding: 2px 5px;
    border-radius: 5px;
    background: #e5d9ff;
    color: #49348e;
    font-weight: 680;
  }
  @media (max-width: 540px) {
    .studio-comparison-scroll tr > :first-child { min-width: 112px; max-width: 145px; }
  }

  #progressions-area .coach-progression-library { margin-top: 24px; }
  #progressions-area .coach-progression-library h2 { margin-bottom: 12px; }
  #progressions-area .coach-progression-examples {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr));
    gap: 12px;
  }
  #progressions-area .coach-progression-examples article {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfaff;
  }
  #progressions-area .coach-progression-examples h3 {
    margin: 5px 0 0;
    font-size: 1.02rem;
  }
  #progressions-area .coach-progression-examples p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: .9rem;
  }
  #progressions-area .coach-progression-week, #progressions-area .coach-progression-phase {
    min-width: 0;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 13px;
  }
  #progressions-area .coach-progression-week > summary,
  #progressions-area .coach-progression-phase > summary {
    cursor: pointer;
    font-weight: 650;
  }
  #progressions-area .coach-progression-week > summary small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-weight: 400;
  }
  #progressions-area .coach-progression-fields, #progressions-area .coach-progression-phase {
    margin: 12px 0;
  }
  #progressions-area .coach-progression-fields h4 { margin: 0 0 8px; }
  #progressions-area .coach-progression-phase[open] > summary { margin-bottom: 10px; }
  #progressions-area .coach-progression-fields .studio-form-grid,
  #progressions-area .coach-progression-phase .studio-form-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  }
}

