/* The one stylesheet for every page the hub serves: the owner's pages, sign-in, desk cards, the screen.
   Structure borrows from the settings pages of the devices this runs on: one column of grouped rows, a label on the
   left and its value on the right. Colour follows the system's light or dark setting. */

:root {
  color-scheme: light dark;
  --canvas: #f2f2f7;
  --cell: #ffffff;
  --well: #f4f4f8;
  --ink: #111113;
  --ink-2: #66666e;
  --ink-3: #9c9ca4;
  --line: #e3e3e8;
  --blue: #0a6cff;
  --on-blue: #ffffff;
  --blue-wash: #e8f1ff;
  --green: #1c9a50;
  --amber: #b46a00;
  --red: #cf3329;
  --bubble: #e9e9ee;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #000000;
    --cell: #1c1c1e;
    --well: #2a2a2d;
    --ink: #f5f5f7;
    --ink-2: #a1a1a8;
    --ink-3: #6f6f76;
    --line: #2f2f33;
    --blue: #2b8cff;
    --blue-wash: #10233f;
    --green: #32d15a;
    --amber: #ffb443;
    --red: #ff6b61;
    --bubble: #2a2a2d;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 17px/1.41 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 20px; overflow-wrap: anywhere; }
h2 { font-size: 13px; line-height: 1.38; font-weight: 400; color: var(--ink-2); margin: 28px 16px 7px; }
h3 { font-size: 17px; font-weight: 600; margin: 0; overflow-wrap: anywhere; }
p { margin: 0 0 10px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .note { font-size: 13px; line-height: 1.38; color: var(--ink-2); }
code, .mono { font-family: var(--mono); font-size: 0.86em; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }

/* ---------- the frame: a list of sections beside the page; on a phone the list is the home page ---------- */

.shell { display: flex; align-items: flex-start; gap: 36px; max-width: 980px; margin: 0 auto; padding: 28px 24px 80px; }
.side { flex: 0 0 216px; position: sticky; top: 28px; }
.page { flex: 1 1 auto; min-width: 0; max-width: 620px; overflow-wrap: anywhere; }
.page :where(span, div, p, a, label, li, summary, form) { min-width: 0; }

.who { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; color: var(--ink); font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.who:hover { text-decoration: none; }

.side nav { display: flex; flex-direction: column; gap: 1px; }
.side nav a { color: var(--ink); padding: 7px 10px; border-radius: 8px; font-size: 15px; }
.side nav a:hover { background: var(--line); text-decoration: none; }
.side nav a[aria-current="page"] { background: var(--blue); color: var(--on-blue); }

.back { display: none; }

@media (max-width: 760px) {
  .shell { display: flex; flex-direction: column; gap: 0; padding: 14px 16px 64px; }
  .page { order: 1; width: 100%; max-width: none; }
  .side { order: 2; position: static; display: none; flex: none; width: 100%; }
  .back { display: inline-flex; align-items: center; gap: 2px; font-size: 17px; margin: 0 0 10px -6px; padding: 6px; }
  .back::before { content: ""; width: 9px; height: 9px; border-left: 2.5px solid var(--blue); border-bottom: 2.5px solid var(--blue); transform: rotate(45deg); margin-right: 4px; }
  /* Home: the page first, then the list of sections as rows */
  .at-home .side { display: block; margin-top: 28px; }
  .at-home .who, .at-home .back { display: none; }
  .at-home .side nav { background: var(--cell); border-radius: var(--radius); overflow: hidden; gap: 0; }
  .at-home .side nav a { position: relative; padding: 12px 34px 12px 16px; border-radius: 0; font-size: 17px; }
  .at-home .side nav a + a { box-shadow: inset 0 1px 0 var(--line); }
  .at-home .side nav a[aria-current="page"] { display: none; }
  .at-home .side nav a[aria-current="page"] + a { box-shadow: none; }
  .at-home .side nav a::after { content: ""; position: absolute; right: 17px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--ink-3); border-top: 2px solid var(--ink-3); transform: translateY(-50%) rotate(45deg); }
}

.banner { background: var(--amber); color: #000; text-align: center; font-size: 13px; font-weight: 600; padding: 6px 12px; }

/* ---------- groups of rows ---------- */

.group { background: var(--cell); border-radius: var(--radius); overflow: hidden; margin: 0 0 12px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 11px 16px; color: var(--ink); }
.row + .row, .group > * + .row, .row + * { box-shadow: inset 0 1px 0 var(--line); }
.row .grow { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.row > .state, .row > .value { flex: 0 0 auto; max-width: 62%; }
.row .value { color: var(--ink-2); text-align: right; overflow-wrap: anywhere; }
.row .sub { display: block; font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
a.row { position: relative; padding-right: 36px; }
a.row:hover { text-decoration: none; background: var(--well); }
a.row::after { content: ""; position: absolute; right: 17px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--ink-3); border-top: 2px solid var(--ink-3); transform: translateY(-50%) rotate(45deg); }
.pad { padding: 14px 16px; }
.empty { color: var(--ink-2); }

/* ---------- state, shown as a dot and one word ---------- */

.state { display: inline-flex; align-items: baseline; gap: 7px; font-size: 15px; color: var(--ink-2); min-width: 0; overflow-wrap: anywhere; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; transform: translateY(-1px); }
.state.ok::before { background: var(--green); }
.state.need::before { background: var(--amber); }
.state.bad::before { background: var(--red); }
.state.live::before { background: var(--amber); animation: waiting 1.6s ease-in-out infinite; }
.state.ok { color: var(--ink); }
@keyframes waiting { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .state.live::before { animation: none; } }

/* ---------- fields and buttons ---------- */

label { display: block; font-size: 13px; color: var(--ink-2); margin: 0 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--well); border: 1px solid transparent;
  border-radius: 10px; padding: 11px 12px; min-height: 46px; margin: 0;
}
textarea { min-height: 132px; resize: vertical; line-height: 1.45; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue); outline-offset: 0; border-radius: 10px; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--blue); flex: none; }
.field { margin: 0 0 14px; }
.field:last-child { margin-bottom: 0; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px;
  font: inherit; font-weight: 600; color: var(--on-blue); background: var(--blue); border: 0; border-radius: 12px;
  cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent;
}
button:hover, .button:hover { filter: brightness(1.07); text-decoration: none; }
button:active, .button:active { filter: brightness(0.93); }
button.quiet, .button.quiet { color: var(--blue); background: transparent; padding-left: 8px; padding-right: 8px; font-weight: 500; }
button.soft, .button.soft { color: var(--blue); background: var(--blue-wash); }
button.danger, .button.danger { color: var(--red); background: transparent; font-weight: 500; }
button.wide, .button.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.error { color: var(--red); font-size: 15px; margin: 0 0 12px; }

/* ---------- a switch: on or off, saved the moment it is flipped ---------- */

.row label.grow { font-size: 17px; color: var(--ink); margin: 0; cursor: pointer; }
input[type="checkbox"].toggle {
  appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--ink-3);
  position: relative; cursor: pointer; transition: background 0.18s; border: 0;
}
input[type="checkbox"].toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.18s;
}
input[type="checkbox"].toggle:checked { background: var(--green); }
input[type="checkbox"].toggle:checked::after { transform: translateX(20px); }
input[type="checkbox"].toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 16px; }
@media (prefers-reduced-motion: reduce) { input[type="checkbox"].toggle, input[type="checkbox"].toggle::after { transition: none; } }

