/* Gab — live letter finishers */

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

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

body.gb-tab-active #panel-gab.panel.active {
  min-height: calc(100dvh - 5.5rem);
  max-height: calc(100dvh - 5.5rem);
}

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

.gb-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse 120% 80% at 50% 100%, #14101a 0%, #06060c 55%, #020208 100%);
}

.gb-top {
  flex: 0 0 auto;
  padding: 0.55rem 0.85rem 0.35rem;
  border-bottom: 1px solid rgba(201, 162, 39, 0.15);
}

.gb-top h2 {
  margin: 0 0 0.15rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--text);
}

.gb-hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.gb-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.65rem;
  padding: 0.55rem 0.65rem 0;
  overflow: hidden;
}

.gb-compose {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  position: relative;
}

.gb-compose::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(201, 162, 39, 0.03) 2px,
      rgba(201, 162, 39, 0.03) 3px
    );
  pointer-events: none;
  opacity: 0.5;
}

.gb-cast-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.gb-predictions-above-wrap {
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
}

.gb-last-word {
  margin: 0 0 0.35rem;
  padding: 0 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  letter-spacing: 0.02em;
}

.gb-stanza-anchor-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}

.gb-stanza-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.gb-stanza-anchor {
  font-family: var(--font-display), "Georgia", serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(201, 162, 39, 0.35);
}

.gb-stanza-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
}

.gb-stanza-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
  min-height: 2.1rem;
  padding: 0.3rem 0.35rem;
  border: 1px solid rgba(201, 162, 39, 0.14);
  border-radius: var(--radius);
  background: rgba(6, 8, 14, 0.85);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}

.gb-stanza-cell:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(201, 162, 39, 0.22);
  transform: translateY(-1px);
}

.gb-stanza-cell:disabled {
  cursor: default;
  opacity: 0.45;
}

.gb-stanza-cell.gb-stanza-idle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.gb-stanza-slot-1 { border-color: rgba(201, 162, 39, 0.42); }
.gb-stanza-slot-2 { border-color: rgba(201, 162, 39, 0.34); }
.gb-stanza-slot-3 { border-color: rgba(180, 200, 255, 0.28); }
.gb-stanza-slot-4 { border-color: rgba(160, 190, 255, 0.24); }
.gb-stanza-slot-5 { border-color: rgba(140, 180, 255, 0.22); }
.gb-stanza-slot-6 { border-color: rgba(200, 140, 255, 0.22); }
.gb-stanza-slot-7 { border-color: rgba(210, 130, 255, 0.26); }
.gb-stanza-slot-8 { border-color: rgba(220, 120, 240, 0.28); }
.gb-stanza-slot-9 { border-color: rgba(255, 140, 180, 0.3); }
.gb-stanza-slot-10 { border-color: rgba(255, 120, 160, 0.34); }

.gb-stanza-word {
  font-family: var(--font-display), "Georgia", serif;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  color: #e8d8a0;
}

.gb-stanza-slot-6 .gb-stanza-word,
.gb-stanza-slot-7 .gb-stanza-word,
.gb-stanza-slot-8 .gb-stanza-word,
.gb-stanza-slot-9 .gb-stanza-word,
.gb-stanza-slot-10 .gb-stanza-word {
  color: #c8e8ff;
}

.gb-stanza-punct {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  margin-left: 0.02rem;
}

.gb-stanza-axis {
  margin: 0.35rem 0 0;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.04em;
}

.gb-predictions-row {
  flex: 0 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
  position: relative;
  z-index: 1;
  overflow-x: auto;
}

.gb-predictions-above {
  flex: 1 1 auto;
  padding-bottom: 0.35rem;
  align-items: end;
}

.gb-predictions-below {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  padding-bottom: 0.25rem;
  border-top: 1px solid rgba(120, 200, 255, 0.18);
  align-items: start;
}

.gb-pred-lane-below {
  border-color: rgba(120, 200, 255, 0.18) !important;
  background: rgba(6, 10, 18, 0.65);
}

.gb-pred-label-below {
  color: #8ec9ff !important;
}

.gb-pred-tiers-below {
  justify-content: flex-start;
}

.gb-pred-lane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.35rem 0.2rem 0.25rem;
  border: 1px solid rgba(201, 162, 39, 0.12);
  border-radius: var(--radius);
  background: rgba(8, 10, 18, 0.55);
}

