.b64-page {
  --b64-frame-width: 1160px;
  --b64-accent: #22c55e;
  --b64-accent-hi: #4ade80;
  --b64-border: rgba(34, 197, 94, 0.22);
  --b64-border-soft: rgba(34, 197, 94, 0.12);
  --b64-surface: rgba(10, 17, 10, 0.98);
  --b64-surface-output: rgba(5, 10, 6, 0.97);
  --b64-workbench-bg: linear-gradient(180deg, rgba(7, 15, 8, 0.99), rgba(4, 9, 5, 0.99));
  --b64-grid-line: rgba(34, 197, 94, 0.055);
  --b64-success: #4ade80;
  --b64-warning: #fbbf24;
  --b64-error: #f87171;
  overflow-x: clip;
}

/* ─── FRAME ─── */
.b64-page .tool-frame {
  width: 100%;
  max-width: var(--b64-frame-width);
  margin-inline: auto;
}

.b64-page .tool-header-block {
  max-width: none;
  margin-inline: 0;
  text-align: left;
  padding-top: 8px;
  padding-bottom: 14px;
}

.b64-page .page-title {
  max-width: none;
  font-size: clamp(2.24rem, 2.7vw, 2.74rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.b64-page .page-subtitle {
  max-width: 34rem;
  margin-inline: 0;
  font-size: 1rem;
  line-height: 1.5;
  text-wrap: balance;
}

.b64-meta-line {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: rgba(34, 197, 94, 0.7);
  letter-spacing: 0.01em;
}

/* ─── WORKBENCH SHELL ─── */
.b64-workbench {
  position: relative;
  padding: 10px;
  border: 1px solid var(--b64-border);
  border-radius: 30px;
  background: var(--b64-workbench-bg);
  box-shadow: 0 28px 76px rgba(0, 8, 2, 0.52);
  overflow: hidden;
}

.b64-workbench::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(var(--b64-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--b64-grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, rgba(255, 255, 255, 0.38), transparent 68%);
  pointer-events: none;
}

/* ─── DECKBAR ─── */
.b64-deckbar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 0 2px 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(34, 197, 94, 0.12);
}

.b64-deckbar__eyebrow {
  margin: 0 0 4px;
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--b64-accent);
}

.b64-deckbar__title {
  margin: 0;
  font-size: 1rem;
  color: rgba(220, 255, 230, 0.92);
}

.b64-deckbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── CHIPS / PILLS ─── */
.b64-chip,
.b64-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid var(--b64-border-soft);
  border-radius: 999px;
  white-space: nowrap;
  background: rgba(5, 12, 7, 0.82);
  color: var(--color-text-muted);
  font-size: 0.79rem;
}

.b64-chip { color: var(--b64-accent-hi); }

.b64-chip--trust {
  color: var(--b64-success);
  border-color: rgba(74, 222, 128, 0.22);
}

.b64-pill--quiet {
  color: rgba(140, 180, 148, 0.5);
  border-color: rgba(34, 197, 94, 0.08);
}

/* ─── LANG TOGGLE ─── */
.b64-lang-toggle {
  display: flex;
  border: 1px solid var(--b64-border-soft);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(5, 12, 7, 0.82);
}

.b64-lang-btn {
  appearance: none;
  border: none;
  padding: 6px 14px;
  background: transparent;
  color: rgba(140, 180, 148, 0.65);
  font: 500 0.79rem/1 inherit;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.b64-lang-btn--active {
  background: rgba(34, 197, 94, 0.16);
  color: var(--b64-accent-hi);
}

/* ─── WORKBENCH LAYOUT ─── */
.b64-workbench__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr);
  gap: 6px;
  align-items: stretch;
}

