/* ==========================================================================
   Base64 & URL Encoder / Decoder
   ========================================================================== */

.b64.workspace { display: block; }

/* Mode tabs ---------------------------------------------------------------- */
.b64-modes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 1rem clamp(12px, 3vw, 36px);
  border-bottom: 1px solid var(--border);
}
.b64-tabs { display: flex; max-width: 100%; }
.b64-tabs [role="tab"] { flex: 1 1 auto; padding: 0.5rem 1rem; font-size: 0.86rem; text-align: center; }
.b64-modes-note { display: inline-flex; align-items: center; gap: 0.45rem; margin: 0; color: var(--muted); font-size: 0.82rem; }
.b64-modes-note .icon { width: 15px; height: 15px; color: var(--lilac); }
@media (max-width: 520px) {
  .b64-tabs { width: 100%; }
  .b64-tabs [role="tab"] { flex: 1 1 0; padding: 0.5rem 0.4rem; font-size: 0.8rem; }
}

/* Panels: the same two-column layout as other workspaces -------------------- */
.b64-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 960px) { .b64-grid { grid-template-columns: 1fr; } }

.b64-field { display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }
.b64-area {
  display: block;
  min-height: 220px;
  font: 0.86rem/1.6 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-all;
  tab-size: 2;
}
.b64-area-sm { min-height: 160px; }
.b64-area[readonly] { cursor: text; }
.b64-count { margin-top: 0; }
.b64 code { padding: 0.05em 0.3em; border-radius: 5px; background: var(--surface-3); font: 0.85em var(--font-mono); }

.b64-opt-row { display: flex; flex-direction: column; gap: 0.4rem; min-height: 1.5rem; }
.b64-opt-row .check { align-items: flex-start; line-height: 1.5; }
.b64-opt-row .check input { margin-top: 0.15rem; flex: none; }
.b64-hint { margin: 0; line-height: 1.5; }

/* Status / error line (live region; collapses when empty) */
.b64-status {
  display: flex; align-items: flex-start; gap: 0.6rem;
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.b64-status:empty { display: none; }
.b64-status .icon { flex: none; width: 18px; height: 18px; margin-top: 0.1rem; stroke-width: 2.4; }
.b64-status.is-good { border: 1px solid rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.08); color: var(--success-text); }
.b64-status.is-warn { border: 1px solid rgba(245, 158, 11, 0.35); background: rgba(245, 158, 11, 0.08); color: var(--warn-text); }
.b64-status.is-bad { border: 1px solid rgba(251, 113, 133, 0.35); background: rgba(251, 113, 133, 0.08); color: var(--danger-text); }
.b64-status strong { color: inherit; }
.b64-status button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.b64-status button:focus-visible { outline: 2px solid var(--lilac); outline-offset: 2px; border-radius: 4px; }

.b64 .stats-row .stat strong { font-size: 1.1rem; }
.b64 .stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* File: selected file card ------------------------------------------------- */
.b64-file-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.b64-fblock { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.b64-thumb {
  display: grid; place-items: center; flex: none;
  width: 52px; height: 52px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--surface-3);
  color: var(--lilac);
}
.b64-thumb img { width: 100%; height: 100%; object-fit: cover; }
.b64-thumb .icon { width: 22px; height: 22px; }
.b64-file-meta { min-width: 0; }
.b64-file-name { margin: 0; color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.b64-file-sub { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.82rem; }

/* File: decoded preview ---------------------------------------------------- */
.b64-detect { margin: 0; color: var(--text-2); font-size: 0.9rem; overflow-wrap: anywhere; }
.b64-detect strong { color: var(--text); }
.b64-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--field-bg);
  background-image:
    linear-gradient(45deg, var(--surface-3) 25%, transparent 25%, transparent 75%, var(--surface-3) 75%),
    linear-gradient(45deg, var(--surface-3) 25%, transparent 25%, transparent 75%, var(--surface-3) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 9px 9px;
}
.b64-preview img { display: block; max-width: 100%; max-height: 300px; height: auto; object-fit: contain; }
.b64-preview figcaption { color: var(--muted); font-size: 0.78rem; }
.b64-textpreview { max-height: 260px; white-space: pre-wrap; overflow-wrap: anywhere; }

.b64-download-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
.b64-name-field { flex: 1 1 200px; }
.b64-download-row .btn { flex: none; }
.b64-download-row .btn .icon { width: 17px; height: 17px; }

/* URL: encode choice ------------------------------------------------------- */
.b64-choice { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.b64-choice legend { margin-bottom: 0.5rem; padding: 0; color: var(--text); font-size: 0.88rem; font-weight: 600; }
.b64-choice-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.9rem;
  line-height: 1.45;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
.b64-choice-item:hover { border-color: rgba(var(--ink), 0.24); }
.b64-choice-item:has(input:checked) { border-color: rgba(139, 92, 246, 0.6); background: var(--grad-soft); }
.b64-choice-item:has(input:focus-visible) { outline: 2px solid var(--lilac); outline-offset: 2px; }
.b64-choice-item input { flex: none; width: 17px; height: 17px; margin: 0.15rem 0 0; accent-color: var(--violet); }
.b64-choice-item strong { color: var(--text); font-weight: 600; }
.b64-choice-item small { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.82rem; }

/* URL: parse view ---------------------------------------------------------- */
.b64-parse { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.b64-parse-empty { min-height: 220px; }
.b64-parse-body { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }
.b64-dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.55rem 1rem;
  margin: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.b64-dl dt { color: var(--muted); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.9; }
.b64-dl dd { min-width: 0; margin: 0; color: var(--text); font: 0.86rem/1.65 var(--font-mono); overflow-wrap: anywhere; word-break: break-all; }
.b64-dl dd small { display: block; color: var(--muted); font: 0.78rem/1.5 var(--font-body); word-break: normal; }
.b64-dl dd.b64-scroll { max-height: 8.5em; overflow-y: auto; }
.b64-dl dd.b64-scroll:focus-visible { outline: 2px solid var(--lilac); outline-offset: 2px; border-radius: 4px; }
.b64-empty-val { color: var(--muted); font-style: italic; font-family: var(--font-body); }
@media (max-width: 420px) {
  .b64-dl { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; }
  .b64-dl dd { margin-bottom: 0.5rem; }
}
.b64-subtitle { margin: 0.35rem 0 0; font: 600 1rem/1.3 var(--font-body); letter-spacing: 0; }
.b64-table-wrap { max-height: 440px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--field-bg); }
.b64-table-wrap:focus-visible { outline: 2px solid var(--lilac); outline-offset: 2px; }
.b64-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 0.86rem; }
.b64-table th, .b64-table td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.b64-table th { position: sticky; top: 0; z-index: 1; background: var(--bg-elev); color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.b64-table th:first-child, .b64-table td:first-child { width: 2.6rem; color: var(--muted); text-align: right; }
.b64-table th:nth-child(2) { width: 34%; }
.b64-table td { font-family: var(--font-mono); overflow-wrap: anywhere; word-break: break-all; }
.b64-table td:nth-child(2) { color: var(--code-k); }
.b64-table tr:last-child td { border-bottom: 0; }
