/* Org Chart Builder — the whole design system, in one stylesheet.
   No frameworks, no external requests, no build step.

   One typeface: the system's own. Hierarchy comes from size, weight and
   colour, so there is no font to download and nothing to shift when it lands. */

/* ----------------------------------------------------------------- tokens -- */

:root {
  color-scheme: light;

  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;

  /* Type scale */
  --text-2xs: .656rem;   /* 10.5 — tags, line labels */
  --text-xs:  .72rem;    /* 11.5 — field labels, card detail */
  --text-sm:  .8125rem;  /* 13   — buttons, secondary text */
  --text-md:  .875rem;   /* 14   — body */
  --text-lg:  1.3125rem; /* 21   — panel headings */
  --text-xl:  1.375rem;  /* 22   — the app's name, page headings */

  /* Spacing scale */
  --s1: 4px;  --s2: 8px;  --s3: 12px;  --s4: 16px;  --s5: 24px;  --s6: 32px;

  /* Surfaces: warm paper, white on top of it */
  --bg:         #f3f1ea;
  --canvas:     #f6f4ee;
  --canvas-dot: #d9d5ca;
  --surface:    #ffffff;
  --surface-2:  #efece4;
  --field:      #fbfaf7;

  --ink:       #1c1b18;
  --text-soft: #3d3a33;
  --text-mute: #5f5b52;

  --line:        #e3dfd5;
  --line-soft:   #ebe8e0;
  --line-strong: #d9d5cc;

  --accent:       #2f5d8a;
  --accent-hover: #264d73;
  --accent-ring:  rgba(47, 93, 138, .18);
  --accent-glow:  rgba(47, 93, 138, .28);

  --danger:      #8a2f2f;
  --danger-line: #e5c4c4;
  --danger-bg:   #fbf0f0;

  --ok-fg: #14532d;  --ok-bg: #e7f6ec;  --ok-line: #b9dfc5;

  /* Dotted lines have a colour of their own, everywhere they appear. */
  --dotted:      #c2410c;
  --dotted-ink:  #9a3412;
  --dotted-line: #fdba74;
  --dotted-bg:   #fff7ed;
  --dotted-soft: #fffaf5;
  --linking:     #f59e0b;

  --connector: #9a9ea6;

  --radius-sm: 9px;
  --radius:    10px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --round:     999px;

  --shadow-card:   0 1px 2px rgba(28, 27, 24, .06), 0 8px 20px rgba(28, 27, 24, .10);
  --shadow-raised: 0 14px 34px rgba(28, 27, 24, .18);
  --shadow-float:  0 10px 28px rgba(28, 27, 24, .25);
  --backdrop:      rgba(28, 27, 24, .4);

  --ease: cubic-bezier(.22, 1, .36, 1);
  --move: .55s;

  /* The smallest thing a finger is asked to hit. */
  --tap: 44px;
}

/* ------------------------------------------------------------------- base -- */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100%;
  font: 400 var(--text-md)/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
}

/* The chart page is a workspace: it fills the window and scrolls inside. */
body.is-fill {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--text-xl); font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }

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

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; opacity: .55; }

code { padding: 0 3px; border-radius: 3px; background: rgba(0, 0, 0, .06); font-size: .92em; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.muted { color: var(--text-mute); }

.icon { width: 15px; height: 15px; flex: none; }

@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes fade { from { opacity: 0; } }

/* ----------------------------------------------------------------- header -- */

.topbar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3) var(--s5);
  min-height: 68px;
  padding: var(--s3) 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; flex-direction: column; gap: 1px; margin-right: auto; min-width: 0; }
.brand-name {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--ink);
  text-decoration: none;
}
.brand-name:hover { color: var(--ink); }
.brand-sub { font-size: var(--text-xs); font-weight: 500; color: var(--text-mute); }
.savestate:not(:empty)::before { content: '·'; margin: 0 .4em; }
.savestate[data-state='offline'] { color: var(--danger); font-weight: 700; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.mainnav { display: flex; gap: 2px; }
.navlink {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--s3);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-mute);
  text-decoration: none;
}
.navlink:hover { background: var(--surface-2); color: var(--ink); }
.navlink.is-current { background: var(--surface-2); color: var(--ink); }

/* The same links, inside the account menu. Phones only — see the end. */
.account-nav { display: none; }

