/* paneherd.com/remote, on top of styles.css: a phone-first control panel. */

body.remote::before { opacity: 0.25; }
.remote-main {
  max-width: 640px;
  margin: 0 auto;
  /* Room under the last row for the composer, which grows with the prompt and its images. */
  padding: 0 max(16px, env(safe-area-inset-left)) max(calc(132px + env(safe-area-inset-bottom)), calc(var(--composer-h, 0px) + 24px)) max(16px, env(safe-area-inset-right));
}

.bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  margin: 0 -16px;
  padding: env(safe-area-inset-top) 16px 0;
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar .brand { font-size: 21px; }

.conn { display: inline-flex; align-items: center; gap: 8px; font: 500 13px var(--mono); color: var(--muted); }
.conn::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--dim); }
.conn.on::before { background: var(--field); box-shadow: 0 0 0 4px rgba(142, 220, 143, 0.18); }
.conn.idle::before { background: var(--signal); }
.conn.off::before { background: var(--alarm); }

.card { margin-top: 28px; padding: 24px 20px; border: 1px solid var(--line-2); border-radius: 18px; background: rgba(18, 24, 22, 0.9); }
.card.center { text-align: left; }
.card h1 { font-size: clamp(36px, 10vw, 52px); line-height: 0.95; }
.card .lede { margin-top: 16px; font-size: 18px; }
.fine { margin: 16px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.steps { margin: 20px 0 0; padding-left: 22px; display: grid; gap: 10px; font-size: 17px; color: #d9d3c4; }
.spinner { width: 28px; height: 28px; margin-top: 22px; border: 3px solid var(--line-2); border-top-color: var(--signal); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ windows and panes */

.win { margin-top: 24px; }
.win-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; margin-bottom: 10px; }
.win-head h2 { margin: 0; font: 700 24px/1.15 var(--display); font-stretch: 85%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-head .app { grid-column: 1; grid-row: 2; color: var(--muted); font: 400 12px var(--mono); }
.win-head .link { grid-column: 2; grid-row: 1 / span 2; white-space: nowrap; }

.panes { display: grid; gap: 8px; }
.pane {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 60px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--ink-2);
  color: var(--chalk);
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.pane.on { border-color: var(--signal); background: color-mix(in srgb, var(--signal) 9%, var(--ink-2)); }
.pane.alarmed { border-color: color-mix(in srgb, var(--alarm) 60%, var(--line-2)); }
.pane button { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pane button:active { background: var(--ink-3); }
.pane button:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }
/* The tick picks the pane for a prompt to several panes; the rest of the row opens its conversation. */
.pick { display: grid; place-items: center; width: 52px; padding: 0; border-right: 1px solid var(--line) !important; }
.pick:disabled { cursor: default; }
.pick:disabled .check { opacity: 0.4; }
.pane-open { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 10px; min-width: 0; padding: 10px 10px 10px 14px; text-align: left; }
.pane.ended .pane-main { opacity: 0.7; }
.chev { color: var(--muted); font-size: 24px; line-height: 1; }
@media (max-width: 480px) {
  .pane-open { grid-template-columns: minmax(0, 1fr) auto; }
  .pane-open .state { grid-column: 1; grid-row: 2; }
  .pane-open .chev { grid-column: 2; grid-row: 1 / span 2; }
}
.check { width: 22px; height: 22px; border: 1.5px solid var(--line-2); border-radius: 6px; display: grid; place-items: center; }
.pane.on .check { border-color: var(--signal); background: var(--signal); }
.pane.on .check::after { content: ''; width: 10px; height: 6px; border: 2.5px solid var(--ink); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.pane-main { display: grid; min-width: 0; }
.pane-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-sub { color: var(--muted); font: 400 12.5px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alarm { color: var(--alarm); }
.state { display: inline-flex; align-items: center; gap: 6px; font: 600 12.5px var(--mono); color: var(--muted); white-space: nowrap; }
.state i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state.s-working { color: var(--field); }
.state.s-permission, .state.s-question { color: var(--signal); }
.state.s-finished, .state.s-ready { color: var(--sky); }
.state.s-exited, .state.s-starting { color: var(--dim); }

/* ------------------------------------------------------------ conversation */

.convo-head {
  position: sticky;
  top: var(--bar-h, 56px);
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 0 -16px;
  padding: 6px 16px 8px 8px;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.back { display: inline-flex; align-items: center; gap: 2px; min-width: 44px; min-height: 44px; padding: 0 8px 0 4px; border: 0; border-radius: 10px; background: none; color: var(--chalk); font: 500 13px var(--mono); cursor: pointer; }
.back span { font-size: 28px; line-height: 1; margin-top: -3px; }
.back:active { background: var(--ink-3); }
.convo-title { display: grid; min-width: 0; }
.convo-title h2 { margin: 0; font: 700 18px/1.25 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.convo-meta .pane-sub { min-width: 0; }

.thread { display: flex; flex-direction: column; gap: 12px; padding: 16px 0 8px; }
.msg { min-width: 0; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 88%; padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--signal) 35%, var(--line-2)); border-radius: 16px 16px 4px 16px; background: color-mix(in srgb, var(--signal) 14%, var(--ink-2)); font-size: 16px; line-height: 1.45; }
.msg.assistant { padding: 0 2px; font-size: 16px; line-height: 1.55; }
.msg.tool { display: flex; gap: 8px; margin: -4px 0; padding: 0 2px; color: var(--muted); font: 400 12.5px/1.5 var(--mono); }
.tool-mark { color: var(--dim); }
.tool-text { min-width: 0; overflow-wrap: anywhere; }
.msg-time { display: block; margin-top: 4px; color: var(--muted); font: 400 12px var(--mono); }
.msg.user .msg-time { text-align: right; }
.thread .earlier { align-self: center; }
.thread .spinner { align-self: center; }
.convo-note { padding: 16px; border: 1px dashed var(--line-2); border-radius: 14px; }
.convo-note b { display: block; font-size: 17px; }
.convo-note p { margin: 6px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.convo-perms { margin-top: 12px; }
.hint { text-align: center; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ permission prompts */

.perm { margin-bottom: 10px; padding: 14px; border: 1.5px solid var(--signal); border-radius: 14px; background: linear-gradient(rgba(255, 182, 72, 0.1), rgba(255, 182, 72, 0.04)), var(--ink-2); }
.perm-head { display: flex; align-items: center; gap: 8px; font: 500 14px var(--mono); }
.perm-head i { width: 8px; height: 8px; border-radius: 50%; background: var(--signal); }
.perm-head span { color: var(--muted); }
.perm-detail { display: block; margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--ink); color: var(--chalk); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; max-height: 9.5em; overflow: auto; }
.perm-conflict { margin: 10px 0 0; color: var(--signal); font-size: 14px; }
.perm-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; margin-top: 12px; }
.perm .btn { width: 100%; padding: 0 12px; }
.btn.allow { background: var(--field); border-color: var(--field); color: var(--ink); }
.btn.deny { background: transparent; border-color: var(--alarm); color: var(--alarm); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: none; }

/* ------------------------------------------------------------ composer */

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 640px;
  margin: 0 auto;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1;
  min-height: 48px;
  max-height: 30vh;
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--ink-2);
  color: var(--chalk);
  font: 400 16px/1.4 var(--display);
  resize: none;
  field-sizing: content;
}
.composer textarea:focus { outline: none; border-color: var(--signal); }
.composer .btn { flex: none; min-width: 96px; }
.composer { flex-wrap: wrap; }
.attach { flex: none; display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 1px solid var(--line-2); border-radius: 14px; background: var(--ink-2); color: var(--chalk); cursor: pointer; }
.attach svg { width: 22px; height: 22px; }
.attach:active { background: var(--ink-3); }
.attach:focus-visible, .thumb-x:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.attach:disabled { opacity: 0.45; cursor: default; }
.thumbs { flex-basis: 100%; display: flex; gap: 12px; overflow-x: auto; padding: 12px 12px 4px 0; }
.thumb { position: relative; flex: none; width: 56px; height: 56px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--ink-2); }
.thumb img { display: block; width: 100%; height: 100%; border-radius: 9px; object-fit: cover; }
.thumb.busy { display: grid; place-items: center; }
.thumb.busy .spinner { width: 22px; height: 22px; margin: 0; }
.thumb-x { position: absolute; top: -12px; right: -12px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.thumb-x span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--chalk); color: var(--ink); font: 700 17px/1 var(--display); box-shadow: 0 0 0 2px var(--ink); }

.link { min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--muted); font: 500 13px var(--mono); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 4px; cursor: pointer; }
.link.small { min-height: 44px; }
.link:hover { color: var(--chalk); }
.foot { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 28px; }

