/* ═══════════════════════════════════════════════════
   UV-5R MINI BOOT IMG CONVERTER
   Aesthetic: Field Radio Ops — phosphor + amber
   ═══════════════════════════════════════════════════ */

/* ── Dark: Night Ops ── */
body.dark {
  --bg:             #07080a;
  --surface:        #0d1009;
  --surface2:       #111508;
  --border:         #2a3c1e;
  --border-hi:      #557240;
  --text:           #c8e0b4;
  --text-hi:        #e6f4d8;
  --text-muted:     #9ab088;
  --text-dim:       #7a9070;
  --accent:         #e89818;
  --accent-lo:      #b07210;
  --accent-glow:    rgba(232,152,24,0.28);
  --on-accent:      #0a0a0a;
  --screen-bg:      #040906;
  --screen-glow:    rgba(60,160,60,0.12);
  --device-hi:      #28261e;
  --device-body:    #1c1a14;
  --device-dark:    #0c0b08;
  --drop-hover:     #0c1208;
  --focus-ring:     #ffd060;
  --status-bg:      #1a1a0a;
  --status-text:    #f0e8c8;
  --status-error:   #ffb060;
}

/* ── Light: Day Ops ── */
body.light {
  --bg:             #ede6d0;
  --surface:        #e0d8c0;
  --surface2:       #d4ccb0;
  --border:         #8a7e54;
  --border-hi:      #5a4e30;
  --text:           #1c1e08;
  --text-hi:        #000000;
  --text-muted:     #2a2c14;
  --text-dim:       #3a3820;
  --accent:         #5a4810;
  --accent-lo:      #7a6818;
  --accent-glow:    rgba(90,72,16,0.22);
  --on-accent:      #f4eccc;
  --screen-bg:      #b0a87a;
  --screen-glow:    rgba(0,0,0,0.08);
  --device-hi:      #48453a;
  --device-body:    #38352c;
  --device-dark:    #201e18;
  --drop-hover:     #d4cdb0;
  --focus-ring:     #5a4810;
  --status-bg:      #d8d0a8;
  --status-text:    #1c1e08;
  --status-error:   #7a2010;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ── */
html { font-size: 16px; }

body {
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.25s, color 0.25s;
  font-size: 1rem;
  line-height: 1.5;
}

/* ── Visually-hidden helper ── */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Skip link ── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0.5rem;
  z-index: 100;
  background: var(--accent);
  color: var(--bg);
  padding: 0.6rem 1rem;
  text-decoration: none;
  font-weight: bold;
  letter-spacing: 0.05em;
  border: 2px solid var(--focus-ring);
}

.skip-link:focus {
  top: 0.5rem;
}

/* ── Global focus ring ── */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════ */

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 0.6rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-top {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin-bottom: 0.3rem;
  font-weight: normal;
  font-size: 1rem;
  flex-wrap: wrap;
}

.brand-make {
  font-size: 1.6rem;
  color: var(--text-hi);
  letter-spacing: 0.12em;
}

.brand-sep {
  font-size: 1rem;
  color: var(--accent);
}

.brand-model {
  font-size: 1.2rem;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.brand-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
}

.brand-spec {
  font-size: 0.8125rem;
  color: var(--text);
  letter-spacing: 0.06em;
}

/* Header right */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding-top: 0.3rem;
  flex-wrap: wrap;
}

/* Signal meter */
.sig-meter {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 22px;
}

.sig-meter span {
  display: block;
  width: 5px;
  border-radius: 1px 1px 0 0;
  animation: sig-pulse 2s ease-in-out infinite;
}

.sig-meter span:nth-child(1) { height: 6px;  background: var(--text-muted);  animation-delay: 0s; }
.sig-meter span:nth-child(2) { height: 10px; background: var(--text-muted);  animation-delay: 0.2s; }
.sig-meter span:nth-child(3) { height: 14px; background: var(--accent-lo);   animation-delay: 0.4s; }
.sig-meter span:nth-child(4) { height: 19px; background: var(--accent);      animation-delay: 0.6s; }
.sig-meter span:nth-child(5) { height: 14px; background: var(--accent);      animation-delay: 0.8s; opacity: 0.6; }

