/* Kith — the map. Builds on styles.css (tokens, type, brand); only what the
   map needs lives here. On /map it is the whole screen: a header, the
   canvas, and a brief that floats beside the map (desktop) or rises over it
   (phone). The landing page embeds the same map in a frame (.map-embed). */

.app { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- header ---- */
.app-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 64px;
  padding: max(10px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: relative; z-index: 5;
}
.app-top .wordmark { font-size: 22px; }
.app-top .mark { width: 22px; height: 23px; }
.app-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-actions form { margin: 0; }

.find { position: relative; }
.find-icon {
  position: absolute; left: 15px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
  fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; pointer-events: none;
}
/* 16px: anything smaller and iOS zooms the page when the field is focused. */
.find input {
  width: min(280px, 44vw); height: 44px; padding: 0 16px 0 40px;
  font: inherit; font-size: 16px; color: var(--strong);
  background: var(--panel); border: 1px solid var(--field-edge); border-radius: 999px;
  -webkit-appearance: none; appearance: none;
}
.find input::-webkit-search-cancel-button { display: none; }
.find input::placeholder { color: var(--muted); }
.find input:focus-visible { outline: 2px solid var(--mark); outline-offset: 2px; border-color: transparent; }

.results {
  position: absolute; top: calc(100% + 8px); right: 0; left: 0; min-width: 270px;
  margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow);
  z-index: 6;
}
.results li[role="option"] {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px;
  align-items: center; min-height: 52px; padding: 8px 10px; border-radius: 12px; cursor: pointer;
}
.results li .avatar { grid-row: span 2; }
.results li.active, .results li[role="option"]:hover { background: var(--sunk); }
.results li.none { padding: 12px 12px; font-size: 14px; color: var(--muted); }
.hit-name { font-size: 15px; color: var(--strong); line-height: 1.3; }
.hit-rel { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.hit-rel:empty { display: none; }

.quiet-btn, .solid-btn, .round-btn {
  font: inherit; cursor: pointer; border-radius: 999px;
  transition: border-color .2s ease, filter .15s ease, transform .15s ease, background-color .2s ease;
}
.quiet-btn {
  min-height: 44px; padding: 0 16px; font-size: 14px; color: var(--ink);
  background: transparent; border: 1px solid var(--line); white-space: nowrap;
}
.quiet-btn:hover { border-color: var(--muted); }
.quiet-btn.danger { color: var(--error); border-color: color-mix(in srgb, var(--error) 40%, transparent); }
.quiet-btn.danger:hover { border-color: var(--error); }
.solid-btn {
  display: inline-block; padding: 15px 26px; font-size: 15px; font-weight: 500;
  color: var(--on-mark); background: var(--mark); border: 0; text-decoration: none;
}
.solid-btn:hover { filter: brightness(.95); }
.solid-btn:active { transform: translateY(1px); }

/* ---- stage ---- */
.stage { position: relative; flex: 1; min-height: 0; display: flex; }
/* The app never scrolls as a page; a screen of words taller than the window
   (the welcome, on a phone) scrolls inside the stage instead. */
.stage:has(> .state:not([hidden])) { overflow-y: auto; }

.state { margin: auto; padding: 32px 24px; max-width: 34em; text-align: center; }
.state .cairn { margin-bottom: 28px; width: 56px; height: 58px; }
.state h1 { font-size: clamp(30px, 5vw, 44px); line-height: 1.12; letter-spacing: -.025em; }
.state .label { margin-bottom: 14px; }
.state-line { margin-top: 18px; color: var(--ink); }
.state-actions { margin-top: 34px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.state-actions a.quiet-btn { display: inline-flex; align-items: center; min-height: 54px; padding: 0 26px; font-size: 15px; text-decoration: none; }
/* The owner's way in, below everyone else's: a link, with room to tap. */
.state-owner { margin-top: 30px; font-size: 14px; color: var(--muted); }
/* Getting started: connecting an assistant is all there is to do. */
.connect-steps { margin: 30px auto 0; padding: 0 0 0 1.4em; max-width: 30em; text-align: left; color: var(--ink); }
.connect-steps li { padding: 8px 0; line-height: 1.55; }
.connect-steps li::marker { color: var(--muted); }
.connect-url { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.connect-url code {
  padding: 8px 12px; font-size: 14px; color: var(--strong); overflow-wrap: anywhere;
  background: var(--sunk); border: 1px solid var(--line); border-radius: 10px;
}
.state-owner .home-tools, .state-owner .sign-out { justify-content: center; }
.delete-confirm { margin-top: 12px; padding: 14px 16px; font-size: 14px; color: var(--ink); background: var(--sunk); border-radius: 14px; text-align: left; }
.delete-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.state-owner a {
  display: inline-block; padding: 12px 0; margin: -12px 0;
  color: var(--ink); text-underline-offset: 3px; text-decoration-color: var(--line);
}
.state-owner a:hover { text-decoration-color: var(--ink); }

/* ---- canvas ---- */
.canvas {
  position: relative; flex: 1; min-width: 0; overflow: hidden;
  background: radial-gradient(ellipse at 50% 50%, var(--panel) 0, var(--bg) 70%);
}
.graph {
  display: block; width: 100%; height: 100%;
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: grab;
}
.graph.dragging { cursor: grabbing; }

/* Pins: a person is placed in map space and drawn at a constant size on
   screen (--pin is 1/zoom, clamped), so zooming spreads people out instead
   of shrinking them. */
.pin { transform: scale(var(--pin, 1)); }

.guides .ring { fill: none; stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.guides .ring-3 { stroke-dasharray: 1 7; stroke-linecap: round; stroke-width: 1.5; }
.guides .sector text {
  font-size: 10px; font-weight: 500; letter-spacing: .3em; text-transform: uppercase;
  fill: var(--muted); text-anchor: middle;
  paint-order: stroke; stroke: var(--bg); stroke-width: 5px; stroke-linejoin: round;
}

/* ties */
.link {
  fill: none; stroke-linecap: round; vector-effect: non-scaling-stroke;
  transition: opacity .25s ease, stroke .25s ease, stroke-width .25s ease, filter .25s ease;
}
.link.spoke { stroke: var(--muted); stroke-width: 1; opacity: .22; }
.link.spoke.dense { opacity: .08; }
.link.spoke.loose { stroke-dasharray: 2 5; opacity: 0; }
.link.tie { stroke: var(--muted); stroke-width: 1; opacity: .35; }
.link.via { stroke: var(--muted); stroke-width: 1; opacity: .32; stroke-dasharray: 2 4; }
.link.weak { stroke: var(--muted); stroke-width: 1; opacity: 0; }
/* Blur is set in screen pixels (--inv undoes the zoom), so friends of
   friends look soft at every size, not merely faint. */
.link.far { filter: blur(calc(1.2px * var(--inv, 1))); opacity: .2; }
.link.far.deep { opacity: .12; }

/* people */
.node, .self { animation: arrive .5s cubic-bezier(.2, .8, .2, 1) both; }
.node { cursor: pointer; transition: opacity .25s ease, filter .25s ease; }
@keyframes arrive { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .node, .self { animation: none; } }

.node .hit { fill: transparent; }
.node .disc { transition: stroke .2s ease, stroke-width .2s ease; }
.node .ring-mark { fill: none; stroke: transparent; stroke-width: 1.5; transition: stroke .2s ease; }
.node .initials { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-anchor: middle; pointer-events: none; }
.node .name {
  font-size: 11.5px; fill: var(--ink); text-anchor: middle;
  paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round;
  pointer-events: none; transition: opacity .2s ease;
}

.node.ring-1 .disc { fill: var(--mark); stroke: var(--node-edge, transparent); stroke-width: 1; }
.node.ring-1 .initials { fill: var(--on-mark); font-size: 12.5px; }
.node.ring-1 .name { font-size: 12.5px; font-weight: 500; fill: var(--strong); }
.node.ring-2 .disc { fill: var(--panel); stroke: var(--mark-ink); stroke-width: 1.4; stroke-opacity: .75; }
.node.ring-2 .initials { fill: var(--mark-ink); font-size: 10px; }
.node.unmet .disc { fill: var(--bg); stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 2.5 2.5; stroke-opacity: 1; }
.node.unmet .initials { fill: var(--muted); }
.node.ring-3 .initials { font-size: 9.5px; }

.node .soon { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }

/* Which name shows: first names at the starting view on a phone, the
   fuller label once zoomed in (or on a wide screen), and only the first
   ring's first names when zoomed right out. */
.node .name.full { display: none; }
.graph.names-full .node .name.full, .node.selected .name.full { display: inline; }
.graph.names-full .node .name.short, .node.selected .name.short { display: none; }
.graph.zoomed-out .node:not(.ring-1):not(.lit):not(.hot):not(.selected) .name { opacity: 0; }

/* Friends of friends: there, but out of focus until you reach for them. */
.node.far { filter: blur(calc(2px * var(--inv, 1))); opacity: .5; }
.node.far.degree-3 { filter: blur(calc(3px * var(--inv, 1))); opacity: .32; }
.graph.reveal .node.far, .node.far.hot, .node.far.lit { filter: none; opacity: 1; }
.graph.reveal .link.far, .link.far.hot, .link.far.lit { filter: none; opacity: .5; }

/* Hover, keyboard focus and selection each get a ring outside the disc, so
   a selected "not met" person never looks like a loading spinner. */
.node:hover .ring-mark { stroke: var(--muted); stroke-opacity: .5; }
.node:focus { outline: none; }
.node:focus-visible .ring-mark { stroke: var(--mark); stroke-width: 2; }
.node.selected .ring-mark { stroke: var(--strong); stroke-width: 1.5; }
.node.selected .name { fill: var(--strong); font-weight: 600; }

.self .halo { fill: var(--mark); opacity: .07; }
.self .halo.inner { opacity: .1; }
.self use { fill: var(--mark); }
.self text { font-size: 12.5px; font-weight: 600; letter-spacing: .02em; fill: var(--strong); text-anchor: middle; }

/* Hovering or choosing someone quiets everything they are not tied to. */
.graph.hovering .node:not(.hot), .graph.focused .node:not(.lit) { opacity: .16; }
.graph.focused.hovering .node.lit:not(.hot) { opacity: .5; }
.graph.hovering .link:not(.hot), .graph.focused .link:not(.lit) { opacity: .05; }
.link.hot, .link.lit { opacity: .95 !important; stroke: var(--mark); stroke-width: 1.5; stroke-dasharray: none; filter: none; }

/* ---- canvas chrome ---- */
/* Chrome sits on its own frosted surface, so it never lies on a name. */
.chip-surface {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 999px;
}

.soon-bar {
  position: absolute; top: 12px; left: max(12px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 4px; max-width: calc(100% - 24px);
  padding: 4px 6px 4px 14px;
  transition: opacity .2s ease;
}
.soon-label {
  margin-right: 6px; font-size: 10.5px; font-weight: 500; letter-spacing: .26em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap;
}
.soon-list { display: flex; align-items: center; gap: 2px; min-width: 0; }
.soon-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 6px 10px; border: 0; border-radius: 999px; background: transparent; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--strong); white-space: nowrap;
}
.soon-chip:hover { background: var(--sunk); }
.soon-chip .soon-name::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%;
  background: var(--accent); vertical-align: 1px;
}
.soon-day { font-size: 12.5px; color: var(--muted); }
.soon-chip.more { min-width: 44px; justify-content: center; color: var(--muted); }
.soon-wrap { position: relative; }
.soon-more {
  position: absolute; top: calc(100% + 8px); left: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); z-index: 3;
}

.legend {
  position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; flex-wrap: nowrap; gap: 14px; padding: 7px 14px;
  font-size: 12px; color: var(--muted); white-space: nowrap;
  pointer-events: none; transition: opacity .2s ease;
}
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--mark); }
/* The four ways a person is drawn: filled (a named tie to you), outlined
   (met, tied to you through someone), dashed (not met), blurred. */