/* ------------------------------------------------------------ notifications */

.notify-box { width: 100%; padding: 16px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--ink-2); }
.notify-box .btn { width: 100%; }
.notify-box .btn[aria-pressed='true'] { border-color: var(--line-2); color: var(--muted); }
.notify-box .fine { margin-top: 10px; font-size: 14px; }
.notify-box .btn[hidden] + .fine { margin-top: 0; }
.notify-box code { font: 500 13px var(--mono); overflow-wrap: anywhere; }

/* ------------------------------------------------------------ pairing from the page */

.scan-actions { margin-top: 20px; }
.scan-actions .btn { width: 100%; }
.scan { margin-top: 14px; }
.scan-video { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border: 1px solid var(--line-2); border-radius: 14px; background: #000; }
.scan .fine { margin-top: 8px; }
.paste { margin-top: 20px; }
.paste label { display: block; color: var(--muted); font: 500 13px var(--mono); }
.paste-row { display: flex; gap: 8px; margin-top: 8px; }
.paste-row input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--ink-2);
  color: var(--chalk);
  font: 400 16px var(--display);
}
.paste-row input:focus { outline: none; border-color: var(--signal); }
.paste-row .btn { flex: none; padding: 0 18px; }
.fine.error { color: var(--alarm); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(calc(88px + env(safe-area-inset-bottom)), calc(var(--composer-h, 0px) + 12px));
  z-index: 5;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 99px;
  background: var(--chalk);
  color: var(--ink);
  font: 600 14px var(--display);
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--field); }
.toast.error { background: var(--alarm); }
