:root {
  color-scheme: light;
  --navy-950: #07182d;
  --navy-900: #0d2340;
  --navy-800: #15365d;
  --navy-700: #214d7d;
  --red-700: #a71930;
  --red-600: #bd263d;
  --red-100: #fbe8eb;
  --blue-100: #e8f1fb;
  --blue-50: #f4f8fd;
  --ink: #152235;
  --muted: #64748b;
  --line: #d5dfeb;
  --paper: #ffffff;
  --shadow-soft: 0 14px 45px rgba(7, 24, 45, 0.12);
  --shadow-tooltip: 0 18px 50px rgba(7, 24, 45, 0.25);
  font-family:
    Inter, Pretendard, "Noto Sans KR", "Noto Sans Devanagari", "Kohinoor Devanagari",
    "Noto Sans Bengali", "Bangla Sangam MN", "Noto Sans Myanmar", "Myanmar Text",
    "Myanmar Sangam MN", "Nirmala UI", "Noto Sans", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--blue-50);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, rgba(189, 38, 61, 0.11), transparent 27rem),
    linear-gradient(180deg, #f8fbff 0, #edf4fb 100%);
}

button,
select {
  font: inherit;
}

button,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid #4b9dea;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  padding: 0.75rem 1rem;
  color: var(--paper);
  background: var(--navy-950);
  border-radius: 0.5rem;
  transform: translateY(-160%);
  transition: transform 150ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(100% - 2rem, 86rem);
  min-height: 100vh;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.5rem 0 1.25rem;
  border-bottom: 1px solid rgba(21, 54, 93, 0.13);
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  width: 3.5rem;
  height: 3.5rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: linear-gradient(145deg, var(--navy-800), var(--navy-950));
  border-radius: 0.85rem 0.85rem 0.85rem 0.2rem;
  box-shadow: 0 8px 20px rgba(7, 24, 45, 0.18);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.brand-copy {
  min-width: 0;
}

.eyebrow,
.slide-kicker {
  margin: 0 0 0.2rem;
  color: var(--red-700);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.masthead h1 {
  margin: 0;
  color: var(--navy-950);
  font-size: clamp(1.2rem, 1.8vw, 1.65rem);
  line-height: 1.15;
}

.deck-subtitle {
  max-width: 45rem;
  margin: 0.25rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: end;
  gap: 0.75rem;
}

.language-control {
  display: grid;
  gap: 0.32rem;
}

.language-control label,
.slide-position label {
  color: var(--navy-800);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

select {
  min-height: 2.6rem;
  padding: 0.55rem 2.35rem 0.55rem 0.8rem;
  color: var(--navy-950);
  background-color: var(--paper);
  border: 1px solid #bdcada;
  border-radius: 0.62rem;
  cursor: pointer;
}

.language-control select {
  min-width: 10rem;
}

.icon-button,
.nav-button,
.secondary-button {
  min-height: 2.65rem;
  border: 0;
  border-radius: 0.65rem;
  cursor: pointer;
  font-weight: 750;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background-color 120ms ease;
}

.icon-button:active,
.nav-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 0.8rem;
  color: var(--navy-800);
  background: var(--blue-100);
  border: 1px solid #c9d9e9;
  text-decoration: none;
}

.icon-button:hover {
  background: #dbe9f7;
}

.icon-button svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

main {
  flex: 1;
  padding: clamp(1.25rem, 3vw, 2.5rem) 0 1.25rem;
}

.state-card {
  width: min(100%, 42rem);
  min-height: 10rem;
  margin: 7vh auto 0;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow-soft);
}

.state-card h2 {
  margin: 0 0 0.35rem;
  color: var(--navy-950);
  font-size: 1.15rem;
}