/* ─── PANEL ─── */
.b64-panel {
  min-width: 0;
  padding: 14px;
  border-radius: 26px;
  border: 1px solid rgba(34, 197, 94, 0.14);
  background: var(--b64-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.b64-panel--output { background: var(--b64-surface-output); }

.b64-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.b64-panel__eyebrow {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--b64-accent);
}

.b64-panel__hint {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.99rem;
  line-height: 1.6;
  max-width: 28ch;
}

.b64-panel__meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* ─── TEXTAREA ─── */
.b64-textarea {
  width: 100%;
  min-height: 160px;
  padding: 15px 16px;
  border-radius: 20px;
  border: 1px solid rgba(34, 197, 94, 0.18);
  background: rgba(8, 15, 10, 0.92);
  color: var(--color-text);
  resize: vertical;
  font: 500 1.04rem/1.65 "IBM Plex Sans", "Segoe UI", sans-serif;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.b64-textarea:focus {
  outline: none;
  border-color: rgba(34, 197, 94, 0.42);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(34, 197, 94, 0.1);
}

/* Output — terminal glow + scanline texture */
.b64-textarea--output {
  min-height: 190px;
  font-family: "IBM Plex Mono", "Courier New", ui-monospace, monospace;
  font-size: 0.97rem;
  color: var(--b64-accent-hi);
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(0, 0, 0, 0.055) 3px,
      rgba(0, 0, 0, 0.055) 4px
    ),
    rgba(4, 9, 5, 0.96);
  border-color: rgba(34, 197, 94, 0.14);
  cursor: default;
}

.b64-textarea--output:focus {
  border-color: rgba(34, 197, 94, 0.28);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.07);
}

/* ─── ACTIONS ─── */
.b64-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Override shared .button sizing so inline tool buttons don't balloon */
.b64-actions .button {
  min-height: 0;
  padding-block: 8px;
}

/* Utility buttons (Example, Clear) — subdued */
.b64-util-btn {
  opacity: 0.6;
  font-size: 0.85em;
  padding-inline: 12px;
}
.b64-util-btn:hover { opacity: 0.9; }

/* Direction buttons (Encode, Decode) — prominent */
.b64-dir-btn {
  min-width: 88px;
  padding-inline: 20px;
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--b64-accent-hi);
}

.b64-dir-btn--active {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.6);
  color: #fff;
}

/* ─── FEEDBACK ─── */
.b64-feedback-slot { min-height: 26px; }

.b64-inline-feedback {
  margin: 0;
  font-size: 0.97rem;
  color: var(--color-text-muted);
}

.b64-inline-feedback[data-state="success"] { color: var(--b64-success); }
.b64-inline-feedback[data-state="warning"]  { color: var(--b64-warning); }
.b64-inline-feedback[data-state="error"]    { color: var(--b64-error); }

/* ─── OUTPUT META ─── */
.b64-output-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── COPY BUTTON ─── */
.b64-copy-btn {
  align-self: flex-start;
  min-width: 84px;
}

/* ─── BRIDGE ─── */
.b64-bridge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 20px;
}

.b64-bridge__line {
  flex: 1;
  width: 1px;
  min-height: 50px;
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.08), rgba(34, 197, 94, 0.35), rgba(34, 197, 94, 0.08));
}

.b64-bridge__copy {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(34, 197, 94, 0.3);
  margin: 0;
}

/* ─── SWAP BUTTON ─── */
.b64-swap-btn {
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--b64-border);
  background: rgba(8, 17, 10, 0.9);
  color: var(--b64-accent);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  flex-shrink: 0;
}

.b64-swap-btn:hover {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.44);
}

.b64-swap-btn:active { transform: scale(0.92); }

.b64-swap-btn--spinning {
  animation: b64-swap-spin 0.18s ease;
}

@keyframes b64-swap-spin {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(90deg) scale(0.88); }
  100% { transform: rotate(0deg) scale(1); }
}