.legend .dot.outline { background: var(--panel); border: 1.4px solid var(--mark-ink); }
.legend .dot.hollow { background: transparent; border: 1.3px dashed var(--muted); }
/* A narrow phone has room for three: the reveal button beside the legend
   already speaks for friends of friends. */
@media (max-width: 420px) { .legend .legend-far { display: none; } }
.legend .dot.blurred { background: var(--muted); filter: blur(1.4px); opacity: .6; }
.legend .dot.soon { width: 8px; height: 8px; background: var(--accent); }

/* The landing page's invitation to tap, gone at the first one (invite() in
   map.js). Top right, clear of the Coming up bar; under it on a phone. */
.map-hint {
  position: absolute; top: 12px; right: max(12px, env(safe-area-inset-right));
  margin: 0; padding: 7px 14px; font-size: 13px; color: var(--ink); white-space: nowrap;
  pointer-events: none;
}
@media (max-width: 760px) { .map-hint { right: auto; left: max(12px, env(safe-area-inset-left)); } }
/* One slow ring spreading from the person the hint names. */
.node.beckon .ring-mark {
  transform-box: fill-box; transform-origin: center;
  animation: beckon 1s ease-out 2;
}
@keyframes beckon {
  from { stroke: var(--mark); stroke-width: 2; transform: scale(1); opacity: 1; }
  to { stroke: var(--mark); stroke-width: 2; transform: scale(1.9); opacity: 0; }
}

