/* HSK One — responsive studio geometry (2026-11-09)
   Components adapt to their available width; previous releases used a 2960px
   study shell plus a 900px-wide card, creating oversized empty panels.
   Keep the landing page generously wide, but constrain focused study UI.
   This stylesheet is deliberately last in the cascade, and does not alter
   exam state, paywall checks, content, or card event handlers. */
:root {
  --hsk-study-max: 2060px;
  --hsk-welcome-max: 2380px;
  --hsk-study-gap: clamp(12px, 1.15vw, 22px);
}
body.hsk3-unified .container,
body.hsk3-unified #hskLevelHub,
body.hsk3-unified #previousWorkspaceMount {
  width: min(calc(100% - 2 * var(--hsk-shell-gutter)), var(--hsk-study-max)) !important;
  max-width: var(--hsk-study-max) !important;
  margin-inline: auto !important;
  box-sizing: border-box !important;
  min-width: 0 !important;
}
body.hsk3-unified #hskWelcome {
  width: min(calc(100% - 2 * var(--hsk-shell-gutter)), var(--hsk-welcome-max)) !important;
  max-width: var(--hsk-welcome-max) !important;
}
body.hsk3-unified .topbar {
  padding-inline: max(var(--hsk-shell-gutter), calc((100vw - var(--hsk-study-max))/2)) !important;
}
/* Readable two-column flashcards on large screens, not a 2960px-wide form. */
@media (min-width: 1141px) {
  body.hsk3-unified #app .flash-full,
  body.hsk3-unified #hskLevelHub .lh-studio-parity {
    display: grid !important;
    grid-template-columns: clamp(310px, 25vw, 410px) minmax(0, 1fr) !important;
    gap: var(--hsk-study-gap) !important;
    min-width: 0 !important;
    align-items: stretch !important;
  }
  body.hsk3-unified #app .flash-full .flash-head,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-head {
    min-width: 0 !important;
    padding: clamp(21px, 1.8vw, 32px) !important;
  }
}
body.hsk3-unified #app .flash-full .flash-shell,
body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-shell {
  min-width: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  align-items: stretch;
}
body.hsk3-unified #app .flash-full .flash-stage,
body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-stage {
  min-width: 0 !important;
  display: flex !important;
  justify-content: center !important;
  align-items: stretch !important;
}
/* A single centered reading surface gives a 34-inch monitor an intentional
   focal point, without stretching a few Hanzi across the whole display. */
body.hsk3-unified #app .flash-full .study-card,
body.hsk3-unified #hskLevelHub .lh-studio-parity .study-card {
  position: relative !important;
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 1220px !important;
  min-width: 0 !important;
  margin: 0 auto !important;
  padding: 76px clamp(18px, 2.1vw, 38px) 24px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  text-align: center !important;
  overflow-wrap: anywhere;
}
/* Both controls are anchored to the CARD, not the vertically centered word.
   The 76px top padding reserves their entire touch/keyboard hit region. */
body.hsk3-unified #app .flash-full .study-card .flash-card-toolbar,
body.hsk3-unified #hskLevelHub .lh-studio-parity .study-card .flash-card-toolbar {
  position: absolute !important;
  top: 18px !important;
  left: 20px !important;
  right: 20px !important;
  bottom: auto !important;
  width: auto !important;
  max-width: none !important;
  min-height: 39px !important;
  margin: 0 !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 8px !important;
  z-index: 5 !important;
}
body.hsk3-unified #app .flash-full .flash-card-toolbar .wordtag,
body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-card-toolbar .wordtag {
  position: static !important;
  max-width: calc(100% - 112px) !important;
  min-width: 0 !important;
  flex: 0 1 auto !important;
  margin: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  line-height: 1.4 !important;
}
body.hsk3-unified #app .flash-full .flash-card-toolbar .audio-in-card,
body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-card-toolbar .audio-in-card {
  position: static !important;
  min-height: 39px !important;
  flex: 0 0 auto !important;
  margin: 0 !important;
  white-space: nowrap;
  touch-action: manipulation;
}
body.hsk3-unified #app .flash-full .study-card .hsk3-flash-content,
body.hsk3-unified #hskLevelHub .lh-studio-parity .study-card .hsk3-flash-content {
  min-width: 0 !important;
  width: 100% !important;
  max-width: 860px !important;
  height: auto !important;
  margin: auto !important;
  padding: 10px 0 !important;
  flex: 0 0 auto !important;
  overflow: visible !important;
  text-align: center !important;
}
/* 768/796px tablets used to squeeze the controls into a tiny sidebar.
   Reflow earlier, then use the settings area's full width. */