/* ---------- a row that opens to what is behind it ---------- */

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary.row { position: relative; padding-right: 40px; cursor: pointer; font-weight: 400; }
details > summary.row::after { content: ""; position: absolute; right: 18px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: translateY(-70%) rotate(45deg); transition: transform 0.15s; }
details[open] > summary.row::after { transform: translateY(-30%) rotate(-135deg); }
details + details, .group > * + details { box-shadow: inset 0 1px 0 var(--line); }
summary.row.add { color: var(--blue); }
@media (prefers-reduced-motion: reduce) { details > summary.row::after { transition: none; } }

/* ---------- small things in a row ---------- */

.fields { display: grid; gap: 0 12px; margin: 0 0 14px; }
.fields .field { margin: 0 0 14px; }
.fields:last-child, .fields .field:last-child { margin-bottom: 0; }
@media (min-width: 520px) {
  .fields.two { grid-template-columns: 1fr 1fr; }
  .fields.two.wide-first { grid-template-columns: 2fr 1fr; }
  .fields.three { grid-template-columns: 1fr 1fr 1fr; }
  .fields.two .field, .fields.three .field { margin-bottom: 0; }
}
textarea.short { min-height: 76px; }
textarea.tall { min-height: 220px; }
textarea.mono, input.mono { font-family: var(--mono); font-size: 14px; }

/* a title with its quiet actions under it */
.row.stack { flex-direction: column; align-items: stretch; gap: 4px; }
.row.stack > a.grow { color: var(--ink); }
.links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 20px; }
.links form { display: contents; }
.links a, .links button { min-height: 34px; padding: 2px 0; font-size: 15px; font-weight: 500; background: none; color: var(--blue); border-radius: 6px; }
.links .danger { color: var(--red); }
.row.links { min-height: 44px; padding-top: 5px; padding-bottom: 5px; }
/* a button in a row sits on the row's line, and a quiet one starts where the row's words start */
.page form.row > button, .page .links form > button, .page .row form > button { margin-top: 0; }
.row button.quiet, .row button.danger { min-height: 30px; padding-top: 2px; padding-bottom: 2px; }
.row > button.quiet:first-child, .row > button.danger:first-child,
.row > .grow > button.quiet:first-child, .row > .grow > button.danger:first-child { padding-left: 0; }
.row > button, .row > form:not(.links), .row > a.button { flex: none; white-space: nowrap; }
.row:not(.links) > form:not(.links) { display: flex; align-items: center; margin: 0; }