/* A brief is the focus: the map's chrome steps back while it is open. */
.briefing .soon-bar, .briefing .legend { opacity: 0; pointer-events: none; }

.canvas-tools {
  position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
}
.round-btn {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  font-size: 20px; line-height: 1; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.round-btn:hover { border-color: var(--muted); }
.round-btn svg { width: 16px; height: 17px; fill: var(--mark); }
.round-btn.reveal svg { width: 20px; height: 20px; fill: var(--ink); }
.round-btn.reveal .o { fill: none; stroke: var(--ink); stroke-width: 1.2; opacity: .5; }
.round-btn.reveal .o2 { stroke-dasharray: 1.5 2.5; }
.round-btn.reveal[aria-pressed="true"] { background: var(--mark); border-color: var(--mark); }
.round-btn.reveal[aria-pressed="true"] svg { fill: var(--on-mark); }
.round-btn.reveal[aria-pressed="true"] .o { stroke: var(--on-mark); opacity: .9; }

/* Touch: bigger targets, and no +/− — pinch does that. */
@media (pointer: coarse) {
  .canvas-tools { gap: 10px; }
  .round-btn { width: 44px; height: 44px; }
  .round-btn.zoom { display: none; }
  .soon-chip { min-height: 44px; align-items: center; }
}

/* ---- avatars (brief, results) ---- */
[data-map] .avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  font-size: 12px; font-weight: 600; letter-spacing: .04em;
  color: var(--on-mark); background: var(--mark);
}
[data-map] .avatar.unmet { color: var(--muted); background: transparent; border: 1.3px dashed var(--muted); }

