:root {
  --black: #050505;
  --near: #0d0d0d;
  --panel: #141414;
  --panel-2: #1f1f1f;
  --tile-glass: rgba(20, 20, 20, 0.72);
  --tile-glass-strong: rgba(31, 31, 31, 0.76);
  --text: #f4f4f4;
  --muted: #aaaaaa;
  --dim: #777;
  --line: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.44);
  --bar-h: 78px;
  --gap: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--black);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

img,
video {
  max-width: 100%;
}

.app {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) calc(var(--bar-h) + var(--safe-bottom));
  width: 100%;
  max-width: 1180px;
  height: 100vh;
  margin: 0 auto;
  padding: calc(8px + var(--safe-top)) calc(10px + var(--safe-right)) 10px calc(10px + var(--safe-left));
  overflow: hidden;
}

.particle-field {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.72;
  mix-blend-mode: screen;
}

@supports (height: 100svh) {
  .app {
    height: 100svh;
  }
}

@supports (height: 100dvh) {
  .app {
    height: 100dvh;
  }
}

.bottombar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 8px;
  padding-bottom: var(--safe-bottom);
  padding-left: 0;
  padding-right: 0;
  border-top: 1px solid var(--line);
  box-sizing: border-box;
  width: 100%;
}

.brand {
  position: relative;
  display: grid;
  place-items: center;
  justify-content: center;
  flex-grow: 1;
  width: 100%;
  max-width: 720px;
  height: 58px;
  min-width: 0;
  overflow: hidden;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--tile-glass);
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: max-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Match home view content width */
.app:has(.screen[data-view="home"].active) .brand {
  max-width: 420px;
}

/* Match get view content width */
.app:has(.screen[data-view="get"].active) .brand {
  max-width: 560px;
}

/* Match how/board view content width */
.app:has(.screen[data-view="how"].active) .brand,
.app:has(.screen[data-view="board"].active) .brand {
  max-width: 900px;
}


.mega-tile span,
.action-tile span,
.info-tile span,
.key-tile,
.option-tile {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--near);
  color: var(--text);
  font-weight: 950;
}

.asset-icon {
  width: 76%;
  height: 76%;
  object-fit: contain;
  filter: grayscale(1);
}

.has-asset {
  font-size: 0;
}

.brand-title {
  position: relative;
  z-index: 1;
  display: block;
  font-size: clamp(24px, 5vw, 42px);
  font-weight: 950;
  line-height: 1;
}

.brand-bg-source {
  display: none !important;
}

.status {
  position: fixed;
  top: 8px;
  left: 50%;
  z-index: 40;
  width: calc(100vw - 20px);
  max-width: 420px;
  min-height: 38px;
  padding: 9px 11px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--near);
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.status.success,
.status.working,
.status.error {
  border-color: var(--line-strong);
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 0;
  overflow: hidden;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.screen.active {
  display: grid;
  gap: var(--gap);
  align-content: stretch;
}

.screen[data-view="send"].active,
.screen[data-view="get"].active {
  grid-template-rows: minmax(0, 1fr);
}

.screen[data-view="pin"].active,
.screen[data-view="code"].active,
.screen[data-view="getpin"].active {
  align-content: stretch;
  grid-template-rows: minmax(0, 1fr);
}

.screen[data-view="send"].active.has-files {
  align-content: start;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: auto;
}

.screen[data-view="send"].active.has-files.has-result {
  align-content: start;
  grid-template-rows: auto auto auto;
  overflow: auto;
}

.screen[data-view="get"].active.has-result {
  align-content: stretch;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.screen[data-view="get"].active.has-result > .get-grid {
  display: none;
}

.screen[data-view="get"].active.has-result > .result-panel {
  height: 100%;
  overflow: auto;
}

.screen[data-view="send"].active > .tile-grid,
.screen[data-view="get"].active > .tile-grid,
.screen[data-view="when"].active > .tile-grid,
.screen[data-view="how"].active > .tile-grid {
  height: 100%;
}

.screen[data-view="send"].active.has-files > .tile-grid {
  height: auto;
  overflow: visible;
}

.mega-tile,
.action-tile,
.info-tile,
.option-tile,
.key-tile,
.pin-readout,
.result-panel,
.files-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--tile-glass);
  color: var(--text);
}

.mega-tile,
.action-tile,
.info-tile,
.option-tile,
.key-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 0;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease, opacity 140ms ease;
}