/* what a turn did, step by step */
.steps .said { color: var(--ink-2); }
.steps .mono { color: var(--ink-2); overflow-wrap: anywhere; }
.steps pre { margin: 0; max-height: 320px; overflow-y: auto; }
.note.foot { margin: 0 16px; }
h2.role { font-size: 17px; font-weight: 650; color: var(--ink); margin: 30px 16px 2px; }
.cap { font-size: 13px; color: var(--ink-2); margin: 15px 16px 7px; }
.bar { flex: 0 0 110px; height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--blue); }
.seg { display: flex; gap: 2px; margin: 2px 16px 10px; }
.seg a { font-size: 13px; color: var(--ink-2); padding: 3px 10px; border-radius: 7px; }
.seg a.on { color: var(--ink); background: var(--blue-wash); }
.row.warn { color: var(--warn-ink, #8a4b00); background: var(--warn-bg, #fff4e5); }
a.row.warn { font-weight: 500; }
@media (prefers-color-scheme: dark) { :root { --warn-ink: #ffd9a3; --warn-bg: #3a2a12; } }
.row .error { margin: 0; }

/* ---------- a command to copy ---------- */

/* A short command has its button beside it; one too long for the line takes the line and the button drops below. */
.command { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 6px; background: var(--well); border-radius: 10px; padding: 12px 8px 12px 14px; }
.command code { flex: 1 1 auto; min-width: 0; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.command button { min-height: 30px; padding: 3px 12px; font-size: 14px; flex: none; }
.command .prompt { flex: 1 1 100%; margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 200px; overflow: auto; }
.assistant { margin-top: 10px; }
.assistant > summary { font-size: 14px; color: var(--blue); cursor: pointer; padding: 5px 2px; list-style: none; }
.assistant > summary::-webkit-details-marker { display: none; }
.assistant[open] > summary { color: var(--ink-2); }

/* ---------- the agent, as a contact ---------- */

.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: var(--on-blue); display: inline-flex; align-items: center; justify-content: center; font-weight: 650; font-size: 15px; flex: none; text-transform: uppercase; }
.contact { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 26px 16px 22px; }
.contact .avatar { width: 76px; height: 76px; font-size: 34px; margin-bottom: 12px; }
.contact .name { font-size: 26px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.15; margin: 0; max-width: 100%; }
.contact .address { color: var(--ink-2); font-size: 15px; margin-top: 3px; overflow-wrap: anywhere; }
.contact .state { margin-top: 10px; }

/* ---------- steps of setup ---------- */

.step { background: var(--cell); border-radius: var(--radius); margin: 0 0 12px; overflow: hidden; }
.step > .row { min-height: 56px; }
.step .n { width: 26px; height: 26px; border-radius: 50%; background: var(--well); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; flex: none; }
.step.done .n { background: var(--green); color: #fff; font-size: 0; }
.step.done .n::before { content: ""; width: 10px; height: 5px; border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff; transform: translateY(-1px) rotate(-45deg); }
.step .body { padding: 14px 16px 16px; }
.step.later > .row { color: var(--ink-3); }
.pad.attached { padding-top: 0; box-shadow: none; }
.step.done .body:empty { display: none; }

/* ---------- messages ---------- */

.thread { display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 82%; padding: 8px 13px; border-radius: 19px; background: var(--bubble); align-self: flex-start; overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble.out { background: var(--blue); color: var(--on-blue); align-self: flex-end; }
.from { font-size: 13px; color: var(--ink-2); margin: 2px 13px 0; }
.to { color: var(--ink-2); margin: 0 0 14px; }
.to a, .to b { color: var(--ink); font-weight: 600; }

/* ---------- pages for people who aren't signed in ---------- */

.door { max-width: 400px; margin: 0 auto; padding: 12vh 20px 60px; overflow-wrap: anywhere; }
.door .avatar { width: 64px; height: 64px; font-size: 28px; margin-bottom: 18px; }
.door h1 { margin-bottom: 22px; }
.door .group { padding: 16px; }

/* ---------- plain elements, for pages not yet rebuilt from the parts above ---------- */

.page > section, .page > form, .page > article, .page > details { background: var(--cell); border-radius: var(--radius); padding: 16px; margin: 0 0 12px; }
.page > section > h2, .page > form > h2 { margin: 0 0 10px; font-size: 17px; font-weight: 600; color: var(--ink); }
.page form label { margin-top: 12px; }
.page form label:first-child { margin-top: 0; }
.page form > button { margin-top: 14px; }
summary { cursor: pointer; font-weight: 500; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 9px 8px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-2); font-weight: 400; font-size: 13px; border-top: 0; }
pre { background: var(--well); border-radius: 10px; padding: 12px 14px; overflow-x: auto; font: 13.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