@media (max-width: 1140px) {
  body.hsk3-unified #app .flash-full,
  body.hsk3-unified #hskLevelHub .lh-studio-parity {
    display: grid !important;
    position: relative !important;
    inset: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
    padding: 0 !important;
    align-items: start !important;
    z-index: auto !important;
  }
  body.hsk3-unified #app .flash-full .flash-head,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-head {
    min-width: 0 !important;
    width: 100% !important;
    height: auto !important;
    padding: 18px 20px !important;
    border: 1px solid var(--line) !important;
    border-radius: 18px !important;
    display: block !important;
  }
  body.hsk3-unified #app .flash-full .flash-side-top,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-side-top {
    display: none !important;
  }
  body.hsk3-unified #app .flash-full .flash-side-footer,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-side-footer {
    display: none !important;
  }
  body.hsk3-unified #app .flash-full .flash-side-controls,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-side-controls {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
    min-width: 0 !important;
    width: 100% !important;
    align-items: stretch !important;
  }
  body.hsk3-unified #app .flash-full .flash-side-controls .controls:first-child,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-side-controls .controls:first-child {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
    align-items: start !important;
    width: 100% !important;
    margin: 0 !important;
  }
  body.hsk3-unified #app .flash-full .flash-side-controls .controls:first-child > label,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-side-controls .controls:first-child > label {
    display: block !important;
    min-width: 0 !important;
    width: 100% !important;
  }
  body.hsk3-unified #app .flash-full .flash-side-controls select,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-side-controls select {
    display: block !important;
    box-sizing: border-box !important;
    width: 100% !important;
    min-height: 48px !important;
    height: 48px !important;
    margin-top: 7px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    font-size: 14px !important;
    line-height: normal !important;
  }
  body.hsk3-unified #app .flash-full .flash-deck-note,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-deck-note {
    margin: 0 !important;
    padding: 10px 12px !important;
    font-size: 12px !important;
    line-height: 1.5 !important;
    max-height: none !important;
    overflow: visible !important;
  }
  body.hsk3-unified #app .flash-full .flash-filter-title,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-filter-title {
    display: block !important;
    width: 100% !important;
    margin: 4px 0 0 !important;
  }
  body.hsk3-unified #app .flash-full .chiprow,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .chiprow {
    display: flex !important;
    flex-flow: row wrap !important;
    gap: 7px !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body.hsk3-unified #app .flash-full .flash-side-controls > .controls:last-child,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-side-controls > .controls:last-child {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
    gap: 10px !important;
    margin: 3px 0 0 !important;
  }
  body.hsk3-unified #app .flash-full .flash-side-controls > .controls:last-child > button,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-side-controls > .controls:last-child > button {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 42px !important;
  }
  body.hsk3-unified #app .flash-full .flash-shell,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-shell {
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
    padding: 15px !important;
    border: 1px solid var(--line) !important;
    border-radius: 18px !important;
  }
  body.hsk3-unified #app .flash-full .flash-stage,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-stage {
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  body.hsk3-unified #app .flash-full .study-card,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .study-card {
    min-height: 335px !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
}
/* Phones: one readable control per line and normal document scrolling.
   Avoid nested scrollbars and accidental zoom/keyboard layout jumps. */
@media (max-width: 740px) {
  body.hsk3-unified #app .flash-full .flash-head,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-head {
    padding: 14px !important;
    border-radius: 16px !important;
  }
  body.hsk3-unified #app .flash-full .flash-side-controls .controls:first-child,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-side-controls .controls:first-child {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  body.hsk3-unified #app .flash-full .flash-side-controls select,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-side-controls select {
    min-height: 48px !important;
    height: 48px !important;
    font-size: 16px !important;
  }
  body.hsk3-unified #app .flash-full .study-card,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .study-card {
    padding: 72px 14px 20px !important;
    min-height: 300px !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    touch-action: pan-y !important;
    transform: none !important;
    transition: background-color .12s, border-color .12s !important;
  }
  body.hsk3-unified #app .flash-full .study-card .flash-card-toolbar,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .study-card .flash-card-toolbar {
    top: 12px !important;
    left: 12px !important;
    right: 12px !important;
    min-height: 40px !important;
  }
  body.hsk3-unified #app .flash-full .hsk3-flash-content,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .hsk3-flash-content {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    padding: 8px 0 !important;
  }
  body.hsk3-unified #app .flash-full .flash-btns,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-btns {margin-top: 8px;}
  body.hsk3-unified #app .flash-full .flash-shell,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-shell {padding: 11px !important;}
}
@media (max-width: 360px) {
  body.hsk3-unified #app .flash-full .flash-card-toolbar .wordtag,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-card-toolbar .wordtag {max-width: calc(100% - 98px) !important;}
  body.hsk3-unified #app .flash-full .flash-shell,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-shell {padding: 8px !important;}
  body.hsk3-unified #app .flash-full .flash-head,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-head {padding: 11px !important;}
}
@media (prefers-reduced-motion: reduce) {
  body.hsk3-unified #app .flash-full *,
  body.hsk3-unified #hskLevelHub .lh-studio-parity * {scroll-behavior: auto !important;}
}
/* Treat the study area as a reading interface at desktop viewing distances. */
@media (min-width: 1600px) {
  body.hsk3-unified #app .flash-full .flash-head .smalllabel,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-head .smalllabel {font-size: 12px !important;}
  body.hsk3-unified #app .flash-full .flash-side-top p,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-side-top p {font-size: 13px !important;line-height: 1.65 !important;}
  body.hsk3-unified #app .flash-full .flash-deck-note,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-deck-note {font-size: 12px !important;line-height: 1.6 !important;}
  body.hsk3-unified #app .flash-full .chiprow .chip,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .chiprow .chip {font-size: 12px !important;min-height: 36px !important;}
  body.hsk3-unified #app .flash-full .flash-progress,
  body.hsk3-unified #hskLevelHub .lh-studio-parity .flash-progress {font-size: 13px !important;}
}
