/* Hangul learning page */

.nav-active {
  color: var(--text) !important;
  font-weight: 600;
}

.hangul-page {
  min-height: calc(100dvh - 72px);
}

body.hangul-detail-open {
  overflow: hidden;
}

.hangul-hero {
  padding: 2rem 0 1.5rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--red);
}

.hangul-hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.hangul-hero p {
  color: var(--text-muted);
  max-width: 520px;
  margin-bottom: 1.5rem;
}

.progress-overview {
  max-width: 400px;
}

.progress-overview-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.5rem;
}

.progress-bar--lg {
  height: 10px;
}

#progress-percent {
  color: var(--red);
}

.hangul-learn {
  padding: 1rem 0 4rem;
}

.hangul-main {
  min-width: 0;
  max-width: 100%;
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.55rem 1.1rem;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.tab:hover {
  border-color: var(--navy-muted);
  color: var(--text);
}

.tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
}

.tab--builder.active {
  background: var(--red);
  border-color: var(--red);
}

/* Syllable builder */
.syllable-builder {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.syllable-builder.hidden {
  display: none;
}

.syllable-builder-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.25rem;
}

.syllable-builder-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.syllable-builder-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.syllable-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  min-height: 88px;
  padding: 0.5rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.syllable-slot:hover,
.syllable-slot:focus-visible {
  border-color: var(--navy-light);
  outline: none;
}

.syllable-slot.is-active {
  border-color: var(--red);
  background: var(--red-light);
  box-shadow: 0 0 0 2px var(--red-glow);
}

.syllable-slot.is-filled {
  border-style: solid;
  border-color: var(--navy-light);
  background: var(--surface);
}

.syllable-slot--optional {
  border-color: var(--cream-darker);
}

.syllable-slot--optional .syllable-slot-label::after {
  content: " (optional)";
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.builder-jamo-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.hangul-builder-active .syllable-builder,
body.hangul-builder-active .builder-jamo-picker,
body.hangul-builder-active .builder-jamo-grid {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.builder-jamo-dragging,
body.builder-jamo-dragging * {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}

.syllable-compose {
  padding-top: 0.15rem;
}

.syllable-builder-status {
  margin: 0.65rem 0 0;
  min-height: 1.2em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--red);
}

.builder-jamo-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
}

.builder-jamo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 0.55rem;
}

.builder-jamo-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 68px;
  padding: 0.45rem 0.35rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--cream);
  cursor: grab;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.builder-jamo-card:active {
  transform: scale(0.96);
  border-color: var(--red);
}

.builder-jamo-card.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}

body.builder-jamo-dragging .builder-jamo-card:not(.is-dragging) {
  pointer-events: none;
}

.builder-jamo-drag-ghost {
  position: fixed;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  min-height: 68px;
  padding: 0.45rem 0.35rem;
  border: 2px solid var(--red);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(15, 22, 35, 0.22);
  pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: 0.96;
}

.builder-jamo-char {
  font-size: 2rem;
  line-height: 1;
  color: var(--navy);
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.syllable-slot.is-dragover {
  border-color: var(--red);
  background: var(--red-light);
}

.syllable-slot-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.syllable-slot-char {
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

.syllable-slot-char.is-empty {
  color: var(--cream-darker);
}

.syllable-op {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-muted);
  user-select: none;
}

.syllable-result-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 100px;
}

.syllable-result-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.syllable-compose-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}

.syllable-result {
  font-size: 3rem;
  line-height: 1;
  color: var(--red);
  min-height: 3rem;
}

.syllable-play-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  color: var(--red);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}

.syllable-play-btn:hover:not(:disabled) {
  border-color: var(--red);
  background: var(--red-light);
}

.syllable-play-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.syllable-clear-btn {
  padding: 0.45rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  margin-left: auto;
  transition: border-color 0.15s, color 0.15s;
}

.syllable-clear-btn:hover {
  border-color: var(--navy-muted);
  color: var(--text);
}

.jamo-card[draggable="true"] {
  cursor: grab;
}

.jamo-card.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.jamo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 0.8rem;
  width: 100%;
  min-width: 0;
}

.jamo-card {
  position: relative;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 0.6rem 0.75rem;
  text-align: center;
  cursor: default;
  transition: border-color 0.15s, box-shadow 0.15s;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
  z-index: 1;
}

.jamo-card:hover,
.jamo-card.is-popup-open {
  z-index: 20;
}