.gb-pred-lane:nth-child(1) { border-color: rgba(201, 162, 39, 0.28); }
.gb-pred-lane:nth-child(2) { border-color: rgba(160, 200, 255, 0.22); }
.gb-pred-lane:nth-child(3) { border-color: rgba(200, 140, 255, 0.22); }
.gb-pred-lane:nth-child(4) { border-color: rgba(255, 180, 120, 0.22); }
.gb-pred-lane:nth-child(5) { border-color: rgba(120, 255, 200, 0.22); }

.gb-pred-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  line-height: 1;
}

.gb-pred-hint {
  font-size: 0.58rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.25;
  min-height: 1.45rem;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  word-break: break-word;
}

.gb-pred-hint.gb-hint-tap {
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
  padding: 0;
  width: 100%;
}

.gb-pred-hint.gb-hint-tap:hover {
  color: var(--accent);
}

.gb-pred-hint.gb-hint-live {
  color: #e8d8a0;
  font-weight: 600;
  -webkit-line-clamp: 3;
}

.gb-pred-lane-below .gb-pred-hint.gb-hint-live {
  color: #a8d8ff;
}

.gb-pred-tiers {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.12rem;
}

.gb-tier {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  min-height: 1.35rem;
  perspective: 600px;
  flex-wrap: nowrap;
}

.gb-word-gap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.5rem;
  min-width: 0.5rem;
  height: 1.15rem;
  margin: 0 0.12rem;
  flex-shrink: 0;
  position: relative;
  animation: gb-gap-pulse 1.4s ease-in-out infinite;
}

.gb-word-gap i {
  display: block;
  width: 3px;
  height: 72%;
  border-radius: 2px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(201, 162, 39, 0.95) 20%,
    rgba(255, 248, 220, 1) 50%,
    rgba(201, 162, 39, 0.95) 80%,
    transparent 100%
  );
  box-shadow:
    0 0 10px rgba(201, 162, 39, 0.85),
    0 0 18px rgba(120, 200, 255, 0.35);
}

.gb-word-gap::after {
  content: "";
  position: absolute;
  inset: 0 -0.15rem;
  border-left: 1px dashed rgba(201, 162, 39, 0.35);
  border-right: 1px dashed rgba(201, 162, 39, 0.35);
  pointer-events: none;
}

.gb-word-gap-start i {
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(120, 200, 255, 0.9) 35%,
    rgba(255, 248, 220, 1) 50%,
    rgba(120, 200, 255, 0.9) 65%,
    transparent 100%
  );
}

@keyframes gb-gap-pulse {
  0%, 100% { transform: scaleX(1); opacity: 0.85; }
  50% { transform: scaleX(1.25); opacity: 1; }
}

.gb-tier-lane.gb-tier-1 { min-height: 1.2rem; }
.gb-tier-lane.gb-tier-2 { min-height: 1.35rem; }
.gb-tier-lane.gb-tier-3 { min-height: 1.5rem; }
.gb-tier-lane.gb-tier-4 { min-height: 1.65rem; }
.gb-tier-lane.gb-tier-5 { min-height: 1.85rem; }

.gb-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display), "Georgia", serif;
  font-weight: 600;
  line-height: 1;
  text-transform: lowercase;
  border-radius: 4px;
  position: relative;
  background: linear-gradient(
    145deg,
    #3a3020 0%,
    #c9a227 18%,
    #fff8e8 42%,
    #8a6f1e 58%,
    #2a2218 82%,
    #c9a227 100%
  );
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 6px rgba(201, 162, 39, 0.55))
    drop-shadow(0 2px 0 rgba(0, 0, 0, 0.85));
  animation: gb-shimmer 2.4s ease-in-out infinite;
}

.gb-tier-lane.gb-tier-1 .gb-letter {
  font-size: 0.82rem;
  width: 0.95rem;
  height: 1.05rem;
}

.gb-tier-lane.gb-tier-2 .gb-letter {
  font-size: 0.9rem;
  width: 1rem;
  height: 1.1rem;
}

.gb-tier-lane.gb-tier-3 .gb-letter {
  font-size: 0.98rem;
  width: 1.08rem;
  height: 1.18rem;
}

