/* Native phone presentation; desktop keeps its existing workspace layout. */
.toolbar-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(0, 85, 85, 0.15);
  border-radius: 28px;
  padding: 0 4px;
  background: rgba(255, 255, 255, 0.1);
}
.toolbar-pill .icon-button {
  border: 0;
  background: transparent;
}
.catalog-lock {
  width: 20px;
  height: 20px;
  color: var(--muted);
  flex-shrink: 0;
}
.set-image > picture {
  width: inherit;
  height: inherit;
}
.notation-link {
  width: 100%;
  text-align: left;
  color: inherit;
}
.notation-link .set-image > .icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
}
.native-pro-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin: 24px 0 30px;
}
.native-pro-banner h2 {
  margin: 0 0 5px;
  font-size: 18px;
  font-weight: 500;
}
.native-pro-banner p {
  margin: 0;
  font-size: 14px;
}
.native-pro-banner > div:last-child {
  display: grid;
  justify-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.native-pro-banner .button {
  border: 0;
  border-radius: 24px;
  min-height: 32px;
  font-size: 13px;
  padding: 6px 12px;
  background: var(--control);
}
.native-pro-banner .button.primary {
  background: var(--accent);
}
.mobile-list-tools {
  margin-bottom: 16px;
}
.mobile-list-tools > summary {
  display: none;
}
.mobile-list-tools > .list-toolbar {
  display: flex;
}
.solution-row {
  position: relative;
  gap: 0;
}
.solution-row .solution {
  padding-right: 44px;
}
.solution-validation {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 3px;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--green);
}
.solution-validation .icon {
  width: 22px;
  height: 22px;
}
.solution-row:has(.remove-notation) .solution-validation {
  right: 42px;
}
.solution-row:has(.remove-notation) .solution {
  padding-right: 42px;
}
.solution > .selected-solution-mark {
  color: var(--text);
}
.case-options {
  display: grid;
  gap: 12px;
}
.notation-reference-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 24px;
}
.notation-reference-grid .notation-card {
  padding: 16px 8px;
}
.notation-guide section {
  margin: 26px 0;
}
.video-thumbnail-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 16px;
  background: var(--control);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}
