@font-face {
  font-family: "APHfont";
  src: url("/fonts/APH_Braille_Shadows.woff2") format("woff2"),
       url("/fonts/APH_Braille_Shadows.woff") format("woff"),
       url("/fonts/APH_Braille_Shadows.ttf") format("truetype");
  font-weight: normal; font-style: normal; font-display: swap;
}

:root {
  --bg: #f4f5f8;
  --panel: #ffffff;
  --panel-head: #fbfbfd;
  --ink: #1f2a44;
  --muted: #5b6478;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --line: #dfe3ec;
  --ok: #1a7f4b;
  --err: #c0392b;
  --radius: 12px;
  --pill-bg: #ffffff;
  --head-bg: #ffffff;
  --btn-bg: #eef1f7;
  --code-bg: #eef1f7;
  --select-bg: #ffffff;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg: #0d1117;
    --panel: #161b22;
    --panel-head: #21262d;
    --ink: #e6edf3;
    --muted: #8b949e;
    --accent: #387df5;
    --accent-ink: #ffffff;
    --line: #30363d;
    --pill-bg: #21262d;
    --head-bg: #161b22;
    --btn-bg: #21262d;
    --code-bg: #21262d;
    --select-bg: #161b22;
    color-scheme: dark;
  }
}
:root.dark {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-head: #21262d;
  --ink: #e6edf3;
  --muted: #8b949e;
  --accent: #387df5;
  --accent-ink: #ffffff;
  --line: #30363d;
  --pill-bg: #21262d;
  --head-bg: #161b22;
  --btn-bg: #21262d;
  --code-bg: #21262d;
  --select-bg: #161b22;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }

header { max-width: min(96vw, 1440px); margin: 0 auto; padding: 18px 20px 8px; }
.header-row { display: flex; align-items: center; gap: 14px; }
.app-logo { width: 46px; height: 46px; border-radius: 11px; flex-shrink: 0; }
header h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; color: var(--accent); }
.brl-title { font-weight: 400; letter-spacing: 0.06em; }
.sub { margin: 6px 0 0; padding-left: 60px; color: var(--muted); font-size: 0.9rem; }
.toolbar { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }
.icon-btn {
  width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 1.2rem; font-weight: 700;
  background: var(--panel); color: var(--ink); border: 1.5px solid var(--line); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
  transition: background .15s, border-color .15s, color .15s;
}
/* larger settings button (holds the gear icon) */
.icon-btn-lg { width: 48px; height: 48px; }
/* SumIt-style highlight: fill with the accent colour, text/icon white */
.icon-btn:hover, .icon-btn:focus-visible {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.icon-btn svg { display: block; }
.adv-btn {
  height: 40px; padding: 0 16px; border-radius: 999px; font: inherit; font-weight: 600; font-size: .92rem;
  background: var(--accent); color: #fff; border: 0; cursor: pointer; white-space: nowrap;
  transition: filter .15s;
}
.adv-btn:hover, .adv-btn:focus-visible { filter: brightness(1.08); }

main { max-width: min(96vw, 1440px); margin: 0 auto; padding: 10px 20px 40px; }

.dropzone {
  position: relative; border: 2.5px dashed #c4cddf; border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f7f9fe 100%);
  padding: 52px 24px 44px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .05s;
}
.dropzone:hover { border-color: #9fb0d6; box-shadow: 0 8px 24px rgba(31,42,68,.06); }
.dropzone.drag { border-color: var(--accent); background: #eaf1fe; box-shadow: 0 0 0 4px rgba(47,111,237,.14); }
.dropzone:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dz-icon {
  width: 96px; height: 96px; display: grid; place-items: center; margin-bottom: 10px;
  border-radius: 50%; background: #eaf1fe; color: var(--accent); transition: transform .15s, background .15s;
}
.dropzone:hover .dz-icon { transform: translateY(-2px); }
.dropzone.drag .dz-icon { background: var(--accent); color: #fff; transform: scale(1.05); }
.dz-title { font-size: 1.3rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.dz-or { color: var(--muted); margin: 8px 0; font-size: 0.9rem; }
.dz-inner #chooseBtn { padding: 12px 30px; font-size: 1.02rem; border-radius: 10px; box-shadow: 0 6px 16px rgba(47,111,237,.28); }
.dz-formats { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: 22px; }
.chip {
  font-size: 0.72rem; font-weight: 700; letter-spacing: .04em; color: var(--muted);
  background: #eef1f7; border: 1px solid #e0e5ef; border-radius: 999px; padding: 4px 11px;
}
.dz-file { margin: 16px 0 0; font-weight: 600; color: var(--accent); min-height: 1.2em; }

button {
  font: inherit; font-weight: 600; color: var(--accent-ink); background: var(--accent);
  border: 0; border-radius: 8px; padding: 10px 18px; cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button:disabled { background: #aeb6c7; cursor: not-allowed; }
#chooseBtn { background: var(--ink); }
.icon-btn:disabled { background: var(--panel); }

.status { min-height: 1.3em; margin: 8px 2px; font-size: 1.05rem; color: var(--muted); text-align: center; }
.status.err { color: var(--err); font-weight: 600; }
.status.ok { color: var(--ok); }

.result { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.result-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
#resultMeta { color: var(--muted); font-size: 0.9rem; }
.preview {
  margin: 0; padding: 16px; overflow-x: hidden; overflow-y: auto; background: var(--panel);
  font-family: "Apple Braille", "Segoe UI Symbol", "SF Mono", "Menlo", "Consolas", monospace;
  font-size: clamp(10px, 1.55vw, 15px); line-height: 1.35; letter-spacing: 0;
  white-space: pre; color: var(--ink); max-height: 60vh;
}

/* dialogs */
.dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; max-width: 680px; width: calc(100% - 32px); max-height: 85vh; margin: auto; box-shadow: 0 24px 60px rgba(0,0,0,.50); color: var(--ink); background: var(--panel); }
.dialog::backdrop { background: rgba(0,0,0,.60); }
.dialog-body { padding: 18px 20px 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; font-size: 1.25rem; }

/* Tabbed Settings Dialog (Left Column Navigation) */
.settings-layout { display: flex; gap: 16px; min-height: 200px; max-height: 65vh; margin-top: 8px; }
.settings-nav { width: 180px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); padding-right: 12px; }
.tab-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font: inherit; font-size: 0.86rem; font-weight: 600; text-align: left; cursor: pointer; transition: background .15s, color .15s;
}
.tab-btn:hover { background: var(--btn-bg); color: var(--ink); }
.tab-btn.active { background: var(--accent); color: #fff; }
.settings-panels { flex: 1; min-width: 0; overflow-y: auto; padding-right: 4px; }
.settings-panel { display: none; }
.settings-panel.active { display: block; }
.settings-panel h3 { margin: 0 0 10px; font-size: 0.98rem; font-weight: 700; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 6px; }

.dialog .field { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.dialog .field.field-check,
.dialog .field:has(.check-label) { margin-top: 6px; }
.dialog .field-row { display: flex; gap: 14px; }
.dialog .field-row .field { flex: 1; }
.field label { font-size: 0.75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.field select, .field input[type="number"], .field input[type="text"] {
  font: inherit; font-size: 0.88rem; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--select-bg); width: 100%; color: var(--ink);
}

.check-label {
  display: flex !important; align-items: center !important; gap: 10px !important;
  cursor: pointer !important; font-size: 0.88rem !important; color: var(--ink) !important;
  text-transform: none !important; font-weight: 400 !important; letter-spacing: normal !important;
  padding: 2px 0 !important; margin: 0 !important;
}
.check-label input { width: 17px !important; height: 17px !important; margin: 0 !important; flex-shrink: 0; cursor: pointer; }
.check-label strong { font-weight: 600; color: var(--ink); }
.check-label span { font-size: 0.84rem; color: var(--muted); }
.dialog-foot { margin-top: 20px; display: flex; justify-content: flex-end; }

/* Unified Download Pill Button */
.download-group {
  display: inline-flex; align-items: center; height: 46px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-size: 0.92rem; font-weight: 600; overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.download-group:hover, .download-group:focus-within { border-color: var(--accent); }
.download-group button {
  height: 100%; border: 0; background: transparent; color: inherit; font: inherit;
  font-weight: 600; padding: 0 10px 0 16px; border-radius: 999px 0 0 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: background .15s, color .15s;
}
.download-group button:hover, .download-group button:focus-visible { background: var(--accent); color: #fff; }
.download-group select {
  height: 100%; border: 0; border-left: 1.5px solid var(--line); background: transparent;
  color: inherit; font: inherit; font-weight: 600; padding: 0 28px 0 10px; border-radius: 0 999px 999px 0;
  cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 20px, calc(100% - 9px) 20px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.download-group select:hover { background-color: rgba(47, 111, 237, 0.08); }
.download-group select:focus { outline: none; }

.help-content h3 { margin: 16px 0 4px; font-size: 0.98rem; }
.help-content p, .help-content li { font-size: 0.92rem; }
.help-content .help-note { color: var(--muted); font-style: italic; font-size: 0.84rem; }
.help-content ol, .help-content ul { margin: 4px 0; padding-left: 20px; }
.help-content code { background: #eef1f7; padding: 1px 5px; border-radius: 5px; font-size: 0.85em; }
.help-content a { color: var(--accent); }
.credits { list-style: none; padding-left: 0; }
.credits li { margin-bottom: 7px; padding-left: 14px; position: relative; }
.credits li::before { content: "•"; position: absolute; left: 0; color: var(--accent); }

@media (max-width: 600px) {
  .settings-layout { flex-direction: column; }
  .settings-nav { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; overflow-x: auto; padding-right: 0; padding-bottom: 8px; }
  .tab-btn { white-space: nowrap; }
}

@media (max-width: 560px) {
  header h1 { font-size: 1.3rem; }
  .sub { font-size: 0.82rem; padding-left: 0; }
}

/* 3D Physical Emboss Relief Simulator Shading */
.brl-emboss-relief {
  background: #f1ebd9 !important;
  background-image: radial-gradient(#e4dcbe 15%, transparent 16%), radial-gradient(#e4dcbe 15%, transparent 16%) !important;
  background-size: 16px 16px !important;
  background-position: 0 0, 8px 8px !important;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.08) !important;
  padding: 12px !important;
  border-radius: 8px !important;
}
.brl-emboss-relief .don {
  fill: #8b6e4e !important;
  filter: drop-shadow(-1px -1px 1px #ffffff) drop-shadow(1.5px 1.5px 1.5px rgba(0,0,0,0.45)) !important;
}
.brl-emboss-relief .doff {
  fill: #ded7bd !important;
  opacity: 0.5 !important;
}

/* Interline Print View Pill Styling */
.brl-interline-print {
  display: inline-block;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1e293b;
  background: #eef2fa;
  border-left: 3px solid var(--accent);
  padding: 3px 8px;
  margin: 6px 0 4px 0;
  border-radius: 0 4px 4px 0;
  line-height: 1.3;
}

/* APHfont Braille Text Styling (matches Translate) */
.brl-text-wrap {
  font-family: "APHfont", "Apple Braille", "Segoe UI Symbol", monospace;
  line-height: 1.35;
  letter-spacing: 0.04em;
  white-space: pre;
  overflow-x: auto;
  display: block;
}
.bcell {
  display: inline-block;
  font-family: "APHfont", "Apple Braille", "Segoe UI Symbol", monospace;
  cursor: pointer;
}
.bcell:hover {
  background: rgba(47, 111, 237, 0.12);
  border-radius: 2px;
}
