/* Share — a carbon-copy clipboard between the owner's devices. */
:root {
  --paper: #f4f5f1;
  --sheet: #ffffff;
  --ink: #24253a;
  --muted: #6b6d83;
  --carbon: #3b3fa0;
  --carbon-deep: #2e3184;
  --carbon-tint: #e6e7f6;
  --rule: #d8dae6;
  --ok: #1f7a4d;
  --bad: #b3261e;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15162a;
    --sheet: #1e2036;
    --ink: #e7e8f4;
    --muted: #a3a5c0;
    --carbon: #7b80e6;
    --carbon-deep: #5c61cf;
    --carbon-tint: #26284a;
    --rule: #34365a;
    --ok: #6fd3a0;
    --bad: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--carbon); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); border: 0;
}

/* ——— Top bar ——— */
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: var(--carbon);
}
.logo { flex: none; width: 34px; height: 34px; border-radius: 9px; display: block; }
.gate-logo { display: block; width: 72px; height: 72px; border-radius: 18px; margin-bottom: 18px; }
.brand { display: flex; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; min-width: 0; }
.usage { margin: 0; font-size: .82rem; color: var(--muted); white-space: nowrap; }
.bar-links { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.link-btn, .portal-back {
  border: 0;
  background: none;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: .9rem;
  color: var(--muted);
  text-decoration: none;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.link-btn:hover, .portal-back:hover { color: var(--carbon); background: var(--carbon-tint); }

.primary {
  border: 0;
  border-radius: 10px;
  background: var(--carbon);
  color: #fff;
  font-weight: 650;
  padding: 10px 18px;
  min-height: 44px;
}
.primary:hover:not(:disabled) { background: var(--carbon-deep); }
.primary:disabled { opacity: .45; cursor: default; }

/* ——— Sign-in ——— */
.gate {
  width: min(100% - 32px, 420px);
  margin: 12vh auto 0;
}
.gate h2 { margin: 0 0 8px; font-size: 1.4rem; }
.gate-lead { margin: 0 0 20px; color: var(--muted); }
.gate-form { display: grid; gap: 14px; }
.gate-form label { display: grid; gap: 6px; font-size: .9rem; color: var(--muted); }
.gate-form input {
  padding: 11px 12px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--sheet);
  font-size: 1rem;
}
.error { color: var(--bad); min-height: 1.4em; margin: 12px 0 0; }

/* ——— App: timeline + docked composer ——— */
.app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
.timeline {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px max(16px, env(safe-area-inset-right)) 20px max(16px, env(safe-area-inset-left));
}
.items {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.older {
  display: block;
  margin: 0 auto 16px;
  border: 1px solid var(--rule);
  background: var(--sheet);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: .88rem;
  color: var(--muted);
}
.empty {
  max-width: 34ch;
  margin: 18vh auto 0;
  text-align: center;
  color: var(--muted);
}
.empty strong { color: var(--ink); font-weight: 600; }

/* One item = meta line, the slip, actions. Mine on the right, other devices on the left. */
.item { display: flex; flex-direction: column; align-items: flex-start; max-width: min(100%, 640px); }
.item.mine { align-self: flex-end; align-items: flex-end; }
.meta { margin: 0 4px 4px; font-size: .78rem; color: var(--muted); }

.slip {
  max-width: 100%;
  border-radius: 14px 14px 14px 4px;
  background: var(--sheet);
  border: 1px solid var(--rule);
  overflow: hidden;
}
.mine .slip {
  border-radius: 14px 14px 4px 14px;
  background: var(--carbon);
  border-color: var(--carbon);
  color: #fff;
}
.item.arrived .slip { animation: carbon 1.6s ease-out 1; }
@keyframes carbon {
  0% { box-shadow: 0 0 0 4px var(--carbon); background: var(--carbon-tint); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .item.arrived .slip { animation: none; }
}

.text {
  margin: 0;
  padding: 11px 14px;
  font: 14.5px/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}
.text.clamped {
  max-height: calc(14.5px * 1.5 * 18 + 22px);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 80%, transparent);
  mask-image: linear-gradient(#000 80%, transparent);
}
.text a { color: inherit; }

.files { list-style: none; margin: 0; padding: 4px 0; }
.text + .files { border-top: 1px solid var(--rule); }
.mine .text + .files { border-top-color: rgba(255, 255, 255, .25); }
.file {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 12px;
  min-width: min(300px, 78vw);
}
.ext {
  min-width: 38px;
  height: 38px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--carbon-tint);
  color: var(--carbon);
  font: 700 .72rem/1 var(--mono);
}
.mine .ext { background: rgba(255, 255, 255, .16); color: #fff; }
.fname { min-width: 0; }
.fname b { display: block; font-weight: 600; font-size: .95rem; overflow-wrap: anywhere; }
.fname span { font-size: .8rem; opacity: .75; }
.get {
  border-radius: 9px;
  padding: 8px 12px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  font-weight: 650;
  font-size: .88rem;
  text-decoration: none;
  color: var(--carbon);
  background: var(--carbon-tint);
}
.mine .get { color: #fff; background: rgba(255, 255, 255, .18); }
.thumb {
  display: block;
  margin: 2px 12px 8px;
  max-width: calc(100% - 24px);
  max-height: 240px;
  border-radius: 8px;
}

.actions { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
.actions button, .actions a {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: .84rem;
  padding: 6px 8px;
  min-height: 36px;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.actions button:hover, .actions a:hover { color: var(--carbon); background: var(--carbon-tint); }
.actions .done { color: var(--ok); }
.actions .delete:hover { color: var(--bad); background: transparent; }

.jump {
  position: sticky;
  bottom: 4px;
  display: block;
  margin: 12px auto 0;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--carbon);
  color: #fff;
  font-weight: 650;
  box-shadow: 0 4px 14px rgba(36, 37, 58, .25);
}

/* ——— Composer ——— */
.composer {
  border-top: 1px solid var(--rule);
  background: var(--paper);
  padding: 10px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.compose-row, .mail-row, .pending, .status, .mail-hint { max-width: 760px; margin-left: auto; margin-right: auto; }
.compose-row { display: flex; align-items: flex-end; gap: 8px; }
.mail-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.mail-to {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .78rem;
  font-weight: 650;
  color: var(--muted);
}
.mail-to input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--sheet);
  font: 16px/1.45 var(--sans);
}
.mail-send {
  flex: none;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--carbon);
  border-radius: 12px;
  background: var(--sheet);
  color: var(--carbon);
  font-weight: 700;
}
.mail-send:hover:not(:disabled) { background: var(--carbon-tint); }
.mail-send:disabled { opacity: .45; cursor: not-allowed; }
.mail-hint { margin: 6px 0 0; font-size: .78rem; color: var(--muted); }
.tools {
  max-width: 760px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.tool {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--carbon-tint);
  color: var(--carbon);
  font-weight: 650;
  font-size: .92rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.tool:hover { background: color-mix(in srgb, var(--carbon-tint) 70%, var(--carbon) 12%); }
.tool:active { transform: translateY(1px); }
.tool input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.tool:focus-within { outline: 3px solid var(--carbon); outline-offset: 2px; }
.ico {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.paste-hint { margin: 0 0 0 4px; font-size: .84rem; color: var(--muted); }
.paste-hint kbd {
  font: 600 .8rem/1 var(--sans);
  padding: 3px 6px;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--sheet);
  color: var(--ink);
}
/* Camera and Photos on touch devices; the paste hint where there is a mouse or trackpad. */
.touch-only, .pointer-only { display: none; }
@media (any-pointer: coarse) { .touch-only { display: inline-flex; } }
@media (hover: hover) and (pointer: fine) { .pointer-only { display: block; } }
@media (max-width: 480px) {
  .tool { flex: 1 1 0; padding: 0 8px; }
}
#text {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 40dvh;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--sheet);
  font: 16px/1.45 var(--mono);
}
#text::placeholder { font-family: var(--sans); color: var(--muted); }
.send { flex: none; }
.status { margin-top: 6px; min-height: 1.2em; font-size: .8rem; color: var(--muted); }
.status.bad { color: var(--bad); }

.pending {
  list-style: none;
  padding: 0;
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 2px 6px;
  max-width: 260px;
  padding: 6px 4px 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--sheet);
  font-size: .82rem;
}
.chip .cthumb { grid-row: 1 / span 2; grid-column: 1; width: 40px; height: 40px; border-radius: 7px; object-fit: cover; margin-right: 2px; }
.chip .cname { grid-column: 2; grid-row: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.chip .cnote { grid-column: 2; grid-row: 2; color: var(--muted); }
.chip.failed .cnote { color: var(--bad); }
.chip progress { grid-column: 1 / -1; grid-row: 3; width: 100%; height: 4px; accent-color: var(--carbon); }
.chip .cx {
  grid-row: 1 / span 2;
  grid-column: 3;
  border: 0;
  background: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 1.1rem;
}
.chip .cx:hover { background: var(--carbon-tint); color: var(--ink); }
.chip .retry {
  border: 0; background: none; padding: 0; color: var(--carbon); font-weight: 650; text-decoration: underline;
}

/* ——— Drop overlay ——— */
.drop {
  position: fixed;
  inset: 10px;
  z-index: 10;
  display: grid;
  place-items: center;
  border: 3px dashed var(--carbon);
  border-radius: 18px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  pointer-events: none;
}
.drop p { margin: 0; font-size: 1.4rem; font-weight: 700; color: var(--carbon); }

@media (min-width: 720px) {
  .timeline { padding-top: 24px; }
  .file { min-width: 340px; }
}

@media (max-width: 480px) {
  .brand { flex-direction: column; align-items: flex-start; gap: 0; }
  .title { font-size: 1.2rem; }
  .usage { font-size: .74rem; }
  .bar-links { gap: 0; }
}

@media (any-pointer: coarse) {
  .actions button, .actions a { min-height: 44px; padding: 8px 12px; }
}
