/* Softdrop. Ported from prototype/index.html, which stays the visual source of truth. */
/* Layout: one calm column. A radar of nearby devices on a tonal slab, then the send card, a pairing strip and an activity list. */
:root {
  --bg: #FBF6F1;
  --surface: #FFFDFB;
  --surface-2: #F5EBE3;
  --fg: #3B2F2A;
  --muted: #7A6860;
  --line: #EBDDD2;
  --accent: #F3AE95;
  --accent-hover: #EE9D80;
  --on-accent: #4B2B1E;
  --accent-ink: #A04E30;
  --accent-soft: #FBE3D7;
  --sage: #4F7F66;
  --sage-soft: #E3EFE7;
  --shadow: 0 1px 2px rgba(120, 80, 55, .05), 0 14px 34px -14px rgba(120, 80, 55, .18);
  --font-body: 'Figtree', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1E2230;
    --surface: #262B3C;
    --surface-2: #2C3246;
    --fg: #F2E8E2;
    --muted: #A8A3B4;
    --line: #373D54;
    --accent: #F4B093;
    --accent-hover: #F7BEA5;
    --on-accent: #3A2217;
    --accent-ink: #F7C3AB;
    --accent-soft: rgba(244, 176, 147, .14);
    --sage: #8FC2A6;
    --sage-soft: rgba(143, 194, 166, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .22), 0 16px 36px -16px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1E2230;
  --surface: #262B3C;
  --surface-2: #2C3246;
  --fg: #F2E8E2;
  --muted: #A8A3B4;
  --line: #373D54;
  --accent: #F4B093;
  --accent-hover: #F7BEA5;
  --on-accent: #3A2217;
  --accent-ink: #F7C3AB;
  --accent-soft: rgba(244, 176, 147, .14);
  --sage: #8FC2A6;
  --sage-soft: rgba(143, 194, 166, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .22), 0 16px 36px -16px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  padding-block: 22px 44px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, .device:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 3px;
}

.app { max-width: 600px; margin: 0 auto; display: grid; gap: 22px; }
.app > * { min-width: 0; }

/* Header */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
h1 { margin: 0; font: 500 34px/1.05 var(--font-display); letter-spacing: -.02em; }
.tagline { margin: 8px 0 0; color: var(--muted); }
.icon-btn {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow);
  display: grid; place-items: center; cursor: pointer;
  transition: transform .35s var(--ease);
}
.icon-btn:hover { transform: translateY(-1px); }

.label { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.stage-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 10px; }
.status { margin: 0; font-size: 13px; color: var(--muted); }

/* Radar */
.radar {
  position: relative; aspect-ratio: 10 / 9; overflow: hidden; border-radius: 30px;
  background: radial-gradient(circle at 50% 52%, var(--accent-soft) 0%, transparent 62%), var(--surface-2);
}
.orbit { position: absolute; left: 50%; top: 52%; aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--line); transform: translate(-50%, -50%); pointer-events: none; }
.orbit.o1 { width: 40%; }
.orbit.o2 { width: 72%; }
.orbit.o3 { width: 104%; }
.ripple {
  position: absolute; left: 50%; top: 52%; width: 40%; aspect-ratio: 1; border-radius: 50%;
  border: 1.5px solid var(--accent); opacity: 0; pointer-events: none;
  transform: translate(-50%, -50%) scale(.4);
  animation: ripple 6s ease-out infinite;
}
.ripple.late { animation-delay: 3s; }
@keyframes ripple {
  0% { opacity: .5; transform: translate(-50%, -50%) scale(.4); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.5); }
}
.me { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); }
.me .dot {
  width: 60px; height: 60px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; box-shadow: 0 0 0 9px var(--accent-soft);
}
.me span { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 12px; font-size: 12px; font-weight: 600; color: var(--accent-ink); white-space: nowrap; }

