/* ═══════════════════════════════════════════════════════════════════════
   Ferry — from the house dot system (franlind-bank → Datum GRID)

   Same discipline: flat OKLCH surface steps, 1px hairlines, exactly two
   shadows, and a dot field the app stands on. A gradient may draw a dot,
   never paint a surface. Accent is a harbour teal (hue 200).

   System fonts on purpose: in offline mode there is no font CDN, and on a
   Mac and an iPhone the system face is San Francisco anyway.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --teal-300: oklch(0.82 0.09 200);
  --teal-400: oklch(0.74 0.12 200);
  --teal-500: oklch(0.64 0.13 205);
  --teal-600: oklch(0.55 0.12 210);
  --teal-700: oklch(0.47 0.1 212);

  --canvas: oklch(0.975 0.004 240);
  --surface: oklch(1 0 0);
  --surface-sunken: oklch(0.96 0.006 240);
  --surface-hover: oklch(0.955 0.008 220);
  --hairline: oklch(0.25 0.02 240 / 0.1);
  --hairline-strong: oklch(0.25 0.02 240 / 0.18);
  --ink: oklch(0.23 0.02 245);
  --ink-soft: oklch(0.46 0.018 245);
  --ink-faint: oklch(0.62 0.014 245);
  --accent: var(--teal-600);
  --accent-ink: oklch(1 0 0);
  --accent-wash: oklch(0.6 0.12 205 / 0.1);
  --good: oklch(0.66 0.15 155);
  --warn: oklch(0.76 0.15 75);
  --bad: oklch(0.6 0.2 25);
  --dot: oklch(0.25 0.02 240 / 0.11);
  --dot-major: oklch(0.55 0.12 210 / 0.22);

  --shadow-lift: 0 1px 2px oklch(0 0 0 / 0.04), 0 8px 24px -10px oklch(0 0 0 / 0.14);
  --shadow-float: 0 2px 4px oklch(0 0 0 / 0.06), 0 24px 56px -16px oklch(0 0 0 / 0.28);

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --pitch: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: oklch(0.175 0.012 245);
    --surface: oklch(0.215 0.014 245);
    --surface-sunken: oklch(0.19 0.012 245);
    --surface-hover: oklch(0.245 0.016 230);
    --hairline: oklch(1 0 0 / 0.08);
    --hairline-strong: oklch(1 0 0 / 0.15);
    --ink: oklch(0.96 0.005 240);
    --ink-soft: oklch(0.75 0.012 240);
    --ink-faint: oklch(0.58 0.014 240);
    --accent: var(--teal-400);
    --accent-ink: oklch(0.17 0.02 230);
    --accent-wash: oklch(0.74 0.12 200 / 0.14);
    --dot: oklch(1 0 0 / 0.075);
    --dot-major: oklch(0.74 0.12 200 / 0.2);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* The canvas: one flat colour under an even dot grid, with a sparser major
   field in the accent so the ground has depth without a painted fade. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(circle at center, var(--dot-major) 1.4px, transparent 1.6px),
    radial-gradient(circle at center, var(--dot) 1px, transparent 1.2px);
  background-size:
    calc(var(--pitch) * 5) calc(var(--pitch) * 5),
    var(--pitch) var(--pitch);
  background-position: calc(var(--pitch) / 2) calc(var(--pitch) / 2);
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
}

::selection {
  background: var(--accent-wash);
}

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

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ─── Shell ─────────────────────────────────────────────────────────── */

.shell {
  max-width: 880px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 18px;
  letter-spacing: -0.01em;
  margin-right: auto;
}

.mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  display: grid;
  grid-template-columns: repeat(3, 4px);
  gap: 3px;
  place-content: center;
}
.mark i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-ink);
  opacity: 0.35;
}
.mark i:nth-child(3n),
.mark i:nth-child(5) {
  opacity: 1;
}

.peers {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.pill b {
  font-weight: 560;
  color: var(--ink);
}
button.pill {
  cursor: pointer;
}
button.pill:hover {
  border-color: var(--hairline-strong);
}

.live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  flex: none;
}
.live.off {
  background: var(--warn);
  animation: blink 1.2s infinite;
}
@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