.mega-tile > *,
.action-tile > *,
.info-tile > *,
.option-tile > *,
.key-tile > * {
  position: relative;
  z-index: 1;
}

.mega-tile.has-bg::before,
.action-tile.has-bg::before,
.info-tile.has-bg::before,
.brand.has-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: linear-gradient(rgba(20, 20, 20, 0.56), rgba(20, 20, 20, 0.72)), var(--tile-bg);
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  background-size: cover, contain;
  filter: grayscale(1) contrast(1.15);
  opacity: 0.42;
}

.mega-tile.has-bg::after,
.action-tile.has-bg::after,
.info-tile.has-bg::after,
.brand.has-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.038) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: 0.24;
  pointer-events: none;
}

.mega-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.4vw, 10px);
  padding: clamp(10px, 2.6vw, 22px);
  text-align: center;
}

.mega-tile > span,
.action-tile > span,
.info-tile > span {
  position: absolute;
  inset: 0;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: clamp(60px, 14vw, 100px);
  font-weight: 900;
  opacity: 0.04;
  filter: grayscale(1);
  color: var(--text);
  pointer-events: none;
  z-index: 0;
  user-select: none;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
}

.mega-tile strong,
.mega-tile small,
.action-tile strong,
.action-tile small,
.info-tile strong,
.info-tile small {
  position: relative;
  z-index: 1;
}


.mega-tile strong {
  font-size: clamp(20px, 5.8vw, 54px);
  line-height: 0.9;
  overflow-wrap: anywhere;
}

.mega-tile small,
.action-tile small,
.info-tile small,
.media-card span,
.panel-title span {
  color: var(--muted);
}

.tile-grid {
  display: grid;
  gap: var(--gap);
  min-height: 0;
  align-content: start;
  overflow: auto;
  scrollbar-width: none;
}

.tile-grid::-webkit-scrollbar {
  display: none;
}

.send-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: auto;
  justify-self: center;
  width: 100%;
  max-width: 720px;
}

.get-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: auto;
  justify-self: center;
  width: 100%;
  max-width: 560px;
}

.option-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  justify-self: center;
  width: 100%;
  max-width: 720px;
}
.option-tile[data-board-expire-seconds="local"] {
  grid-column: 1 / -1;
}

.screen[data-view="boardtime"] .option-tile {
  min-height: 72px;
  aspect-ratio: auto;
}

.how-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  justify-self: center;
  width: 100%;
  max-width: 900px;
}

.action-tile,
.info-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: clamp(12px, 2.6vw, 20px);
  text-align: center;
}

.note-tile {
  display: grid;
  grid-template-rows: minmax(0, 0.7fr) auto minmax(0, 1fr);
  align-items: center;
  justify-items: center;
}

.action-tile input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.action-tile strong,
.info-tile strong {
  font-size: clamp(18px, 3.2vw, 34px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.action-tile small,
.info-tile small {
  font-size: clamp(12px, 1.6vw, 16px);
  line-height: 1.25;
}

.action-tile.active,
.action-tile.dragging,
.option-tile.active,
.key-tile:active,
.primary-action {
  border-color: var(--line-strong);
  background: var(--tile-glass-strong);
}

.mega-tile:active,
.action-tile:active,
.info-tile:active,
.option-tile:active,
.key-tile:active {
  transform: scale(0.985);
}

.mega-tile:focus-visible,
.action-tile:focus-visible,
.info-tile:focus-visible,
.option-tile:focus-visible,
.key-tile:focus-visible,
.button:focus-visible,
.brand:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.screen[data-view="send"]:not(.can-synk) .primary-action {
  border-color: var(--line);
  background: var(--panel);
  color: var(--muted);
}

.screen[data-view="send"].can-synk .primary-action {
  border-color: var(--text);
}

.button.primary {
  border-color: var(--text);
  background: var(--panel-2);
  color: var(--text);
}

.home-action {
  border-color: var(--line-strong);
}

.scan-action {
  grid-column: 1 / -1;
  aspect-ratio: 2 / 1;
  border-color: var(--line-strong);
}

.note-tile textarea {
  width: 100%;
  min-height: 0;
  max-height: 100%;
  padding: 8px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--near);
  color: var(--text);
  font-weight: 700;
  line-height: 1.25;
}

.screen[data-view="send"].active.has-files .send-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 560px;
}

