:root {
  --bg: #faf7f4;
  --card: #ffffff;
  --text: #1f1a17;
  --muted: #6f655e;
  --line: #e9e1da;
  --accent: #d9702a;
  --accent-text: #ffffff;
  --accent-soft: #fbe9dc;
  --error: #c0392b;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161311;
    --card: #211d1a;
    --text: #f3ede8;
    --muted: #a99e95;
    --line: #362f2a;
    --accent: #f0904a;
    --accent-text: #1a120c;
    --accent-soft: #3a2618;
    --error: #ff7b6b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161311; --card: #211d1a; --text: #f3ede8; --muted: #a99e95; --line: #362f2a;
  --accent: #f0904a; --accent-text: #1a120c; --accent-soft: #3a2618; --error: #ff7b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
main {
  max-width: 440px;
  margin: 0 auto;
  padding: 32px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
header { text-align: center; }
.logo { font-size: 52px; line-height: 1; }
h1 { margin: 8px 0 4px; font-size: 28px; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 19px; }
h2.small { font-size: 15px; font-weight: 600; }
.tagline { margin: 0; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a { color: var(--accent); }

.view { display: flex; flex-direction: column; gap: 14px; }
.view[hidden] { display: none; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.row-text { display: flex; justify-content: space-between; font-size: 14px; }

button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-text);
}
button.secondary, a.button.secondary { background: var(--accent-soft); color: var(--text); }
a.button {
  display: block; text-align: center; text-decoration: none;
  font-weight: 600; border-radius: 999px; padding: 13px 18px;
}
button.text { background: none; color: var(--muted); font-weight: 500; }
button:focus-visible, textarea:focus-visible, .drop:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 32px 16px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { font-size: 28px; color: var(--accent); }
.drop strong { font-size: 18px; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

textarea, .codebox {
  width: 100%;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  resize: vertical;
}
.codebox { word-break: break-all; user-select: all; max-height: 7.5em; overflow: auto; }
.error { color: var(--error); margin: 0; font-size: 14px; }

.qr {
  align-self: center;
  width: min(280px, 100%);
  aspect-ratio: 1;
  padding: 12px;
  background: #fff;
  border-radius: var(--radius);
}
.qr svg { width: 100%; height: 100%; display: block; }

.files { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.files:empty { display: none; }
.files li { display: flex; gap: 12px; justify-content: space-between; padding: 10px 14px; font-size: 14px; }
.files li + li { border-top: 1px solid var(--line); }
.files .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .size { color: var(--muted); flex-shrink: 0; }
.files a { font-weight: 600; }

.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
#bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.big-icon { font-size: 48px; text-align: center; line-height: 1; }
.spinner {
  align-self: center; width: 40px; height: 40px; margin-top: 24px;
  border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.waiting { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; margin: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .spinner, .dot { animation-duration: 3s; } }

footer { text-align: center; margin-top: 8px; }
.loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--muted); font-size: 15px;
}
.loading[hidden] { display: none; }