/* ─── Buttons ───────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  font-weight: 540;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.1s;
}
.btn:hover {
  background: var(--surface-hover);
}
.btn:active {
  transform: scale(0.98);
}
.btn svg {
  width: 17px;
  height: 17px;
  flex: none;
}
.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}
.btn.primary:hover {
  background: var(--teal-500);
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
}
.btn.ghost:hover {
  background: var(--surface-hover);
  color: var(--ink);
}
.btn.icon {
  width: 38px;
  padding: 0;
}
.btn.small {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
}
.btn.small.icon {
  width: 32px;
}
.btn.danger:hover {
  color: var(--bad);
}
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

/* ─── Cards ─────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lift);
}

/* Corner ticks off a drawing sheet — the GRID mark for "this is a place". */
.sheet {
  position: relative;
}
.sheet::before,
.sheet::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--accent);
  pointer-events: none;
  opacity: 0.55;
}
.sheet::before {
  top: -6px;
  left: -6px;
  border-right: 0;
  border-bottom: 0;
}
.sheet::after {
  bottom: -6px;
  right: -6px;
  border-left: 0;
  border-top: 0;
}

/* ─── Pairing ───────────────────────────────────────────────────────── */

.pair {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  padding: 22px;
  margin-bottom: 16px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 8px;
}

.pair h2 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: -0.015em;
  font-weight: 650;
}
.pair p {
  margin: 0;
  color: var(--ink-soft);
}

.code {
  display: flex;
  gap: 6px;
  margin: 16px 0 6px;
  font: 600 30px/1 var(--mono);
  letter-spacing: 0;
}
.code span {
  width: 42px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--hairline);
}
.code span:nth-child(4) {
  margin-left: 10px;
}
.code-life {
  font-size: 12.5px;
  color: var(--ink-faint);
}

.qr {
  width: 156px;
  padding: 12px;
  border-radius: var(--r);
  background: oklch(1 0 0);
  border: 1px solid var(--hairline);
  align-self: start;
  text-align: center;
}
.qr img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}
.qr small {
  display: block;
  margin-top: 8px;
  font-size: 11.5px;
  color: oklch(0.45 0.02 245);
  line-height: 1.3;
}

.join {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 18px;
  border-top: 1px dashed var(--hairline-strong);
}
.join label {
  color: var(--ink-soft);
  font-size: 14px;
  margin-right: auto;
}
.join-row {
  display: flex;
  gap: 8px;
}
.code-input {
  width: 150px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline-strong);
  background: var(--surface-sunken);
  font: 600 19px var(--mono);
  letter-spacing: 0.12em;
  text-align: center;
}
.code-input::placeholder {
  color: var(--ink-faint);
  font-weight: 400;
}

.join-only {
  max-width: 440px;
  margin: 8vh auto 0;
  padding: 28px 24px;
  text-align: center;
}
.join-only .join {
  justify-content: center;
  border: 0;
  padding: 18px 0 0;
}
.join-only .join label {
  margin: 0;
}

/* ─── Composer ──────────────────────────────────────────────────────── */

.composer {
  padding: 8px;
  margin-bottom: 26px;
}

.dropzone {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 20px;
  border-radius: calc(var(--r-lg) - 6px);
  border: 1.5px dashed var(--hairline-strong);
  background: var(--surface-sunken);
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-wash);
}
.dropzone-text {
  flex: 1;
  min-width: 0;
}
.dropzone-text strong {
  display: block;
  font-size: 16px;
  font-weight: 620;
}
.dropzone-text span {
  color: var(--ink-soft);
  font-size: 13.5px;
}

/* A 3×3 dot glyph that "lifts" its centre — the send mark. */
.drop-mark {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--accent-wash);
  position: relative;
}
.drop-mark::before {
  content: '';
  position: absolute;
  inset: 9px;
  background-image: radial-gradient(circle, var(--accent) 2.4px, transparent 2.6px);
  background-size: 9.33px 9.33px;
  opacity: 0.4;
}
.drop-mark::after {
  content: '';
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  animation: lift 2.4s var(--ease) infinite;
}
@keyframes lift {
  0%,
  100% {
    translate: -50% -50%;
  }
  50% {
    translate: -50% -110%;
  }
}

.textrow {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 4px 2px 8px;
}
.textrow textarea {
  flex: 1;
  min-height: 40px;
  max-height: 180px;
  resize: none;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  line-height: 1.4;
}
.textrow textarea:focus {
  outline: 0;
  background: var(--surface-sunken);
  border-color: var(--hairline);
}
.textrow textarea::placeholder {
  color: var(--ink-faint);
}

/* ─── List ──────────────────────────────────────────────────────────── */

.listhead {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 4px 10px;
}
.listhead h3 {
  margin: 0 auto 0 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.items {
  display: grid;
  gap: 8px;
}

.item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 10px 10px 10px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-lift);
  animation: arrive 0.35s var(--ease);
}
.item.fresh {
  border-color: var(--accent);
}
@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}
.item[draggable='true'] {
  cursor: grab;
}

.thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--hairline);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--accent);
  position: relative;
}
.thumb img,
.thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb svg {
  width: 22px;
  height: 22px;
}
.thumb .ext {
  position: absolute;
  bottom: 4px;
  font: 600 8.5px var(--mono);
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  text-transform: uppercase;
}
a.thumb {
  cursor: zoom-in;
}

.body {
  min-width: 0;
}
.name {
  font-weight: 560;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta {
  font-size: 12.5px;
  color: var(--ink-faint);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta .saved {
  color: var(--good);
}

.text {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.text.open {
  -webkit-line-clamp: unset;
  display: block;
}
.text-more {
  border: 0;
  background: none;
  padding: 0;
  font-size: 12.5px;
  color: var(--accent);
  cursor: pointer;
}

.acts {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* Progress: a dotted track (the grid, again) with a flat accent fill. */
.meter {
  position: relative;
  height: 6px;
  margin-top: 7px;
  border-radius: 3px;
  background-image: radial-gradient(circle, var(--hairline-strong) 1.2px, transparent 1.4px);
  background-size: 6px 6px;
  overflow: hidden;
}
.meter i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.3s linear;
}
.meter.wait i {
  background: var(--ink-faint);
}

.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--ink-faint);
}
.empty .dot-scatter {
  margin: 0 auto 12px;
}

.foot {
  margin-top: 34px;
  display: flex;
  gap: 8px 16px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 12.5px;
  color: var(--ink-faint);
}
.foot button {
  border: 0;
  background: none;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
}

/* ─── Overlays ──────────────────────────────────────────────────────── */

#drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  background: oklch(0.2 0.02 240 / 0.28);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  pointer-events: none;
}
#drop-overlay.on {
  display: grid;
}
.drop-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 34px 48px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 2px dashed var(--accent);
  box-shadow: var(--shadow-float);
  font-size: 18px;
}
.drop-card span:last-child {
  font-size: 13.5px;
  color: var(--ink-soft);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: oklch(0.2 0.02 240 / 0.35);
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fade 0.2s;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.dialog {
  width: min(560px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  box-shadow: var(--shadow-float);
}
.dialog .pair {
  margin: 0;
  box-shadow: none;
  border: 0;
}
.dialog-foot {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 0 22px 18px;
}

#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  translate: -50% 0;
  z-index: 60;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--canvas);
  font-size: 14px;
  box-shadow: var(--shadow-float);
  animation: rise 0.3s var(--ease);
}
.toast button {
  border: 0;
  background: none;
  color: var(--teal-300);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Loading: dots, never a spinner. */
.dot-scatter {
  display: block;
  width: 40px;
  height: 10px;
  background-image: radial-gradient(circle, var(--accent) 3px, transparent 3.3px);
  background-size: 13.33px 10px;
  animation: scatter 1s steps(3) infinite;
  mask-image: linear-gradient(90deg, #000 0 33%, transparent 33%);
  -webkit-mask-image: linear-gradient(90deg, #000 0 33%, transparent 33%);
  mask-size: 300% 100%;
  -webkit-mask-size: 300% 100%;
}
@keyframes scatter {
  to {
    mask-position: -150% 0;
    -webkit-mask-position: -150% 0;
  }
}
.boot {
  min-height: 80vh;
  display: grid;
  place-items: center;
}

/* ─── Small screens ─────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .pair {
    grid-template-columns: 1fr;
    padding: 18px;
  }
  .qr {
    display: none;
  }
  .pair.show-qr .qr {
    display: block;
    justify-self: center;
  }
  .code span {
    width: 38px;
    height: 48px;
    font-size: 27px;
  }
  .dropzone {
    padding: 18px 16px;
  }
  .dropzone .drop-mark {
    display: none;
  }
  .dropzone {
    gap: 12px;
  }
  .item {
    grid-template-columns: 46px minmax(0, 1fr) auto;
    gap: 12px;
  }
  .thumb {
    width: 46px;
    height: 46px;
  }
  .acts {
    gap: 2px;
  }
  .acts .lbl {
    display: none;
  }
  .acts .btn.small:not(.icon):has(.lbl) {
    width: 36px;
    padding: 0;
  }
  .acts .btn.small {
    height: 36px;
  }
  .acts .btn.small.icon {
    width: 36px;
  }
  .peers .pill.me {
    display: none;
  }
  .top {
    margin-bottom: 14px;
  }
}

@media (hover: none) {
  .item[draggable='true'] {
    cursor: default;
  }
}

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