.jamo-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
}

.jamo-card-play {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-top: 0.05rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--red);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.jamo-card-play:hover {
  border-color: var(--red);
  background: var(--red-light);
}

@media (hover: hover) {
  .jamo-card:hover {
    border-color: var(--navy-light);
    box-shadow: var(--shadow);
  }

  .builder-jamo-card:hover {
    border-color: var(--navy-light);
    background: var(--surface);
    transform: translateY(-1px);
  }
}

.jamo-card.learned::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
}

.jamo-char {
  font-size: 2.7rem;
  line-height: 1.1;
  margin: 0;
}

.jamo-roman {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.25;
}

/* Hover / tap popup */
.jamo-popup {
  position: absolute;
  top: calc(100% - 2px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  width: max(240px, 18vw);
  max-width: 280px;
  padding-top: 10px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}

.jamo-popup-inner {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  box-shadow: var(--shadow-lg);
  text-align: left;
}

.jamo-popup-close {
  display: none;
}

.hangul-jamo-popup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1090;
  border: 0;
  padding: 0;
  background: rgba(15, 23, 42, 0.45);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hangul-jamo-popup-backdrop.hidden {
  display: none;
}

body.hangul-jamo-popup-open {
  overflow: hidden;
}

body.hangul-jamo-popup-open .mobile-tabbar {
  z-index: 1080;
}

.jamo-popup-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
}

.jamo-popup-type {
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--navy-light);
  color: var(--navy);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.jamo-popup-name {
  font-weight: 600;
  color: var(--text-muted);
}

.jamo-popup-line {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text);
}

.jamo-popup-label {
  display: block;
  margin-bottom: 0.1rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.jamo-popup-examples {
  margin-top: 0.45rem;
}

.jamo-popup-examples-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.jamo-popup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.jamo-example-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--cream);
  font: inherit;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.jamo-example-chip:hover {
  border-color: var(--red);
  background: var(--red-light);
}

.jamo-example-chip .learning-kr {
  font-size: 0.95rem;
  color: var(--navy);
}

.jamo-popup-learn {
  display: block;
  width: 100%;
  margin-top: 0.55rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.jamo-popup-learn:hover {
  border-color: var(--navy-muted);
  color: var(--text);
}

.jamo-popup-learn.is-learned {
  border-color: var(--red);
  background: var(--red-light);
  color: var(--red);
}

@media (hover: hover) {
  .jamo-card:hover .jamo-popup,
  .jamo-card:focus-within .jamo-popup {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
  }
}

.jamo-card.is-popup-open .jamo-popup {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

@media (hover: none) and (pointer: coarse) {
  .hangul-main,
  .jamo-grid {
    overflow: visible;
  }

  .jamo-card.is-popup-open {
    z-index: 1100;
  }

  .jamo-card.is-popup-open .jamo-popup {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    transform: none;
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .jamo-card.is-popup-open .jamo-popup-inner {
    max-height: min(78dvh, 560px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border: 0;
    border-radius: 1rem 1rem 0 0;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0));
    box-shadow: 0 -10px 40px rgba(15, 23, 42, 0.18);
  }

  .jamo-popup-close {
    display: grid;
    place-items: center;
    position: sticky;
    top: 0;
    z-index: 2;
    width: 2rem;
    height: 2rem;
    margin: 0 0 0.35rem auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--cream);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
  }

  body.has-mobile-tabbar .jamo-card.is-popup-open .jamo-popup {
    bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  body.has-mobile-tabbar .jamo-card.is-popup-open .jamo-popup-inner {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
  }
}

.btn-block {
  width: 100%;
}

.footer--compact {
  padding: 1.5rem 0;
}

.footer--compact .footer-bottom {
  border-top: none;
  padding-top: 0;
}

.footer--compact a {
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 0.8rem;
}

.footer--compact a:hover {
  color: white;
}

@media (max-width: 900px) {
  .jamo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.7rem;
  }

  .jamo-card {
    padding: 0.75rem 0.5rem 0.65rem;
  }

  .jamo-char {
    font-size: 2.25rem;
  }

  .jamo-card-play {
    width: 36px;
    height: 36px;
  }

  .jamo-popup {
    width: min(260px, calc(100vw - 2rem));
  }

  .hangul-hero h1 {
    font-size: clamp(1.4rem, 6vw, 2rem);
  }

  .hangul-hero p {
    font-size: 0.9rem;
    max-width: none;
  }

  .hangul-learn {
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0));
  }

  body.has-mobile-tabbar .hangul-learn {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0));
  }

  body.has-mobile-tabbar .hangul-hero {
    padding-top: calc(0.85rem + env(safe-area-inset-top, 0));
  }
}