.screen[data-view="send"].active.has-files .action-tile {
  gap: 5px;
  padding: 8px;
}

.screen[data-view="send"].active.has-files .action-tile strong {
  font-size: clamp(16px, 5vw, 26px);
}

.screen[data-view="send"].active.has-files .action-tile small {
  font-size: 11px;
}

.screen[data-view="send"].active.has-files .note-tile textarea {
  min-height: 34px;
  padding: 6px;
}

.files-panel,
.result-panel {
  display: grid;
  gap: 8px;
  min-height: 0;
  padding: 10px;
  overflow: auto;
  scroll-margin-top: 8px;
}

.panel-title,
.file-row,
.button-row,
.code-grid {
  display: grid;
  gap: 8px;
}

.panel-title {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.media-card {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.download-panel {
  align-content: start;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  border-radius: 12px;
  background: rgba(20, 20, 20, 0.86);
}

.download-head {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  min-width: 0;
  max-width: 100%;
}

.download-stat,
.download-action,
.download-all {
  gap: 5px;
  min-width: 0;
  max-width: 100%;
  padding: 10px;
  overflow: hidden;
  aspect-ratio: 2.25 / 1;
  border-color: var(--line-strong);
}

.download-stat strong,
.download-action strong,
.download-all strong {
  font-size: clamp(16px, 4.5vw, 28px);
  line-height: 1;
}

.download-stat small,
.download-action small,
.download-all small {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(10px, 2.6vw, 14px);
  line-height: 1.15;
  text-overflow: ellipsis;
}

.download-files {
  display: grid;
  gap: var(--gap);
  min-width: 0;
  max-width: 100%;
  min-height: 0;
}

.download-card {
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 10px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--panel);
}

.download-card .media-thumb {
  max-height: min(42vh, 360px);
  border-radius: 8px;
}

.download-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 8px 2px 2px;
}

.download-meta strong {
  overflow-wrap: anywhere;
  font-size: clamp(14px, 3.6vw, 20px);
}

.download-meta span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.download-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  min-width: 0;
  max-width: 100%;
}

.download-all {
  width: 100%;
  min-height: 74px;
  aspect-ratio: auto;
}

.media-card.previewable {
  cursor: zoom-in;
}

.media-card strong {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.15;
}

.media-card span {
  font-size: 12px;
}

.media-thumb {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: clamp(170px, 34vh, 320px);
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--black);
}

.file-symbol {
  font-weight: 950;
}

.remove-file,
.button {
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--near);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.file-list {
  display: grid;
  gap: 6px;
}

.file-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.file-row span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.pin-board {
  display: grid;
  grid-template-rows: minmax(54px, 0.55fr) minmax(0, 4fr) minmax(70px, 0.8fr);
  gap: 8px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.pin-readout {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 6px 10px;
  overflow: hidden;
  font-size: clamp(22px, 7vw, 54px);
  font-weight: 950;
  line-height: 1;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.key-tile {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  min-height: 0;
  font-size: clamp(22px, 5.8vw, 48px);
}

.option-tile {
  padding: clamp(8px, 2.5vw, 14px);
  font-size: clamp(18px, 4.6vw, 42px);
  line-height: 1;
  text-align: center;
  overflow-wrap: anywhere;
}

.check-tile {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  min-height: 0;
  border-color: var(--text);
  background: var(--panel-2);
}

.check-tile strong {
  display: block;
  color: var(--text);
  font-size: clamp(28px, 7vw, 58px);
  line-height: 0.9;
}

.check-tile small {
  display: block;
  color: var(--muted);
  font-size: clamp(12px, 2.8vw, 18px);
  line-height: 1.1;
}

.code-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.code-grid div,
.link-box,
.note-display {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--near);
}

.code-grid span,
.note-display strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.code-grid strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(24px, 4vw, 42px);
}