@keyframes sig-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* Theme toggle */
#themeToggle {
  background: transparent;
  border: 1px solid var(--border-hi);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  letter-spacing: 0.08em;
  padding: 0.5rem 0.85rem;
  min-height: 36px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

#themeToggle:hover,
#themeToggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle-icon {
  font-size: 1rem;
}

/* Header rule */
.header-rule {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 1.5rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  overflow: hidden;
}

.rule-line {
  width: 52px;
  height: 1px;
  background: var(--border-hi);
  flex-shrink: 0;
}

.rule-dots {
  font-size: 0.625rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════
   MAIN LAYOUT
   ═══════════════════════════════════════════════════ */

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* ═══════════════════════════════════════════════════
   DROP ZONE
   ═══════════════════════════════════════════════════ */

.drop-zone {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
  outline: none;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
}

/* Corner targeting marks */
.drop-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--accent-lo);
  border-style: solid;
  transition: border-color 0.2s, width 0.2s, height 0.2s;
}
.drop-corner.tl { top: 10px;  left: 10px;  border-width: 2px 0 0 2px; }
.drop-corner.tr { top: 10px;  right: 10px; border-width: 2px 2px 0 0; }
.drop-corner.bl { bottom: 10px; left: 10px;  border-width: 0 0 2px 2px; }
.drop-corner.br { bottom: 10px; right: 10px; border-width: 0 2px 2px 0; }

.drop-zone:hover .drop-corner,
.drop-zone:has(#fileInput:focus-visible) .drop-corner,
.drop-zone.drag-over .drop-corner {
  border-color: var(--accent);
  width: 22px;
  height: 22px;
}

.drop-zone:hover,
.drop-zone:has(#fileInput:focus-visible),
.drop-zone.drag-over {
  background: var(--drop-hover);
  border-color: var(--border-hi);
}

.drop-zone:has(#fileInput:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.drop-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 2.75rem 2rem 2.25rem;
  cursor: pointer;
}

/* Waveform */
.drop-wave {
  width: 160px;
  height: 44px;
  color: var(--accent-lo);
  margin-bottom: 0.4rem;
  transition: color 0.15s;
}

.drop-zone:hover .drop-wave,
.drop-zone.drag-over .drop-wave {
  color: var(--accent);
}

.wave-path {
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  animation: wave-in 1.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes wave-in {
  to { stroke-dashoffset: 0; }
}

.drop-label {
  font-size: 1.125rem;
  color: var(--text-hi);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.drop-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.drop-formats {
  font-size: 0.8125rem;
  color: var(--text);
  letter-spacing: 0.08em;
  margin-top: 0.2rem;
}

/* ═══════════════════════════════════════════════════
   STATUS / ERRORS
   ═══════════════════════════════════════════════════ */

.status {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1000;
  max-width: min(380px, calc(100vw - 2.5rem));
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  background: var(--status-bg);
  border: 1px solid var(--border-hi);
  color: var(--status-text);
  padding: 0.65rem 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.status:not(:empty) {
  opacity: 1;
  transform: translateY(0);
}

.status.error {
  border-color: var(--status-error);
  color: var(--status-error);
}

@media (max-width: 560px) {
  .status {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    max-width: none;
  }
}

/* ═══════════════════════════════════════════════════
   OPTIONS PANEL
   ═══════════════════════════════════════════════════ */

.options {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}

.options-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  padding-right: 1rem;
  margin-right: 1rem;
  border-right: 1px solid var(--border);
  align-self: stretch;
  display: flex;
  align-items: center;
}

.options-controls {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  flex-wrap: wrap;
  padding: 0.2rem 0;
}

/* Toggle switch */
.toggle-control {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  min-height: 32px;
}

.toggle-control input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.toggle-track {
  display: inline-block;
  position: relative;
  width: 44px;
  height: 22px;
  background: var(--surface2);
  border: 1px solid var(--border-hi);
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.toggle-control input[type="checkbox"]:focus-visible + .toggle-track {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Sliding knob */
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-dim);
  transition: transform 0.15s, background 0.15s;
}

#keepAspect:checked + .toggle-track {
  border-color: var(--accent);
  background: var(--accent-lo);
}

#keepAspect:checked + .toggle-track::after {
  transform: translateX(22px);
  background: var(--accent);
}

/* Color control */
.color-control {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  min-height: 32px;
}

.control-text {
  font-size: 0.875rem;
  color: var(--text);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.color-control input[type="color"] {
  width: 44px;
  height: 28px;
  border: 1px solid var(--border-hi);
  padding: 1px 2px;
  cursor: pointer;
  background: none;
  display: block;
}

/* ═══════════════════════════════════════════════════
   PREVIEWS
   ═══════════════════════════════════════════════════ */

.previews {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  align-items: stretch;
}

.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.85rem;
  flex: 1 1 300px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.card-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.ch-tag {
  font-size: 0.8125rem;
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: bold;
}

.ch-info {
  font-size: 0.8125rem;
  color: var(--text);
  letter-spacing: 0.06em;
}

/* Original canvas */
.canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--surface2);
  min-height: 90px;
  overflow: hidden;
}

.src-card .canvas-wrap {
  flex: 1;
}

.canvas-wrap canvas {
  max-width: 100%;
  max-height: 300px;
  display: block;
  image-rendering: pixelated;
}

/* ── Device Bezel ── */
.device-stage {
  display: flex;
  justify-content: center;
  background: var(--surface2);
  padding: 2rem 1rem 1.25rem 1.5rem;
}

.device-body {
  position: relative;
  background: linear-gradient(150deg, var(--device-hi) 0%, var(--device-body) 60%);
  border-radius: 10px 10px 12px 12px;
  padding: 10px 12px 14px;
  border: 2px solid var(--device-dark);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.07),
    inset -1px 0 0 rgba(0,0,0,0.3),
    0 10px 40px rgba(0,0,0,0.55),
    0 3px 10px rgba(0,0,0,0.4);
  width: 228px;
  max-width: 100%;
}