/* ---- the brief ---- */
/* Desktop: a card floating over the map's right edge, like the landing
   page's brief card, so the map doesn't jump sideways when it opens. */
.panel {
  position: absolute; top: 16px; right: 16px; bottom: 16px; z-index: 4;
  width: 400px; max-width: calc(100% - 32px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--line); border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 22px 26px 36px;
  opacity: 0; transform: translateX(16px);
  transition: transform .32s cubic-bezier(.22, 1, .36, 1), opacity .2s ease;
}
.panel.open { opacity: 1; transform: none; }
/* The close button (and on a phone, the grabber) stays put while the brief
   scrolls under it. */
.panel-top {
  position: sticky; top: 0; z-index: 2; height: 0;
  display: flex; justify-content: flex-end; margin: 0 -14px;
}
.handle { display: none; }
.panel-close {
  position: relative; top: -6px;
  width: 44px; height: 44px; padding: 0; cursor: pointer;
  display: grid; place-items: center;
  font: inherit; font-size: 22px; line-height: 1; color: var(--muted);
  background: transparent; border: 0; border-radius: 50%;
}
.panel-close::before {
  content: ""; position: absolute; inset: 7px; border: 1px solid var(--line); border-radius: 50%;
}
.panel-close:hover { color: var(--ink); }
.panel-close:hover::before { border-color: var(--muted); }

.brief-who { display: flex; align-items: center; gap: 14px; padding-right: 48px; min-height: 48px; }
[data-map] .brief-who .avatar { width: 48px; height: 48px; font-size: 16px; }
.brief-head h2 { font-size: 26px; line-height: 1.15; font-weight: 300; }
.brief-head h2:focus { outline: none; }
.brief-rel { margin-top: 3px; color: var(--mark-ink); font-size: 15px; }
.brief-aka { margin-top: 12px; color: var(--muted); font-size: 13.5px; }
.brief-meta { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 14px; }
.brief-meta span {
  padding: 4px 11px; font-size: 12.5px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
}