.link-box,
.note-display p {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

/* MD/text clone: received text/markdown keeps its formatting + stays readable */
.note-display p {
  white-space: pre-wrap;
  color: #f4f4f4;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.5;
  max-height: 60vh;
  overflow-y: auto;
  margin: 0;
}

/* Received and board text remain true text surfaces on touch devices. */
.selectable-text,
.selectable-text * {
  -webkit-user-select: text;
  user-select: text;
}

.selectable-text {
  -webkit-touch-callout: default;
  touch-action: pan-y pinch-zoom;
  cursor: text;
}

.selectable-text::selection,
.selectable-text *::selection {
  background: var(--text);
  color: var(--black);
}

/* MD/text clone: hero paste box on SEND */
.hero-paste {
  grid-column: 1 / -1;     /* full-width row; it's now FIRST in the DOM so no order hack */
  display: block;          /* block so the textarea height defines the row cleanly */
  text-align: left;
  min-height: 0;
}
.hero-paste > strong { display: block; margin-bottom: 6px; }
.hero-paste .paste-btn { margin-top: 8px; }
.hero-paste > strong { color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.hero-paste textarea {
  flex: none;              /* fixed height so it can't overflow its grid cell */
  height: 30vh;
  min-height: 120px;
  max-height: 320px;
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
  background: var(--near);
  color: #f4f4f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}
.paste-btn {
  align-self: flex-start;
  background: var(--near);
  color: #f4f4f4;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  min-height: 44px;
  font-size: 13px;
  cursor: pointer;
}
.paste-btn:hover { border-color: #888; }
.secondary-tile { opacity: .72; }

/* MD/text clone: rendered-markdown preview on GET */
.md-rendered {
  white-space: normal;
  color: #f4f4f4;
  font-size: 14px;
  line-height: 1.55;
  max-height: 60vh;
  overflow-y: auto;
  text-align: left;
}
.md-rendered h1, .md-rendered h2, .md-rendered h3,
.md-rendered h4, .md-rendered h5, .md-rendered h6 { margin: .6em 0 .3em; line-height: 1.25; }
.md-rendered p { margin: .5em 0; white-space: normal; font-family: inherit; color: #f4f4f4; font-size: 14px; }
.md-rendered ul, .md-rendered ol { margin: .4em 0 .4em 1.2em; }
.md-rendered code { background: var(--near); padding: 1px 4px; border-radius: 4px; font-family: ui-monospace, Menlo, monospace; font-size: .9em; }
.md-rendered pre { background: var(--near); padding: 10px; border-radius: 8px; overflow-x: auto; }
.md-rendered pre code { background: none; padding: 0; }
.md-rendered blockquote { margin: .5em 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.md-rendered a { color: #6cb6ff; }
.md-rendered hr { border: none; border-top: 1px solid var(--line); margin: .8em 0; }

/* MD/text clone: cohesive, monadic result state. After SYNK, mirror the GET
   screen — collapse the compose form and show ONLY the result panel (code /
   PIN / link / QR). One focused thing, no tile/paste-box overlap, and SEND now
   behaves consistently with GET. Tap the SYNKS·MD bar to start another.
   (Live-test + cohesion pass 2026-05-29) */
.screen[data-view="send"].active.has-files.has-result {
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}
.screen[data-view="send"].active.has-files.has-result > .tile-grid,
.screen[data-view="send"].active.has-files.has-result > .files-panel {
  display: none;
}
.screen[data-view="send"].active.has-result > .result-panel {
  height: 100%;
  overflow: auto;
}

/* MD/text clone — EQUAL-TILE MONAD LAYOUT (the original's design philosophy):
   SEND tiles are equal cells SIZED BY THE SCREEN (1fr rows + columns), so they
   always fill the viewport — no overlap, no scroll — on mobile or any screen.
   The shared .action-tile aspect-ratio:1/1 is dropped here so the grid's
   definite 1fr rows size the tiles (that is what makes them equal AND fit). */
.screen[data-view="send"].active {
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}
.screen[data-view="send"].active > .tile-grid {
  height: 100%;
  overflow: hidden;
}
.send-grid,
.get-grid,
.board-grid {
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  align-content: stretch;
  height: 100%;
}
.send-grid > .action-tile,
.get-grid > .action-tile,
.board-grid > .action-tile {
  aspect-ratio: auto;   /* fill the grid cell, not a fixed square */
  min-height: 0;
  height: auto;
}
.screen[data-view="board"].active,
.screen[data-view="boardjoin"].active,
.screen[data-view="boardcreate"].active,
.screen[data-view="boardtime"].active {
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}
.board-grid > .action-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.join-field { gap: 6px; }
.join-field input {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 22px;
  padding: 8px 4px;
  text-align: center;
  font-family: ui-monospace, Menlo, monospace;
  letter-spacing: .1em;
  margin-top: 8px;
  outline: none;
}
/* Paste box: full-width, two rows tall for comfortable typing, textarea fills
   it. SYNK: full-width. Both stay equal members of the screen-filling grid. */
.hero-paste {
  grid-column: 1 / -1;
  grid-row: span 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.hero-paste textarea {
  flex: 1;
  min-height: 44px;
  height: auto;
  max-height: none;
  resize: none;
}
.send-grid > .primary-action { grid-column: 1 / -1; }

.qr {
  justify-self: center;
  width: 160px;
  max-width: 100%;
  padding: 8px;
  border-radius: 8px;
  background: #fff;
  filter: grayscale(1);
}

.button-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.button-row .button:last-child:nth-child(odd),
.button.wide {
  grid-column: 1 / -1;
}

/* ===== Shared BOARD view ===== */
.screen[data-view="boardview"].active { grid-template-rows: minmax(0, 1fr); overflow: hidden; }
.screen[data-view="boardview"].active > .board-wrap { height: 100%; }
.board-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: 8px; padding: 4px; box-sizing: border-box; }
.board-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.board-id { display: flex; gap: 6px 14px; align-items: baseline; justify-content: center; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.board-id strong { color: var(--text); font-size: 15px; letter-spacing: .06em; font-family: ui-monospace, Menlo, monospace; }
.board-timer { display: flex; gap: 6px; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.board-timer strong { color: var(--text); font-size: 15px; font-family: ui-monospace, Menlo, monospace; letter-spacing: .04em; }
.board-timer .bbtn { min-height: 44px; padding: 4px 10px; font-size: 11px; min-width: 50px; }
.board-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.bbtn { background: var(--tile-glass); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 64px; min-height: 44px; font-size: 13px; font-weight: 850; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: border-color 140ms ease, background 140ms ease; }
.bbtn:hover { border-color: var(--line-strong); }
.bbtn.primary { background: var(--panel-2); border-color: var(--line-strong); }
.bbtn.danger { border-color: var(--line-strong); color: var(--muted); }
.bbtn.danger:hover { color: var(--text); }
.board-share { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--tile-glass); }
.bshare-ids { display: flex; gap: 28px; text-align: center; }
.bshare-ids span { display: block; font-size: 11px; color: var(--muted); }
.bshare-ids strong { font-size: 20px; font-family: ui-monospace, Menlo, monospace; letter-spacing: .08em; }
.board-feed { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px; }
.board-empty { color: var(--muted); text-align: center; margin: auto; padding: 20px; font-size: 14px; }
.board-entry {
  border: 1px solid var(--line);
  border-radius: 12px;
  border-bottom-left-radius: 2px;
  background: var(--tile-glass);
  padding: 8px 12px;
  align-self: flex-start;
  max-width: 85%;
  min-width: 140px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.board-entry.is-me {
  align-self: flex-end;
  border-color: var(--line-strong);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 2px;
  background: var(--tile-glass-strong);
}
.board-entry.is-me .be-head {
  flex-direction: row-reverse;
}
.board-entry.is-me .be-when {
  margin-left: 0;
  margin-right: auto;
}
.be-head { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.be-who { font-weight: 600; text-transform: uppercase; }
.be-when { margin-left: auto; }
.be-copy { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; font-size: 11px; cursor: pointer; }
.be-copy:hover { color: var(--text); border-color: var(--line-strong); }
.be-body { color: var(--text); }
.board-raw { white-space: pre-wrap; word-break: break-word; margin: 0; font-family: ui-monospace, Menlo, monospace; font-size: 13px; line-height: 1.5; color: var(--text); }
.board-compose { display: flex; flex-direction: column; gap: 6px; }
.board-compose input { width: 100%; min-height: 44px; box-sizing: border-box; background: var(--near); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; outline: none; transition: border-color 0.15s ease; }
.board-compose input:focus { border-color: var(--line-strong); }
.board-compose textarea { width: 100%; box-sizing: border-box; height: 84px; min-height: 44px; max-height: 180px; resize: vertical; background: var(--near); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; line-height: 1.5; }
.board-compose-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* Mutual Matches display in the board */
.board-matches {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--tile-glass-strong);
}
.match-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--near);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}
.match-card strong {
  color: var(--text);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.match-card span {
  color: var(--muted);
  font-size: 13px;
  font-family: ui-monospace, Menlo, monospace;
  word-break: break-all;
  user-select: all;
}
.match-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
}
.match-heart {
  color: var(--line-strong);
}

/* Q-NOTES — structured note composer + note entries on the board */
.board-note { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--tile-glass-strong); padding: 8px; }
.board-note input { min-height: 44px; background: var(--black); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; font-weight: 600; outline: none; }
.board-note textarea { width: 100%; box-sizing: border-box; height: 90px; min-height: 44px; max-height: 200px; resize: vertical; background: var(--black); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; line-height: 1.5; }
.board-note-fields { display: flex; flex-direction: column; gap: 6px; }
.board-note-fields input { min-height: 44px; background: var(--black); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px; outline: none; }
.board-note-fields textarea { width: 100%; box-sizing: border-box; height: 72px; min-height: 44px; max-height: 160px; resize: vertical; background: var(--black); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.board-entry.is-note { border-color: var(--line-strong); background: var(--tile-glass-strong); }
.be-note { background: var(--panel-2); color: var(--text); font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 5px; letter-spacing: .06em; border: 1px solid var(--line-strong); }
/* Files in the board — pending-attach chips + entry attachments */
.board-attach { display: flex; flex-wrap: wrap; gap: 6px; }
.battach { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; background: var(--black); border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px 3px 10px; font-size: 12px; }
.battach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.battach-size { color: var(--muted); font-size: 11px; }
.battach-x { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; background: transparent; color: var(--muted); border: none; cursor: pointer; font-size: 15px; line-height: 1; padding: 0; }
.battach-x:hover { color: var(--text); }
.be-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.be-file { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; background: var(--black); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font-size: 12px; color: var(--text); text-decoration: none; }
.be-file:hover { border-color: var(--line-strong); }
.be-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.be-file-meta { color: var(--muted); font-size: 11px; }
.be-file-img { flex-direction: column; align-items: flex-start; padding: 4px; gap: 4px; }
.be-file-img img { display: block; max-width: 220px; max-height: 200px; border-radius: 5px; object-fit: cover; }
.be-file-img .be-file-meta { padding: 0 4px 2px; }
/* Notes/Pastes filter (segmented) */
.board-filter { display: flex; gap: 4px; justify-content: center; }
.bfilt { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 64px; min-height: 44px; font-size: 12px; font-weight: 850; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: border-color 140ms ease, background 140ms ease; }
.bfilt.active { background: var(--near); color: var(--text); border-color: var(--line-strong); }

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 10px;
}

.scanner-viewer {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  padding: 10px;
}

.scanner-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.86);
}

.scanner-sheet {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  width: min(100%, 560px);
  height: min(100%, 720px);
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel);
}

.scanner-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--black);
}

.scanner-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-frame {
  position: absolute;
  inset: 18%;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 16px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.scanner-frame::before,
.scanner-frame::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  height: 1px;
  background: rgba(255, 255, 255, 0.72);
}

.scanner-frame::before {
  top: 50%;
}

.scanner-frame::after {
  top: calc(50% + 10px);
  opacity: 0.4;
}

.scanner-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.viewer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.82);
}