/* Antenna */
.device-antenna {
  position: absolute;
  top: -42px;
  right: 28px;
  width: 9px;
  height: 44px;
  background: linear-gradient(to right, var(--device-dark), var(--device-hi), var(--device-dark));
  border-radius: 4px 4px 0 0;
  border: 1px solid var(--device-dark);
  border-bottom: none;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.4);
}

/* Top controls: vol knob · speaker grille · ch knob */
.device-top-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
}

.device-knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  background: radial-gradient(circle at 38% 35%, var(--device-hi), var(--device-dark) 80%);
  border: 1px solid rgba(0, 0, 0, 0.6);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.device-grille {
  flex: 1;
  height: 20px;
  border-radius: 2px;
  background: repeating-linear-gradient(
    to bottom,
    var(--device-dark) 0,
    var(--device-dark) 2px,
    transparent 2px,
    transparent 5px
  );
  opacity: 0.8;
}

/* Screen */
.screen-bezel {
  background: #030303;
  border-radius: 3px;
  padding: 5px;
  border: 1px solid #000;
  box-shadow:
    inset 0 0 12px rgba(0,0,0,0.9),
    inset 0 1px 0 rgba(255,255,255,0.04);
}

.screen-inner {
  position: relative;
  overflow: hidden;
  background: var(--screen-bg);
  line-height: 0;
  box-shadow:
    inset 0 0 24px rgba(0,0,0,0.7),
    inset 0 0 10px var(--screen-glow);
}

.output-wrap {
  background: var(--screen-bg);
  min-height: auto;
}

/* Display at 1.5× for visibility */
.output-wrap canvas {
  width: 192px;
  height: 207px;
  display: block;
  image-rendering: pixelated;
}

