/* The start page. Plain CSS, light and dark. */

:root {
  color-scheme: light dark;
  --page: #f7f7fb;
  --card: #ffffff;
  --ink: #161b26;
  --dim: #5d6679;
  --faint: #8e96a8;
  --line: #e6e8ef;
  --field: #ffffff;
  --field-line: #d3d7e1;
  --hover: #f0f1f6;
  --accent: #5b5bf0;
  --accent-hover: #4a4ae0;
  --accent-soft: #eeeefe;
  --accent-ink: #ffffff;
  --bad: #d92d20;
  --good: #12805c;
  --paper: #ffffff;
  --paper-grid: #eef0f5;
  --edge: #7d8698;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-high: 0 2px 4px rgba(16, 24, 40, .06), 0 18px 40px -10px rgba(16, 24, 40, .24);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0f1016;
    --card: #181a22;
    --ink: #eceef3;
    --dim: #a3aabb;
    --faint: #737b8e;
    --line: #262934;
    --field: #12141a;
    --field-line: #343846;
    --hover: #20232d;
    --accent: #7c7cf8;
    --accent-hover: #8e8efa;
    --accent-soft: #23234a;
    --accent-ink: #0f1016;
    --bad: #ff6b60;
    --good: #4fd1a1;
    --paper: #1b1d26;
    --paper-grid: #242733;
    --edge: #8790a3;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-high: 0 2px 4px rgba(0, 0, 0, .3), 0 18px 40px -10px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", system-ui, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--accent); }

[hidden] { display: none !important; }

/* --- top bar ---------------------------------------------------------------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.01em;
  text-decoration: none;
}

.me {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 60vw;
  padding: 4px 14px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.me:hover { background: var(--hover); }

.me-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  --size: 30px;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--color, #667085);
  color: #fff;
  font-size: calc(var(--size) * .4);
  font-weight: 650;
  letter-spacing: .02em;
  user-select: none;
}

/* --- hero --------------------------------------------------------------------- */

main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  gap: 48px;
  padding: 40px 0 56px;
}

.hero.compact {
  grid-template-columns: 1fr;
  padding: 18px 0 28px;
}

.hero.compact .hero-art,
.hero.compact .lead,
.hero.compact .hint {
  display: none;
}

.hero.compact h1 {
  font-size: clamp(26px, 3vw, 32px);
  margin-bottom: 18px;
}

h1 {
  margin: 0 0 18px;
  font-size: clamp(36px, 5.2vw, 58px);
  line-height: 1.05;
  letter-spacing: -.035em;
  font-weight: 750;
}

.lead {
  max-width: 34em;
  margin: 0 0 30px;
  color: var(--dim);
  font-size: clamp(16px, 1.6vw, 18.5px);
  line-height: 1.6;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--field-line);
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
  box-shadow: var(--shadow);
}

.button:hover { background: var(--hover); }
.button:active { transform: scale(.98); }
.button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.button:disabled { opacity: .6; cursor: progress; }

.button.big {
  height: 50px;
  padding: 0 22px;
  border-radius: 13px;
  font-size: 16px;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1), 0 6px 18px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}

.button.primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--accent);
}

.button.ghost:hover { background: var(--accent-soft); }

.button.small { height: 32px; padding: 0 11px; border-radius: 9px; font-size: 13px; }

.button.danger {
  border-color: var(--bad);
  background: var(--bad);
  color: #fff;
}

.linkish {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hero-art {
  min-width: 0;
}

.art {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 22px;
  box-shadow: var(--shadow-high);
}

.art-paper { fill: var(--paper); }
.art-grid { stroke: var(--paper-grid); }
.art-edges { stroke: var(--edge); }
.art-labels { fill: #1d2330; font-family: inherit; }
.art text { font-family: inherit; }

.art-pointer-a { animation: drift-a 7s ease-in-out infinite; }
.art-pointer-b { animation: drift-b 9s ease-in-out infinite; }

@keyframes drift-a {
  0%, 100% { transform: translate(430px, 128px); }
  45% { transform: translate(392px, 150px); }
  70% { transform: translate(420px, 96px); }
}

@keyframes drift-b {
  0%, 100% { transform: translate(190px, 236px); }
  40% { transform: translate(232px, 222px); }
  75% { transform: translate(206px, 262px); }
}

@media (prefers-reduced-motion: reduce) {
  .art-pointer-a, .art-pointer-b { animation: none; }
}

/* --- the diagrams --------------------------------------------------------------- */

.library {
  padding-bottom: 40px;
}

.library-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
  margin-bottom: 20px;
}

.library-head h2 {
  margin: 0;
  margin-right: auto;
  font-size: 22px;
  letter-spacing: -.015em;
}

.filters {
  display: inline-flex;
  padding: 3px;
  border-radius: 11px;
  background: var(--hover);
}

.filters button {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.filters .short { display: none; }

.filters button[aria-selected="true"] {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--field-line);
  border-radius: 10px;
  background: var(--field);
  color: var(--faint);
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.search input {
  width: 170px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}

.card:hover,
.card:focus-within {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  box-shadow: var(--shadow-high);
  transform: translateY(-2px);
}

.card-open {
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius);
  outline: none;
}

.card-open:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent);
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(var(--paper-grid) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(90deg, var(--paper-grid) 1px, transparent 1px) 0 0 / 16px 16px,
    var(--paper);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.thumb-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
}