.viewer-sheet {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  height: 100%;
  max-width: 980px;
  max-height: 92vh;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel);
}

.viewer-stage {
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--black);
  touch-action: none;
}

.viewer-media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform: translate(var(--pan-x, 0px), var(--pan-y, 0px)) scale(var(--zoom, 1));
  transform-origin: center;
  cursor: grab;
  user-select: none;
}

.viewer-media:active {
  cursor: grabbing;
}

.screen[data-view="home"].active {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  align-content: stretch;
  justify-self: center;
  margin: 0 auto;
  width: 100%;
  height: 100%;
  max-width: 420px;
}

.screen[data-view="home"] .mega-tile {
  aspect-ratio: auto;
  min-height: 0;
}

.screen[data-view="how"] .info-tile {
  appearance: none;
  border-color: var(--line);
  /* Fill the grid rows instead of forcing a square — a square tile is taller
     than its 1fr row on short windows, which made the bottom row overlap and
     hide behind the footer. Same treatment as the home tiles. */
  aspect-ratio: auto;
  min-height: 0;
}

.hold-menu {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: end center;
  padding: 12px;
}

.hold-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.72);
}

.hold-sheet {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--gap);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel);
}

.hold-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

.hold-grid .option-tile {
  display: grid;
  align-content: center;
  gap: 6px;
  font-size: clamp(14px, 4vw, 22px);
}