.device {
  position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%);
  width: 96px; display: grid; justify-items: center; gap: 5px; padding: 0; border: 0; background: none;
  text-align: center; cursor: pointer;
}
.avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--surface); color: var(--accent-ink);
  display: grid; place-items: center; box-shadow: var(--shadow);
  transition: transform .4s var(--ease), box-shadow .4s var(--ease);
}
.device:hover .avatar { transform: translateY(-3px); }
.device[aria-pressed="true"] .avatar { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.device.relay .avatar { outline: 1.5px dashed var(--muted); outline-offset: 4px; }
.dname { font-size: 13px; font-weight: 600; line-height: 1.15; }
.dkind { font-size: 11px; line-height: 1.15; color: var(--muted); }
.who { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.who strong { color: var(--fg); font-weight: 600; }

/* Cards and buttons */
.card { background: var(--surface); border-radius: 26px; box-shadow: var(--shadow); padding: 18px; }
.btn {
  min-height: 44px; padding: 11px 20px; border: 0; border-radius: 99px; font-weight: 600; cursor: pointer;
  transition: background .3s var(--ease), transform .3s var(--ease), opacity .3s;
}
.btn.sm { min-height: 40px; padding: 8px 16px; font-size: 14px; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: var(--surface-2); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.98); }

.route {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.route::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.route.lan { background: var(--sage-soft); color: var(--sage); }
.route.relay { background: var(--accent-soft); color: var(--accent-ink); }

/* Send */
.to { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 12px; font-size: 14px; }
.to .k { color: var(--muted); }
.zone {
  border-radius: 22px; background: var(--surface-2); padding: 14px 16px;
  transition: box-shadow .4s var(--ease), background .4s var(--ease);
  animation: breathe 7s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); }
  50% { box-shadow: 0 0 0 7px var(--accent-soft); }
}
.zone:focus-within { animation: none; box-shadow: 0 0 0 2px var(--accent); }
.zone.over { animation: none; background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent), 0 0 44px 6px var(--accent-soft); }
textarea {
  display: block; width: 100%; min-height: 88px; padding: 0; border: 0; background: transparent;
  resize: vertical; outline: none; line-height: 1.5;
}
textarea::placeholder { color: var(--muted); }
.staged { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.staged:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 4px 4px 4px 12px;
  border-radius: 99px; background: var(--surface); font-size: 13px;
}
.chip .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .sz { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip-x { width: 28px; height: 28px; flex: none; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.chip-x:hover { background: var(--surface-2); color: var(--fg); }
.actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.zone + .actions { margin-top: 14px; }

/* Pairing */
.pair { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px; padding: 16px 18px; border-radius: 26px; background: var(--surface-2); }
.pair-info { min-width: 0; }
.pair-info p { margin: 0; }
.pair-info .sub { font-size: 13px; color: var(--muted); }
.code { font-weight: 600; letter-spacing: .08em; font-variant-numeric: tabular-nums; color: var(--accent-ink); }
.pair form { display: flex; gap: 8px; flex-wrap: wrap; }
.pair input {
  width: 132px; min-height: 44px; padding: 10px 16px; border: 0; border-radius: 99px; background: var(--surface);
  font-variant-numeric: tabular-nums; letter-spacing: .08em;
}
.pair input::placeholder { color: var(--muted); letter-spacing: .08em; }
.pairmsg { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--muted); min-height: 1.5em; }

/* Activity */
.list { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.item {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 14px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow);
}
.item.new { animation: rise .5s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.ico { width: 44px; height: 44px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; }
.meta { min-width: 0; }
.title { font-weight: 600; overflow-wrap: anywhere; }
.sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; }
.speed { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.preview { margin: 8px 0 0; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); font-size: 14px; overflow-wrap: anywhere; user-select: text; }
.end { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.end.buttons { flex-direction: row; }
.done { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--sage); white-space: nowrap; }
.muted { font-size: 14px; color: var(--muted); }
.prog { position: relative; width: 44px; height: 44px; }
.prog span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.empty { padding: 18px; border-radius: 22px; background: var(--surface-2); color: var(--muted); text-align: left; }

.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; font-size: 13px; color: var(--muted); }
.foot p { margin: 0; max-width: 38ch; }
.link { padding: 8px 0; border: 0; background: none; font-weight: 600; font-size: 13px; color: var(--accent-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 480px) {
  .end.buttons { grid-column: 1 / -1; justify-content: flex-end; }
  .item:has(.end.buttons) { grid-template-columns: 44px minmax(0, 1fr); }
  h1 { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Additions for the live app ---------- */
[hidden] { display: none !important; }
.label-gap { margin-bottom: 10px; }
.route.direct { background: var(--sage-soft); color: var(--sage); }
.route.pending { background: var(--surface-2); color: var(--muted); }
.route.pending::before { opacity: .6; }

.notice {
  padding: 12px 16px; border-radius: 22px; background: var(--accent-soft); color: var(--accent-ink);
  font-size: 14px; animation: rise .5s var(--ease);
}

.radar-empty {
  position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%); width: min(86%, 340px);
  margin: 0; text-align: center; font-size: 14px; color: var(--muted); line-height: 1.45;
  transition: opacity .4s var(--ease);
}
.radar-empty small { font-size: 12px; }
.device { animation: appear .5s var(--ease); transition: left .5s var(--ease), top .5s var(--ease); }
@keyframes appear { from { opacity: 0; transform: translate(-50%, -50%) scale(.85); } to { opacity: 1; transform: translate(-50%, -50%); } }
.device.connecting .avatar { animation: softpulse 1.6s ease-in-out infinite; }
@keyframes softpulse { 50% { box-shadow: 0 0 0 7px var(--accent-soft), var(--shadow); } }
.device .badge {
  position: absolute; top: 0; left: calc(50% + 14px); width: 18px; height: 18px; border-radius: 50%;
  background: var(--sage); color: var(--surface); display: grid; place-items: center;
}

.who { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.name-btn {
  padding: 2px 8px; margin-left: -2px; border: 0; border-radius: 99px; background: transparent; cursor: pointer;
  font-weight: 600; color: var(--fg); text-decoration: underline dotted var(--muted); text-underline-offset: 4px;
  transition: background .3s var(--ease);
}
.name-btn:hover { background: var(--surface-2); }
.name-form { display: flex; gap: 8px; align-items: center; }
.name-form input {
  width: 170px; min-height: 40px; padding: 8px 14px; border: 0; border-radius: 99px; background: var(--surface-2);
}

.pair-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pair .code { font-size: 15px; }
.paired { flex-basis: 100%; margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.paired:empty { display: none; }
.paired li { display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border-radius: 99px; background: var(--surface); font-size: 13px; }
.paired .on { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.paired .on.yes { background: var(--sage); }

.item .end .btn.sm { white-space: nowrap; }
.end.buttons { flex-wrap: wrap; justify-content: flex-end; }
.err { font-size: 13px; color: var(--accent-ink); }
.thumb { display: block; max-width: 100%; max-height: 220px; margin-top: 8px; border-radius: 14px; }
.cancel-x { width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.cancel-x:hover { color: var(--fg); background: var(--accent-soft); }
.trust { font-size: 12px; color: var(--muted); }
.trust.yes { color: var(--sage); }

.install {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 14px 18px; border-radius: 26px; background: var(--surface); box-shadow: var(--shadow); font-size: 14px;
  animation: rise .5s var(--ease);
}
.install p { margin: 0; max-width: 42ch; }
.install-btns { display: flex; gap: 8px; }

.foot .fp { font-variant-numeric: tabular-nums; letter-spacing: .04em; }

.sheet {
  width: min(420px, calc(100vw - 32px)); padding: 24px; border: 0; border-radius: 30px;
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow);
}
.sheet[open] { animation: rise .4s var(--ease); }
.sheet::backdrop { background: rgba(40, 30, 25, .32); backdrop-filter: blur(3px); }
.sheet-title { margin: 0 0 6px; font-size: 19px; font-weight: 600; }
.sheet .sub { margin: 0; font-size: 14px; color: var(--muted); }
.sas {
  margin: 22px 0; text-align: center; font-size: 40px; font-weight: 600; letter-spacing: .12em;
  font-variant-numeric: tabular-nums; color: var(--accent-ink);
}
.sheet-btns { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.pair .btn.ghost { background: var(--surface); }
.pair .btn.ghost:hover { background: var(--accent-soft); }

/* Language picker and CJK type */
.top-btns { display: flex; align-items: center; gap: 10px; flex: none; }
.lang {
  position: relative; display: inline-flex; align-items: center; height: 44px; border-radius: 99px;
  background: var(--surface); box-shadow: var(--shadow); color: var(--fg);
  transition: transform .35s var(--ease);
}
.lang:hover { transform: translateY(-1px); }
.lang-ico { position: absolute; left: 13px; display: grid; place-items: center; pointer-events: none; color: var(--muted); }
.lang select {
  appearance: none; -webkit-appearance: none; height: 44px; padding: 0 16px 0 38px; border: 0; border-radius: 99px;
  background: transparent; font-size: 14px; font-weight: 500; cursor: pointer;
}
.lang select:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; }
.lang option { background: var(--surface); color: var(--fg); }
:lang(ja) { --font-body: 'Figtree', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic UI', 'Meiryo', system-ui, sans-serif; }
:lang(zh) { --font-body: 'Figtree', 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans SC', 'Microsoft YaHei', system-ui, sans-serif; }
:lang(ja) .label, :lang(zh) .label { letter-spacing: .04em; }
@media (max-width: 400px) {
  .lang select { padding: 0 12px 0 34px; font-size: 13px; }
  .lang-ico { left: 11px; }
}
:lang(zh-Hant) { --font-body: 'Figtree', 'PingFang TC', 'Hiragino Sans CNS', 'Noto Sans TC', 'Microsoft JhengHei', system-ui, sans-serif; }
