* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg0: #0b1020;
  --bg1: #131a33;
  --card: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .12);
  --txt: #eef2ff;
  --mut: #9aa3c7;
  --acc: #2dd4bf;
  --acc2: #818cf8;
  --mine: linear-gradient(135deg, #0d9488, #2563eb);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--txt);
  background:
    radial-gradient(1200px 800px at 80% -10%, #1e2a5a 0%, transparent 60%),
    radial-gradient(900px 700px at 10% 110%, #123f3c 0%, transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  min-height: 100vh;
  min-height: 100dvh;
}
.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.logo { font-weight: 800; font-size: 20px; letter-spacing: .3px; }
.status {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--mut);
  background: var(--card); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px;
  max-width: 55%;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #64748b; flex: none; }
.status.ok .dot { background: #34d399; box-shadow: 0 0 8px #34d399; }
.status.ok { color: #a7f3d0; }
.status.bad .dot { background: #f87171; }
.status.bad { color: #fecaca; }
#statusText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.view { flex: 1; display: flex; flex-direction: column; }
.hidden { display: none !important; }

h1 { font-size: 34px; line-height: 1.12; margin: 26px 0 10px; letter-spacing: -.5px; }
h1 em {
  font-style: normal;
  background: linear-gradient(90deg, var(--acc), var(--acc2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
h2 { font-size: 24px; margin: 6px 0 4px; }
.sub { color: var(--mut); font-size: 15px; line-height: 1.5; margin-bottom: 22px; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 24px 14px; color: var(--txt); cursor: pointer; text-align: center;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  transition: transform .12s ease, border-color .12s ease;
  font-family: inherit;
}
.card:active { transform: scale(.97); border-color: var(--acc); }
.card-icon { font-size: 34px; }
.card-title { font-weight: 700; font-size: 17px; }
.card-desc { font-size: 12.5px; color: var(--mut); }
.hint { color: var(--mut); font-size: 13px; line-height: 1.55; margin-top: 18px; }

:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}
.back {
  align-self: flex-start; background: none; border: none;
  color: var(--mut); font-size: 14px; cursor: pointer;
  margin-bottom: 8px; padding: 10px 12px; margin-left: -12px;
  min-height: 44px; min-width: 44px; display: inline-flex; align-items: center;
  font-family: inherit; border-radius: 8px;
}
.step { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0 8px; font-size: 14.5px; }
.step .n {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--acc), var(--acc2));
  color: #04211d; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.step p { padding-top: 2px; color: var(--mut); }

textarea, .composer input[type="text"] {
  width: 100%; background: #0a0f22; border: 1px solid var(--line);
  border-radius: 12px; color: var(--txt); padding: 12px;
  font-size: 16px; font-family: ui-monospace, Menlo, Consolas, monospace;
  resize: vertical;
}
textarea:focus, .composer input:focus { outline: none; border-color: var(--acc); }
.codeRow { display: flex; gap: 8px; align-items: stretch; }
.codeRow textarea { flex: 1; }

.btn {
  background: var(--card); border: 1px solid var(--line); color: var(--txt);
  border-radius: 12px; padding: 12px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.btn.primary {
  background: linear-gradient(135deg, #14b8a6, #4f46e5);
  border: none; width: 100%; margin-top: 10px; padding: 14px;
}
.btn.small {
  white-space: nowrap; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:active { transform: scale(.98); }

.qr {
  background: #fff; padding: 14px; border-radius: 16px;
  width: 228px; margin: 6px auto;
  display: flex; align-items: center; justify-content: center;
  min-height: 60px;
}
.qr img, .qr canvas { width: 200px !important; height: 200px !important; }
.qr .hint { margin: 0; }

/* chat */
#view-chat { min-height: 0; }
.messages {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
  gap: 10px; padding: 6px 2px 12px; min-height: 200px;
}
.bubble {
  max-width: 82%; padding: 10px 13px; border-radius: 16px;
  font-size: 14.5px; line-height: 1.45; word-break: break-word;
}
.bubble.mine { align-self: flex-end; background: var(--mine); border-bottom-right-radius: 6px; }
.bubble.theirs { align-self: flex-start; background: rgba(255, 255, 255, .09); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble .meta { font-size: 10.5px; opacity: .65; margin-top: 5px; text-align: right; }
.bubble a { color: #a5f3fc; }
.sys {
  align-self: center; font-size: 12.5px; color: var(--mut);
  background: rgba(255, 255, 255, .05); padding: 6px 14px; border-radius: 999px;
  text-align: center;
}
.fname { font-weight: 600; font-size: 13.5px; }
.fsize { font-size: 12px; opacity: .7; margin: 2px 0 0; }
.track { height: 6px; background: rgba(0, 0, 0, .3); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar { height: 100%; width: 0; background: var(--acc); border-radius: 99px; transition: width .2s; }
.preview { max-width: 100%; border-radius: 10px; margin-top: 8px; display: block; }
.dl {
  display: inline-block; margin-top: 8px; font-size: 13.5px; font-weight: 700;
  color: #04211d; background: var(--acc); padding: 8px 14px;
  border-radius: 10px; text-decoration: none;
}
.composer {
  display: flex; gap: 8px; align-items: center;
  padding-top: 10px; border-top: 1px solid var(--line);
}
.composer input[type="text"] { font-family: inherit; font-size: 16px; flex: 1; }
.composer .btn.primary { width: auto; margin: 0; padding: 12px 16px; }
.attach {
  font-size: 22px; cursor: pointer; padding: 10px;
  min-width: 44px; min-height: 44px; display: inline-flex;
  align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none;
}
.attachbtn {
  background: none; border: none; font-size: 22px; cursor: pointer;
  padding: 10px; min-width: 44px; min-height: 44px; display: inline-flex;
  align-items: center; justify-content: center;
  font-family: inherit; color: var(--txt);
}
.attach:active, .attachbtn:active { transform: scale(.9); }

/* chat header */
.chathead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.chathead .back { margin-bottom: 0; }
.peerlabel {
  font-size: 12.5px; color: var(--mut);
  background: var(--card); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.headright { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex: 1; min-width: 0; }
.fileactions { display: flex; gap: 6px; flex: none; }
.fileactions .btn { white-space: nowrap; }

/* message entrance */
@keyframes msgin { from { opacity: 0; transform: translateY(6px); } }
.bubble, .sys { animation: msgin .16s ease; }

/* file cards */
.frow { display: flex; align-items: center; gap: 10px; }
.fic { font-size: 26px; flex: none; }
.finfo { flex: 1; min-width: 0; }
.finfo .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xbtn {
  flex: none; width: 44px; height: 44px; min-width: 44px; min-height: 44px; border-radius: 50%;
  background: rgba(248, 113, 113, .1); border: 1px solid rgba(248, 113, 113, .45);
  color: #fca5a5; font-size: 16px; cursor: pointer; font-family: inherit; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.xbtn:active { transform: scale(.9); }
.fnote { font-size: 12px; color: var(--mut); margin-top: 5px; display: none; font-style: italic; }
.spd { font-size: 11.5px; color: var(--mut); margin-top: 5px; text-align: right; min-height: 15px; font-variant-numeric: tabular-nums; }
.track { position: relative; }
.bar.busy {
  background-image: linear-gradient(90deg, var(--acc), var(--acc2), var(--acc));
  background-size: 44px 100%;
  animation: slideshimmer 1.1s linear infinite;
}
@keyframes slideshimmer { from { background-position: 0 0; } to { background-position: 44px 0; } }

/* incoming file approval card */
.bubble.ask { border: 1.5px dashed var(--acc); }
.bubble.ask .fnote { display: block; }
.askrow { display: flex; gap: 8px; margin-top: 10px; }
.askrow .btn { flex: 1; margin-top: 0; padding: 10px 8px; font-size: 14px; }
.askrow .okbtn { border: 1px solid var(--acc); color: #a7f3d0; }
.askrow .nobtn { opacity: .8; }

/* drag & drop send overlay */
#view-chat { position: relative; }
.dropoverlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 8, 20, .82); backdrop-filter: blur(3px);
  border-radius: 18px; pointer-events: none;
}
.dropcard {
  border: 2px dashed var(--acc); border-radius: 20px;
  background: rgba(45, 212, 191, .07);
  padding: 38px 46px; text-align: center;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.93); opacity: .35; } }
.droplogo { font-size: 46px; margin-bottom: 8px; }
.droptitle { font-weight: 800; font-size: 19px; }
.dropsub { color: var(--mut); font-size: 13px; margin-top: 6px; }

/* tap-to-connect */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px; margin-top: 22px;
}
.panel h3 { font-size: 15px; margin: 14px 0 8px; color: var(--txt); }
.panel h3:first-child { margin-top: 0; }
.rowline { display: flex; align-items: flex-end; gap: 10px; }
.rowline .fld { flex: 1; }
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--mut); }
.fld input {
  background: #0a0f22; border: 1px solid var(--line); border-radius: 10px;
  color: var(--txt); padding: 10px 12px; font-size: 16px; font-family: inherit; width: 100%;
}
.fld input:focus { outline: none; border-color: var(--acc); }
.sigdot {
  flex: none; width: 10px; height: 10px; border-radius: 50%;
  background: #64748b; margin-bottom: 14px;
}
.sigdot.on { background: #34d399; box-shadow: 0 0 8px #34d399; }
.sigdot.bad { background: #f87171; }
.devlist { display: flex; flex-direction: column; gap: 8px; }
.devlist .empty { font-size: 13px; color: var(--mut); }
.dev {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 13px; width: 100%;
  color: var(--txt); font-family: inherit; font-size: 15px; text-align: left;
}
button.dev { cursor: pointer; }
button.dev:active { transform: scale(.98); border-color: var(--acc); }
.dev .avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--acc), var(--acc2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #04211d; font-size: 15px;
}
.dev .who { flex: 1; min-width: 0; }
.dev .dname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev .dsub { font-size: 12px; color: var(--mut); }
.dev .badge {
  flex: none; font-size: 11px; font-weight: 700; color: #04211d;
  background: var(--acc); border-radius: 999px; padding: 3px 9px;
}
.dev.off { opacity: .55; }
.dev .go { color: var(--acc); font-size: 18px; flex: none; }
#callState {
  margin-top: 10px; background: rgba(45, 212, 191, .08);
  border: 1px solid var(--acc); border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; font-size: 14px;
}
#callState .btn.small { margin-left: auto; }
details.settings { margin-top: 14px; }
details.settings summary { cursor: pointer; color: var(--mut); font-size: 14px; }
details.settings .fld { margin-top: 10px; }
details.settings .hint { margin-top: 10px; }

/* tap-to-connect how-to */
details.howto { margin: 2px 0 10px; }
details.howto summary { cursor: pointer; color: var(--acc); font-size: 13.5px; }
details.howto ol { margin: 10px 0 4px; padding-left: 22px; font-size: 14px; line-height: 1.65; color: var(--txt); }
details.howto .hint { margin-top: 8px; }

/* server link line */
.serverline { margin: 0 0 6px; }
.serverline a { color: var(--acc); text-decoration: underline; text-underline-offset: 2px; }
details.settings a.deploylink { color: var(--acc); font-weight: 600; }

/* private mode toggle */
.privrow {
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  margin: 0 0 8px; cursor: pointer; color: var(--txt);
  min-height: 44px;
}
.privrow input { width: 18px; height: 18px; accent-color: var(--acc); flex: none; }
.privrow .hint { margin: 0; }

/* update-available toast */
#updateToast {
  position: fixed; left: 50%; bottom: 18px; z-index: 60;
  transform: translate(-50%, 20px);
  background: var(--card); border: 1px solid var(--acc); color: var(--txt);
  padding: 10px 14px; border-radius: 999px; font-size: 14px;
  display: flex; gap: 10px; align-items: center;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
}
#updateToast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#updateToast button {
  background: var(--acc); border: none; color: #04121a; font-weight: 700;
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
  font-size: 13px; font-family: inherit;
}

/* incoming call modal */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 8, 20, .72); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.sheet {
  background: var(--bg1); border: 1px solid var(--line); border-radius: 20px;
  padding: 26px 22px; max-width: 340px; width: 100%; text-align: center;
}
.ringicon { font-size: 44px; margin-bottom: 10px; animation: ring 1.2s ease-in-out infinite; }
@keyframes ring {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(14deg); } 40% { transform: rotate(-12deg); }
  60% { transform: rotate(8deg); } 80% { transform: rotate(-6deg); }
}
.sheet h2 { margin-bottom: 6px; }
.sheet .hint { margin-top: 6px; }
.mrow { display: flex; gap: 10px; margin-top: 18px; }
.mrow .btn { flex: 1; }
.mrow .btn.primary { margin-top: 0; }