@media (max-width: 720px) {
  .hangul-page {
    min-height: auto;
  }

  .hangul-hero {
    padding: calc(0.85rem + env(safe-area-inset-top, 0)) 0 0.75rem;
  }

  .hangul-hero h1 {
    font-size: clamp(1.35rem, 6.5vw, 1.85rem);
    margin-bottom: 0.45rem;
  }

  .hangul-hero p {
    font-size: 0.88rem;
    margin-bottom: 0.85rem;
    line-height: 1.5;
  }

  .hangul-learn {
    padding: 0.5rem 0 5rem;
  }

  .progress-overview-text {
    font-size: 0.8rem;
  }

  .progress-bar--lg {
    height: 8px;
  }

  .progress-overview {
    max-width: none;
  }

  .tab-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.35rem;
    margin-bottom: 1.25rem;
    margin-inline: -0.15rem;
    padding-inline: 0.15rem;
  }

  .tab-bar::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
    padding: 0.55rem 1rem;
  }

  .syllable-builder {
    padding: 1rem;
  }

  .builder-jamo-picker {
    grid-template-columns: 1fr;
  }

  .builder-jamo-grid {
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    gap: 0.5rem;
  }

  .jamo-card,
  .builder-jamo-card {
    min-height: 58px;
  }

  .syllable-slot {
    min-width: 76px;
    min-height: 76px;
  }

  .syllable-play-btn,
  .syllable-clear-btn,
  .learned-btn,
  .example-play-btn {
    min-height: 44px;
  }

  .example-play-btn {
    width: 44px;
    height: 44px;
  }

  .detail-meta {
    flex-wrap: wrap;
    gap: 0.65rem;
  }

  .detail-char {
    font-size: 3.25rem;
  }

  .voice-bottom {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0));
  }
}

@media (max-width: 480px) {
  .syllable-builder-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    justify-items: center;
  }

  .syllable-op {
    display: none;
  }

  .syllable-slot {
    width: 100%;
    min-width: 0;
    min-height: 72px;
  }

  .syllable-result-wrap {
    grid-column: 1 / -1;
    width: 100%;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    padding-top: 0.35rem;
    border-top: 1px dashed var(--border);
  }

  .syllable-result {
    font-size: 2.5rem;
    min-height: 2.5rem;
  }

  .syllable-play-btn {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
  }

  .syllable-clear-btn {
    grid-column: 1 / -1;
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }

  .builder-jamo-grid {
    grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  }

  .jamo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
  }

  .jamo-char {
    font-size: 2.35rem;
  }

  .jamo-roman {
    font-size: 0.78rem;
  }

  .jamo-card {
    padding: 0.95rem 0.5rem 0.75rem;
  }

  .jamo-card-play {
    width: 40px;
    height: 40px;
  }
}