.panel section { margin-top: 28px; }
.panel .label { margin-bottom: 12px; }
.panel ul { margin: 0; padding: 0; list-style: none; }
.panel .lines li { padding: 12px 0; border-top: 1px solid var(--line); font-size: 15.5px; line-height: 1.5; color: var(--strong); }
.panel .lines li:last-child { border-bottom: 1px solid var(--line); }
.panel .facts li { padding: 8px 0; font-size: 15px; line-height: 1.5; }
.panel .facts li .kind { display: block; font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.panel .facts li.unconfirmed { color: var(--ink); }
.panel .facts li .unsure { font-size: 12.5px; color: var(--muted); }
.panel .ties li { border-top: 1px solid var(--line); }
.panel .ties button, .panel .ties .tie {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 6px 0;
  font: inherit; color: var(--strong); background: none; border: 0; text-align: left;
}
.panel .ties button { cursor: pointer; }
.panel .ties button .avatar, .panel .ties .tie .avatar { width: 32px; height: 32px; font-size: 11px; }
.panel .tie-text { display: flex; flex-direction: column; min-width: 0; }
.panel .tie-name { font-size: 15px; line-height: 1.3; }
.panel .ties button:hover .tie-name { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.panel .ties .rel { font-size: 13px; line-height: 1.3; color: var(--muted); }
.panel .thin { margin-top: 22px; padding: 14px 16px; font-size: 14px; color: var(--ink); background: var(--sunk); border-radius: 14px; }
.panel-loading { margin-top: 22px; color: var(--muted); }

/* ---- editing ---- */
.brief-head { position: relative; }
.edit-btn {
  margin-top: 14px; min-height: 36px; padding: 0 14px; cursor: pointer;
  font: inherit; font-size: 13.5px; color: var(--ink);
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
}
.edit-btn:hover { border-color: var(--muted); }
.edit-block { margin-top: 24px; }
.edit-block .label { display: block; margin-bottom: 10px; }
.edit-name, .chip-add, .edit-notes textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--strong);
  background: var(--bg); border: 1px solid var(--field-edge); border-radius: 12px;
}
.edit-name { height: 46px; padding: 0 14px; }
.edit-name:focus-visible, .chip-add:focus-visible, .edit-notes textarea:focus-visible { outline: 2px solid var(--mark); outline-offset: 1px; border-color: transparent; }
.rename-preview .note { margin-top: 10px; font-size: 13.5px; color: var(--mark-ink); }
.spread-head { margin-top: 14px; font-size: 14px; color: var(--ink); }
.spread-list { margin-top: 6px !important; }
.spread { display: flex; gap: 10px; align-items: center; min-height: 36px; font-size: 14px; color: var(--strong); cursor: pointer; }
.spread input { accent-color: var(--mark); width: 18px; height: 18px; flex: none; }
@media (pointer: coarse) { .spread { min-height: 44px; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 2px; padding: 4px 4px 4px 12px;
  font-size: 14px; color: var(--strong); background: var(--sunk); border-radius: 999px;
}
.chip button {
  width: 28px; height: 28px; padding: 0; cursor: pointer; border: 0; border-radius: 50%;
  font: inherit; font-size: 17px; line-height: 1; color: var(--muted); background: transparent;
}
.chip button:hover { color: var(--strong); }
.chip-add { flex: 1 1 140px; height: 38px; padding: 0 12px; font-size: 15px; }
.toggle { display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--strong); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .track {
  position: relative; width: 44px; height: 26px; flex: none; border-radius: 999px;
  background: var(--line); transition: background-color .2s ease;
}
.toggle .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--panel); box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s ease;
}
.toggle input:checked + .track { background: var(--mark); }
.toggle input:checked + .track::after { transform: translateX(18px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--mark); outline-offset: 2px; }
.edit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 24px; }
/* "Discard changes?" on its own line, its two answers under it. */
.edit-actions .confirm { flex: 1 1 100%; }
.solid-btn.small { padding: 11px 20px; font-size: 14px; min-height: 44px; }
.solid-btn[disabled] { opacity: .6; cursor: progress; }
.edit-status { font-size: 13.5px; color: var(--muted); }
.edit-notes li { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.edit-notes .note-text {
  font: inherit; font-size: 15px; line-height: 1.5; color: var(--strong); text-align: left;
  background: none; border: 0; padding: 0; cursor: text;
}
/* Save stays in reach however long the notes run. */
.panel.editing .edit-actions {
  position: sticky; bottom: -36px; z-index: 2;
  margin: 24px -26px -36px; padding: 14px 26px 18px;
  background: var(--panel); border-top: 1px solid var(--line);
}
/* A note in the brief is also the way into fixing it. */
.fact-btn {
  display: block; width: 100%; padding: 0; margin: 0; text-align: left;
  font: inherit; color: inherit; background: none; border: 0; cursor: pointer; border-radius: 6px;
}
.fact-btn:hover { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.fact-btn:focus-visible { outline: 2px solid var(--mark); outline-offset: 3px; }
.flash {
  margin-top: 16px; font-size: 13.5px; color: var(--mark-ink, var(--ink));
  animation: flash-out 5s ease forwards;
}
@keyframes flash-out { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; } }
.edit-notes textarea { padding: 10px 12px; resize: vertical; line-height: 1.5; }
.note-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.icon-btn {
  min-height: 34px; padding: 0 12px; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--muted);
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
}
.icon-btn:hover { color: var(--ink); border-color: var(--muted); }
.icon-btn.danger { color: var(--error); border-color: color-mix(in srgb, var(--error) 40%, transparent); }
.confirm { font-size: 13.5px; color: var(--ink); margin-right: 4px; }
@media (pointer: coarse) { .icon-btn { min-height: 44px; } }