.account { position: relative; }
.account > summary { list-style: none; cursor: pointer; border-radius: 50%; }
.account > summary::-webkit-details-marker { display: none; }
.avatar {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .02em;
}
.avatar--sm { width: 32px; height: 32px; flex: none; }
.account-menu {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  z-index: 20;
  width: 240px;
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
}
.account-name { font-size: var(--text-sm); font-weight: 700; }
.account-email { font-size: var(--text-xs); color: var(--text-mute); word-break: break-all; }
.account-role {
  margin: var(--s2) 0 var(--s3);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--accent);
}

/* ---------------------------------------------------------------- buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-soft);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  transition: background-color .2s, color .2s, border-color .2s, box-shadow .2s, transform .1s;
}
.btn:hover { background: var(--field); color: var(--ink); }
.btn:active { transform: scale(.97); }
.btn--sm { padding: 6px 11px; }
.btn--block { width: 100%; }

.btn--primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn--primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); color: #fff; }
.btn--lift { padding: 10px 16px; box-shadow: 0 4px 12px var(--accent-glow); }

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

.btn--dashed { border: 1px dashed var(--dotted); color: var(--dotted); }
.btn--dashed:hover { background: var(--dotted-soft); color: var(--dotted-ink); }

/* On the dark bar that appears while a dotted line is being drawn. */
.btn--onink { padding: 5px 10px; border-color: rgba(255, 255, 255, .3); background: transparent; color: #fff; }
.btn--onink:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.btn--onink:focus-visible { outline-color: #fff; }

.btn--google { padding: 11px 16px; font-size: var(--text-md); color: var(--ink); }
.icon--google { width: 18px; height: 18px; }

.iconbtn {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px; height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-mute);
}
.iconbtn:hover { background: var(--field); color: var(--ink); }
.iconbtn--sm { width: 24px; height: 24px; border: 0; background: transparent; color: var(--dotted-ink); }
.iconbtn--sm:hover { background: var(--dotted-bg); color: var(--dotted-ink); }
.iconbtn--sm .icon { width: 13px; height: 13px; }

/* The Vertical / Horizontal switch */
.segmented { display: flex; gap: var(--s1); padding: var(--s1); border-radius: var(--radius-md); background: var(--surface-2); }
.segmented-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-mute);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.35;
  transition: background-color .2s, color .2s, box-shadow .2s;
}
.segmented-btn:hover { color: var(--ink); }
.segmented-btn[aria-pressed='true'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(28, 27, 24, .12);
}

/* ------------------------------------------------------------------ forms -- */

.formfield { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.formfield--grow { flex: 1 1 240px; }

.formfield > label,
.formfield > legend,
.label {
  padding: 0;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-mute);
}
/* A legend is not a flex item, so the gap above does not reach it. */
.formfield > legend { margin-bottom: var(--s2); }
.optional { font-weight: 500; letter-spacing: 0; text-transform: none; }

.field {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--field);
  font-size: .844rem;
  line-height: 1.5;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.field::placeholder { color: var(--text-mute); opacity: .8; }
.field:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.field[aria-invalid='true'] { border-color: var(--danger); }
.field--sm { padding: 7px 10px; font-size: var(--text-sm); }
textarea.field { resize: vertical; min-height: 5.5em; }
select.field { width: auto; padding-right: 28px; }

.fielderror { font-size: var(--text-sm); font-weight: 600; color: var(--danger); }
.formhelp { font-size: var(--text-sm); color: var(--text-mute); }

/* ------------------------------------------------------------------- tags -- */

.tag {
  padding: 3px 8px;
  border-radius: var(--round);
  background: #e5e7eb;
  color: #1f2937;
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.4;
}

/* One pair of colours per tag, shared by the card and the editor's pills.
   The names come from TAGS in lib/chart.js. */