.state-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.loading-spinner {
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  border: 4px solid #cfdfef;
  border-top-color: var(--red-600);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.state-card--error {
  align-items: flex-start;
  border-top: 4px solid var(--red-600);
}

.state-card__symbol {
  width: 2.4rem;
  height: 2.4rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: var(--red-600);
  border-radius: 50%;
  font-size: 1.25rem;
  font-weight: 900;
}

.secondary-button {
  margin-top: 1rem;
  padding: 0.6rem 1rem;
  color: var(--navy-800);
  background: var(--blue-100);
  border: 1px solid #c4d5e6;
}

.viewer-panel {
  width: min(100%, 78rem);
  margin-inline: auto;
}

.slide-heading {
  min-height: 3.65rem;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.slide-heading h2 {
  margin: 0;
  color: var(--navy-950);
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  line-height: 1.25;
}

.translation-notice {
  max-width: 31rem;
  margin: 0;
  padding: 0.5rem 0.68rem;
  color: #772132;
  background: var(--red-100);
  border: 1px solid #efc4cb;
  border-radius: 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: right;
}

.translation-notice.is-loading {
  color: var(--navy-800);
  background: var(--blue-100);
  border-color: #c9dcec;
}

.stage-frame {
  position: relative;
  padding: clamp(0.35rem, 0.8vw, 0.65rem);
  overflow: hidden;
  background: var(--navy-950);
  border-radius: clamp(0.75rem, 1.5vw, 1.15rem);
  box-shadow: var(--shadow-soft);
}

.stage-frame::before {
  position: absolute;
  top: 0;
  right: 13%;
  width: 18%;
  height: 3px;
  content: "";
  background: var(--red-600);
}

.slide-stage {
  position: relative;
  width: 100%;
  aspect-ratio: var(--slide-aspect, 16 / 9);
  overflow: hidden;
  background: #dce6ef;
  border-radius: clamp(0.45rem, 1vw, 0.72rem);
  isolation: isolate;
}

.slide-stage img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  user-select: none;
}

.hotspot-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.hotspot {
  position: absolute;
  min-width: 0.45rem;
  min-height: 0.45rem;
  margin: 0;
  padding: 0;
  color: transparent;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.28rem;
  cursor: help;
}

.hotspot:focus-visible {
  z-index: 3;
  background: rgba(232, 241, 251, 0.18);
  border-color: rgba(255, 255, 255, 0.95);
  outline: 3px solid var(--red-600);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(7, 24, 45, 0.26);
}

.debug-hotspots .hotspot {
  color: var(--paper);
  background: rgba(189, 38, 61, 0.09);
  border: 2px dashed rgba(189, 38, 61, 0.82);
  cursor: crosshair;
}

.debug-hotspots .hotspot:hover,
.debug-hotspots .hotspot:focus {
  z-index: 4;
  background: rgba(189, 38, 61, 0.2);
  border-style: solid;
}

.debug-hotspots .hotspot:hover::after,
.debug-hotspots .hotspot:focus::after {
  position: absolute;
  top: 0;
  left: 0;
  max-width: min(18rem, 75vw);
  padding: 0.2rem 0.38rem;
  content: attr(data-debug-label);
  overflow: hidden;
  color: var(--paper);
  background: rgba(7, 24, 45, 0.96);
  border-radius: 0.22rem;
  font-size: clamp(0.55rem, 1vw, 0.72rem);
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.image-error {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-content: center;
  gap: 0.35rem;
  padding: 1.5rem;
  color: var(--navy-900);
  background: repeating-linear-gradient(
    -45deg,
    #edf3f9,
    #edf3f9 12px,
    #e5edf5 12px,
    #e5edf5 24px
  );
  text-align: center;
}

.image-error span {
  color: var(--muted);
  font-size: 0.9rem;
}

.slide-controls {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) minmax(15rem, 2fr) minmax(8rem, 1fr);
  align-items: center;
  gap: 0.9rem;
}

.nav-button {
  min-height: 3rem;
  padding: 0.7rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  color: var(--navy-800);
  background: var(--paper);
  border: 1px solid #c7d3e0;
  box-shadow: 0 3px 10px rgba(7, 24, 45, 0.06);
}

.nav-button:hover:not(:disabled) {
  border-color: #93abc2;
  box-shadow: 0 5px 14px rgba(7, 24, 45, 0.1);
}

.nav-button--primary {
  color: var(--paper);
  background: var(--navy-800);
  border-color: var(--navy-800);
}

.nav-button--primary:hover:not(:disabled) {
  background: var(--navy-700);
  border-color: var(--navy-700);
}

.nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.slide-position {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.28rem 0.75rem;
}

.slide-position label {
  grid-column: 1 / -1;
}

.slide-position select {
  width: 100%;
  min-width: 0;
}

.slide-position output {
  padding-bottom: 0.68rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.interaction-help {
  margin: 0.85rem auto 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}

.translation-list {
  margin-top: 0.9rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid #c7d5e3;
  border-radius: 0.72rem;
}

.translation-list summary {
  padding: 0.78rem 0.95rem;
  color: var(--navy-800);
  background: var(--blue-100);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.4;
}

.translation-list summary::marker {
  color: var(--red-600);
}

.translation-list[open] summary {
  border-bottom: 1px solid #c7d5e3;
}

.translation-list__items {
  padding: 0.85rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 25rem), 1fr));
  gap: 0.7rem;
}

