/* 0–Z — vertical glyph ladder, 0 highest, Z lowest */

#panel-az.panel[hidden] {
  display: none !important;
}

#panel-az.panel.active {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 5rem);
  max-height: calc(100dvh - 5rem);
  overflow: hidden;
  padding: 0;
  margin: 0;
}

body.az-tab-active #panel-az.panel.active {
  min-height: 100dvh;
  max-height: 100dvh;
}

body.az-tab-active .site-footer,
body.az-tab-active .site-header .subtitle {
  display: none;
}

body.az-tab-active .site-header {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.az-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 55% 40% at 50% 0%, rgba(201, 162, 39, 0.12), transparent 58%),
    #0c1018;
  color: #1a2030;
}

.az-top {
  flex: 0 0 auto;
  padding: 0.7rem 1.1rem 0.55rem;
  color: #eef3ee;
}

.az-top h2 {
  margin: 0 0 0.2rem;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
}

.az-hint {
  margin: 0;
  max-width: 42rem;
  font-size: 0.88rem;
  line-height: 1.4;
  color: rgba(238, 243, 238, 0.72);
}

.az-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16.5rem;
  gap: 0;
  padding: 0 0.85rem 0.85rem;
}

.az-plate {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7.6rem;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "fold ladder"
    "prompt prompt";
  background: #fbfcfe;
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  overflow: hidden;
}

.az-fold-wrap {
  grid-area: fold;
  position: relative;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid rgba(154, 167, 184, 0.45);
}

.az-fold {
  display: block;
  width: 100%;
  height: 100%;
}

.az-eq-toggle {
  position: absolute;
  left: 0.7rem;
  top: 0.5rem;
  z-index: 6;
  margin: 0;
  padding: 0.22rem 0.5rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #1a2030;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(26, 32, 48, 0.28);
  border-radius: 5px;
  cursor: pointer;
  pointer-events: auto;
}

.az-equations {
  position: absolute;
  left: 0.7rem;
  top: 2.15rem;
  z-index: 6;
  max-width: 46%;
  margin: 0;
  padding: 0.35rem 0.45rem;
  font-family: "Times New Roman", Times, serif;
  font-style: italic;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #1d4ed8;
  background: rgba(251, 252, 254, 0.82);
  pointer-events: none;
}

.az-equations.is-hidden {
  display: none !important;
}

.az-preview-drawer {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  bottom: 1.45rem;
  z-index: 5;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  pointer-events: auto;
}

.az-preview-rail {
  flex: 0 0 3.35rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.az-preview-handle {
  flex: 0 0 1.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(26, 32, 48, 0.28);
  border-right: 0;
  border-radius: 6px 0 0 0;
  background: rgba(255, 255, 255, 0.92);
  color: #1a2030;
  cursor: ew-resize;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  user-select: none;
  touch-action: none;
}

.az-space-tile {
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 0 0 0 6px;
  border-right: 0;
}

.az-space-tile canvas,
.az-space-tile img {
  height: auto;
  flex: 1 1 auto;
  min-height: 4rem;
}

.az-preview-handle:hover {
  background: #fff;
}

.az-previews {
  position: relative;
  width: calc(var(--az-cols, 6) * 3.65rem);
  max-width: 46vw;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(var(--az-cols, 6), minmax(0, 1fr));
  grid-auto-rows: minmax(3.4rem, 1fr);
  gap: 0.22rem;
  overflow: auto;
  padding: 0.12rem;
  background: rgba(251, 252, 254, 0.72);
  border: 1px solid rgba(26, 32, 48, 0.2);
  border-radius: 0 6px 6px 0;
}

.az-preview-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(26, 32, 48, 0.28);
  border-radius: 5px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  padding: 0;
  font: inherit;
  color: inherit;
}

.az-preview-tile.is-active {
  border-color: #1d4ed8;
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.28);
}

.az-lightbox {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(12, 16, 24, 0.55);
}

.az-lightbox[hidden] {
  display: none !important;
}

.az-lightbox-card {
  width: min(42rem, 92%);
  max-height: 92%;
  overflow: auto;
  padding: 0.85rem 0.95rem 1rem;
  background: #fbfcfe;
  border: 1px solid rgba(26, 32, 48, 0.28);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.az-lightbox-title {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  font-weight: 800;
}

.az-lightbox-stage {
  min-height: 16rem;
  background: #fff;
  border: 1px solid rgba(26, 32, 48, 0.16);
  border-radius: 8px;
  overflow: hidden;
}

.az-lightbox-stage img,
.az-lightbox-stage canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 58vh;
  object-fit: contain;
  background: #f7f9fc;
}

