:root {
  color-scheme: light;
  --ink: #23251f;
  --muted: #6b6e66;
  --faint: #9a9d95;
  --line: #e2e2da;
  --line-soft: #ecece5;
  --paper: #f1f0eb;
  --card: #fcfcf8;
  --field: #fdfdfa;
  --moss: #4f6452;
  --moss-dark: #3f5d45;
  --moss-soft: #dfe5dd;
  --moss-wash: #f1f4ee;
  --terracotta: #c9684d;
  --error: #b65743;
  --ring: rgba(79, 104, 84, .25);
  --shadow: 0 26px 70px rgba(64, 66, 55, .12), 0 4px 12px rgba(64, 66, 55, .05);
  --text-xs: 11px;
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 20px;
  --text-xl: 28px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, p { margin-top: 0; }
.hidden, .view.hidden { display: none !important; }

.sr-only,
.intro-hidden .hero-copy {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:where(button, a, input, textarea):focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

/* Page */

.page-glow { position: fixed; width: 520px; height: 520px; border-radius: 50%; pointer-events: none; filter: blur(2px); opacity: .48; }
.page-glow-one { top: -250px; left: -170px; background: #e7eedf; }
.page-glow-two { right: -250px; bottom: -250px; background: #f1ddd0; }

.topbar, .app-shell, .site-footer { position: relative; z-index: 1; }
.topbar { width: 100%; max-width: 1120px; margin: 0 auto; padding: 26px 32px; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 18px; font-weight: 650; letter-spacing: -.04em; text-decoration: none; }
.brand-mark { display: block; width: 22px; height: 22px; flex: 0 0 22px; }

/* One anchor for every view: slightly above centre, never jumping between steps. */
.app-shell {
  display: grid;
  flex: 1 0 auto;
  grid-template-columns: minmax(300px, .85fr) minmax(460px, 1fr);
  align-items: start;
  align-content: start;
  gap: clamp(42px, 6vw, 88px);
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(40px, 13vh, 140px) 32px 48px;
}

.hero-copy { padding-top: 28px; }
.eyebrow { margin: 0 0 20px; color: var(--moss); font-size: var(--text-xs); font-weight: 650; letter-spacing: .16em; text-transform: uppercase; }
h1 { margin-bottom: 20px; font-size: clamp(36px, 4vw, 50px); font-weight: 500; line-height: 1; letter-spacing: -.035em; }
h1 em { color: var(--moss); font-family: Georgia, serif; font-weight: 400; letter-spacing: -.025em; }
.hero-description { max-width: 340px; color: var(--muted); font-size: var(--text-md); line-height: 1.6; }

/* Introduction dismissal: offered only once paired; restored from the footer. */
.quiet-link { padding: 0; border: 0; color: var(--faint); background: transparent; font-size: var(--text-xs); text-underline-offset: 2px; }
.quiet-link:hover { color: var(--moss); text-decoration: underline; }
.intro-hide, .intro-show { display: none; }
body.is-paired .intro-hide { display: inline; }
.intro-hidden .intro-show { display: inline; margin-left: 10px; }
.intro-hidden .hero-copy > :not(h1) { display: none; }
.intro-hidden .app-shell { grid-template-columns: minmax(0, 600px); justify-content: center; }

.site-footer { padding: 0 16px 24px; color: var(--faint); font-size: var(--text-xs); text-align: center; }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: var(--moss); text-decoration: underline; }
.app-version { margin-left: 10px; opacity: .7; font-variant-numeric: tabular-nums; }

/* Encryption caption: sits under the main input of whichever view is showing. */
.privacy-caption { display: flex; align-items: center; gap: 6px; margin: 10px 0 0 2px; color: var(--faint); font-size: var(--text-xs); }
.card-privacy { margin-top: 18px; }
#relay-view:not(.hidden) ~ .card-privacy { display: none; }
.security-lock { display: block; width: 12px; height: 12px; flex: 0 0 auto; }
.privacy-trigger { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; color: inherit; background: transparent; font-size: var(--text-xs); text-underline-offset: 2px; cursor: pointer; }
.privacy-trigger:hover { color: var(--ink); text-decoration: underline; }

/* Card and shared controls */

/* Every view shares one card, one padding and one rhythm: back link, heading, lead, content. */
.card { position: relative; padding: 24px 26px 26px; border: 1px solid var(--line); border-radius: 22px; background: var(--card); box-shadow: 0 20px 48px rgba(64, 66, 55, .085); }

.view { animation: view-in .24s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h2 { margin-bottom: 10px; font-size: var(--text-xl); font-weight: 650; line-height: 1.1; letter-spacing: -.03em; }
.view-lead { max-width: 400px; margin-bottom: 20px; color: var(--muted); font-size: var(--text-md); line-height: 1.55; }

.back-button { display: block; margin: 0 0 16px; padding: 0; border: 0; color: var(--muted); background: transparent; font-size: var(--text-sm); }
.back-button:hover { color: var(--ink); }

.button-stack { display: grid; gap: 10px; }
.or-divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: var(--text-xs); }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Getting started: numbered steps above the two pairing actions. */
.start-steps { margin: 4px 0 22px; padding: 0; list-style: none; counter-reset: step; }
.start-steps li { position: relative; padding: 2px 0 12px 34px; color: var(--muted); font-size: var(--text-md); line-height: 1.45; counter-increment: step; }
.start-steps li:last-child { padding-bottom: 0; }
.start-steps li::before { content: counter(step); position: absolute; top: 1px; left: 0; display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--moss-soft); border-radius: 50%; color: var(--moss); background: var(--moss-wash); font-size: var(--text-xs); font-weight: 650; }
.button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; padding: 0 18px; border: 1px solid transparent; border-radius: 11px; font-size: var(--text-md); font-weight: 500; transition: background .16s ease; }
.button-primary { color: white; background: var(--moss); }
.button-primary:hover:not(:disabled) { background: var(--moss-dark); }
.button-secondary { color: var(--moss-dark); border-color: #dde3d9; background: var(--moss-wash); }
.button-secondary:hover:not(:disabled) { background: #e8eee4; }
.button:disabled { cursor: not-allowed; opacity: .45; }

.icon-button { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 9px; color: var(--muted); background: transparent; }
.icon-button svg { width: 17px; height: 17px; }
.icon-button:hover:not(:disabled) { color: var(--ink); background: #eef0ea; }
.icon-button:disabled { cursor: not-allowed; opacity: .5; }

.spinner { width: 13px; height: 13px; flex: 0 0 auto; border: 2px solid #cad8c6; border-top-color: var(--moss); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Pairing */

.pairing-input { width: 100%; height: 50px; margin-bottom: 6px; padding: 0 14px; border: 1px solid #d9ded3; border-radius: 11px; outline: none; color: var(--moss-dark); background: var(--field); font-size: var(--text-lg); font-weight: 500; letter-spacing: .14em; transition: border-color .16s, box-shadow .16s; }
.pairing-input:focus { border-color: var(--moss); box-shadow: 0 0 0 4px rgba(79, 104, 84, .11); }
.field-error { min-height: 18px; margin: 0 0 8px; color: var(--error); font-size: var(--text-sm); }
.view-message { margin: 16px 0 0; color: var(--error); font-size: var(--text-sm); line-height: 1.5; }
.view-message:empty { display: none; }

.pairing-code-wrap, .verification-code { border-radius: 14px; background: var(--moss-wash); text-align: center; }
.pairing-code-wrap { padding: 22px 16px 14px; }
.pairing-code { color: var(--moss-dark); font-size: var(--text-xl); font-weight: 650; letter-spacing: .14em; white-space: nowrap; }
.copy-code { margin-top: 8px; padding: 4px 8px; border: 0; border-radius: 7px; color: var(--moss); background: transparent; font-size: var(--text-xs); font-weight: 650; }
.copy-code:hover { background: #e6ece2; }
.waiting-row { display: flex; align-items: center; gap: 10px; margin: 20px 0 0; color: var(--muted); font-size: var(--text-sm); }

.verification-code { margin: 0 0 16px; padding: 22px 14px; color: var(--moss-dark); font-size: var(--text-xl); font-weight: 650; letter-spacing: .1em; text-wrap: balance; }
.device-name-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 18px; color: var(--muted); font-size: var(--text-sm); }
.device-name-summary strong { color: var(--ink); font-weight: 500; }
.device-name-edit, .device-name-reset { padding: 4px 8px; border: 0; border-radius: 7px; color: var(--moss); background: transparent; font-size: var(--text-sm); font-weight: 500; white-space: nowrap; }
.device-name-edit:hover, .device-name-reset:hover { background: #edf2e9; }

/* Relay header */

.relay-header { position: relative; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 12px; }
.devices-trigger { display: inline-flex; align-items: center; gap: 8px; min-width: 0; height: 32px; padding: 0 10px 0 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: transparent; font-size: var(--text-sm); font-weight: 500; }
.devices-trigger:hover, .devices-trigger[aria-expanded="true"] { background: #f1f2ec; }
.devices-trigger #connection-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevron { width: 14px; height: 14px; flex: 0 0 auto; color: var(--faint); transition: transform .15s ease; }
.devices-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.status-dot { display: inline-block; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--moss); box-shadow: 0 0 0 3px var(--moss-soft); }
.status-dot.offline { background: #a1a49d; box-shadow: 0 0 0 3px #edeee8; }

.notification-button .bell-slash { display: none; }
.notification-button.is-blocked { color: var(--faint); }
.notification-button.is-blocked .bell-slash { display: inline; }

.devices-popover { position: absolute; top: calc(100% + 6px); left: 0; width: min(380px, calc(100vw - 48px)); padding: 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: 0 18px 42px rgba(40, 43, 36, .16); }
.devices-list { margin: 0; padding: 0; list-style: none; }
.device-row { padding: 2px 8px; border-bottom: 1px solid var(--line-soft); }
.device-row-summary { display: flex; align-items: center; gap: 12px; min-height: 46px; }
.device-row .status-dot.hollow { background: var(--card); box-shadow: inset 0 0 0 1.5px #a2a59d; }
.device-row-identity { display: grid; flex: 1; min-width: 0; gap: 1px; }
.device-row-name { overflow: hidden; font-size: var(--text-sm); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.device-row-status, .forget-prompt { color: var(--muted); font-size: var(--text-xs); }
.device-row-actions { display: flex; align-items: center; gap: 4px; }
.forget-prompt { max-width: 120px; }
.forget-device, .forget-confirm, .forget-cancel { min-width: 44px; min-height: 40px; padding: 0 4px; border: 0; color: #9a3a2f; background: transparent; font-size: var(--text-sm); }
.forget-device:hover, .forget-confirm:hover { text-decoration: underline; }
.forget-cancel { color: var(--muted); }
.devices-this-device { display: flex; align-items: center; gap: 4px; min-height: 46px; padding: 2px 8px; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: var(--text-sm); }
.devices-this-device strong { overflow: hidden; color: var(--ink); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.devices-this-device .device-name-edit { margin-left: auto; }
.add-device-button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; margin-top: 8px; padding: 0 12px; border: 0; border-radius: 10px; color: var(--moss-dark); background: var(--moss-wash); font-size: var(--text-sm); font-weight: 500; text-align: left; }
.add-device-button:hover { background: #e8eee4; }

/* Recipients */

.recipient-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.recipient-label, .offline-count { color: var(--muted); font-size: var(--text-sm); }
.recipient-list { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.recipient-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: transparent; font-size: var(--text-sm); }
.recipient-chip.selected { border-color: #c3cfc1; color: #2f4234; background: #e6ece4; }
.recipient-tick { width: 10px; font-size: var(--text-xs); font-weight: 650; }
.recipient-tick:empty { display: none; }

/* Composer */

.composer-wrap { border: 1px solid #dcdfd6; border-radius: 14px; background: var(--field); transition: border-color .16s, box-shadow .16s, background .16s; }
.composer-wrap:focus-within { border-color: var(--moss); box-shadow: 0 0 0 4px rgba(79, 104, 84, .1); }
.composer-wrap.drop-active { border-color: var(--moss); background: #f0f6ed; box-shadow: 0 0 0 4px rgba(79, 104, 84, .18); }
textarea { display: block; width: 100%; min-height: 150px; padding: 16px 18px 8px; resize: none; border: 0; outline: none; color: var(--ink); background: transparent; font-size: var(--text-md); line-height: 1.55; }
textarea:disabled { cursor: not-allowed; opacity: .72; }
textarea::placeholder { color: #adb2a8; }
textarea:focus-visible { outline: none; }

.composer-footer { display: flex; align-items: center; gap: 10px; padding: 6px 8px 8px 8px; }
.composer-file-control { display: flex; flex: 1; align-items: center; gap: 6px; min-width: 0; }
.file-selection { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }
.file-selection-item { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; height: 28px; padding: 0 4px 0 10px; border-radius: 8px; background: var(--moss-wash); font-size: var(--text-xs); }
.file-selection-item.is-error { color: var(--error); background: #f7e8e2; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remove-file { width: 22px; height: 22px; flex: 0 0 auto; padding: 0; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 16px; line-height: 1; }
.remove-file:hover:not(:disabled) { color: var(--terracotta); background: #f7e8e2; }
.remove-file:disabled { cursor: not-allowed; opacity: .5; }

.composer-meta { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: var(--text-xs); white-space: nowrap; }
#char-count.is-error { color: var(--error); }
#shortcut-hint { opacity: 0; transition: opacity .16s; }
.composer-wrap:focus-within #shortcut-hint { opacity: 1; }
@media (hover: none) { #shortcut-hint { display: none; } }

.send-button { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 14px; border: 0; border-radius: 10px; color: white; background: var(--moss-dark); font-size: var(--text-sm); font-weight: 500; transition: background .16s; }
.send-button svg { width: 15px; height: 15px; }
.send-button:hover:not(:disabled) { background: #2e4633; }
.send-button:disabled { cursor: not-allowed; color: var(--faint); background: #eceee8; }

.file-progress { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); font-size: var(--text-xs); }
.file-progress progress { width: 110px; height: 6px; accent-color: var(--moss); }

/* Recent items */

.recent-section { margin-top: 18px; }
.recent-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 6px; color: var(--faint); font-size: var(--text-xs); }
.clear-button { padding: 2px 4px; border: 0; color: var(--faint); background: transparent; font-size: var(--text-xs); }
.clear-button:hover { color: var(--ink); text-decoration: underline; }
.recent-list { margin: 0; padding: 0; list-style: none; }
.recent-item { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 2px; border-top: 1px solid var(--line-soft); }
.recent-item-details { flex: 1; min-width: 0; }
.recent-preview { overflow: hidden; font-size: var(--text-sm); text-overflow: ellipsis; white-space: nowrap; }
.recent-item-meta { display: flex; gap: 6px; margin-top: 2px; color: var(--faint); font-size: var(--text-xs); }
.recent-item-meta span::after { content: '·'; margin-left: 6px; }
.recent-item-meta span.is-sending { color: var(--muted); }
.recent-item-meta span.is-error { color: var(--error); }
.recent-action { flex: 0 0 auto; padding: 5px 8px; border: 0; border-radius: 7px; color: var(--moss-dark); background: transparent; font-size: var(--text-xs); font-weight: 500; }
.recent-action:hover { background: var(--moss-wash); }

.clipboard-helper { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* Dialogs */

.privacy-dialog { width: min(440px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 32px)); padding: 0; overflow: auto; border: 1px solid rgba(215, 215, 204, .9); border-radius: 18px; color: var(--ink); background: transparent; box-shadow: var(--shadow); }
.privacy-dialog::backdrop { background: rgba(32, 34, 31, .28); backdrop-filter: blur(3px); }
.privacy-dialog-card { padding: 24px 26px 26px; background: rgba(255, 255, 252, .96); }
.privacy-dialog-topline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.privacy-dialog-kicker { color: var(--moss); font-size: var(--text-xs); font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.privacy-close { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px; color: var(--faint); background: transparent; font-size: 20px; line-height: 1; }
.privacy-close:hover { color: var(--ink); background: #f0f1ec; }
.privacy-dialog h2 { font-size: var(--text-lg); }
.privacy-dialog-intro { margin-bottom: 18px; color: var(--muted); font-size: var(--text-sm); line-height: 1.6; }
.privacy-points { margin: 0; padding: 0; list-style: none; }
.privacy-points li { padding: 12px 0; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: var(--text-sm); line-height: 1.55; }
.privacy-points li:last-child { padding-bottom: 0; }
.privacy-points strong { color: var(--ink); font-weight: 500; }
.field-label { display: block; margin: 0 0 8px; font-size: var(--text-sm); font-weight: 500; }
.device-name-dialog { width: min(420px, calc(100vw - 32px)); }
.device-name-field { width: 100%; height: 44px; padding: 0 12px; border: 1px solid #d9ded3; border-radius: 10px; outline: none; background: var(--field); font-size: var(--text-md); }
.device-name-field:focus { border-color: var(--moss); box-shadow: 0 0 0 4px rgba(79, 104, 84, .11); }
.device-name-dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 20px; }
.dialog-actions { display: flex; flex: 1; justify-content: flex-end; gap: 8px; }
.dialog-actions .button { width: auto; min-width: 90px; min-height: 40px; font-size: var(--text-sm); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); gap: 28px; max-width: 600px; padding: 24px 20px 36px; }
  .hero-copy { padding-top: 0; }
}

@media (max-width: 500px) {
  .topbar { padding: 20px 16px; }
  .app-shell, body.is-paired .app-shell { padding-right: 16px; padding-left: 16px; }
  .card { padding: 20px 18px 20px; }
  h1 { font-size: 34px; }
  .eyebrow { margin-bottom: 14px; }
  body.is-paired .hero-description { display: none; }
  h2 { font-size: 24px; }
  .pairing-code { font-size: 24px; }
  .verification-code { font-size: 24px; }
  textarea { min-height: 130px; padding: 14px 14px 6px; }
  .device-name-dialog-actions { flex-direction: column; align-items: stretch; }
  /* The file pill already shows the size; give the name the room. */
  .composer-wrap.has-file #char-count { display: none; }
  .file-selection { min-width: 88px; }
}
