:root {
  --bg: #f6f7f9; --fg: #1d2330; --muted: #667085; --card: #fff; --line: #e1e5ec;
  --accent: #2563eb; --accent-fg: #fff; --danger: #c62828; --ok: #1b7f3b; --warn: #a15c00;
  --tap: 2.75rem; /* minimum touch target */
  --pad: max(1rem, env(safe-area-inset-left));
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11141a; --fg: #e6e9ef; --muted: #98a2b3; --card: #1a1f29; --line: #2b3240; --accent: #5b8cff; --accent-fg: #0b1020; --danger: #ff6b6b; --ok: #4cc37a; --warn: #e0a64a; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--fg);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; overflow-wrap: break-word;
}
main { max-width: 56rem; margin: 0 auto; padding: 1rem var(--pad) calc(3rem + env(safe-area-inset-bottom)); }
a { color: var(--accent); }
h1 { font-size: 1.4rem; line-height: 1.25; margin: .5rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
code { background: var(--line); padding: 0 .3em; border-radius: 4px; }
.muted { color: var(--muted); font-size: .9rem; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
button, .btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* Header */
.bar {
  position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0 1rem; padding: .25rem var(--pad); padding-top: max(.25rem, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.bar nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; padding-bottom: .5rem; }
.bar .nav-toggle:checked ~ nav { display: flex; }
.bar nav form { margin: 0; }
.bar nav a, .bar nav .link { display: flex; align-items: center; justify-content: center; width: 100%; min-height: var(--tap); padding: 0 .6rem; text-decoration: none; border-top: 1px solid var(--line); text-align: center; }
.brand { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 700; text-decoration: none; color: var(--fg); }

/* Hamburger: a checkbox drawn as a button, so it works without JavaScript */
.nav-toggle {
  -webkit-appearance: none; appearance: none; flex: none; width: var(--tap); height: var(--tap);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background-color: var(--card); background-repeat: no-repeat;
  background-image: linear-gradient(var(--fg), var(--fg)), linear-gradient(var(--fg), var(--fg)), linear-gradient(var(--fg), var(--fg));
  background-size: 1.3rem 2px, 1.3rem 2px, 1.3rem 2px;
  background-position: center 30%, center 50%, center 70%;
}
.nav-toggle:checked {
  background-image: linear-gradient(45deg, transparent 45%, var(--fg) 45%, var(--fg) 55%, transparent 55%), linear-gradient(-45deg, transparent 45%, var(--fg) 45%, var(--fg) 55%, transparent 55%);
  background-size: 1.3rem 1.3rem, 1.3rem 1.3rem;
  background-position: center, center;
}

/* Cards and layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.card.narrow { max-width: 26rem; margin: 1.5rem auto; }
.head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: space-between; align-items: center; }
.head h1 { margin: 0; }

/* Forms: 16px inputs so iOS does not zoom on focus */
label { display: block; margin-bottom: 1rem; font-size: .9rem; color: var(--muted); }
label.check { display: flex; gap: .6rem; align-items: center; min-height: var(--tap); margin: 0; }
label.check input { width: 1.25rem; height: 1.25rem; }
input:not([type=checkbox]):not([type=file]), textarea, select {
  display: block; width: 100%; min-height: var(--tap); margin-top: .25rem; padding: .6rem .75rem;
  font: inherit; font-size: 1rem; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
textarea { resize: vertical; }
.row { display: flex; gap: .5rem; align-items: center; justify-content: center; margin-top: .25rem; }
.row > input { flex: 1; min-width: 0; margin-top: 0; }
.row > select { flex: none; width: auto; margin-top: 0; }
.row.wrap { flex-wrap: wrap; margin-top: 1rem; }
.grid2 { display: grid; gap: 0 1rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 1rem;
  font: inherit; font-size: 1rem; color: var(--fg); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.btn.danger, .link.danger { color: var(--danger); }
.btn.small { min-height: 2.5rem; padding: 0 .8rem; font-size: .9rem; }
form > .btn.primary { width: 100%; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }

.msg { padding: .6rem .8rem; border-radius: 10px; margin: 0 0 1rem; }
.msg.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.msg.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge { display: inline-block; font-size: .75rem; line-height: 1.4; padding: 0 .5rem; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); vertical-align: middle; }
.badge.warn { color: var(--warn); border-color: var(--warn); }

/* Share list: stacked cards on phones, table from tablet width up */
table.shares { margin-top: 10px; }
table.shares, table.shares tbody, table.shares tr, table.shares td { display: block; }
table.shares thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
table.shares tr { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .75rem 1rem; margin-bottom: .75rem; }
table.shares td { padding: .15rem 0; font-size: .92rem; }
table.shares td.title { font-size: 1.05rem; font-weight: 600; padding-bottom: .35rem; }
table.shares td[data-label] { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); text-align: right; }
table.shares td[data-label]::before { content: attr(data-label); text-align: left; }
table.shares td.actions { display: flex; gap: .5rem; padding-top: .6rem; }
table.shares td.actions .btn { flex: 1; }

/* File lists */
.icon { width: 1.4rem; height: 1.4rem; flex: none; color: var(--muted); }
.icon.big { width: 2.4rem; height: 2.4rem; color: inherit; }
ul.files { list-style: none; margin: 0; padding: 0; }
ul.files li {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: .75rem; align-items: center;
  padding: .6rem 0; border-bottom: 1px solid var(--line);
}
ul.files li:last-child { border-bottom: 0; }
ul.files .icon { grid-row: 1 / 3; align-self: start; margin-top: .15rem; }
ul.files .name { grid-column: 2; overflow-wrap: anywhere; }
ul.files .meta { grid-column: 2; }
ul.files .act { grid-column: 3; grid-row: 1 / 3; min-height: var(--tap); padding: 0 .5rem; }
ul.files li.folder { display: block; font-weight: 600; font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; }
ul.files.card { padding: .25rem 1rem; }
ul.files a.name { display: block; padding: .1rem 0; }

/* Upload */
#dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 1rem; text-align: center; margin-bottom: 1rem; }
#dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
#dropzone .drop-hint { display: none; margin: 0 0 .5rem; }
#dropzone .btn { width: 100%; }
#queue { list-style: none; margin: 0 0 1rem; padding: 0; }
#queue li { display: grid; grid-template-columns: minmax(0, 1fr); gap: .15rem; padding: .5rem 0; font-size: .9rem; border-bottom: 1px solid var(--line); }
#queue progress { width: 100%; height: .6rem; }
#queue .err { color: var(--danger); }

/* Public share page */
.public { max-width: 40rem; margin: 0 auto; }
.public .message { white-space: pre-wrap; }
.download {
  display: flex; align-items: center; justify-content: center; gap: .9rem; padding: 1.25rem 1rem; margin: 1.25rem 0;
  background: var(--accent); color: var(--accent-fg); border-radius: 14px; text-decoration: none;
  font-size: clamp(1.15rem, 5vw, 1.5rem); font-weight: 600; line-height: 1.25;
}
.download small { display: block; font-size: .85rem; font-weight: 400; opacity: .85; }
.download:hover, .download:active { filter: brightness(1.08); }

/* Pointers that can drag and drop get the hint; touch devices just get the button. */
@media (hover: hover) and (pointer: fine) {
  #dropzone .drop-hint { display: block; }
  #dropzone .btn { width: auto; }
}

/* Tablet and up */
@media (min-width: 40rem) {
  .nav-toggle { display: none; }
  .bar nav, .bar .nav-toggle:checked ~ nav { display: flex; flex-basis: auto; flex-direction: row; align-items: center; gap: .25rem; padding-bottom: 0; }
  .bar nav a, .bar nav .link { display: inline-flex; width: auto; border-top: 0; }
  h1 { font-size: 1.6rem; }
  main { padding-top: 1.5rem; }
  .card { padding: 1.25rem; }
  .card.narrow { margin-top: 3rem; }
  .grid2 { grid-template-columns: 1fr 1fr; }
  form > .btn.primary { width: auto; }
  .btn.small { min-height: 2rem; padding: 0 .6rem; }
  ul.files.card { padding: .5rem 1.25rem; }

  table.shares { display: table; width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); }
  table.shares thead { position: static; width: auto; height: auto; overflow: visible; clip-path: none; display: table-header-group; }
  table.shares tbody { display: table-row-group; }
  table.shares tr { display: table-row; background: none; border: 0; border-radius: 0; padding: 0; margin: 0; }
  table.shares th, table.shares td { display: table-cell; padding: .6rem .8rem; border-bottom: 1px solid var(--line); font-size: .92rem; text-align: left; vertical-align: middle; }
  table.shares th { color: var(--muted); font-weight: 500; }
  table.shares td.title { font-size: inherit; font-weight: 400; }
  table.shares td[data-label] { display: table-cell; color: inherit; }
  table.shares td[data-label]::before { content: none; }
  table.shares td.actions { display: table-cell; white-space: nowrap; }
  table.shares td.actions .btn { flex: none; }
}
@media (min-width: 40rem) and (max-width: 63.99rem) {
  /* Narrow tablets: drop the deletion column to avoid horizontal scrolling. */
  table.shares th:nth-child(5), table.shares td:nth-child(5) { display: none; }
}

@media (min-width: 48rem) {
  ul.files li { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  ul.files .icon { grid-row: 1; align-self: center; margin: 0; }
  ul.files .meta { grid-column: 3; white-space: nowrap; }
  ul.files .act { grid-column: 4; grid-row: 1; }
  #queue li { grid-template-columns: minmax(0, 1fr) auto; }
  #queue progress { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
