:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #14201e;
  --muted: #5d6b68;
  --line: #dfe5e3;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --accent-soft: #e2f3f0;
  --danger: #b42318;
  --ok: #15803d;
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1514;
    --card: #172120;
    --text: #e8efed;
    --muted: #9aaba7;
    --line: #2a3836;
    --accent: #2dd4bf;
    --accent-text: #06201d;
    --accent-soft: #15302d;
    --danger: #ff8a7a;
    --ok: #4ade80;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  padding: 24px 16px 48px;
}

.top {
  max-width: 920px;
  margin: 0 auto 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
}

.name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 8px 0 0;
  color: var(--muted);
}

.grid {
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

/* On a phone, show whichever side the visitor came for first. */
#receive-card {
  order: -1;
}

.grid.sending #receive-card {
  order: 1;
}

@media (min-width: 760px) {
  .grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  #receive-card,
  .grid.sending #receive-card {
    order: 1;
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
}

.card-head h2 {
  margin-bottom: 0;
}

label,
.label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.card-head + .label {
  margin-top: 16px;
}

.code-row,
.link-row {
  display: flex;
  gap: 8px;
}

.code-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: 600 1.5rem/1 ui-monospace, 'Cascadia Mono', Consolas, monospace;
  letter-spacing: 0.3em;
  text-align: center;
}

.code-input::placeholder {
  color: var(--line);
}

.btn {
  padding: 0 18px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.link {
  border: 0;
  background: none;
  padding: 0 4px;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.center {
  text-align: center;
}

.error {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 0.92rem;
}

.target {
  margin: 0 0 12px;
}

.target strong {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  letter-spacing: 0.12em;
}

.secure {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.9rem;
}

#receive-secure {
  margin: 16px 0 0;
}

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 28px 16px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--accent);
  text-align: center;
  cursor: pointer;
}

.drop.over,
.drop:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#file-input:focus-visible + .drop,
#picker:focus-within .drop {
  border-color: var(--accent);
}

.drop-title {
  color: var(--text);
  font-weight: 600;
  font-size: 1.05rem;
}

.drop-sub {
  color: var(--muted);
  font-size: 0.9rem;
}

.pill {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.pill.on {
  background: var(--accent-soft);
  color: var(--accent);
}

.my-code {
  margin: 0;
  font: 700 clamp(2.2rem, 11vw, 3rem) / 1.1 ui-monospace, 'Cascadia Mono', Consolas, monospace;
  letter-spacing: 0.16em;
}

.qr-wrap {
  display: grid;
  place-items: center;
  min-height: 224px;
  margin-top: 16px;
}

.qr {
  width: 200px;
  height: 200px;
  padding: 10px;
  border-radius: 12px;
  background: #fff;
  box-sizing: content-box;
  image-rendering: pixelated;
}

.link-row {
  margin-top: 16px;
}

.share-link {
  flex: 1;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
}

.files {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.files:empty {
  display: none;
}

.file {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.file-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.file-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.file.ok .file-meta {
  color: var(--ok);
}

.file.bad .file-meta {
  color: var(--danger);
}

.bar {
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s linear;
}

.file.ok .bar,
.file.bad .bar {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .bar > span {
    transition: none;
  }
}
