/* Brew — A–Z letter-weighted spell alphabet */

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

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

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

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

.br-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse 110% 75% at 50% 0%, #0e1418 0%, #040608 50%, #000 100%);
}

.br-top {
  flex: 0 0 auto;
  padding: 0.5rem 0.75rem 0.35rem;
  border-bottom: 1px solid rgba(90, 180, 160, 0.2);
}

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

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

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

.br-compose {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
}

.br-input {
  width: 100%;
  min-height: 5.5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(90, 180, 160, 0.25);
  border-radius: calc(var(--radius) + 2px);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  resize: vertical;
}

.br-input:focus {
  outline: none;
  border-color: rgba(120, 220, 190, 0.55);
  box-shadow: 0 0 0 2px rgba(90, 180, 160, 0.12);
}

.br-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.72rem;
}

.br-metric {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.4rem;
}

.br-metric-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.62rem;
}

.br-metric-val {
  font-weight: 600;
  color: #8ed4c0;
}

.br-metric-hint {
  color: var(--text-muted);
  font-size: 0.65rem;
}

.br-section-label {
  margin: 0 0 0.25rem;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.br-weight-bars {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 2px 3px;
}

.br-weight-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
}

.br-weight-letter {
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
}

.br-weight-bar-wrap {
  width: 100%;
  height: 2.2rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 2px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.br-weight-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  transition: height 0.2s ease, background 0.2s ease;
}

.br-weight-pct {
  font-size: 0.5rem;
  color: var(--text-muted);
  line-height: 1;
}

.br-weight-cell.br-hot .br-weight-letter { color: #b8f0dc; }

.br-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-height: 4.5rem;
  overflow-y: auto;
  padding: 0.35rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(90, 180, 160, 0.12);
  border-radius: var(--radius);
}

.br-seq-empty {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.br-seq-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.15rem;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.br-linear-panel {
  padding: 0.4rem;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(90, 180, 160, 0.2);
  border-radius: var(--radius);
}

.br-linear-panel[hidden] { display: none !important; }

body.br-linear-active .br-sequence-panel .br-section-label::after {
  content: " · jumps across A–Z";
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(142, 212, 192, 0.55);
}

.br-linear-row {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: 0.35rem;
  align-items: start;
  margin-bottom: 0.35rem;
}

.br-linear-label {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding-top: 0.2rem;
}

.br-organized-speech {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.br-speech-word {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.12rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid rgba(90, 180, 160, 0.2);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.72rem;
  color: var(--text);
  cursor: default;
}

.br-speech-word-text { line-height: 1.2; }

.br-speech-span {
  display: flex;
  height: 0.28rem;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  position: relative;
}

.br-speech-span-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 2px;
  opacity: 0.85;
}

.br-linear-track {
  display: grid;
  grid-template-columns: repeat(26, minmax(1.1rem, 1fr));
  gap: 1px;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.br-linear-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
  padding: 0.1rem 0;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.03);
}

.br-linear-slot.br-linear-hit {
  background: rgba(90, 180, 160, 0.12);
  box-shadow: inset 0 0 0 1px rgba(120, 220, 190, 0.25);
}

.br-linear-glyph {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
}

.br-linear-bar-wrap {
  width: 100%;
  height: 2rem;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

.br-linear-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  transition: height 0.2s ease;
}

.br-linear-ord {
  font-size: 0.45rem;
  color: rgba(142, 212, 192, 0.55);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.br-linear-ticks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1px;
  min-height: 0.35rem;
}

.br-linear-tick {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  opacity: 0.9;
}

.br-linear-natural {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  max-height: 5rem;
  overflow-y: auto;
  padding: 0.25rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius);
}

.br-linear-chip-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.br-linear-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: 1.35rem;
}

.br-linear-chip-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.br-linear-chip-ord {
  font-size: 0.48rem;
  color: rgba(142, 212, 192, 0.7);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.br-linear-jump-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  padding: 0 0.05rem;
  font-size: 0.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  line-height: 1;
}