.live {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px 3px 4px;
  border-radius: 999px;
  background: rgba(17, 20, 28, .82);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.live .faces { display: inline-flex; }
.live .avatar { --size: 20px; box-shadow: 0 0 0 1.5px rgba(17, 20, 28, .9); }
.live .avatar + .avatar { margin-left: -5px; }

.live::before {
  content: "";
  order: 2;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: blink 1.6s ease-in-out infinite alternate;
}

.live span:last-child { order: 3; }

@keyframes blink { from { opacity: 1; } to { opacity: .35; } }

.card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 12px 44px 14px 14px;
}

.card-title {
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  color: var(--dim);
  font-size: 13px;
  white-space: nowrap;
}

.card-meta span:last-child { overflow: hidden; text-overflow: ellipsis; }

.badge {
  flex: none;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 19px;
}

.more {
  position: absolute;
  right: 8px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
}

.more:hover,
.more[aria-expanded="true"] {
  background: var(--hover);
  color: var(--ink);
}

.menu {
  position: fixed;
  z-index: 50;
  min-width: 210px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-high);
  animation: pop .14s ease-out;
}

@keyframes pop { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

.menu button,
.menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu button:hover,
.menu a:hover,
.menu button:focus-visible,
.menu a:focus-visible {
  background: var(--hover);
  outline: none;
}

.menu .danger-item { color: var(--bad); }

.menu hr {
  margin: 5px 4px;
  border: 0;
  border-top: 1px solid var(--line);
}

.menu svg { flex: none; color: var(--dim); }
.menu .danger-item svg { color: var(--bad); }

.none {
  padding: 40px 0;
  color: var(--dim);
  text-align: center;
}

.skeleton .thumb { animation: shimmer 1.2s ease-in-out infinite alternate; }
.skeleton .card-title,
.skeleton .card-meta {
  height: 12px;
  margin: 4px 0;
  border-radius: 6px;
  background: var(--hover);
}
.skeleton .card-title { width: 60%; }
.skeleton .card-meta { width: 40%; }

@keyframes shimmer { from { opacity: 1; } to { opacity: .55; } }

/* --- how it works ----------------------------------------------------------------- */

.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  padding: 8px 0 56px;
}

.step {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.step-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.step h3 { margin: 14px 0 6px; font-size: 17px; }
.step p { margin: 0; color: var(--dim); font-size: 14.5px; line-height: 1.55; }

/* --- footer ------------------------------------------------------------------------------ */

.foot {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 24px 30px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 13.5px;
}

.foot p { margin: 0 0 6px; }
.foot .fine { color: var(--faint); font-size: 12.5px; }
.foot .fine a { color: inherit; }

/* --- dialogs, messages, dropping ----------------------------------------------------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(16, 24, 40, .42);
  backdrop-filter: blur(3px);
  animation: fade .16s ease-out;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.dialog {
  position: relative;
  width: min(460px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 26px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-high);
  animation: rise .2s cubic-bezier(.2, .8, .2, 1);
}

@keyframes rise { from { transform: translateY(8px) scale(.98); } to { transform: none; } }

.dialog h2 { margin: 0 34px 6px 0; font-size: 20px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.dialog p { margin: 0 0 18px; color: var(--dim); font-size: 14.5px; }
.dialog .warn { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--ink); font-size: 13.5px; }

.dialog label {
  display: block;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
}

.field {
  display: block;
  width: 100%;
  height: 42px;
  margin-top: 7px;
  padding: 0 12px;
  border: 1px solid var(--field-line);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font-size: 15px;
  outline: none;
}

.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.row { display: flex; gap: 8px; }
.row .field { margin: 0; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
}

.close:hover { background: var(--hover); color: var(--ink); }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

.swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--color);
  cursor: pointer;
}

.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--color); }
.swatch:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }

.error { min-height: 1.2em; margin: 6px 0 0; color: var(--bad); font-size: 13px; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: min(460px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 11px;
  background: #1d2330;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .25);
  animation: rise .2s ease-out;
}

.toast.bad { background: var(--bad); }

@media (prefers-color-scheme: dark) {
  .toast { background: #eceef3; color: #161b26; }
  .toast.bad { background: var(--bad); color: #fff; }
}

.drop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, var(--accent) 14%, rgba(247, 247, 251, .82));
  backdrop-filter: blur(2px);
  pointer-events: none;
}

.drop-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(520px, 100%);
  padding: 48px 24px;
  border: 2px dashed var(--accent);
  border-radius: 22px;
  background: var(--card);
  color: var(--accent);
  box-shadow: var(--shadow-high);
}

.drop-box strong { color: var(--ink); font-size: 20px; }
.drop-box span { color: var(--dim); font-size: 14px; }

/* --- connecting an assistant ------------------------------------------------------------- */

.dialog.wide { width: min(600px, 100%); }

.dialog h3 { margin: 20px 0 8px; font-size: 14.5px; }

.code {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 10px 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--hover);
}

.code code {
  flex: 1;
  min-width: 0;
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.dialog .note { font-size: 13px; color: var(--dim); margin: 8px 0 0; }

.connections { margin: 6px 0 0; padding: 0; list-style: none; }

.connections li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.connections .what { flex: 1; min-width: 0; }
.connections .what strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connections .what span { color: var(--dim); font-size: 12.5px; }

/* --- narrow screens ------------------------------------------------------------------------ */

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 32px; padding: 20px 0 40px; }
  .hero-art { max-width: 560px; }
  .steps { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .top { padding: 14px 16px; }
  main { padding: 0 16px; }
  .foot { padding: 20px 16px 26px; }
  .actions .button { flex: 1 1 100%; }
  .library-head h2 { width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .filters { width: 100%; }
  .filters button { flex: 1; padding: 0 6px; }
  .filters .long { display: none; }
  .filters .short { display: inline; }
  .thumb { aspect-ratio: 2 / 1; }
  .me-name { display: none; }
  .me { padding: 4px; }
}
