/* Lienzo — the look of artico.io, applied to a working tool.
 *
 * Dark by default like artico.io, with its light palette for anyone whose
 * system asks for one. Every colour below is a token; nothing further down
 * names a colour directly, so both themes stay complete. */

:root {
  /* artico.io, dark */
  --bg: hsl(253 42% 6%);
  --panel: hsl(252 36% 9%);
  --panel-2: hsl(252 32% 12%);
  --hover: hsl(252 40% 60% / .08);
  --border: hsl(250 30% 80% / .10);
  --border-strong: hsl(250 30% 80% / .20);
  --text: #E5E9F0;
  --muted: hsl(248 16% 64%);
  --violet: hsl(277 100% 50%);
  --accent: hsl(270 85% 72%);              /* violet-soft: readable on dark */
  --accent-soft: hsl(277 100% 60% / .14);
  --accent-line: hsl(277 100% 66% / .55);
  --ice: hsl(202 70% 78%);
  --magenta: hsl(325 90% 64%);
  --ok: hsl(152 72% 54%);                  /* boreal */
  --ok-soft: hsl(152 72% 54% / .13);
  --warn: hsl(38 95% 62%);
  --warn-soft: hsl(38 95% 62% / .13);
  --danger: hsl(355 90% 67%);
  --danger-soft: hsl(355 90% 67% / .13);
  --grad: linear-gradient(120deg, #8400d6, #a71aff 55%, #d82efa);
  --grad-glow: 0 6px 30px -10px #9d00ff8c, inset 0 1px #ffffff2e;
  --stage: hsl(253 40% 4%);
  --stage-dot: hsl(250 30% 80% / .07);
  --shadow: 0 1px 2px hsl(253 60% 2% / .5);
  --shadow-lg: 0 24px 60px -12px hsl(253 60% 2% / .7), 0 0 0 1px var(--border);
  --backdrop: hsl(253 50% 3% / .72);
  --diff-del: hsl(355 90% 72%);
  --diff-del-bg: hsl(355 90% 60% / .14);
  --diff-add: hsl(152 72% 60%);
  --diff-add-bg: hsl(152 72% 50% / .14);

  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --display: "Montserrat", system-ui, sans-serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
  font-size: 15px;
}

@media (prefers-color-scheme: light) {
  :root {
    /* artico.io, light */
    --bg: hsl(250 40% 98%);
    --panel: #ffffff;
    --panel-2: hsl(250 35% 96.5%);
    --hover: hsl(253 40% 50% / .06);
    --border: hsl(253 30% 20% / .12);
    --border-strong: hsl(253 30% 20% / .22);
    --text: hsl(253 32% 13%);
    --muted: hsl(250 12% 42%);
    --accent: hsl(270 75% 46%);
    --accent-soft: hsl(277 100% 50% / .08);
    --accent-line: hsl(277 90% 50% / .45);
    --ice: hsl(202 65% 36%);
    --ok: hsl(152 62% 32%);
    --ok-soft: hsl(152 62% 38% / .11);
    --warn: hsl(32 90% 38%);
    --warn-soft: hsl(38 95% 50% / .13);
    --danger: hsl(355 72% 46%);
    --danger-soft: hsl(355 80% 50% / .09);
    --stage: hsl(250 25% 91%);
    --stage-dot: hsl(253 30% 20% / .09);
    --shadow: 0 1px 2px hsl(253 30% 20% / .06), 0 1px 3px hsl(253 30% 20% / .06);
    --shadow-lg: 0 24px 60px -16px hsl(253 40% 20% / .28), 0 0 0 1px var(--border);
    --backdrop: hsl(253 30% 12% / .45);
    --diff-del: hsl(355 72% 42%);
    --diff-del-bg: hsl(355 80% 50% / .09);
    --diff-add: hsl(152 62% 28%);
    --diff-add-bg: hsl(152 62% 38% / .12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans); font-size: 1rem; line-height: 1.45;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0 0 .5rem; font-family: var(--display); font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
::selection { background: hsl(277 100% 60% / .35); }

/* ---------- icons ---------- */
.icon {
  width: 1.1em; height: 1.1em; flex: 0 0 auto;
  vertical-align: -.18em; pointer-events: none;
}
button .icon, .btn .icon { width: 16px; height: 16px; vertical-align: middle; }
button.small .icon, .btn.small .icon { width: 15px; height: 15px; }

/* ---------- buttons: the artico line button, and its gradient one ---------- */
button, .btn {
  font: inherit; font-weight: 500; font-size: .92rem; line-height: 1.2;
  cursor: pointer; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid var(--border-strong); background: var(--hover);
  padding: .55rem 1rem; border-radius: 10px;
  transition: border-color .2s, background .2s, color .2s, box-shadow .3s, transform .2s var(--ease);
  white-space: nowrap;
}
button:hover, .btn:hover {
  border-color: var(--accent-line); background: var(--accent-soft); text-decoration: none;
}
button:active, .btn:active { transform: scale(.98); }
button:focus-visible, .btn:focus-visible, a:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button.primary, .btn.primary {
  color: #fff; border-color: transparent; background: var(--grad);
  box-shadow: var(--grad-glow); font-weight: 600;
}
button.primary:hover, .btn.primary:hover {
  background: var(--grad); border-color: transparent;
  box-shadow: 0 10px 34px -10px #a71affb3, inset 0 1px #ffffff38;
  filter: brightness(1.06);
}
button.danger, .btn.danger { color: var(--danger); }
button.danger:hover, .btn.danger:hover { border-color: var(--danger); background: var(--danger-soft); }
button.small, .btn.small { padding: .36rem .7rem; font-size: .84rem; border-radius: 9px; }
button:disabled, button:disabled:hover {
  opacity: .45; cursor: not-allowed; transform: none;
  background: var(--hover); border-color: var(--border-strong);
}
button.primary:disabled { background: var(--grad); }

/* A square button that is only an icon. */
button.icon-btn, .btn.icon-btn { padding: 0; width: 34px; height: 34px; }
button.icon-btn.small { width: 30px; height: 30px; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); background: var(--hover); border-color: var(--border); }

/* ---------- form fields ---------- */
input, select, textarea {
  font: inherit; font-size: .93rem; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: .6rem .75rem; width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"] { width: auto; accent-color: var(--violet); }
textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
label { display: block; font-size: .82rem; font-weight: 500; color: var(--muted); margin: .9rem 0 .35rem; }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
option { background: var(--panel); color: var(--text); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: .8rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: .65rem 1.4rem; position: sticky; top: 0; z-index: 50;
}
.brand {
  display: inline-flex; align-items: center;
  font-family: var(--display); font-weight: 700; font-size: 1.02rem;
  color: var(--text); letter-spacing: -.01em; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
/* The mark: a feedback pin cut out of the artico gradient. */
.brand::before {
  content: ""; width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto; margin-right: .55rem;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E") center / 14px no-repeat,
    var(--grad);
  box-shadow: 0 4px 16px -6px #a71affaa;
}
.brand span { color: var(--accent); }
.topbar .spacer, .viewer-toolbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: .86rem; }

.container { max-width: 1160px; margin: 0 auto; padding: 2rem 1.4rem 3rem; }

/* ---------- surfaces ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem;
}
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.canvas-card {
  display: flex; flex-direction: column; gap: .5rem; cursor: pointer; position: relative;
  transition: border-color .25s, transform .25s var(--ease), box-shadow .3s;
}
.canvas-card:hover {
  border-color: var(--accent-line); transform: translateY(-2px);
  box-shadow: 0 14px 36px -18px #a71aff88;
}
.canvas-card strong { font-weight: 600; }
.canvas-card .url {
  color: var(--muted); font-size: .8rem; font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .12rem .55rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; letter-spacing: .01em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.ready { background: var(--ok-soft); color: var(--ok); }
.badge.pending, .badge.capturing { background: var(--warn-soft); color: var(--warn); }
.badge.failed { background: var(--danger-soft); color: var(--danger); }
.badge.count { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }

.muted { color: var(--muted); font-size: .87rem; }
/* A class that sets `display` beats the browser's own [hidden] rule, so an
   element toggled with the hidden attribute stays on screen — which is how the
   notification badge kept showing a count of zero. One line here rather than
   remembering it at every call site. */
[hidden] { display: none !important; }

.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.mt { margin-top: 1rem; }

/* ---------- auth / landing ---------- */
.auth-wrap {
  min-height: 100%; display: grid; place-items: center; padding: 2rem 1rem;
  background:
    radial-gradient(60% 45% at 50% 0%, hsl(277 100% 50% / .16), transparent 70%),
    radial-gradient(40% 35% at 85% 100%, hsl(325 90% 64% / .08), transparent 70%);
}
.auth-card { width: 100%; max-width: 410px; padding: 1.6rem; }
.auth-card .tabs {
  display: flex; gap: .25rem; margin-bottom: 1.1rem; padding: .25rem;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
}
.auth-card .tabs button { flex: 1; border-color: transparent; background: transparent; color: var(--muted); }
.auth-card .tabs button.active { background: var(--panel); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow); }
.hero { text-align: center; margin-bottom: 1.8rem; }
.hero .brand { font-size: 1.1rem; margin-bottom: 1.2rem; }
.hero h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.hero h1 em {
  font-style: normal; background: var(--grad); -webkit-background-clip: text;
  background-clip: text; color: transparent;
}
.hero p { color: var(--muted); max-width: 440px; margin: .6rem auto 0; line-height: 1.55; }

.error-msg { color: var(--danger); font-size: .85rem; margin-top: .6rem; min-height: 1.2em; }

/* ---------- viewer ---------- */
.viewer { display: flex; flex-direction: column; height: 100vh; }
.viewer-toolbar {
  display: flex; align-items: center; gap: .5rem; padding: .5rem .8rem;
  background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap;
  position: relative; z-index: 30;
}
.viewer-toolbar .brand { font-size: .95rem; margin-right: .2rem; }
.viewer-toolbar .brand::before { width: 24px; height: 24px; }
#canvas-name { font-weight: 600; font-size: .92rem; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-divider { width: 1px; height: 22px; background: var(--border-strong); margin: 0 .2rem; }
.viewer-main { flex: 1; display: flex; min-height: 0; }
.stage {
  flex: 1; overflow: auto; background-color: var(--stage);
  background-image: radial-gradient(var(--stage-dot) 1px, transparent 1px);
  background-size: 18px 18px;
  /* Not justify-content: center — a frame wider than the stage would then
     overflow on both sides, and the left side cannot be scrolled to. Auto
     margins centre it when it fits and fall back to 0 when it does not. */
  display: flex; justify-content: flex-start; align-items: flex-start; padding: 1.4rem;
}
/* The holder is exactly one device viewport; the iframe scrolls inside it. */
.frame-holder {
  position: relative; background: #fff; flex: 0 0 auto; margin: 0 auto;
  border-radius: 10px; overflow: visible;
  box-shadow: 0 30px 70px -30px hsl(253 60% 2% / .8), 0 0 0 1px var(--border-strong);
}
.frame-holder iframe { display: block; border: 0; background: #fff; border-radius: 10px; }
.stage.commenting .frame-holder { box-shadow: 0 30px 70px -30px hsl(253 60% 2% / .8), 0 0 0 2px var(--violet), 0 0 0 6px var(--accent-soft); }
.stage.commenting iframe { cursor: crosshair; }
#browse-status { font-size: .8rem; color: var(--accent); }

/* Segmented controls: Browse/Comment and the three widths. */
.mode-toggle, .bp-toggle {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 11px;
}
.bp-toggle.row { gap: 2px; flex-wrap: nowrap; }
.mode-toggle button, .bp-toggle button {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  border-radius: 8px; padding: .32rem .65rem; font-size: .84rem;
}
.bp-toggle button { padding: .32rem .5rem; }
.mode-toggle button:hover, .bp-toggle button:hover { color: var(--text); background: var(--hover); border-color: transparent; }
.mode-toggle button.active {
  color: #fff; background: var(--grad); box-shadow: 0 4px 14px -6px #a71affaa;
}
.bp-toggle button.active {
  color: var(--text); background: var(--panel); border-color: var(--border-strong); box-shadow: var(--shadow);
}

.sidebar {
  width: 368px; background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head { padding: .75rem .9rem; border-bottom: 1px solid var(--border); gap: .5rem; }
.sidebar-head > strong { font-family: var(--display); font-size: .98rem; }
.sidebar-list { flex: 1; overflow: auto; padding: .7rem; display: flex; flex-direction: column; gap: .6rem; }

.ann-card {
  border: 1px solid var(--border); border-radius: 12px; padding: .75rem .85rem;
  cursor: pointer; background: var(--panel);
  transition: border-color .2s, background .2s;
}
.ann-card:hover { border-color: var(--border-strong); background: var(--hover); }
.ann-card.selected {
  border-color: var(--accent-line); background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--violet);
}
.ann-card.orphaned { border-style: dashed; opacity: .82; }
.ann-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.ann-num {
  width: 22px; height: 22px; border-radius: 50% 50% 50% 4px; background: var(--grad);
  color: #fff; font-size: .72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ann-card.resolved .ann-num { background: var(--ok); color: hsl(253 42% 6%); }
.ann-body { font-size: .9rem; white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.ann-meta { font-size: .76rem; color: var(--muted); margin-top: .3rem; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.ann-meta .icon { width: 13px; height: 13px; }
.orphan-note { display: flex; gap: .5rem; align-items: flex-start; color: var(--warn); background: var(--warn-soft); border-radius: 10px; padding: .55rem .7rem; font-size: .8rem; }
.orphan-note .icon { margin-top: .1rem; }

.thread { border-top: 1px solid var(--border); margin-top: .6rem; padding-top: .6rem; display: flex; flex-direction: column; gap: .55rem; }
.thread .reply { font-size: .87rem; }
.thread .reply .who { font-weight: 600; font-size: .8rem; }
.thread .reply .when { color: var(--muted); font-size: .74rem; margin-left: .3rem; }

.status-select { font-size: .8rem; padding: .3rem 1.7rem .3rem .55rem; width: auto; border-radius: 8px; background-color: var(--panel-2); }

.composer { padding: .8rem .9rem; border-top: 1px solid var(--border); }
/* Beside the pin, over the frame — see positionComposer() in viewer.js. */
.composer.floating {
  position: absolute; z-index: 40; width: 330px; max-width: calc(100% - 16px);
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: .7rem .75rem;
}
.composer.floating textarea { min-height: 80px; }
.composer.floating .muted { font-size: .74rem; }

.filelist { display: flex; flex-direction: column; gap: .3rem; margin-top: .4rem; }
.fileitem {
  display: flex; justify-content: space-between; gap: .6rem; align-items: center;
  font-size: .78rem; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: .3rem .5rem;
}
.fileitem .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: .35rem; }
.fileitem .fsize { color: var(--muted); flex: 0 0 auto; font-family: var(--mono); font-size: .72rem; }
a.filelink { text-decoration: none; color: inherit; }
a.filelink:hover { border-color: var(--accent-line); }

.attachments { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.attachments .thumb {
  display: block; border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; line-height: 0;
}
.attachments .thumb:hover { border-color: var(--accent-line); }
.attachments .thumb img { width: 84px; height: 62px; object-fit: cover; display: block; }
.attachments .fileitem { flex: 1 1 100%; }

.toasts { position: fixed; bottom: 1.2rem; right: 1.2rem; display: flex; flex-direction: column; gap: .5rem; z-index: 1000; }
.toast {
  background: var(--panel); color: var(--text); padding: .7rem 1rem;
  border: 1px solid var(--border-strong); border-left: 3px solid var(--violet);
  border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .88rem; max-width: 360px;
  animation: toast-in .35s var(--ease);
}
.toast-error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

dialog {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 18px;
  box-shadow: var(--shadow-lg); padding: 1.5rem; width: 100%; max-width: 460px;
}
dialog h3 { font-size: 1.15rem; }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }

.sitemap {
  display: flex; flex-direction: column; gap: .2rem;
  max-height: 46vh; overflow: auto; margin-top: .5rem;
  border: 1px solid var(--border); border-radius: 12px; padding: .35rem;
}
.sitemap-item {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto;
  gap: .6rem; align-items: baseline; text-align: left; width: 100%;
  border: 1px solid transparent; border-radius: 8px; padding: .4rem .55rem; background: transparent;
  font-weight: 400;
}
.sitemap-item:hover { background: var(--accent-soft); border-color: transparent; }
.sm-route { font-family: var(--mono); font-size: .78rem; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-label { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.export-options { display: flex; flex-direction: column; gap: .6rem; }
.export-option {
  display: flex; flex-direction: column; gap: .25rem; align-items: flex-start;
  text-align: left; padding: .9rem 1rem; width: 100%; white-space: normal; border-radius: 12px;
}
.export-option strong { font-size: .95rem; font-weight: 600; }
.export-option span { color: var(--muted); font-size: .82rem; font-weight: 400; line-height: 1.45; }
.export-option:hover:not(:disabled) { border-color: var(--accent-line); background: var(--accent-soft); }

.empty { text-align: center; color: var(--muted); padding: 2.8rem 1rem; }
code.inline, code {
  font-family: var(--mono); background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; padding: .08rem .35rem; font-size: .78rem; word-break: break-all;
}

/* Which screen a comment was left at. */
.device-tag {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .08rem .45rem; border-radius: 999px;
  font-size: .7rem; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--border-strong); color: var(--muted);
}
.device-tag .icon { width: 12px; height: 12px; }
.device-desktop { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.device-tablet  { color: var(--ice); border-color: hsl(202 70% 60% / .25); background: hsl(202 70% 60% / .10); }
.device-mobile  { color: var(--magenta); border-color: hsl(325 90% 64% / .25); background: hsl(325 90% 64% / .10); }

/* ---------- teams, organizations ---------- */
.orglist { display: flex; flex-direction: column; gap: .5rem; }
.orgitem {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; text-align: left; padding: .85rem 1rem; border-radius: 12px;
}
.orgitem:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.orgitem.current { border-color: var(--accent-line); }

table.plain { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.plain th {
  text-align: left; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); font-weight: 600;
  padding: 0 .6rem .55rem 0; border-bottom: 1px solid var(--border);
}
table.plain td { padding: .6rem .6rem .6rem 0; border-bottom: 1px solid var(--border); }
table.plain tr:last-child td { border-bottom: 0; }
.warn-text { color: var(--warn); }

/* A named person reads as a named person, not as punctuation. */
.mention {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 5px; padding: 0 4px; font-weight: 600;
}
.mention-list { box-shadow: var(--shadow-lg); }
.mention-option:hover { background: var(--accent-soft); }

/* Popovers: the bell, emoji, tags, mentions. */
.popover { box-shadow: var(--shadow-lg); border-color: var(--border-strong); }

/* The notification bell. */
.bell-count {
  position: absolute; top: -5px; right: -6px; min-width: 18px; height: 18px;
  padding: 0 5px; justify-content: center;
  background: var(--grad); color: #fff; border: 2px solid var(--panel);
  font-size: .64rem; line-height: 1;
}
.notif-icon {
  width: 28px; height: 28px; border-radius: 8px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.notif-icon .icon { width: 15px; height: 15px; }

/* The emoji picker in the comment box and in replies. */
.emoji-wrap { position: relative; display: inline-block; }
.emoji-grid {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 60;
  display: grid; grid-template-columns: repeat(8, 30px); gap: 2px; padding: 6px;
  box-shadow: var(--shadow-lg);
}
.emoji-option {
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 7px;
  background: transparent; font-size: 18px; line-height: 30px; cursor: pointer;
}
.emoji-option:hover { background: var(--accent-soft); border: 0; }

/* Suggesting a text change on the page itself. */
/* `button.` on purpose: the base `button.small` rule is more specific than a
   bare class, and without it this rendered white on white. */
button.suggest-pill {
  background: var(--grad); color: #fff; border-color: transparent;
  margin-bottom: .5rem; font-weight: 600; box-shadow: 0 4px 14px -6px #a71affaa;
}
button.suggest-pill:hover { background: var(--grad); filter: brightness(1.08); border-color: transparent; }
button.suggest-pill.editing { background: var(--ok); color: hsl(253 42% 6%); box-shadow: none; }
.suggest-box {
  border: 1px solid var(--border); border-radius: 10px; padding: .45rem .6rem;
  margin-bottom: .5rem; font-size: .85rem; line-height: 1.5; background: var(--panel-2);
}
.suggest-box .suggest-label, .ann-suggest .suggest-label {
  font-size: .66rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: .15rem;
}
.ann-suggest {
  border: 1px solid var(--border); border-radius: 10px; padding: .4rem .55rem;
  margin: .35rem 0; font-size: .86rem; line-height: 1.5; background: var(--panel-2);
}
.diff-del { color: var(--diff-del); text-decoration: line-through; background: var(--diff-del-bg); border-radius: 3px; }
.diff-add { color: var(--diff-add); background: var(--diff-add-bg); border-radius: 3px; font-weight: 600; }

/* Tags: team labels on comments. The colour comes from the tag itself. */
.tag-chip {
  display: inline-flex; align-items: center; font-size: .7rem; font-weight: 600; line-height: 1.55;
  padding: 0 .5rem; border-radius: 999px; white-space: nowrap;
  color: var(--tag); border: 1px solid color-mix(in srgb, var(--tag) 55%, transparent);
  background: color-mix(in srgb, var(--tag) 14%, transparent);
}
.tag-chips { display: flex; flex-wrap: wrap; gap: .25rem; margin: .3rem 0; }
.tag-wrap { position: relative; display: inline-block; }
.tag-panel {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 60; width: 240px;
  padding: .5rem; box-shadow: var(--shadow-lg);
}
.tag-input { width: 100%; margin-bottom: .4rem; }
.tag-list { max-height: 180px; overflow: auto; display: flex; flex-direction: column; gap: .2rem; }
.tag-row { display: flex; align-items: center; gap: .45rem; margin: 0; cursor: pointer; color: var(--text); font-size: .85rem; padding: .15rem .2rem; border-radius: 6px; }
.tag-row:hover { background: var(--hover); }
.tag-create { margin-top: .25rem; text-align: left; justify-content: flex-start; }

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  .viewer-main { flex-direction: column; }
  .sidebar { width: 100%; max-height: 45vh; border-left: 0; border-top: 1px solid var(--border); }
  .topbar { padding: .6rem 1rem; flex-wrap: wrap; }
  .container { padding: 1.4rem 1rem 2.4rem; }
  .tb-divider { display: none; }
}

/* A checkbox with its sentence beside it, not above it. */
label.row { flex-wrap: nowrap; align-items: flex-start; color: var(--text); }
label.row input[type="checkbox"] { margin-top: .2rem; }
/* The selector a new comment is about: one line, cut rather than broken mid-word. */
#composer-target {
  display: block; margin-top: .2rem; word-break: normal;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* The language switch: in the bar where there is one, in a corner otherwise. */
.lang-switch { font-size: .78rem; }
.lang-corner { position: fixed; top: 14px; right: 16px; z-index: 60; }

/* New review: from a website or from a file. */
.source-toggle { margin: .2rem 0 .4rem; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: .35rem; text-align: center;
  margin: 0; padding: 1.3rem 1rem; cursor: pointer; color: var(--text);
  border: 1.5px dashed var(--border-strong); border-radius: 12px; background: var(--panel-2);
  transition: border-color .2s, background .2s;
}
.dropzone .icon { width: 26px; height: 26px; color: var(--accent); }
.dropzone strong { font-weight: 600; font-size: .9rem; word-break: break-all; }
.dropzone .muted { font-size: .78rem; line-height: 1.45; }
.dropzone:hover, .dropzone.dragging { border-color: var(--accent-line); background: var(--accent-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--accent-line); }

/* ---------- dashboard ---------- */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.dash-head h2 { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.dash-head p { margin: .2rem 0 0; }
.dash-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: .45rem; margin: 0; padding: 0 .75rem;
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: 10px;
  color: var(--muted); min-width: 230px;
}
.search:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { border: 0; background: transparent; padding: .55rem 0; box-shadow: none; }
.search input:focus { box-shadow: none; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; margin: 1.4rem 0 1.6rem; }
.stat {
  display: flex; align-items: center; gap: .8rem; padding: .9rem 1rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.stat-icon {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.stat-icon .icon { width: 19px; height: 19px; }
.stat-value { font-family: var(--display); font-weight: 800; font-size: 1.35rem; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .8rem; }

.project {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  padding: 1rem 1.1rem 1.15rem; margin-bottom: 1.1rem;
}
.project.shut { padding-bottom: 1rem; }
.project-head { display: flex; align-items: center; gap: .7rem; }
.project-toggle .icon { transition: transform .25s var(--ease); }
.project:not(.shut) .project-toggle .icon { transform: rotate(90deg); }
.project-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 800; color: #fff; font-size: 1rem;
  background: linear-gradient(135deg, hsl(var(--h) 85% 58%), hsl(calc(var(--h) + 40) 85% 50%));
  box-shadow: 0 6px 18px -8px hsl(var(--h) 85% 50% / .8);
}
.project-title { flex: 1; min-width: 0; }
.project-title h3 { margin: 0; font-size: 1.08rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-meta { display: flex; flex-wrap: wrap; gap: .25rem .8rem; color: var(--muted); font-size: .8rem; margin-top: .1rem; }
.project-meta span + span::before { content: "·"; margin-right: .8rem; opacity: .6; }
.project-actions { display: flex; gap: .4rem; align-items: center; }

.tiles {
  display: grid; gap: .9rem; margin-top: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.tile {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 14px;
  color: var(--text); text-decoration: none;
  transition: border-color .25s, transform .25s var(--ease), box-shadow .3s;
}
a.tile:hover {
  text-decoration: none; border-color: var(--accent-line); transform: translateY(-3px);
  box-shadow: 0 18px 40px -22px #a71aff99;
}
.tile.not-ready { cursor: default; }
.tile-thumb { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--stage); border-bottom: 1px solid var(--border); }
.tile-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; transition: transform .5s var(--ease); }
a.tile:hover .tile-thumb img { transform: scale(1.03); }
.tile-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .5rem; color: var(--accent); font-size: .8rem; font-family: var(--mono);
  background:
    radial-gradient(70% 60% at 30% 20%, hsl(277 100% 60% / .18), transparent 70%),
    radial-gradient(60% 60% at 80% 90%, hsl(325 90% 64% / .12), transparent 70%),
    var(--panel);
}
.tile-placeholder .icon { width: 30px; height: 30px; }
.tile-placeholder span { color: var(--muted); max-width: 85%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-kind, .tile-status {
  position: absolute; top: 8px; display: inline-flex; align-items: center; gap: .25rem;
  font-size: .68rem; font-weight: 600; border-radius: 999px;
}
.tile-kind {
  left: 8px; padding: .15rem .5rem; color: #fff;
  background: hsl(253 42% 6% / .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tile-kind .icon { width: 11px; height: 11px; }
.tile-status { top: auto; bottom: 8px; left: 8px; }
.tile-status .badge { backdrop-filter: blur(6px); }
.tile-status.busy .badge { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.tile-body { padding: .75rem .85rem .8rem; display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.tile-name { font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .url { font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .error-msg { margin-top: 0; font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-foot { display: flex; align-items: center; gap: .6rem; margin-top: .3rem; font-size: .78rem; }
.tile-foot .muted { font-size: .76rem; }
.tile-when { margin-left: auto; }
.badge.quiet { background: var(--hover); color: var(--muted); }
.tile-delete {
  position: absolute; right: 8px; top: 8px; opacity: 0;
  background: var(--panel); color: var(--danger); border-color: var(--border-strong);
}
.tile:hover .tile-delete, .tile-delete:focus-visible { opacity: 1; }
.tile-delete:hover { background: var(--danger-soft); border-color: var(--danger); }
.tile-add {
  min-height: 200px; align-items: center; justify-content: center; gap: .45rem; text-align: center;
  border: 1.5px dashed var(--border-strong); background: transparent; white-space: normal;
  padding: 1rem; font-weight: 400;
}
.tile-add strong { font-weight: 600; }
.tile-add .muted { font-size: .78rem; max-width: 22ch; }
.tile-add:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.dash-empty { display: flex; flex-direction: column; align-items: center; gap: .6rem; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search { min-width: 0; flex: 1 1 100%; }
  .project-meta span:nth-child(n+3) { display: none; }
}
@media (hover: none) { .tile-delete { opacity: 1; } }

/* A comment whose element is out of sight right now (closed accordion, other
   tab, back of a card): its number is outlined instead of filled. Selecting
   it opens what hides it. */
.ann-card.pin-hidden .ann-num {
  background: transparent; color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--accent-line);
}

/* ---------- opening another page ---------- */
.stage-wrap { flex: 1; position: relative; display: flex; min-width: 0; min-height: 0; }
.stage-loading {
  position: absolute; inset: 0; z-index: 45; display: grid; place-items: center; padding: 1rem;
  background: color-mix(in srgb, var(--stage) 72%, transparent);
  backdrop-filter: blur(5px) saturate(.8); -webkit-backdrop-filter: blur(5px) saturate(.8);
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.loading-card {
  width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: .6rem;
  text-align: center; padding: 1.6rem 1.5rem 1.3rem;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 18px;
  box-shadow: var(--shadow-lg);
}
.loading-card strong { font-family: var(--display); font-size: 1.15rem; }
.loading-card #loading-route { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
.loading-step { font-size: .88rem; color: var(--accent); font-weight: 500; min-height: 1.3em; }
.loading-card .muted { font-size: .8rem; line-height: 1.5; }
.loading-spinner {
  width: 46px; height: 46px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 25%, #a71aff 60%, #d82efa);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-bar { width: 100%; height: 4px; border-radius: 99px; background: var(--hover); overflow: hidden; }
.loading-bar span {
  display: block; height: 100%; width: 40%; border-radius: inherit; background: var(--grad);
  animation: slide 1.4s var(--ease) infinite;
}
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.loading-failed-icon { display: none; width: 40px; height: 40px; color: var(--danger); }
.stage-loading.failed .loading-spinner, .stage-loading.failed .loading-bar { display: none; }
.stage-loading.failed .loading-failed-icon { display: block; }
.stage-loading.failed .loading-step { color: var(--danger); }
@media (prefers-reduced-motion: reduce) {
  .loading-spinner, .loading-bar span { animation-duration: 3s; }
}

/* The viewer's bar on one line on laptop screens: the less used actions keep
   their icon and say their name on hover. */
@media (max-width: 1280px) {
  .viewer-toolbar .tb-label { display: none; }
  .viewer-toolbar #add-page, .viewer-toolbar #recapture, .viewer-toolbar #export-btn,
  .viewer-toolbar #sitemap-btn { padding-left: .5rem; padding-right: .5rem; }
}
.viewer-toolbar #page-select { max-width: 170px; }
#canvas-name { max-width: 16ch; }
@media (max-width: 1400px) { .viewer-toolbar #who-view { display: none; } }

/* ---------- folding the comments panel away ---------- */
.sidebar { transition: width .28s var(--ease); position: relative; }
.sidebar.folded { width: 52px; }
.sidebar.folded > :not(.sidebar-rail) { display: none; }
.sidebar-rail {
  display: flex; flex-direction: column; align-items: center; gap: .7rem;
  width: 100%; height: 100%; padding: .8rem 0; border: 0; border-radius: 0;
  background: transparent; color: var(--muted); justify-content: flex-start;
}
.sidebar-rail:hover { background: var(--hover); color: var(--text); border: 0; }
.sidebar-rail .icon { width: 20px; height: 20px; }
.rail-count {
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad); color: #fff; font-size: .74rem; font-weight: 700;
}
.rail-count.none { background: var(--hover); color: var(--muted); }
.rail-label {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: var(--display); font-weight: 700; font-size: .82rem; letter-spacing: .02em;
}
@media (max-width: 900px) {
  /* The panel sits under the page on a phone: folded, it is one slim bar. */
  .sidebar.folded { width: 100%; height: 46px; max-height: 46px; }
  .sidebar-rail { flex-direction: row; justify-content: center; height: 46px; padding: 0 1rem; }
  .rail-label { writing-mode: horizontal-tb; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
/* A status line in the bar never pushes the bar onto a second line. */
#browse-status { flex: 0 1 auto; min-width: 0; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- connecting an AI agent ---------- */
.agent-dialog { max-width: 540px; position: relative; }
.agent-dialog h3 { font-size: 1.3rem; padding-right: 2rem; line-height: 1.3; }
.agent-dialog p { line-height: 1.55; margin: .5rem 0; }
.agent-close { position: absolute; top: 14px; right: 14px; }
.agent-choose { display: block; margin: 1.1rem 0 .3rem; font-family: var(--display); }
.agent-list { display: flex; flex-direction: column; }
.agent-row { display: flex; align-items: center; gap: .8rem; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.agent-row:last-child { border-bottom: 0; }
.agent-mark {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 800; font-size: .9rem; color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 75% 55%), hsl(calc(var(--h) + 30) 70% 42%));
}
.agent-name { flex: 1; font-weight: 500; }
button.linkish {
  background: none; border: 0; padding: .6rem 0 0; color: var(--accent); font-weight: 500;
  text-decoration: underline; text-underline-offset: 3px;
}
button.linkish:hover { background: none; border: 0; }
.agent-foot { font-size: .78rem; margin-top: 1rem; }
.agent-warn {
  display: flex; gap: .55rem; align-items: flex-start; font-size: .82rem; line-height: 1.45;
  background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: .6rem .75rem; margin: .4rem 0 .6rem;
}
.agent-warn .icon { margin-top: .12rem; }
.agent-step { display: block; margin-top: .9rem; font-size: .9rem; }
.agent-where { font-size: .8rem; margin: .25rem 0 .3rem; }
.agent-code-wrap { position: relative; }
.agent-code {
  margin: 0; padding: .65rem 2.6rem .65rem .75rem; max-height: 220px; overflow: auto;
  font-family: var(--mono); font-size: .74rem; line-height: 1.5; white-space: pre-wrap; word-break: break-all;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
}
.agent-copy { position: absolute; top: 6px; right: 6px; }

/* What is done with the comments, under the panel's title: export, an AI
   agent, the canvas's history. */
.sidebar-actions {
  display: flex; gap: .4rem; padding: .55rem .9rem; border-bottom: 1px solid var(--border);
}
.sidebar-actions button { flex: 1; min-width: 0; }
.sidebar-actions button[hidden] { display: none; }
/* The panel's head: its title on one line, the filters in one even row under it. */
.sidebar-head { flex-direction: column; align-items: stretch; gap: .55rem; }
.sidebar-head > span:last-child { display: flex; width: 100%; gap: .35rem; }
.sidebar-head > span:last-child select { flex: 1 1 0; min-width: 0; text-overflow: ellipsis; }
.sidebar-head > span:last-child select[hidden] { display: none; }

/* The platform panel's test email result. */
  .mail-warn { background: var(--warn-soft); color: var(--warn); }
.mail-ok, .mail-fail, .mail-warn { border-radius: 10px; padding: .65rem .8rem; font-size: .88rem; line-height: 1.5; }
.mail-ok { background: var(--ok-soft); color: var(--ok); }
.mail-fail { background: var(--danger-soft); color: var(--danger); }
.mail-fail code.inline { color: var(--text); }
.mail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .2rem 1rem; }
.mail-grid[hidden] { display: none; }
.mail-field { display: flex; flex-direction: column; gap: .3rem; margin: .7rem 0 0; color: var(--text); }
.mail-field > span { font-size: .8rem; color: var(--muted); font-weight: 500; }
.mail-field small { font-size: .74rem; line-height: 1.4; }
.mail-sep { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0 .8rem; }