.br-linear-jump-arrow.br-jump-wide { color: #e8a090; }
.br-linear-jump-arrow.br-jump-mid { color: #c9a227; }
.br-linear-jump-arrow.br-jump-near { color: #8ed4c0; }

.br-linear-jump {
  margin: 0.15rem 0 0;
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.br-btn.br-toggle[aria-pressed="true"] {
  border-color: #6ec4ae;
  color: #b8f0dc;
  background: rgba(90, 180, 160, 0.14);
  box-shadow: inset 0 0 0 1px rgba(120, 220, 190, 0.2);
}

.br-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.br-btn {
  min-height: 36px;
  padding: 0.35rem 0.7rem;
  font: inherit;
  font-size: 0.78rem;
  border: 1px solid rgba(90, 180, 160, 0.3);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.br-btn.accent {
  border-color: #6ec4ae;
  color: #8ed4c0;
}

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

.br-status {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.br-status.ok { color: #8ec9a0; }
.br-status.error { color: #e8a090; }
.br-status.pending { color: #8ed4c0; }

.br-preview-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow: hidden;
}

.br-stage {
  flex: 1 1 auto;
  min-height: 8rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050608;
  border: 2px dashed rgba(90, 180, 160, 0.28);
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
}

.br-stage.br-generating .br-preview { opacity: 0.5; filter: blur(2px); }

.br-stage-empty {
  margin: 0;
  padding: 1rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.br-preview {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.br-culpability {
  flex: 0 0 auto;
  max-height: 6rem;
  overflow-y: auto;
}

.br-culp-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.br-culp-row {
  display: grid;
  grid-template-columns: 1.5rem 2.5rem 1fr 2.5rem;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
}

.br-culp-letter {
  font-weight: 700;
  color: #8ed4c0;
}

.br-culp-spell {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.br-culp-bar-wrap {
  height: 0.45rem;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.br-culp-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.2s ease;
}

.br-culp-pct {
  text-align: right;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.br-alpha-wrap {
  flex: 0 0 auto;
  padding: 0.35rem 0.65rem 0.25rem;
  border-top: 1px solid rgba(90, 180, 160, 0.15);
}

.br-inventory-case {
  border: 1px solid rgba(90, 180, 160, 0.22);
  border-radius: calc(var(--radius) + 2px);
  background: linear-gradient(180deg, rgba(12, 18, 20, 0.95) 0%, rgba(4, 6, 8, 0.98) 100%);
  box-shadow: inset 0 1px 0 rgba(120, 220, 190, 0.08), 0 4px 16px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.br-inventory-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(90, 180, 160, 0.18);
  background: rgba(0, 0, 0, 0.35);
}

.br-inventory-tab {
  flex: 1 1 0;
  min-height: 2rem;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: none;
  border-right: 1px solid rgba(90, 180, 160, 0.12);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.br-inventory-tab:last-child { border-right: none; }

.br-inventory-tab:hover {
  color: #8ed4c0;
  background: rgba(90, 180, 160, 0.06);
}

.br-inventory-tab.active {
  color: #b8f0dc;
  background: rgba(90, 180, 160, 0.14);
  box-shadow: inset 0 -2px 0 #6ec4ae;
}

.br-inventory-panels {
  max-height: 8.5rem;
  overflow-y: auto;
}

.br-inventory-panel {
  display: none;
  padding: 0.4rem;
}

.br-inventory-panel.active { display: block; }

.br-alphabet {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.3rem;
}

.br-letter-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.2rem;
  border: 1px solid rgba(90, 180, 160, 0.18);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.br-letter-slot:hover,
.br-letter-slot.br-selected {
  border-color: rgba(120, 220, 190, 0.55);
  box-shadow: 0 0 12px rgba(90, 180, 160, 0.15);
}

.br-letter-slot.br-drop-active {
  border-color: #8ed4c0;
  box-shadow: inset 0 0 20px rgba(90, 180, 160, 0.2);
}

.br-letter-slot.br-weighted {
  border-color: rgba(120, 220, 190, 0.4);
}

.br-letter-glyph {
  font-size: 0.75rem;
  font-weight: 700;
  color: #8ed4c0;
  line-height: 1;
}

.br-letter-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 2px;
  background: #111;
}

.br-letter-num {
  font-size: 0.52rem;
  color: var(--text-muted);
  line-height: 1;
}

.br-letter-inclusion {
  font-size: 0.48rem;
  color: #6a9a8a;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.br-letter-slot.br-equipped {
  border-color: rgba(90, 180, 160, 0.35);
}

.br-letter-slot .br-letter-floor {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.45rem;
  color: rgba(142, 212, 192, 0.65);
  line-height: 1;
  pointer-events: none;
}

.br-letter-slot input.br-letter-replace {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.br-tray {
  flex: 0 0 auto;
  border-top: 1px solid rgba(90, 180, 160, 0.12);
}

#panel-brew .st-spell.br-spell { border-color: rgba(90, 180, 160, 0.25); }

@media (max-width: 720px) {
  .br-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .br-alphabet { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .br-weight-bars { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .br-inventory-tab { font-size: 0.62rem; padding: 0.3rem 0.25rem; }
}