/* Scanlines overlay */
.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.18) 2px,
    rgba(0, 0, 0, 0.18) 4px
  );
  pointer-events: none;
  z-index: 2;
}

/* Screen glare */
.screen-glare {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255,255,255,0.05) 0%,
    transparent 50%
  );
  pointer-events: none;
  z-index: 3;
}

/* Device label */
.device-label {
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  font-size: 8px;
  color: rgba(255, 255, 255, 0.28);
  letter-spacing: 0.2em;
  text-align: center;
  margin-top: 7px;
}

/* Function key row (Menu / ▲ / ▼ / Exit) */
.device-fn-row {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}

.device-fn-row span {
  flex: 1;
  height: 10px;
  background: linear-gradient(to bottom, var(--device-hi), var(--device-body));
  border-radius: 2px;
  border: 1px solid var(--device-dark);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Numeric keypad 4 × 3 */
.device-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  margin-top: 3px;
}

.device-numpad span {
  height: 10px;
  background: linear-gradient(to bottom, var(--device-hi), var(--device-body));
  border-radius: 2px;
  border: 1px solid var(--device-dark);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* PTT button on left side */
.device-ptt {
  position: absolute;
  left: -10px;
  top: 44px;
  width: 10px;
  height: 44px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.5), var(--device-body));
  border-radius: 4px 0 0 4px;
  border: 1px solid var(--device-dark);
  border-right: none;
  box-shadow: -2px 1px 5px rgba(0, 0, 0, 0.5);
}

/* ═══════════════════════════════════════════════════
   ACTIONS
   ═══════════════════════════════════════════════════ */

.actions {
  display: flex;
  justify-content: center;
  padding-top: 0.35rem;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border: 2px solid transparent;
  font-family: inherit;
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.85rem 3rem;
  min-height: 48px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
  transition: filter 0.15s;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.12);
  transform: translateX(-110%) skewX(-12deg);
  transition: transform 0.35s ease;
}

.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:hover::before { transform: translateX(110%) skewX(-12deg); }
.btn-primary:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
.btn-primary:disabled::before { display: none; }

.btn-arrow {
  font-size: 0.7rem;
  animation: blink-arrow 1.4s step-end infinite;
}

.btn-primary:disabled .btn-arrow {
  animation: none;
}

@keyframes blink-arrow {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ═══════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════ */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  background: var(--surface);
}

.footer-inner {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-vibe {
  color: var(--accent);
}

.footer-gh {
  color: var(--text);
  text-decoration: underline;
  letter-spacing: 0.06em;
  transition: color 0.2s;
  padding: 0.25rem 0;
}

.footer-gh:hover,
.footer-gh:focus-visible {
  color: var(--accent);
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */

@media (max-width: 720px) {
  .header-inner {
    padding: 1rem 1rem 0.5rem;
  }
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .header-inner { padding: 1rem 1rem 0.5rem; }
  .header-rule  { padding: 0 1rem 0.5rem; }
  main { padding: 1rem 1rem 2rem; }

  .brand-make { font-size: 1.25rem; }
  .brand-model { font-size: 1rem; }
  .brand-desc { font-size: 0.8125rem; }
  .brand-spec { font-size: 0.75rem; }

  .drop-content { padding: 2rem 1rem 1.75rem; }
  .drop-label { font-size: 1rem; }

  .options {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .options-tag {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    margin-right: 0;
    padding-bottom: 0.4rem;
    align-self: stretch;
  }

  .btn-primary {
    padding: 0.85rem 2rem;
    font-size: 0.9375rem;
    letter-spacing: 0.12em;
  }

  .footer-inner { gap: 1rem; }
}

@media (max-width: 380px) {
  .brand-make { font-size: 1.1rem; }
  .brand-model { font-size: 0.9rem; }
  .header-right { gap: 0.5rem; }
  #themeToggle { font-size: 0.8125rem; padding: 0.45rem 0.6rem; }
  .drop-formats { font-size: 0.75rem; }
}

/* ═══════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .wave-path {
    stroke-dashoffset: 0;
  }
}