/* ─── BYTE METER (vertical in bridge) ─── */
.b64-meter {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.b64-meter[hidden] { display: none; }

.b64-meter__bar {
  width: 4px;
  height: 80px;
  border-radius: 4px;
  background: rgba(34, 197, 94, 0.1);
  overflow: hidden;
  position: relative;
}

.b64-meter__fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(0deg, var(--b64-accent), var(--b64-accent-hi));
  border-radius: 4px;
  height: 0%;
  transition: height 0.25s ease-out;
}

.b64-meter__label {
  margin: 0;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: rgba(34, 197, 94, 0.55);
  white-space: nowrap;
}

/* ─── MOBILE BRIDGE ROW ─── */
/* Hidden on desktop — shown between panels when grid stacks to 1 col on mobile */
.b64-mobile-bridge {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 0 4px;
  /* Span full width when inside the 3-col grid on desktop (keeps it invisible) */
  grid-column: 1 / -1;
}

.b64-swap-btn--mobile {
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
}

.b64-meter--mobile {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: auto;
}

.b64-meter--mobile .b64-meter__bar {
  width: 80px;
  height: 4px;
}

.b64-meter--mobile .b64-meter__fill {
  position: absolute;
  bottom: 0;
  top: 0;
  left: 0;
  right: auto;
  height: 100%;
  width: 0%;
  transition: width 0.25s ease-out;
}

.b64-meter--mobile .b64-meter__label {
  writing-mode: horizontal-tb;
  transform: none;
  font-size: 0.72rem;
  color: rgba(34, 197, 94, 0.6);
  max-width: none;
}

/* ─── TOOL NOTES ─── */
.b64-page .tool-notes { margin-top: 24px; }

.b64-page .tool-notes code {
  font-family: "IBM Plex Mono", "Courier New", monospace;
  font-size: 0.88em;
  color: var(--b64-accent-hi);
  background: rgba(34, 197, 94, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ─── 960px ─── */
@media (max-width: 960px) {
  .b64-page .page-title { font-size: 2.28rem; }
  .b64-workbench { padding: 8px; }
  .b64-deckbar { padding-bottom: 8px; margin-bottom: 8px; }
  .b64-panel { padding: 12px; gap: 8px; }
  .b64-textarea { min-height: 140px; font-size: 0.98rem; }
  .b64-textarea--output { min-height: 180px; }
  .b64-panel__hint { font-size: 0.86rem; }
}

/* ─── 820px — narrow bridge ─── */
@media (min-width: 701px) and (max-width: 820px) {
  .b64-workbench__layout {
    grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
  }

  .b64-swap-btn { width: 28px; height: 28px; font-size: 0.95rem; }
  .b64-textarea { min-height: 136px; }
  .b64-textarea--output { min-height: 180px; }
}

/* ─── 700px — stack ─── */
@media (max-width: 700px) {
  .b64-page .tool-frame { padding-inline: 16px; }
  .b64-page .page-title { font-size: clamp(1.7rem, 6.2vw, 2.1rem); line-height: 1.03; }
  .b64-page .page-subtitle { font-size: 0.9rem; }

  .b64-workbench__layout { grid-template-columns: 1fr; gap: 10px; }
  .b64-bridge { display: none; }
  .b64-mobile-bridge { display: flex; }
  .b64-workbench,
  .b64-panel { padding: 12px; }
  .b64-textarea { min-height: 120px; }
  .b64-textarea--output { min-height: 130px; }
  .b64-deckbar { display: none; }
  .b64-panel__hint { display: none; }
  .b64-panel--output .b64-panel__header { flex-direction: row; align-items: center; }
}

/* ─── 560px ─── */
@media (max-width: 560px) {
  .b64-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .b64-actions .button { width: 100%; min-width: 0; }
  .b64-action-primary { order: 3; grid-column: 1 / -1; }
  .b64-action-secondary { order: 4; }
  .b64-panel__header { flex-direction: column; }

  .b64-chip,
  .b64-pill { padding: 6px 10px; font-size: 0.75rem; }
}
