/* ===========================================================
   Base64 工具專用樣式
   - 所有 class 皆以 b64- 前綴，與全站 style.css 零撞名（避免跑版）
   - CSS 變數 scope 在 .b64-tool 底下，不外洩全站
   =========================================================== */

.b64-tool {
  /* 版面寬度：刻意比 header / 全站預設(1180) 更寬 */
  width: min(1480px, calc(100% - 48px));
  margin-inline: auto;

  /* 區域變數 */
  --b-card: #ffffff;
  --b-text: #101828;
  --b-muted: #667085;
  --b-border: #e3e8f1;
  --b-primary: #6b3ce8;
  --b-primary-dark: #5125c8;
  --b-purple-soft: #efe8ff;
  --b-green-soft: #e7f8ee;
  --b-green: #16a46b;
  --b-dark: #111827;
  --b-shadow: 0 10px 30px rgba(31, 42, 68, .06);
  --b-radius: 16px;

  color: var(--b-text);
}

.b64-tool * { box-sizing: border-box; }
.b64-tool button,
.b64-tool input,
.b64-tool textarea { font: inherit; }
.b64-tool button { cursor: pointer; }
.b64-tool h1,
.b64-tool h2 { margin: 0; }

/* 讓麵包屑跟著加寬後的內容對齊（沿用全站 .crumb-row 樣式，只調整外距） */
.b64-tool .crumb-row { margin: 8px 0 18px; }

/* ---------- 按鈕 ---------- */
.b64-btn,
.b64-btn-primary,
.b64-btn-ghost {
  border: 1px solid var(--b-border);
  border-radius: 11px;
  background: #fff;
  color: var(--b-text);
  padding: 10px 14px;
  font-weight: 700;
  transition: .15s ease;
  white-space: nowrap;
}
.b64-btn:hover { border-color: #c9bff4; color: var(--b-primary); }
.b64-btn-primary {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--b-primary), var(--b-primary-dark));
}
.b64-btn-primary:hover { filter: brightness(1.05); }
.b64-btn-ghost { border: 0; background: transparent; color: var(--b-muted); }
.b64-btn-ghost:hover { color: var(--b-primary); }
.b64-sm { padding: 8px 12px; font-size: 13px; }
.b64-wide { width: 100%; }

/* ---------- Hero ---------- */
.b64-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.b64-hero > div:first-child { min-width: 0; flex: 1 1 420px; }
.b64-eyebrow {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--b-primary);
  background: var(--b-purple-soft);
  font-size: 13px;
  font-weight: 800;
}
.b64-hero h1 {
  margin: 12px 0 8px;
  font-size: clamp(30px, 3.4vw, 46px);
  line-height: 1.14;
  letter-spacing: -.03em;
}
.b64-hero p {
  margin: 0;
  max-width: 820px;
  color: var(--b-muted);
  line-height: 1.8;
}
.b64-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ---------- 卡片基底 ---------- */
.b64-card {
  background: var(--b-card);
  border: 1px solid var(--b-border);
  border-radius: var(--b-radius);
  box-shadow: var(--b-shadow);
}

/* ---------- 編碼 / 解碼雙欄 ---------- */
.b64-convert {
  display: grid;
  grid-template-columns: 1fr 74px 1fr;
  gap: 14px;
  align-items: stretch;
}
.b64-editor { padding: 20px; min-width: 0; display: flex; flex-direction: column; }
.b64-cardhead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.b64-titleline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.b64-editor h2 { font-size: 18px; }
.b64-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--b-green-soft);
  color: var(--b-green);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.b64-chip.success { background: #e8f8ea; color: #18a45d; }
.b64-headactions,
.b64-bottomactions { display: flex; gap: 8px; flex-wrap: wrap; }

.b64-tool textarea {
  width: 100%;
  max-width: 100%;
  min-height: 260px;
  flex: 1;
  resize: vertical;
  outline: 0;
  border: 1px solid #dbe2ec;
  border-radius: 12px;
  padding: 14px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.65;
  color: var(--b-text);
  background: #fff;
}
.b64-tool textarea:focus {
  border-color: #a48aff;
  box-shadow: 0 0 0 4px rgba(107, 60, 232, .08);
}
.b64-editorbottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.b64-stats { display: flex; gap: 18px; color: var(--b-muted); font-size: 13px; flex-wrap: wrap; }

.b64-swapcol { display: grid; place-items: center; }
.b64-swap {
  width: 64px;
  min-height: 78px;
  border: 1px solid #d8d1f8;
  border-radius: 14px;
  background: #fff;
  color: var(--b-primary);
  font-size: 28px;
  box-shadow: var(--b-shadow);
}
.b64-swap span { display: block; margin-top: 2px; color: var(--b-muted); font-size: 12px; }

/* ---------- 設定列 ---------- */
.b64-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}
.b64-setcard {
  min-height: 64px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px 26px;
  flex-wrap: wrap;
}
.b64-setcard strong { margin-right: 4px; }
.b64-setcard label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #344054;
  font-size: 13px;
}
.b64-tool input[type="checkbox"],
.b64-tool input[type="radio"] { accent-color: var(--b-primary); width: 17px; height: 17px; }

