@font-face {
  font-family: "Schibsted Grotesk";
  src: url("fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("fonts/schibsted-grotesk-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+1E00-1E9F, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --panel: #17393b;
  --panel-up: #21494b;
  --panel-line: #33605f;
  --panel-text: #e4ebe6;
  --panel-dim: #a3bab5;
  --paper: #eef1ec;
  --sheet: #f8faf6;
  --ink: #12262a;
  --ink-dim: #566a6c;
  --rule: #cdd6d0;
  --lamp: #f2b33d;
  --line: #1c7c74;
  --person: #7a3e6e;
  --danger: #a83232;
  --focus: #0d5f8a;

  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.125rem;
  --step-2: 1.5rem;
  --step-3: 2.25rem;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.5 "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}
#app { height: 100%; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: var(--step-1); font-weight: 600; }
code, pre { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: 0.875em; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rail :focus-visible { outline-color: var(--lamp); }

.hidden-text {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select {
  width: 100%;
  padding: 0.5rem 0.625rem;
  background: var(--sheet);
  border: 1px solid #a5b3ad;
  border-radius: 4px;
}
textarea { resize: vertical; }
label { display: block; font-weight: 500; }
label > span.hint { display: block; font-weight: 400; color: var(--ink-dim); font-size: var(--step--1); }
label input, label select, label textarea { margin-top: 0.25rem; }

.btn {
  padding: 0.4375rem 0.875rem;
  background: var(--panel);
  color: var(--panel-text);
  border: 1px solid var(--panel);
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: var(--panel-up); }
.btn.plain { background: transparent; color: var(--ink); border-color: #a5b3ad; }
.btn.plain:hover { background: #e2e8e2; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.error { color: var(--danger); font-size: var(--step--1); min-height: 1.25rem; }

/* Sign in */
.auth {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 26rem);
  background: var(--panel);
}
.auth-story { padding: 3.5rem clamp(1.5rem, 6vw, 5rem); color: var(--panel-text); align-self: center; }
.auth-story h1 { font-size: clamp(var(--step-3), 4vw, 3.25rem); line-height: 1.08; font-weight: 600; max-width: 16ch; }
.auth-story p { margin-top: 1rem; max-width: 42ch; color: var(--panel-dim); }
.auth-demo { margin-top: 2.5rem; max-width: 34rem; display: block; width: 100%; }
.auth-demo text { fill: var(--panel-text); font-size: 13px; }
.auth-demo .life { stroke: var(--panel-line); stroke-width: 1.5; }
.auth-demo .call { stroke: var(--lamp); stroke-width: 2; fill: none; }
.auth-demo .back { stroke: var(--panel-text); stroke-width: 2; fill: none; stroke-dasharray: 5 4; }
.auth-demo .tip-call { fill: var(--lamp); }
.auth-demo .tip-back { fill: var(--panel-text); }
.auth-demo .say { fill: var(--panel-dim); font-size: 12px; }
.auth-demo .draw { opacity: 0; animation: arrive 0.4s ease-out forwards; }
.auth-demo .d2 { animation-delay: 0.9s; }
@keyframes arrive { to { opacity: 1; } }
.auth-form {
  background: var(--paper);
  padding: 3rem 2rem;
  display: flex; flex-direction: column; justify-content: center; gap: 1rem;
}
.auth-form h2 { font-size: var(--step-2); }
.switch-mode { background: none; border: 0; padding: 0; color: var(--focus); text-decoration: underline; cursor: pointer; text-align: left; }

/* Main layout */
.shell { height: 100%; display: grid; grid-template-columns: 15rem 19rem minmax(0, 1fr); }

.rail {
  background: var(--panel);
  color: var(--panel-text);
  display: flex; flex-direction: column;
  min-height: 0;
  padding: 0.875rem 0;
}
.rail-top { padding: 0 0.875rem 0.875rem; border-bottom: 1px solid var(--panel-line); }
.rail select { background: var(--panel-up); border-color: var(--panel-line); color: var(--panel-text); font-weight: 600; }
.rail-note { margin-top: 0.5rem; font-size: var(--step--1); color: var(--lamp); }
.rail-scroll { flex: 1; overflow-y: auto; padding: 0.75rem 0; }
.rail h2 {
  font-size: var(--step--1); font-weight: 500; color: var(--panel-dim);
  padding: 0.5rem 0.875rem 0.25rem;
}
.jack {
  display: grid; grid-template-columns: 0.75rem minmax(0, 1fr); gap: 0.625rem; align-items: center;
  width: 100%; padding: 0.375rem 0.875rem;
  background: none; border: 0; color: inherit; text-align: left; cursor: pointer;
}
.jack:hover { background: var(--panel-up); }
.jack .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.jack .what { display: block; font-size: var(--step--1); color: var(--panel-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }

/* The one loud element: lamps that say who can answer right now. */
.lamp {
  width: 0.75rem; height: 0.75rem; border-radius: 50%;
  border: 2px solid var(--panel-dim);
  background: transparent;
  flex: none;
}
.lamp.recent { border-color: var(--lamp); }
.lamp.online { border-color: var(--lamp); background: var(--lamp); box-shadow: 0 0 8px 1px rgb(242 179 61 / 0.75); }
.sheet .lamp { border-color: #8a9c98; }
.sheet .lamp.recent { border-color: #b98512; }
.sheet .lamp.online { border-color: #b98512; background: var(--lamp); box-shadow: none; }

.rail-add { margin: 0.25rem 0.875rem 0.5rem; width: calc(100% - 1.75rem); background: transparent; border-color: var(--panel-line); }
.rail-add:hover { background: var(--panel-up); }
.rail-foot { border-top: 1px solid var(--panel-line); padding: 0.625rem 0.875rem 0; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.rail-foot .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--panel-dim); font-size: var(--step--1); }
.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font-size: var(--step--1); }

.threads { background: #e4e9e3; border-right: 1px solid var(--rule); display: flex; flex-direction: column; min-height: 0; }
.threads-top { padding: 0.875rem; display: grid; gap: 0.5rem; border-bottom: 1px solid var(--rule); }
.thread-list { flex: 1; overflow-y: auto; }
.thread-row {
  display: block; width: 100%; padding: 0.625rem 0.875rem;
  background: none; border: 0; border-bottom: 1px solid var(--rule);
  text-align: left; cursor: pointer;
}
.thread-row:hover { background: #dbe2dc; }
.thread-row[aria-current="true"] { background: var(--sheet); box-shadow: inset 3px 0 0 var(--line); }
.thread-row .who { font-weight: 600; display: flex; justify-content: space-between; gap: 0.5rem; }
.thread-row .when { font-weight: 400; color: var(--ink-dim); font-size: var(--step--1); white-space: nowrap; }
.thread-row .preview {
  color: var(--ink-dim); font-size: var(--step--1);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.more-threads { display: block; margin: 0.75rem auto; }
.empty { padding: 1.25rem 0.875rem; color: var(--ink-dim); }
.empty .btn { margin-top: 0.75rem; }

/* Conversation drawn as a sequence diagram */
.sheet { display: flex; flex-direction: column; min-height: 0; background: var(--sheet); position: relative; }
.banner { background: var(--lamp); padding: 0.25rem 1rem; font-size: var(--step--1); font-weight: 500; }
.seq-scroll { flex: 1; overflow-y: auto; }
.seq { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); position: relative; min-height: 100%; }
.seq-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--sheet); border-bottom: 1px solid var(--rule);
  padding: 0.625rem 0.5rem;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-weight: 600; min-width: 0;
}
.seq-head .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seq-head.person { color: var(--person); }
.lifeline {
  grid-row: 1 / 9999;
  justify-self: center; width: 1px;
  background: var(--rule);
  pointer-events: none;
}
.step { padding-top: 0.75rem; min-width: 0; display: flex; flex-direction: column; z-index: 1; }
.step:last-child { padding-bottom: 1.5rem; }
.step.rightward { align-items: flex-start; }
.step.leftward { align-items: flex-end; }
.bubble {
  max-width: min(calc(100% - 1.25rem), 44rem);
  margin-inline: 0.625rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  overflow-wrap: anywhere;
}
.step.person .bubble { border-color: #c9abc3; }
.bubble .meta { display: flex; gap: 0.625rem; color: var(--ink-dim); font-size: var(--step--1); margin-bottom: 0.125rem; }
.bubble .sender { font-weight: 600; color: var(--ink); }
.bubble p { white-space: pre-wrap; }
.bubble p + p, .bubble pre + p, .bubble p + pre { margin-top: 0.5rem; }
.bubble pre { margin: 0.5rem 0 0; background: #eaefe9; border-radius: 4px; padding: 0.5rem 0.625rem; overflow-x: auto; white-space: pre; }
.bubble code { background: #eaefe9; border-radius: 3px; padding: 0 0.25rem; }
.bubble pre code { background: none; padding: 0; }
.answer { margin-top: 0.375rem; }

/* The arrow under each message: solid asks, dashed answers, dotted notes. */
/* Runs from lifeline to lifeline, which sit in the middle of the first and last column. */
.arrow {
  align-self: stretch; height: 0.625rem; margin-top: 0.3125rem; position: relative; color: var(--line);
  margin-inline: calc(100% / var(--span) / 2);
}
.step.person .arrow { color: var(--person); }
.arrow::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  border-top: 2px solid currentColor;
}
.kind-reply .arrow::before { border-top-style: dashed; }
.kind-note .arrow::before { border-top-style: dotted; }
.arrow::after {
  content: ""; position: absolute; top: calc(50% - 4px); width: 0; height: 0;
  border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}
.rightward .arrow::after { right: 0; border-left: 8px solid currentColor; }
.leftward .arrow::after { left: 0; border-right: 8px solid currentColor; }
.arrive { animation: arrive 0.25s ease-out; }

.seq-empty { padding: 3rem clamp(1rem, 5vw, 3rem); max-width: 40rem; }
.seq-empty h2 { font-size: var(--step-2); }
.seq-empty p { margin-top: 0.5rem; color: var(--ink-dim); }
.seq-empty ol { margin: 1rem 0 0; padding-left: 1.25rem; }
.seq-empty li { margin-top: 0.375rem; }
.seq-empty .btn { margin-top: 1.25rem; }

.composer { border-top: 1px solid var(--rule); padding: 0.75rem 1rem; display: grid; gap: 0.5rem; background: var(--paper); }
.composer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; align-items: end; }
.composer-to { display: flex; align-items: center; gap: 0.5rem; font-size: var(--step--1); color: var(--ink-dim); }
.composer-to select { width: auto; padding: 0.125rem 0.375rem; }

dialog {
  border: 0; border-radius: 8px; padding: 0;
  width: min(36rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  background: var(--paper); color: var(--ink);
  box-shadow: 0 18px 50px rgb(18 38 42 / 0.35);
}
dialog::backdrop { background: rgb(18 38 42 / 0.5); }
.dlg { padding: 1.25rem; display: grid; gap: 0.875rem; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }
.dlg-actions .push { margin-right: auto; }
.cmd { position: relative; }
.cmd pre {
  margin: 0.25rem 0 0; background: var(--panel); color: var(--panel-text);
  border-radius: 4px; padding: 0.625rem 4.5rem 0.625rem 0.75rem;
  overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}
.cmd button {
  position: absolute; right: 0.375rem; top: 0.375rem;
  background: var(--panel-up); color: var(--panel-text); border: 1px solid var(--panel-line);
  border-radius: 3px; padding: 0.125rem 0.5rem; font-size: var(--step--1); cursor: pointer;
}
.steps { margin: 0; padding-left: 1.25rem; display: grid; gap: 0.875rem; }
.note { font-size: var(--step--1); color: var(--ink-dim); }
.warn { font-size: var(--step--1); background: #f7e9c9; border-left: 3px solid var(--lamp); padding: 0.5rem 0.625rem; }
details summary { cursor: pointer; font-weight: 500; }
details > *:not(summary) { margin-top: 0.5rem; }
.row-list { display: grid; gap: 0.25rem; }
.row-list > div { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.25rem 0; border-bottom: 1px solid var(--rule); }

.back-btn { display: none; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 12.5rem minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .threads { display: none; }
  .shell.show-list .threads { display: flex; }
  .shell.show-list .sheet { display: none; }
  .back-btn { display: inline-block; margin: 0.5rem 1rem 0; justify-self: start; }
}
@media (max-width: 640px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-story { padding: 2rem 1.5rem 1.5rem; }
  .auth-demo { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .rail { max-height: 38vh; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .auth-demo .draw { opacity: 1; }
}