.az-lightbox-meta {
  margin: 0.55rem 0 0.7rem;
  font-size: 0.88rem;
  line-height: 1.4;
  color: rgba(26, 32, 48, 0.78);
}

.az-lightbox-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.az-preview-tile img {
  display: block;
  width: 100%;
  height: 3.35rem;
  object-fit: cover;
  background: #f7f9fc;
}

.az-preview-tile canvas.az-desmos {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 3.35rem;
  object-fit: cover;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.82;
}

.az-preview-g {
  padding: 0.12rem 0.25rem 0.18rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  background: rgba(255, 255, 255, 0.92);
}

.az-fold-count {
  position: absolute;
  left: 0.55rem;
  right: auto;
  bottom: 0.4rem;
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(26, 32, 48, 0.45);
  pointer-events: none;
}

.az-column {
  grid-area: ladder;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  min-height: 0;
  overflow: auto;
  padding: 0.55rem 0.15rem;
  margin: 0;
  width: 100%;
  background: linear-gradient(90deg, rgba(232, 238, 246, 0.65), #fbfcfe 18%);
}

.az-prompt-bar {
  grid-area: prompt;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.65rem;
  border-top: 1px solid rgba(154, 167, 184, 0.55);
  background: #f4f7fb;
}

.az-prompt-bar label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(26, 32, 48, 0.55);
}

.az-prompt-bar input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.95rem;
  color: #111;
  background: #fff;
  border: 1px solid rgba(29, 78, 216, 0.28);
  border-radius: 6px;
}

.az-prompt-bar input:focus {
  outline: 2px solid rgba(29, 78, 216, 0.35);
}

.az-prompt-bar .az-btn {
  margin-top: 0;
  color: #1a2030;
}

.az-rung {
  appearance: none;
  border: 0;
  background: transparent;
  margin: 0;
  padding: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 3.2rem 1fr 3.2rem;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: #111;
  font-family: "Times New Roman", Times, serif;
  line-height: 1;
}

.az-rung:hover .az-glyph,
.az-rung:focus-visible .az-glyph {
  color: #8a6a12;
}

.az-rung.is-selected .az-glyph {
  color: #1d4ed8;
  text-shadow: 0 0 0.4px #1d4ed8;
}

.az-y {
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: rgba(17, 17, 17, 0.38);
  text-align: right;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.az-glyph {
  justify-self: center;
  font-size: clamp(1.05rem, 2.1vh, 1.55rem);
  font-weight: 700;
}

.az-idx {
  font-size: 0.62rem;
  color: rgba(17, 17, 17, 0.32);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.az-side {
  min-height: 0;
  overflow: auto;
  padding: 0.85rem 0.9rem 0.85rem 1rem;
  color: #eef3ee;
}

.az-card {
  margin: 0 0 0.9rem;
  padding: 0.75rem 0.8rem;
  background: rgba(16, 22, 32, 0.72);
  border: 1px solid rgba(201, 162, 39, 0.22);
  border-radius: 8px;
}

.az-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(201, 162, 39, 0.92);
}

.az-readout {
  margin: 0 0 0.35rem;
  font-size: 2.4rem;
  font-family: "Times New Roman", Times, serif;
  line-height: 1;
}

.az-meta {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: rgba(238, 243, 238, 0.78);
}

.az-btn {
  margin-top: 0.55rem;
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: #eef3ee;
  background: rgba(201, 162, 39, 0.16);
  border: 1px solid rgba(201, 162, 39, 0.45);
  border-radius: 6px;
  cursor: pointer;
}

.az-btn:hover {
  background: rgba(201, 162, 39, 0.28);
}

@media (max-width: 720px) {
  .az-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(16rem, 1fr) auto;
  }

  .az-plate {
    grid-template-columns: minmax(0, 1fr) 5.6rem;
  }

  .az-side {
    padding-left: 0.15rem;
  }
}


.az-letter-grid-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.28rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(26, 32, 48, 0.78);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(26, 32, 48, 0.22);
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.az-letter-grid-toggle input {
  width: 0.95rem;
  height: 0.95rem;
  margin: 0;
  accent-color: #1d4ed8;
  cursor: pointer;
}

.az-letter-grid-toggle:hover {
  border-color: rgba(29, 78, 216, 0.45);
  color: #1a2030;
}

.az-shell.az-letter-grid-off .az-preview-drawer {
  display: none !important;
}

.az-shell.az-letter-grid-off .az-fold-wrap {
  /* standalone: give the still the full plate */
}

@media (max-width: 720px) {
  .az-letter-grid-toggle span {
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
