/*
 * THE PHONE REMOTE - styles (2026-11-22).
 *
 * Colours are the hub's own brand tokens (src/styles/tokens.css), copied here
 * by value because this page is served by the broker port on its own, with no
 * build step and no access to the hub's stylesheet.
 *
 * Phone rules this file keeps:
 *   - every input is 16px, because iOS zooms the whole page into any field
 *     with smaller text;
 *   - every tap target is at least 44px tall;
 *   - the top and bottom bars pad themselves with the safe-area insets, so
 *     nothing sits under the notch or the home bar when it runs full-screen.
 */

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1e1e1e;
  --border: #2a2a2a;
  --text: #ededed;
  --muted: #8a8a8a;
  --gold: #d4af37;
  --gold-hover: #e6c04a;
  --purple: #7b2cbf;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #ef4444;
  --radius: 12px;
  --top-h: 52px;
  --tabs-h: 54px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.35;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.hint {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin: 0;
}

/* ───────────── buttons ───────────── */

.btn {
  min-height: 46px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 600;
  width: 100%;
}

.btn:disabled {
  opacity: 0.38;
}

.btn.big {
  min-height: 56px;
  font-size: 17px;
}

.btn.gold {
  background: var(--gold);
  border-color: var(--gold);
  color: #0a0a0a;
}

.btn.gold:active {
  background: var(--gold-hover);
}

.btn.line {
  background: var(--surface);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-weight: 500;
}

.btn.danger-line {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

.btn.panic {
  min-height: 64px;
  font-size: 18px;
  letter-spacing: 0.04em;
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn.panic.held {
  background: var(--surface);
  color: var(--success);
  border-color: var(--success);
}

.btn.busy {
  opacity: 0.6;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  flex: none;
}

.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ───────────── pairing ───────────── */

.pair-wrap {
  margin: auto;
  width: 100%;
  max-width: 380px;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}

.pair-wrap section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pair-logo {
  width: 84px;
  height: 84px;
  margin: 0 auto;
  border-radius: 20px;
}

.pair-wrap h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.steps {
  margin: 0;
  padding-left: 22px;
  text-align: left;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.code-show {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 32px;
  letter-spacing: 0.12em;
  color: var(--gold);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 8px;
  user-select: all;
  -webkit-user-select: all;
}

.code-input {
  height: 60px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 26px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}

.code-input:focus {
  border-color: var(--gold);
}

/* ───────────── top bar ───────────── */

.top {
  flex: none;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.dot.on {
  background: var(--success);
}

.dot.bad {
  background: var(--danger);
}

.who {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 55%;
  height: 38px;
  padding: 0 28px 0 10px;
  font-size: 17px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 15px) 16px,
    calc(100% - 10px) 16px;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
}

.link-text {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ───────────── tabs ───────────── */

.tab {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#tab-chat {
  padding: 0;
  gap: 0;
  overflow: hidden;
}

.tabs {
  flex: none;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.nav {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 15px;
  position: relative;
}

.nav.on {
  color: var(--gold);
}

.badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--purple);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  vertical-align: 1px;
}

/* ───────────── control tab ───────────── */

.banner {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--warning);
  color: var(--warning);
  background: rgba(251, 191, 36, 0.08);
  font-size: 14px;
  font-weight: 600;
}

.banner.bad {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.card-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.st-stream {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.st-stream.live {
  color: var(--success);
}

.st-stream.off {
  color: var(--text);
}

.st-stream.hold {
  color: var(--danger);
}

.st-stream.gone {
  color: var(--muted);
}

.st-stale {
  margin-top: 2px;
  color: var(--warning);
  font-size: 13px;
}

.rows {
  margin: 10px 0 0;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.row dt {
  color: var(--muted);
  flex: none;
}

.row dd {
  margin: 0;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}

.row dd.warn {
  color: var(--warning);
}

.row dd.bad {
  color: var(--danger);
}

.toggles {
  padding: 2px 14px;
}

.toggle {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border);
  font-size: 16px;
  font-weight: 500;
  padding: 0;
}

.toggle:first-child {
  border-top: 0;
}

.toggle i {
  width: 52px;
  height: 32px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  flex: none;
  transition: background 0.15s;
}

.toggle i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--muted);
  transition:
    transform 0.15s,
    background 0.15s;
}

.toggle[aria-checked="true"] i {
  background: var(--gold);
  border-color: var(--gold);
}

.toggle[aria-checked="true"] i::after {
  transform: translateX(20px);
  background: #0a0a0a;
}

.toggle.unknown i {
  opacity: 0.35;
}

.toggle.busy i {
  opacity: 0.55;
}

.toggle:disabled {
  opacity: 0.5;
}

.feed-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.feed-lines p {
  margin: 0;
  overflow-wrap: anywhere;
}

.feed-lines time {
  color: var(--muted);
  font-size: 12px;
  margin-right: 6px;
}

/* ───────────── chat tab ───────────── */

.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 16px;
  font-size: 16px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.msg.me {
  align-self: flex-end;
  background: var(--gold);
  color: #0a0a0a;
  border-bottom-right-radius: 5px;
}

.msg.her {
  align-self: flex-start;
  background: var(--surface-2);
  border-bottom-left-radius: 5px;
}

.msg.her.partial {
  color: var(--muted);
  font-style: italic;
}

.msg.sys {
  align-self: center;
  max-width: 100%;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 2px 8px;
  text-align: center;
}

.msg.sys.bad {
  color: var(--danger);
}

.msg small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  opacity: 0.6;
}

.photo-strip {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 8px 12px 0;
  overflow-x: auto;
}

.photo-strip .ph {
  position: relative;
  flex: none;
}

.photo-strip img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}

.photo-strip button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 8px 8px 4px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.say {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 132px;
  padding: 10px 12px;
  resize: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
}

.say:focus {
  border-color: var(--gold);
}

.btn.send {
  width: auto;
  min-height: 44px;
  padding: 0 16px;
  flex: none;
}

/* ───────────── sheets + toast ───────────── */

.sheet-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 20;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sheet h2 {
  margin: 0;
  font-size: 19px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field input {
  height: 46px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}

.field input:focus {
  border-color: var(--gold);
}

.about {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 30;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.toast.good {
  border-color: var(--success);
}

.toast.bad {
  border-color: var(--danger);
  color: var(--danger);
}
