/* ============================================================
   LAN Mailbox - design tokens
   Palette: sun-bleached rural mailbox on a gravel road at dusk.
   Display type: system serif (postal-stamp personality, no CDN
   dependency so this still looks right on an offline LAN).
   UI type: system sans, generous tracking on small caps labels.
   Signature element: the illustrated mailbox itself.
   ============================================================ */

:root {
  --paper: #f5efdd;
  --paper-dark: #e9dcb8;
  --ink: #2b2118;
  --ink-soft: #6b5842;
  --red: #a33b2e;
  --red-dark: #7c2b21;
  --red-tint: #c8695a;
  --gold: #d9a441;
  --green: #4b7455;
  --sky: #7fa8b8;
  --line: rgba(43, 33, 24, 0.16);
  --shadow: rgba(43, 33, 24, 0.22);

  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 14px;
}

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

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 1px 1px, rgba(43,33,24,0.05) 1px, transparent 0) 0 0/22px 22px,
    var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
}

.yard {
  max-width: 620px;
  margin: 0 auto;
  padding: 48px 20px 40px;
}

/* ---------- header ---------- */

.masthead {
  text-align: center;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--red-dark);
  font-weight: 700;
}

.masthead h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(30px, 6vw, 42px);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.tagline {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 14.5px;
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 0 auto 8px;
  width: fit-content;
  background: var(--paper-dark);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.tab {
  appearance: none;
  border: none;
  background: transparent;
  padding: 9px 20px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.tab.active {
  background: var(--red);
  color: var(--paper);
}

.tab:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

/* ---------- stage ---------- */

.stage {
  margin-top: 24px;
}

.mailbox-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.mailbox-svg {
  width: 200px;
  height: auto;
  overflow: visible;
}

.mb-shadow { fill: var(--shadow); opacity: 0.35; }
.mb-post { fill: var(--ink-soft); }
.mb-body {
  fill: var(--red);
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linejoin: round;
}
.mb-slot { fill: var(--red-dark); }

.mb-door-group {
  transition: transform 0.55s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.mb-door {
  fill: var(--red-tint);
  stroke: var(--ink);
  stroke-width: 4;
}
.mailbox-svg.door-open .mb-door-group {
  transform: rotate(-108deg);
}

.mb-flag-group {
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: rotate(0deg);
}
.mb-flag, .mb-flag-blade {
  fill: var(--gold);
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linejoin: round;
}
.mailbox-svg.flag-up .mb-flag-group {
  transform: rotate(-92deg);
}

.envelope {
  opacity: 0;
  transform: translate(102px, 155px) scale(0.4);
  transform-box: fill-box;
}
.env-body {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 3;
}
.env-flap {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linejoin: round;
}

@keyframes envFlyIn {
  0%   { opacity: 1; transform: translate(102px, 20px) scale(0.7); }
  70%  { opacity: 1; transform: translate(102px, 150px) scale(0.55); }
  100% { opacity: 0; transform: translate(102px, 155px) scale(0.4); }
}
@keyframes envFlyOut {
  0%   { opacity: 0; transform: translate(196px, 160px) scale(0.35); }
  25%  { opacity: 1; transform: translate(196px, 150px) scale(0.55); }
  100% { opacity: 1; transform: translate(260px, 90px) scale(0.7) rotate(8deg); }
}
.envelope.fly-in  { animation: envFlyIn 0.9s ease forwards; }
.envelope.fly-out { animation: envFlyOut 0.9s ease forwards; }

.mailbox-svg.idle-bob .mb-body,
.mailbox-svg.idle-bob .mb-post {
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* ---------- panels & fields ---------- */

.panel {
  max-width: 460px;
  margin: 0 auto;
}

.status-line {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14.5px;
  margin: 0 0 20px;
  min-height: 1.4em;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field > span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.address-row {
  display: flex;
  gap: 8px;
}

input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #fff;
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--ink);
}
input[type="text"]::placeholder { color: #b7a98d; }

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-soft);
}
.checkbox-field input { width: 16px; height: 16px; }

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--paper-dark); }
.btn:active { transform: translateY(1px); }

.btn.ghost {
  background: transparent;
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--paper-dark); }

.btn.small { padding: 7px 12px; font-size: 13px; }

.btn.primary {
  background: var(--red);
  border-color: var(--red-dark);
  color: var(--paper);
}
.btn.primary:hover { background: var(--red-dark); }
.btn.primary:disabled {
  background: #cbbfa4;
  border-color: #cbbfa4;
  color: #8a7c60;
  cursor: not-allowed;
}

.btn.big {
  width: 100%;
  padding: 13px 16px;
  font-size: 15px;
  margin-top: 6px;
}

/* ---------- dropzone ---------- */

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  background: rgba(255,255,255,0.4);
  margin-bottom: 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone.dragover {
  border-color: var(--red);
  background: rgba(163,59,46,0.06);
}
.drop-title { margin: 0 0 4px; font-weight: 600; }
.drop-sub { margin: 0 0 10px; color: var(--ink-soft); font-size: 13px; }
.drop-buttons { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- file list ---------- */

.file-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  max-height: 180px;
  overflow-y: auto;
}
.file-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.file-list li:last-child { border-bottom: none; }
.file-list .fname { overflow-wrap: anywhere; }
.file-list .fsize { color: var(--ink-soft); white-space: nowrap; }

/* ---------- progress ---------- */

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--paper-dark);
  border: 1px solid var(--line);
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  transition: width 0.2s ease;
}

/* ---------- result card ---------- */

.result-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--paper-dark);
  border: 1px solid var(--line);
  text-align: center;
}
.result-card p { margin: 0 0 10px; font-size: 14px; color: var(--ink-soft); }

.address-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}
.address-display code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  font-weight: 700;
  background: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.hint {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- footer ---------- */

.footnote {
  text-align: center;
  margin-top: 36px;
  color: var(--ink-soft);
  font-size: 12px;
}

@media (max-width: 480px) {
  .yard { padding: 32px 14px 28px; }
  .address-row { flex-direction: column; }
  .drop-buttons { flex-direction: column; }
}