/* ---------- 功能區三欄 ---------- */
.b64-features {
  display: grid;
  grid-template-columns: 1.35fr .7fr 1.15fr;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}
.b64-file,
.b64-quick,
.b64-code { padding: 20px; min-width: 0; }
.b64-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.b64-heading h2 { font-size: 17px; }
.b64-heading span { color: var(--b-muted); font-size: 13px; }

.b64-filecontent { display: grid; grid-template-columns: 1.1fr .8fr; gap: 18px; }
.b64-drop {
  min-height: 200px;
  padding: 20px;
  border: 1.5px dashed #cfc6f4;
  border-radius: 13px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  color: var(--b-muted);
  background: #fcfbff;
  transition: .2s ease;
  cursor: pointer;
}
.b64-drop.dragging { border-color: var(--b-primary); background: #f7f2ff; }
.b64-drop strong { color: #4b5565; font-size: 13px; }
.b64-drop span { font-size: 12px; }
.b64-upicon { color: var(--b-primary); font-size: 36px; line-height: 1; }
.b64-note { display: block; margin-top: 10px; color: var(--b-muted); font-size: 12px; }

.b64-previewcol { display: flex; flex-direction: column; gap: 10px; }
.b64-preview {
  min-height: 160px;
  border: 1px solid var(--b-border);
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--b-muted);
  background: #f8fafc;
  padding: 10px;
}
.b64-preview img { width: 100%; height: 100%; object-fit: contain; }

.b64-quickgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.b64-quickgrid button {
  min-height: 74px;
  border: 1px solid var(--b-border);
  border-radius: 12px;
  background: #fff;
  color: var(--b-text);
  font-weight: 700;
  transition: .15s ease;
}
.b64-quickgrid button:hover { border-color: #c9bff4; color: var(--b-primary); }
.b64-quickgrid button span { display: block; margin-top: 6px; font-size: 12px; }

.b64-tabs {
  display: flex;
  gap: 18px;
  border-bottom: 1px solid var(--b-border);
  overflow-x: auto;
}
.b64-tabs button {
  padding: 9px 2px;
  border: 0;
  background: transparent;
  color: var(--b-muted);
  font-weight: 700;
  white-space: nowrap;
}
.b64-tabs button.active { color: var(--b-primary); border-bottom: 2px solid var(--b-primary); }
.b64-codewrap {
  position: relative;
  margin-top: 12px;
  border-radius: 12px;
  background: var(--b-dark);
  overflow: hidden;
  min-width: 0;
}
.b64-copycode {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  border: 1px solid #344054;
  border-radius: 9px;
  background: #182230;
  color: #fff;
  padding: 8px 10px;
}
.b64-codewrap pre {
  margin: 0;
  min-height: 244px;
  padding: 22px;
  overflow: auto;
  color: #d1fae5;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
}
.b64-codewrap code { font-family: inherit; }

/* ---------- 隱私條 ---------- */
.b64-privacy {
  margin-top: 18px;
  padding: 18px 22px;
  border: 1px solid #edf0f5;
  border-radius: 15px;
  background: linear-gradient(90deg, #fff, #fafbff);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.b64-privacy > div { display: flex; align-items: center; gap: 12px; }
.b64-privacy strong,
.b64-privacy small { display: block; }
.b64-privacy small { margin-top: 3px; color: var(--b-muted); }
.b64-picon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
}
.b64-picon.green { background: #e8f8ee; }
.b64-picon.blue { background: #eaf2ff; }
.b64-picon.orange { background: #fff0da; }

/* ---------- Toast ---------- */
.b64-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
  transition: .25s ease;
  border-radius: 10px;
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  font-weight: 700;
}
.b64-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===========================================================
   RWD
   =========================================================== */
@media (max-width: 1040px) {
  .b64-hero { align-items: flex-start; flex-direction: column; }
  .b64-hero-actions { justify-content: flex-start; }
  .b64-convert { grid-template-columns: 1fr; }
  .b64-swapcol { min-height: 8px; }
  .b64-swap {
    width: 100%;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 20px;
  }
  .b64-swap span { margin-top: 0; }
  .b64-features { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .b64-hero-actions { display: none; }
  .b64-settings,
  .b64-privacy { grid-template-columns: 1fr; }
  .b64-setcard { align-items: flex-start; }
  .b64-filecontent { grid-template-columns: 1fr; }
  .b64-cardhead,
  .b64-editorbottom { align-items: stretch; flex-direction: column; }
  .b64-headactions,
  .b64-bottomactions { width: 100%; }
  .b64-tool textarea { min-height: 210px; }
}

@media (max-width: 560px) {
  .b64-tool { width: min(100% - 28px, 1480px); }
  .b64-quickgrid { grid-template-columns: 1fr; }
  .b64-hero h1 { font-size: 28px; }
  .b64-headactions .b64-btn,
  .b64-bottomactions button { flex: 1; }
}