.tag--c-suite       { --tag-bg: #ede9fe; --tag-fg: #4c1d95; }
.tag--management    { --tag-bg: #dbeafe; --tag-fg: #1e3a8a; }
.tag--team-lead     { --tag-bg: #ccfbf1; --tag-fg: #134e4a; }
.tag--worker        { --tag-bg: #e5e7eb; --tag-fg: #1f2937; }
.tag--casual        { --tag-bg: #fef3c7; --tag-fg: #78350f; }
.tag--full-time     { --tag-bg: #dcfce7; --tag-fg: #14532d; }
.tag--remote-worker { --tag-bg: #fce7f3; --tag-fg: #831843; }
.tag[class*='tag--'] { background: var(--tag-bg); color: var(--tag-fg); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--round);
  background: var(--surface);
  color: var(--text-mute);
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.35;
  transition: background-color .2s, color .2s, border-color .2s, box-shadow .2s;
}
.pill:hover { border-color: var(--text-mute); }
.pill[aria-pressed='true'] {
  border-color: var(--tag-bg);
  background: var(--tag-bg);
  color: var(--tag-fg);
  box-shadow: inset 0 0 0 1px var(--tag-fg);
}

.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.swatch {
  width: 28px; height: 28px;
  padding: 0;
  border: 1px solid rgba(28, 27, 24, .15);
  border-radius: 50%;
  transition: transform .15s, box-shadow .15s;
}
.swatch:hover { transform: scale(1.12); }
.swatch[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

.customcolor {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: var(--s1);
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-mute);
  cursor: pointer;
}
.customcolor input {
  width: 28px; height: 28px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

/* -------------------------------------------------------------- the chart -- */

.main { max-width: 980px; margin: 0 auto; padding: var(--s5) clamp(16px, 3vw, 24px) 48px; }
.main--fill {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 0;
}
.main--fill > .flash { margin: var(--s3) var(--s4) 0; }

.workspace { flex: 1; display: flex; min-height: 0; }

.canvas {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: auto;
  background: var(--canvas) radial-gradient(var(--canvas-dot) 1px, transparent 1px) 0 0 / 22px 22px local;
}
.canvas::-webkit-scrollbar { width: 10px; height: 10px; }
.canvas::-webkit-scrollbar-thumb { border-radius: 6px; background: #d4d0c5; }

.stage { position: relative; margin: 0 auto; }
.layer { position: absolute; inset: 0; pointer-events: none; }

.card {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  width: 230px;
  min-height: 64px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
  pointer-events: auto;
  --detail: rgba(28, 27, 24, .72);
  transition: left var(--move) var(--ease), top var(--move) var(--ease),
              background-color .35s, box-shadow .25s, color .35s;
  animation: rise .45s var(--ease) both;
}
.card.is-dark { color: #fff; --detail: rgba(255, 255, 255, .85); }
.card.is-selected { box-shadow: 0 0 0 3px var(--accent), var(--shadow-raised); }
.card.is-linksource { box-shadow: 0 0 0 3px var(--linking), 0 8px 20px rgba(28, 27, 24, .12); }

.card-title { font-size: .906rem; font-weight: 700; line-height: 1.3; letter-spacing: -.005em; overflow-wrap: anywhere; }
.card-select {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  overflow-wrap: anywhere;
}
/* The whole card is the button. */
.card-select::after { content: ''; position: absolute; inset: 0; border-radius: var(--radius-lg); }
.card-select:focus-visible { outline: none; }
.card-select:focus-visible::after { outline: 3px solid var(--accent); outline-offset: 3px; }
.canvas.is-linking .card-select { cursor: crosshair; }
.canvas.is-linking .is-linksource .card-select { cursor: not-allowed; }

.card-name { font-size: .78rem; font-weight: 500; line-height: 1.4; color: var(--detail); overflow-wrap: anywhere; }
.card-bullets {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 6px 0 0;
  padding-left: 14px;
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--detail);
  overflow-wrap: anywhere;
}
.card-tags { display: flex; flex-wrap: wrap; gap: var(--s1); margin-top: var(--s2); }

/* The plus that adds a report. Shown on hover, on keyboard focus and on the
   selected card — so a touch screen, which has no hover, gets it by selecting. */
.card-add {
  position: absolute;
  left: 50%; bottom: -14px;
  translate: -50% 0;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 10px rgba(28, 27, 24, .25);
  opacity: 0;
  transition: opacity .2s, scale .2s;
}
.card-add .icon { width: 14px; height: 14px; }
/* A 44px target around a 28px button. */
.card-add::before { content: ''; position: absolute; inset: -10px; border-radius: 50%; }
.stage[data-orient='h'] .card-add { left: auto; right: -14px; top: 50%; bottom: auto; translate: 0 -50%; }
.card:hover .card-add,
.card:focus-within .card-add,
.card.is-selected .card-add { opacity: 1; }
.card-add:hover { scale: 1.12; }
.canvas.is-linking .card-add { display: none; }

.line {
  position: absolute;
  border-radius: 2px;
  background: var(--connector);
  transition: left var(--move) var(--ease), top var(--move) var(--ease),
              width var(--move) var(--ease), height var(--move) var(--ease);
  animation: fade .5s ease both;
}

/* A dotted line is a box as long as the line, turned to the angle it runs at. */
.dotline {
  position: absolute;
  height: 0;
  transform-origin: 0 0;
  transition: left var(--move) var(--ease), top var(--move) var(--ease),
              width var(--move) var(--ease), transform var(--move) var(--ease);
  animation: fade .5s ease both;
}
.dotline::before {
  content: '';
  position: absolute;
  left: 0; right: 8px; top: -1px;
  border-top: 2px dashed var(--dotted);
}
.dotline::after {
  content: '';
  position: absolute;
  right: -1px; top: -5px;
  border: 5px solid transparent;
  border-left: 9px solid var(--dotted);
  border-right: 0;
}

.dotlabel {
  position: absolute;
  translate: -50% -50%;
  padding: 3px 9px;
  border: 1px solid var(--dotted-line);
  border-radius: var(--round);
  background: var(--dotted-bg);
  color: var(--dotted-ink);
  font-size: var(--text-2xs);
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(28, 27, 24, .12);
  transition: left var(--move) var(--ease), top var(--move) var(--ease);
  animation: fade .5s ease both;
}

/* Shown while a dotted line is being drawn. It takes no room, so the chart
   does not jump when it appears. */
.linkbar {
  position: sticky;
  top: 6px; left: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  height: 0;
  padding: 0 var(--s3);
  pointer-events: none;
}
.linkbar-body {
  display: flex;
  align-items: center;
  gap: 14px;
  align-self: flex-start;
  padding: 8px 10px 8px 14px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-float);
  pointer-events: auto;
  animation: rise .35s ease both;
}
.linkbar-dot {
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--linking);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, .25);
}

/* ------------------------------------------------------------ empty states -- */

.empty { text-align: center; }
.empty p { max-width: 360px; margin: 0 auto; color: var(--text-mute); }
.empty h1, .empty h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.empty .btn { margin-top: 6px; }

.empty--chart {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: var(--s5);
  animation: rise .45s ease both;
}
.empty-mark, .signin-mark {
  display: grid;
  place-items: center;
  width: 64px; height: 64px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 8px 24px rgba(28, 27, 24, .08);
}
.empty-mark .icon, .signin-mark .icon { width: 28px; height: 28px; }

.empty--page { display: grid; gap: var(--s3); justify-items: center; padding: clamp(40px, 8vw, 80px) var(--s5); }
.errcode { font-size: var(--text-sm); font-weight: 700; letter-spacing: .08em; color: var(--accent); }

/* ----------------------------------------------------------------- editor -- */

.editor {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 340px;
  padding: 22px 22px var(--s6);
  overflow: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  animation: fade .3s ease both;
}
.editor-head { display: flex; align-items: center; justify-content: space-between; }
.editor-head h2 { font-size: var(--text-lg); font-weight: 700; letter-spacing: -.02em; }

.dottedlist { display: flex; flex-direction: column; gap: var(--s2); margin: 0; padding: 0; list-style: none; }
.dottedrow {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px dashed var(--dotted-line);
  border-radius: var(--radius);
  background: var(--dotted-soft);
}
.dottedrow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  font-size: .75rem;
  font-weight: 700;
  color: var(--dotted-ink);
  overflow-wrap: anywhere;
}

.editor-foot {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin-top: var(--s1);
  padding-top: var(--s4);
  border-top: 1px solid var(--line-soft);
}
.editor-foot .btn { padding-block: 11px; }

/* ----------------------------------------------------------------- dialog -- */

.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: var(--s5);
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-float);
}
.dialog[open] { animation: rise .25s var(--ease) both; }
.dialog::backdrop { background: var(--backdrop); }
.dialog h2 { font-size: 1.125rem; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.dialog p { margin-top: var(--s2); color: var(--text-mute); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); margin-top: var(--s5); }
.dialog .btn--danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.dialog .btn--danger:hover { background: #742525; color: #fff; }

/* ------------------------------------------------------------------ toast -- */

.toast {
  position: fixed;
  left: 50%; bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 50;
  translate: -50% 12px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-float);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, translate .2s;
}
.toast.is-on { opacity: 1; translate: -50% 0; }
.toast[data-state='error'] { background: var(--danger); }

/* ------------------------------------------------------------------ flash -- */

.flash {
  margin-bottom: var(--s4);
  padding: 10px 14px;
  border: 1px solid;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
}
.flash--ok    { border-color: var(--ok-line);     background: var(--ok-bg);     color: var(--ok-fg); }
.flash--error { border-color: var(--danger-line); background: var(--danger-bg); color: var(--danger); }

/* ---------------------------------------------------------------- sign in -- */

.signin { display: grid; place-items: center; min-height: 84vh; }
.signin-card {
  width: min(380px, 100%);
  padding: var(--s6) var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  text-align: center;
  box-shadow: var(--shadow-card);
}
.signin-mark { margin: 0 auto var(--s4); }
.signin-sub { margin: var(--s1) 0 22px; font-size: var(--text-sm); color: var(--text-mute); }
.signin-card .flash { text-align: left; }
.signin-foot { margin-top: 20px; font-size: .75rem; color: var(--text-mute); }

/* ----------------------------------------------------------------- people -- */

.pagehead { margin-bottom: var(--s5); }
.pagehead-sub { margin-top: 2px; font-size: var(--text-sm); color: var(--text-mute); }

.panel {
  margin-bottom: var(--s4);
  padding: var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
}
.panel--muted { background: transparent; }
.panel-title { margin-bottom: var(--s4); font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.panel > .formhelp { margin-top: var(--s3); }

.inlineform { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s3); }
/* Level with the fields, which sit under a label. */
.inlineform > .btn { margin-top: 25px; }

.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: var(--s3) var(--s3); text-align: left; vertical-align: middle; font-weight: 400; }
.table thead th {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-mute);
  border-bottom: 1px solid var(--line);
}
.table tbody tr + tr { border-top: 1px solid var(--line-soft); }
.table tbody tr.is-inactive .person { opacity: .6; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }

.person { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.person-body { display: flex; flex-direction: column; min-width: 0; }
.person-name { font-weight: 700; }
.person-email { font-size: .75rem; color: var(--text-mute); word-break: break-all; }
.chip {
  padding: 1px 7px;
  border-radius: var(--round);
  background: var(--surface-2);
  font-size: var(--text-2xs);
  font-weight: 700;
  color: var(--text-mute);
}

.rowactions { display: flex; flex-wrap: wrap; gap: var(--s2); }
td.rowactions { display: table-cell; white-space: nowrap; }
.rowform { display: inline-block; }
.rowform + .rowform { margin-left: var(--s1); }

.rolelist { display: grid; gap: var(--s3); margin: 0; }
.rolelist > div { display: grid; grid-template-columns: 120px 1fr; gap: var(--s3); }
.rolelist dt { font-size: var(--text-sm); font-weight: 700; }
.rolelist dd { margin: 0; font-size: var(--text-sm); color: var(--text-mute); }

/* ------------------------------------------------------------- responsive -- */

/* Fingers: everything that can be pressed is at least 44px. */
@media (pointer: coarse) {
  .btn, .segmented-btn, .pill, .navlink, .field { min-height: var(--tap); }
  .segmented-btn { min-width: var(--tap); }
  .iconbtn, .iconbtn--sm, .swatch, .customcolor input, .avatar { width: var(--tap); height: var(--tap); }
  .swatches { gap: var(--s1); }
  /* The app's name is a link home: a line of text, with a taller target. */
  .brand-name { position: relative; }
  .brand-name::after { content: ''; position: absolute; inset: -12px 0; }
  /* Under 16px, iOS zooms the page in on focus and leaves it there. */
  .field, .field--sm { font-size: 1rem; }
}

@media (max-width: 760px) {
  .topbar { gap: var(--s2) var(--s3); min-height: 0; padding: 10px var(--s4); }
  .brand-name { font-size: 1.125rem; }
  .mainnav { display: none; }
  .account-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--s3); }
  /* The page's controls take a row of their own, under the name. */
  .toolbar { order: 10; flex-basis: 100%; gap: var(--s2); }
  .segmented-btn > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .segmented-btn { padding-inline: var(--s3); }

  /* The editor moves from beside the chart to beneath it. */
  .workspace { flex-direction: column; }
  .editor {
    width: auto;
    max-height: 50vh;
    max-height: 50dvh;
    padding: var(--s4) var(--s4) var(--s5);
    border-left: 0;
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(28, 27, 24, .08);
  }
  .linkbar-body { gap: 10px; }

  .panel { padding: var(--s4); }
  .inlineform > .btn { width: 100%; margin-top: 0; }
  select.field { width: 100%; }

  /* A table row becomes a card: one fact per line, each with its label. */
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table, .table tbody, .table tr, .table th, .table td { display: block; }
  .table th, .table td, td.rowactions { padding: var(--s1) 0; white-space: normal; }
  .table tbody tr { padding: var(--s3) 0; }
  .table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-mute);
  }
  .rolelist > div { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