.hold-grid .option-tile small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

@media (max-width: 760px) {
  :root {
    --bar-h: 72px;
    --gap: 7px;
  }

  .app {
    width: 100%;
    padding: calc(6px + var(--safe-top)) calc(7px + var(--safe-right)) 7px calc(7px + var(--safe-left));
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  textarea:not([readonly]),
  select {
    font-size: 16px;
  }

  .brand {
    height: 54px;
  }

  .brand-title {
    font-size: 24px;
  }

  .status {
    width: calc(100vw - 14px);
    max-width: 360px;
    min-height: 34px;
    padding: 8px;
    font-size: 12px;
  }

  .send-grid,
  .get-grid,
  .option-grid,
  .how-grid,
  .hold-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option-grid {
    grid-auto-rows: minmax(0, 1fr);
  }

  .send-grid,
  .option-grid {
    width: 100%;
    max-width: 560px;
  }

  .screen[data-view="send"].active.has-files .send-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .screen[data-view="send"].active.has-files .action-tile {
    aspect-ratio: 1 / 0.86;
  }

  .pin-board {
    grid-template-rows: minmax(48px, 0.5fr) minmax(0, 4.4fr) minmax(64px, 0.78fr);
    gap: 6px;
  }

  .numpad {
    gap: 6px;
  }

  .pin-readout {
    font-size: clamp(22px, 7.5vw, 42px);
  }

  .key-tile {
    font-size: clamp(22px, 7vw, 38px);
  }

  .check-tile strong {
    font-size: clamp(28px, 8vw, 46px);
  }

  .scan-action {
    aspect-ratio: 2 / 0.82;
  }

  .files-panel,
  .result-panel {
    padding: 8px;
  }

  .download-panel {
    gap: 7px;
  }

  .download-stat,
  .download-action {
    aspect-ratio: 2 / 0.82;
    padding: 8px;
  }

  .download-card {
    padding: 8px;
  }

  .download-card .media-thumb {
    max-height: min(38vh, 300px);
  }

  .preview-grid {
    grid-template-columns: 1fr;
  }

  .media-thumb {
    max-height: clamp(170px, 30vh, 260px);
  }

  .how-grid {
    width: 100%;
  }

  .mega-tile,
  .action-tile,
  .info-tile {
    padding: 9px;
  }

  .mega-tile strong {
    font-size: clamp(24px, 12vw, 52px);
  }

  .action-tile strong,
  .info-tile strong {
    font-size: clamp(20px, 7vw, 34px);
  }

  .mega-tile span,
  .action-tile span,
  .info-tile span {
    width: 34px;
    height: 34px;
  }
}

@media (orientation: landscape) {
  .screen[data-view="home"].active {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    max-width: 900px;
  }

  .screen[data-view="home"] .mega-tile {
    aspect-ratio: auto;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .screen[data-view="send"].active > .tile-grid {
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .send-grid {
    grid-auto-rows: minmax(64px, auto);
    align-content: start;
  }

  .send-grid > .action-tile {
    min-height: 64px;
  }

  .hero-paste {
    min-height: 135px;
  }

  .screen[data-view="when"] .option-tile,
  .screen[data-view="boardtime"] .option-tile,
  .hold-grid .option-tile {
    min-height: 64px;
    aspect-ratio: auto;
  }

  .pin-board {
    grid-template-rows: 44px minmax(188px, 1fr) 44px;
    gap: 4px;
  }

  .numpad {
    gap: 4px;
  }

  .key-tile,
  .check-tile {
    min-height: 44px;
    aspect-ratio: auto;
  }
}

@media (max-width: 420px) {
  :root {
    --gap: 6px;
  }

  .mega-tile small,
  .action-tile small,
  .info-tile small {
    font-size: 10px;
  }

  .note-tile textarea {
    font-size: 12px;
  }

  .brand-title {
    font-size: 24px;
  }
}

.how-trigger {
  position: absolute;
  right: clamp(12px, 3.2vw, 30px);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--tile-glass);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  box-sizing: border-box;
  z-index: 5;
}

.how-trigger:hover,
.how-trigger:focus-visible {
  border-color: var(--line-strong);
  background: var(--tile-glass-strong);
}

.how-trigger:active {
  transform: scale(0.95);
}