.edit-hint { margin-top: 10px; font-size: 13.5px; color: var(--muted); }
/* The line is picked from chips, or written: one choice, seen at a glance. */
.line-choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pick { position: relative; display: inline-flex; cursor: pointer; }
.pick input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.pick span {
  padding: 9px 14px; font-size: 14px; line-height: 1.35; color: var(--ink);
  border: 1px solid var(--line); border-radius: 18px; transition: border-color .15s ease, background .15s ease;
}
.pick:hover span { border-color: var(--muted); }
.pick input:checked + span { color: var(--strong); border-color: var(--mark); background: color-mix(in srgb, var(--mark) 16%, transparent); }
.pick input:focus-visible + span { outline: 2px solid var(--mark); outline-offset: 2px; }
.own-line { flex: 1 1 100%; }
.know-preview {
  margin-top: 14px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--bg);
  font-size: 15px; color: var(--strong);
}
.know-preview .label { margin-bottom: 10px; }
.know-preview .know-hi { font-size: 20px; font-weight: 300; margin-bottom: 6px; }
.know-preview .know-line { margin-top: 10px; padding-left: 12px; border-left: 2px solid var(--accent); }
.know-preview .know-ask { margin-top: 10px; font-weight: 500; }

.findable-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; border-top: 1px solid var(--line); }
.findable-list li.edit-hint { border: 0; min-height: 0; }
.link-row { padding: 0; font: inherit; font-size: 15px; color: var(--strong); background: none; border: 0; cursor: pointer; text-align: left; }
.link-row:hover { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.findable-list .rel { font-size: 13px; color: var(--muted); }
.home-tools { margin-top: 14px; }
.sign-out { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
/* Connected assistants: the name and Disconnect on one line, the dates
   under them, so a phone never squeezes the three together. */
.connections { margin-top: 24px; }
.connections li { flex-wrap: wrap; row-gap: 2px; padding: 8px 0; }
.connections li > span:first-child { flex: 1; color: var(--strong); }
.connections li .rel { order: 3; flex-basis: 100%; }
/* The map's own buttons would peek out behind the desktop brief card. */
@media (min-width: 761px) { .briefing .canvas-tools { opacity: 0; pointer-events: none; } }
.canvas-tools { transition: opacity .2s ease; }

/* ---- phone ---- */
@media (max-width: 760px) {
  .stage { flex-direction: column; }
  .app-top { gap: 10px; }
  .app-top .wordmark { display: none; }
  .app-actions { flex: 1; justify-content: flex-end; }
  .app-actions .find { flex: 1; max-width: 320px; }
  /* Sign out lives in your own brief on a phone: the header is for search. */
  .app-actions form { display: none; }
  .find input { width: 100%; }
  .legend { font-size: 11px; gap: 10px; padding: 6px 12px; }
  .panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: auto; max-width: none; max-height: 56dvh;
    border-width: 1px 0 0; border-radius: 24px 24px 0 0;
    padding: 0 22px max(34px, env(safe-area-inset-bottom));
    transform: translateY(100%); opacity: 1;
    transition: transform .38s cubic-bezier(.22, 1, .36, 1);
  }
  .panel.open { transform: none; }
  .panel.dragging { transition: none; }
  /* Editing wants the room: the sheet rises to just under the header. */
  .panel.editing { max-height: calc(100dvh - 72px); }
  .panel.editing .edit-actions {
    bottom: calc(-1 * max(34px, env(safe-area-inset-bottom)));
    margin: 24px -22px calc(-1 * max(34px, env(safe-area-inset-bottom)));
    padding: 12px 22px max(18px, env(safe-area-inset-bottom));
  }
  .panel-top { height: 44px; margin: 0 -22px; background: var(--panel); justify-content: center; }
  .handle {
    display: grid; place-items: center; flex: 1; height: 44px; cursor: grab; touch-action: none;
  }
  .handle span { width: 36px; height: 5px; border-radius: 5px; background: var(--line); }
  .panel-close { position: absolute; top: 0; right: 8px; }
  .brief-head h2 { font-size: 23px; }
}