/* Combine tab: fit builder on one mobile screen without scrolling */
@media (max-width: 900px) {
  .page-hangul:has(#builder-panel:not(.hidden)) .hangul-hero,
  body.hangul-builder-active .hangul-hero {
    display: none !important;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .hangul-learn,
  body.hangul-builder-active .hangul-learn {
    padding: 0.35rem 0 calc(4.5rem + env(safe-area-inset-bottom, 0)) !important;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .tab-bar,
  body.hangul-builder-active .tab-bar {
    margin-bottom: 0.45rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .tab,
  body.hangul-builder-active .tab {
    min-height: 36px;
    padding: 0.35rem 0.8rem;
    font-size: 0.78rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .voice-bottom,
  .page-hangul:has(#builder-panel:not(.hidden)) .footer--compact,
  body.hangul-builder-active .voice-bottom,
  body.hangul-builder-active .footer--compact {
    display: none !important;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-builder,
  body.hangul-builder-active .syllable-builder {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.65rem 0.7rem 0.75rem;
    margin-bottom: 0;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-builder-header,
  body.hangul-builder-active .syllable-builder-header {
    margin: 0;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-builder-title,
  body.hangul-builder-active .syllable-builder-title {
    font-size: 0.88rem;
    margin-bottom: 0;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-builder-desc,
  body.hangul-builder-active .syllable-builder-desc {
    display: none;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-compose,
  body.hangul-builder-active .syllable-compose {
    padding-top: 0;
    border-top: 1px dashed var(--border);
    margin-top: 0.15rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .builder-jamo-picker,
  body.hangul-builder-active .builder-jamo-picker {
    grid-template-columns: 1fr !important;
    gap: 0.35rem;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .builder-jamo-group + .builder-jamo-group,
  body.hangul-builder-active .builder-jamo-group + .builder-jamo-group {
    margin-top: 0.1rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .builder-jamo-heading,
  body.hangul-builder-active .builder-jamo-heading {
    font-size: 0.6rem;
    margin-bottom: 0.22rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) #builder-consonants,
  body.hangul-builder-active #builder-consonants {
    grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
    gap: 0.18rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) #builder-vowels,
  body.hangul-builder-active #builder-vowels {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 0.18rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .builder-jamo-card,
  body.hangul-builder-active .builder-jamo-card {
    position: relative;
    min-height: 0 !important;
    aspect-ratio: 1;
    padding: 0.08rem;
    border-radius: 5px;
    border-width: 1px;
    user-select: none;
    touch-action: none;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .builder-jamo-char,
  body.hangul-builder-active .builder-jamo-char {
    font-size: clamp(1.25rem, 5vw, 1.5rem);
    line-height: 1;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .builder-jamo-drag-ghost,
  body.hangul-builder-active .builder-jamo-drag-ghost {
    min-width: 44px;
    min-height: 44px;
    padding: 0.1rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-builder-row,
  body.hangul-builder-active .syllable-builder-row {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
    align-items: stretch;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-op,
  body.hangul-builder-active .syllable-op {
    display: none;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-slot,
  body.hangul-builder-active .syllable-slot {
    min-width: 0;
    width: 100%;
    min-height: 46px;
    flex: none;
    padding: 0.18rem 0.12rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-slot-label,
  body.hangul-builder-active .syllable-slot-label {
    font-size: 0.52rem;
    margin-bottom: 0.1rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-slot--optional .syllable-slot-label::after,
  body.hangul-builder-active .syllable-slot--optional .syllable-slot-label::after {
    content: none;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-slot-char,
  body.hangul-builder-active .syllable-slot-char {
    font-size: 1.2rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-result-wrap,
  body.hangul-builder-active .syllable-result-wrap {
    grid-column: 1 / -1;
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
    min-width: 0;
    border-top: 1px dashed var(--border);
    padding-top: 0.35rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-result-box,
  body.hangul-builder-active .syllable-result-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 4.25rem;
    padding: 0.35rem 0.5rem;
    border: 2px solid var(--navy-light);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-sizing: border-box;
    overflow: hidden;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-result,
  body.hangul-builder-active .syllable-result {
    font-size: clamp(2rem, 11vw, 2.85rem);
    line-height: 1;
    min-height: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: clip;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-compose-actions,
  body.hangul-builder-active .syllable-compose-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-play-btn,
  body.hangul-builder-active .syllable-play-btn {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 0.22rem 0.5rem;
    font-size: 0.68rem;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-play-btn span,
  body.hangul-builder-active .syllable-play-btn span {
    display: none;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-play-btn svg,
  body.hangul-builder-active .syllable-play-btn svg {
    width: 15px;
    height: 15px;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-clear-btn,
  body.hangul-builder-active .syllable-clear-btn {
    flex: 0 0 auto;
    width: auto !important;
    min-height: 30px;
    margin-left: 0;
    padding: 0.22rem 0.55rem;
    font-size: 0.68rem;
    grid-column: auto;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-builder-status,
  body.hangul-builder-active .syllable-builder-status {
    margin-top: 0.25rem;
    min-height: 1em;
    font-size: 0.72rem;
  }
}

@media (max-width: 380px) {
  .page-hangul:has(#builder-panel:not(.hidden)) #builder-consonants,
  body.hangul-builder-active #builder-consonants {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) #builder-vowels,
  body.hangul-builder-active #builder-vowels {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-slot,
  body.hangul-builder-active .syllable-slot {
    min-height: 42px;
  }

  .page-hangul:has(#builder-panel:not(.hidden)) .syllable-result,
  body.hangul-builder-active .syllable-result {
    font-size: clamp(1.85rem, 10vw, 2.5rem);
  }
}