.gb-tier-lane.gb-tier-4 .gb-letter {
  font-size: 1.05rem;
  width: 1.15rem;
  height: 1.25rem;
}

.gb-tier-lane.gb-tier-5 .gb-letter {
  font-size: 1.12rem;
  width: 1.22rem;
  height: 1.32rem;
  filter: drop-shadow(0 0 8px rgba(201, 162, 39, 0.65))
    drop-shadow(0 0 14px rgba(120, 200, 255, 0.2))
    drop-shadow(0 2px 0 rgba(0, 0, 0, 0.85));
}

.gb-tier.gb-idle .gb-letter {
  animation: gb-idle-flash 0.12s steps(1) infinite, gb-shimmer 1.8s ease-in-out infinite;
  color: var(--accent);
  -webkit-background-clip: border-box;
  background-clip: border-box;
  background: transparent;
  filter: drop-shadow(0 0 8px rgba(201, 162, 39, 0.4));
}

.gb-tier.gb-live .gb-letter {
  animation: gb-live-pulse 1.6s ease-in-out infinite, gb-shimmer 2.2s ease-in-out infinite;
}

.gb-tier.gb-live .gb-letter.gb-letter-predict {
  color: #a8e8ff;
  filter: drop-shadow(0 0 12px rgba(100, 200, 255, 0.65))
    drop-shadow(0 0 4px rgba(201, 162, 39, 0.5));
}

.gb-tier.gb-live .gb-letter.gb-letter-bridge {
  color: #ffd89a;
  filter: drop-shadow(0 0 14px rgba(255, 200, 100, 0.7));
}

@keyframes gb-idle-flash {
  0%, 49% { opacity: 1; transform: scale(1) rotateY(0deg); }
  50%, 100% { opacity: 0.15; transform: scale(0.92) rotateY(12deg); }
}

@keyframes gb-live-pulse {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.04); }
}

@keyframes gb-shimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.gb-input-wrap {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
}

.gb-input-wrap::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(135deg, rgba(201, 162, 39, 0.45), rgba(80, 160, 255, 0.2), rgba(201, 162, 39, 0.35));
  opacity: 0.55;
  z-index: -1;
  animation: gb-border-glow 3s ease-in-out infinite;
}

@keyframes gb-border-glow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.85; }
}

.gb-input {
  display: block;
  width: 100%;
  min-height: 5.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: calc(var(--radius) + 2px);
  background: rgba(6, 8, 14, 0.92);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5), 0 8px 32px rgba(0, 0, 0, 0.35);
}

.gb-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow:
    inset 0 0 40px rgba(201, 162, 39, 0.06),
    0 0 24px rgba(201, 162, 39, 0.2);
}

.gb-count {
  margin: 0.35rem 0 0;
  text-align: right;
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.gb-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
  position: relative;
  z-index: 2;
}

.gb-btn {
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.gb-btn:hover { border-color: var(--accent); color: var(--accent); }

.gb-btn.accent {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.gb-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.gb-status {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  position: relative;
  z-index: 2;
}

.gb-status.ok { color: #8ec9a0; }
.gb-status.error { color: #e8a090; }
.gb-status.pending { color: var(--accent); }

.gb-cast-stage {
  flex: 0 1 auto;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 100%;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #080a10;
  border: 2px dashed var(--border);
  border-radius: calc(var(--radius) + 2px);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.gb-cast-stage.gb-drop-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 60px rgba(201, 162, 39, 0.14);
}

.gb-cast-stage.gb-generating .gb-cast-preview {
  opacity: 0.45;
  filter: blur(1px);
}

.gb-cast-empty {
  margin: 0;
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.gb-cast-empty[hidden] { display: none !important; }

.gb-cast-preview {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.gb-cast-preview[hidden] { display: none !important; }

.gb-applied {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-height: 1.4rem;
}

.gb-applied-empty {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.gb-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: rgba(201, 162, 39, 0.18);
  font-size: 0.65rem;
  color: #e8d8a0;
}

.gb-chip-rm {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
}

.gb-tray { flex: 0 0 auto; }

#panel-gab .gb-spell { cursor: grab; touch-action: none; }

@media (max-width: 780px) {
  .gb-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .gb-cast-col { min-height: 12rem; }
  .gb-predictions-row {
    grid-template-columns: repeat(5, minmax(4.2rem, 1fr));
  }
}