.puzzle-wheel-window {
  display: none;
}
.puzzle-wheel select {
  width: 100%;
  text-align: center;
}
.detail-bottom-setup {
  display: none;
}
.notation-editor {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.editor-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.editor-preview-tabs {
  width: 220px;
}
#editor-cube {
  display: grid;
  place-items: center;
  width: 100%;
  height: 240px;
}
.editor-diagram {
  display: block;
  width: 240px;
  height: 240px;
  max-width: 85%;
}
.editor-diagram img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
#editor-cube .cube-illustration {
  width: 100%;
  height: 100%;
}
.editor-input {
  position: relative;
  padding-bottom: 20px;
}
.editor-input textarea {
  display: block;
  min-height: 80px;
  padding: 7px 36px 25px 8px;
  border-color: rgba(0, 85, 85, 0.25);
  border-radius: 9px;
  background: transparent;
  font-size: 17px;
  line-height: 1.35;
  resize: none;
}
#notation-counter {
  position: absolute;
  right: 0;
  bottom: 0;
  color: var(--muted);
  font-size: 12px;
}
#notation-validation {
  position: absolute;
  right: 7px;
  bottom: 27px;
  color: var(--yellow);
}
#notation-validation.valid {
  color: var(--green);
}
#notation-validation .icon {
  width: 24px;
  height: 24px;
}
.notation-keyboard {
  display: grid;
  gap: 6px;
}
.notation-keyboard > div {
  display: grid;
  gap: 6px;
}
.rotation-keys {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.move-keys {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.modifier-keys {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.notation-keyboard .button {
  padding: 3px;
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  background: var(--control);
  color: var(--accent);
  font-size: 20px;
  font-weight: 400;
}
.notation-keyboard .button.selected {
  background: var(--selected);
}
.notation-keyboard .icon {
  width: 20px;
  height: 20px;
}
.editor-save {
  font-size: 18px;
  font-weight: 400;
}

@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  :root {
    --gradient: linear-gradient(
      var(--native-gradient-angle, 155deg),
      var(--primary) 0%,
      var(--theme-end) 100%
    );
  }
  @supports (background: linear-gradient(155deg in srgb-linear, #00ffff, #fff)) {
    :root {
      --gradient: linear-gradient(
        var(--native-gradient-angle, 155deg) in srgb-linear,
        var(--primary) 0%,
        var(--theme-end) 100%
      );
    }
  }
  .workspace main {
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: calc(108px + env(safe-area-inset-bottom));
  }
  .topbar {
    position: relative;
    top: auto;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    min-height: 50px;
    flex-basis: 50px;
    padding: 3px 16px;
  }
  .topbar .navigation-back {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 9px;
    color: var(--text);
  }
  .navigation-back .icon {
    width: 26px;
    height: 26px;
    stroke-width: 2.3;
  }
  .topbar .toolbar-pill .icon-button {
    width: 48px;
    height: 44px;
    min-height: 44px;
    padding: 9px;
  }
  .toolbar-pill .icon {
    width: 26px;
    height: 26px;
  }
  .page-head,
  .workspace[data-screen='case'] .page-head {
    min-height: 41px;
    margin: 8px 0 32px;
  }
  .page-head h1,
  .workspace[data-screen='case'] .page-head h1 {
    font-size: 34px;
    letter-spacing: -0.6px;
    font-weight: 700;
    line-height: 1.2;
  }
  .mobile-tabs {
    left: 20px;
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    min-height: 64px;
    padding: 4px;
    border-radius: 34px;
    border-color: rgba(0, 0, 0, 0.18);
    background: rgba(255, 255, 255, 0.5);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
  }
  .mobile-tabs a {
    padding: 5px 3px;
    min-height: 54px;
    gap: 3px;
    font-size: 11px;
    color: var(--text);
  }
  .mobile-tabs .icon {
    width: 28px;
    height: 28px;
  }
  .mobile-tabs a.active {
    background: rgba(0, 85, 85, 0.1);
    color: var(--accent);
  }
  .section-caption {
    font-size: 16px;
    color: var(--muted);
    line-height: 1.2;
    margin: 0 0 7px;
  }
  .puzzle-overview .native-catalog-intro {
    display: none;
  }
  .puzzle-overview .set-section {
    margin: 0 0 32px;
  }
  .puzzle-overview.zbll-overview .set-section {
    margin-bottom: 16px;
  }
  .puzzle-overview .set-grid {
    gap: 9px;
  }
  .puzzle-overview .set-card,
  .puzzle-overview .notation-link {
    min-height: 80px;
    gap: 18px;
    border-radius: 17px;
    padding: 10px 12px;
  }
  .puzzle-overview .set-image {
    width: 60px;
    height: 58px;
    display: grid;
    place-items: center;
  }
  .puzzle-overview .set-copy h3 {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 5px;
  }
  .puzzle-overview .set-copy p {
    font-size: 15px;
    line-height: 1.25;
  }
  .puzzle-overview .set-card > .catalog-lock {
    display: block;
    width: 20px;
    height: 20px;
  }
  .native-pro-banner {
    margin: -6px 0 28px;
    gap: 10px;
  }
  .native-pro-banner > div:first-child {
    min-width: 0;
  }
  .native-pro-banner h2 {
    font-size: 17px;
  }
  .native-pro-banner p {
    font-size: 13px;
    line-height: 1.4;
  }
  .workspace[data-screen='algorithms'] main:has(.algorithm-list-layout) > .page-head {
    margin-bottom: 14px;
  }
  .mobile-list-tools {
    position: relative;
    height: 0;
    margin: 0;
  }
  .mobile-list-tools[open] {
    height: auto;
    margin-bottom: 14px;
  }
  .mobile-list-tools > summary {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    position: absolute;
    right: 0;
    top: -3px;
    font-size: 0;
    color: var(--accent);
    cursor: pointer;
    min-height: 24px;
  }
  .mobile-list-tools > summary .icon {
    width: 17px;
    height: 17px;
  }
  .mobile-list-tools[open] > summary {
    top: -28px;
  }
  .mobile-list-tools > .list-toolbar {
    display: none;
    margin-top: 10px;
  }
  .mobile-list-tools[open] > .list-toolbar {
    display: flex;
  }
  .case-section {
    margin-bottom: 30px;
  }
  .case-section > h2 {
    font-size: 17px;
    margin-bottom: 7px;
  }
  .case-grid {
    gap: 7px;
  }
  .case-card {
    min-height: 74px;
    gap: 9px;
    padding: 9px 11px 9px 7px;
    border-radius: 17px;
  }
  .case-card .status-dot {
    width: 12px;
    height: 12px;
  }
  .case-diagram {
    width: 54px;
    height: 54px;
  }
  .case-card h3 {
    font-size: 15px;
    line-height: 1.25;
    margin-bottom: 3px;
  }
  .case-card .notation {
    font-size: 17px;
    line-height: 1.3;
    overflow-wrap: normal;
  }
  .workspace[data-screen='case'] .page-head {
    margin-bottom: 18px;
  }
  .learning-control {
    margin-bottom: 0;
  }
  .status-picker {
    min-height: 32px;
  }
  .status-picker button {
    font-size: 13px;
    padding: 6px 3px;
  }
  .detail-preview-tabs,
  .detail-preview-actions {
    display: none;
  }
  .diagram-stage {
    min-height: 240px;
    margin: 16px 0 15px;
  }
  .detail-diagram {
    width: min(60vw, 240px);
    height: min(60vw, 240px);
  }
  .native-preview-content {
    min-height: 0;
  }
  .native-case-notation {
    font-size: 21px;
    font-weight: 650;
    line-height: 1.3;
    margin: 17px 0 0;
  }
  .detail-layout {
    gap: 26px;
    margin: 0 -5px;
  }
  .case-preview .learning-control {
    margin-left: 5px;
    margin-right: 5px;
  }
  .case-preview > .detail-setup,
  .case-preview > [data-action='practice-case'] {
    display: none;
  }
  .detail-right {
    gap: 24px;
  }
  .solutions-panel .panel-heading {
    margin: 0 5px 12px;
    color: var(--muted);
  }
  .solutions-panel .panel-heading h2 {
    font-size: 15px;
  }
  .solution {
    min-height: 44px;
    padding: 10px 44px 10px 12px;
    border-radius: 16px;
    margin: 4px 0;
    background: color-mix(in srgb, var(--primary) 30%, transparent);
  }
  .solution.selected {
    background: color-mix(in srgb, var(--primary) 30%, transparent);
  }
  .solution code {
    font-size: 17px;
    line-height: 1.35;
  }
  .solution > .selected-solution-mark {
    width: 22px;
    height: 22px;
  }
  .detail-bottom-setup {
    display: block;
    font-size: 15px;
    text-align: center;
    color: var(--muted);
  }
  .practice-menu .practice-menu-options {
    width: 100%;
    max-width: none;
    min-height: 41px;
    margin: -12px 0 12px;
    padding: 3px;
    border: 1px solid rgba(0, 85, 85, 0.2);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.15);
  }
  .practice-menu .practice-menu-options button {
    font-size: 15px;
    font-weight: 600;
    padding: 8px;
    color: color-mix(in srgb, var(--accent) 50%, transparent);
  }
  .practice-menu .practice-menu-options button.selected {
    color: var(--text);
    background: var(--control);
  }
  .practice-menu .practice-set-groups {
    gap: 28px;
  }
  .practice-set-groups .set-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }
  .practice-set-groups .section-caption {
    font-size: 17px;
    color: var(--text);
    margin: 0 6px 17px;
  }
  .practice-set-card {
    position: relative;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 12px;
    min-height: 150px;
    padding: 16px;
    border-radius: 18px;
  }
  .practice-set-card .set-image {
    width: 80px;
    height: 80px;
  }
  .practice-set-card .set-copy {
    flex: 0;
    width: 100%;
  }
  .practice-set-card .set-copy h3 {
    font-size: 17px;
    line-height: 1.25;
    margin: 0;
  }
  .practice-set-card .set-copy p {
    display: none;
  }
  .practice-set-card > .catalog-lock {
    display: block;
    position: absolute;
    right: 10px;
    top: 10px;
    width: 20px;
    height: 20px;
  }
  .practice-filters,
  .learn-library > .filter-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 8px;
    margin: 0 -16px 36px;
    padding: 0 16px;
  }
  .practice-filters::-webkit-scrollbar,
  .learn-library > .filter-chips::-webkit-scrollbar {
    display: none;
  }
  .practice-filters .chip,
  .learn-library > .filter-chips .chip {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 17px;
    min-height: 30px;
    border-radius: 20px;
    color: color-mix(in srgb, var(--accent) 50%, transparent);
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.2);
  }
  .practice-filters .chip.selected,
  .learn-library > .filter-chips .chip.selected {
    color: var(--text);
  }
  .practice-puzzle-picker {
    width: 100%;
    max-width: none;
    gap: 0;
    margin: 0;
    padding: 0;
  }
  .practice-menu.puzzle-mode {
    min-height: calc(100dvh - 210px - env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
  }
  .puzzle-mode .practice-puzzle-picker {
    flex: 1;
    display: flex;
    justify-content: space-evenly;
  }
  .practice-puzzle-image {
    width: 225px;
    height: 225px;
    max-width: 75vw;
    margin: 25px 0 30px;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.22));
  }
  .puzzle-wheel {
    position: relative;
    width: 100%;
    margin: 15px 0 25px;
  }
  .puzzle-wheel-window {
    display: block;
    position: relative;
    height: 124px;
    overflow: hidden;
    mask-image: linear-gradient(transparent, #000 20%, #000 62%, transparent);
    -webkit-mask-image: linear-gradient(transparent, #000 20%, #000 62%, transparent);
  }
  .puzzle-wheel-window::before {
    content: '';
    position: absolute;
    left: 8px;
    right: 8px;
    top: 28px;
    height: 32px;
    border-radius: 20px;
    background: rgba(0, 85, 85, 0.06);
  }
  .puzzle-wheel-options {
    transform: translateY(calc((1 - var(--wheel-index)) * 28px));
  }
  .puzzle-wheel-options button {
    display: block;
    width: 100%;
    height: 28px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 20px;
    line-height: 28px;
    font-weight: 400;
  }
  .puzzle-wheel-options button.selected {
    color: var(--text);
  }
  .puzzle-wheel select {
    position: absolute;
    width: 1px;
    height: 1px;
    left: 50%;
    bottom: 0;
    padding: 0;
    opacity: 0;
  }
  .puzzle-wheel select:focus-visible {
    position: relative;
    width: 100%;
    height: 44px;
    left: 0;
    opacity: 1;
  }
  .start-practice {
    position: relative;
    min-height: 50px;
    background: var(--panel);
    border-radius: 16px;
    font-size: 18px;
    font-weight: 600;
  }
  .start-practice .icon {
    position: absolute;
    right: 12px;
    width: 22px;
    height: 22px;
    color: var(--muted);
  }
  .workspace[data-screen='learn'] main > .page-head {
    margin-bottom: 14px;
  }
  .practice-menu > .page-head {
    margin-bottom: 26px;
  }
  .learn-library > .set-section > h2 {
    font-size: 17px;
    margin: 0 6px 17px;
  }
  .learn-layout .video-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    align-items: start;
  }
  .learn-layout .video-card {
    padding: 15px;
    border-radius: 18px;
    min-height: 150px;
  }
  .learn-layout .video-art {
    height: auto;
    aspect-ratio: 16/9;
    border-radius: 9px;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.25));
  }
  .video-art .video-thumbnail {
    object-fit: cover;
  }
  .learn-layout .video-card h3 {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    margin: 10px 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .play-badge {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.7);
  }
  .play-badge .icon {
    color: #fff;
    width: 19px;
    height: 19px;
  }
  dialog.notation-sheet,
  dialog.playback-sheet {
    position: fixed;
    inset: auto 0 0;
    margin: 0;
    width: 100%;
    max-width: none;
    height: calc(100dvh - max(24px, env(safe-area-inset-top)));
    max-height: none;
    padding: 22px 16px 24px;
    border-radius: 40px 40px 28px 28px;
    overflow-y: auto;
  }
  dialog.notation-sheet::before,
  dialog.playback-sheet::before {
    content: '';
    position: absolute;
    left: calc(50% - 30px);
    top: 6px;
    width: 60px;
    height: 4px;
    border-radius: 3px;
    background: var(--accent);
    opacity: 0.25;
  }
  .notation-sheet .modal-head,
  .playback-sheet .modal-head {
    position: relative;
    justify-content: center;
    min-height: 44px;
    margin-bottom: 10px;
  }
  .notation-sheet .modal-head h2,
  .playback-sheet .modal-head h2 {
    max-width: calc(100% - 66px);
    font-size: 17px;
    text-align: center;
  }
  .notation-sheet .modal-head .icon-button,
  .playback-sheet .modal-head .icon-button {
    position: absolute;
    left: -8px;
    width: 44px;
    height: 44px;
    color: var(--text);
  }
  .notation-sheet .notation-editor {
    min-height: calc(100% - 54px);
    justify-content: space-evenly;
    gap: 16px;
  }
  .editor-preview-tabs {
    min-height: 32px;
  }
  .editor-preview-tabs button {
    font-size: 13px;
  }
  #editor-cube {
    height: min(34dvh, 260px);
  }
  .editor-diagram {
    width: min(60vw, 240px);
    height: min(60vw, 240px);
  }
  .notation-editor .modal-actions {
    margin: 0;
  }
  .playback-sheet .playback-panel {
    display: flex;
    flex-direction: column;
    min-height: calc(100% - 60px);
  }
  .playback-sheet .preview-expansion {
    display: none;
  }
  .playback-sheet .playback-cube {
    flex: 1;
    min-height: 280px;
    height: auto;
  }
  .playback-sheet .native-case-notation {
    margin: 20px 0 50px;
    font-size: 20px;
    color: var(--text);
    font-weight: 500;
  }
  .playback-sheet .move-tokens {
    display: none;
  }
  .playback-sheet .playback-controls {
    position: relative;
    margin: 20px 0 30px;
    gap: 10px;
  }
  .playback-sheet .playback-controls > span {
    position: absolute;
    bottom: calc(100% + 15px);
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 13px;
  }
  .playback-sheet .playback-controls .icon-button {
    width: 60px;
    height: 50px;
    min-height: 50px;
    border-radius: 30px;
  }
  .playback-sheet .playback-controls .icon {
    width: 28px;
    height: 28px;
  }
  .playback-sheet .playback-controls select {
    flex-basis: 100%;
    max-width: 130px;
    margin: 12px 25% 0;
  }
  #toast {
    bottom: calc(98px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 370px) {
  .workspace main {
    padding-left: 12px;
    padding-right: 12px;
  }
  .mobile-tabs {
    left: 12px;
    right: 12px;
  }
  .mobile-tabs a {
    font-size: 10px;
  }
  .puzzle-overview .set-card {
    gap: 12px;
  }
  .puzzle-overview .set-copy p {
    font-size: 14px;
  }
  .practice-set-card,
  .learn-layout .video-card {
    padding: 12px;
  }
  .practice-set-card .set-copy h3,
  .learn-layout .video-card h3 {
    font-size: 15px;
  }
  .case-card .notation {
    font-size: 15px;
  }
  .practice-set-groups .set-grid,
  .learn-layout .video-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 700px) and (max-height: 700px) {
  .puzzle-mode .practice-puzzle-image {
    width: 180px;
    height: 180px;
    margin: 10px 0;
  }
  .puzzle-mode .puzzle-wheel {
    margin: 0 0 10px;
  }
  .notation-sheet #editor-cube {
    height: 180px;
  }
  .notation-sheet .editor-diagram {
    height: 180px;
    width: 180px;
  }
  .notation-sheet .notation-editor {
    gap: 10px;
  }
}
@media (max-height: 500px) and (pointer: coarse) {
  .practice-menu.puzzle-mode {
    min-height: auto;
  }
  .puzzle-mode .practice-puzzle-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
  }
  .puzzle-mode .practice-puzzle-image {
    grid-row: span 2;
    margin: 0;
    width: 175px;
    height: 175px;
    justify-self: center;
  }
  .puzzle-mode .puzzle-wheel {
    margin: 0;
  }
  dialog.notation-sheet,
  dialog.playback-sheet {
    border-radius: 24px;
  }
  .notation-sheet .notation-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
  }
  .notation-sheet .editor-preview {
    grid-row: span 3;
  }
  .notation-sheet #editor-cube {
    height: 180px;
  }
  .notation-sheet .editor-diagram {
    height: 180px;
    width: 180px;
  }
}