.translation-list__item {
  min-width: 0;
  padding: 0.72rem 0.78rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.58rem;
}

.translation-list__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.translation-list__label,
.translation-list__original-label {
  color: var(--navy-700);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.translation-list__selected,
.translation-list__original,
.translation-list__empty {
  margin: 0.38rem 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.translation-list__selected {
  color: var(--navy-950);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.5;
}

.translation-list__original-label {
  margin-top: 0.65rem;
  padding-top: 0.58rem;
  display: block;
  border-top: 1px solid var(--line);
}

.translation-list__original,
.translation-list__empty {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.translation-list__empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.5rem;
  text-align: center;
}

.interaction-help > span {
  margin-right: 0.25rem;
  color: var(--red-600);
  font-weight: 900;
}

kbd {
  padding: 0.08rem 0.3rem;
  color: var(--navy-800);
  background: var(--paper);
  border: 1px solid #bdcada;
  border-bottom-width: 2px;
  border-radius: 0.25rem;
  font: 0.72rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.translation-tooltip {
  position: fixed;
  z-index: 999;
  width: max-content;
  max-width: min(28rem, calc(100vw - 1.5rem));
  max-height: min(60vh, 30rem);
  padding: 0.85rem 0.95rem 0.9rem;
  overflow: auto;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.985);
  border: 1px solid #b9c9da;
  border-top: 4px solid var(--red-600);
  border-radius: 0.72rem;
  box-shadow: var(--shadow-tooltip);
  overscroll-behavior: contain;
}

.tooltip-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.tooltip-language,
.tooltip-original__label {
  color: var(--navy-700);
  font-size: 0.69rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.fallback-badge {
  padding: 0.2rem 0.38rem;
  color: #84263a;
  background: var(--red-100);
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 800;
  white-space: nowrap;
}

.tooltip-text,
.tooltip-original p {
  margin: 0.42rem 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.tooltip-text {
  color: var(--navy-950);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.48;
}

.tooltip-original {
  margin-top: 0.7rem;
  padding-top: 0.62rem;
  border-top: 1px solid var(--line);
}

.tooltip-original p {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.42;
}

.site-footer {
  padding: 1rem 0 1.35rem;
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  color: #77869a;
  font-size: 0.72rem;
}

.noscript-message {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  z-index: 1200;
  padding: 1rem;
  color: var(--paper);
  background: var(--red-700);
  border-radius: 0.65rem;
  text-align: center;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 1rem, 86rem);
  }

  .masthead {
    align-items: flex-start;
    gap: 0.8rem;
    padding-top: 1rem;
  }

  .brand-mark {
    width: 3rem;
    height: 3rem;
  }

  .eyebrow {
    font-size: 0.62rem;
  }

  .deck-subtitle {
    max-width: 50vw;
  }

  .header-actions {
    align-items: stretch;
  }

  .language-control label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .language-control select {
    min-width: 8.5rem;
  }

  .header-actions,
  .language-control select,
  .icon-button {
    min-height: 2.65rem;
  }

  .slide-heading {
    min-height: 0;
    align-items: flex-start;
    flex-direction: column;
    gap: 0.45rem;
  }

  .translation-notice {
    max-width: 100%;
    text-align: left;
  }

  .slide-controls {
    grid-template-columns: 1fr 1fr;
  }

  .slide-position {
    grid-row: 1;
    grid-column: 1 / -1;
  }

  .nav-button {
    min-height: 2.8rem;
  }
}

@media (max-width: 520px) {
  .masthead {
    flex-direction: column;
  }

  .brand-lockup,
  .header-actions {
    width: 100%;
  }

  .header-actions {
    justify-content: space-between;
  }

  .language-control {
    flex: 1;
  }

  .language-control select {
    width: 100%;
  }

  .deck-subtitle {
    max-width: calc(100vw - 5.5rem);
  }

  main {
    padding-top: 1rem;
  }

  .stage-frame {
    padding: 0.25rem;
    border-radius: 0.68rem;
  }

  .slide-stage {
    border-radius: 0.48rem;
  }

  .slide-position {
    grid-template-columns: minmax(0, 1fr);
  }

  .slide-position output {
    padding: 0;
    text-align: center;
  }

  .interaction-help {
    padding-inline: 0.25rem;
  }

  .translation-tooltip {
    width: auto;
    min-width: min(18rem, calc(100vw - 1.5rem));
  }

  .site-footer {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .hotspot:focus-visible {
    border: 3px solid ButtonText;
  }

  .loading-spinner {
    border-top-color: Highlight;
  }
}
