/* CUPI review site: the brand guidelines as a scrolling book, with shared comments.
   Quiet chrome so the pages carry the colour. Tokens only. */
* { box-sizing: border-box; margin: 0; padding: 0; min-width: 0; }
html { scroll-padding-top: 88px; }
body { font: 15px/1.45 var(--font-body); color: var(--grey-900); background: var(--grey-100); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue-400); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.bar { position: sticky; top: 0; z-index: 30; height: 64px; display: flex; align-items: center; gap: 24px; padding: 0 20px;
  background: var(--cupi-white); border-bottom: 1px solid var(--grey-200); }
.bar__brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--grey-900); font-weight: 600; white-space: nowrap; }
.bar__brand img { height: 26px; width: auto; display: block; }
.bar__brand small { color: var(--grey-700); font-weight: 400; }
.bar__fonts { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.bar__fonts > span { color: var(--grey-700); }
.bar__actions { display: flex; align-items: center; gap: 8px; }
.bar__menu { display: none; }
.seg { display: inline-flex; border: 1px solid var(--grey-300); border-radius: 8px; overflow: hidden; background: var(--cupi-white); }
.seg button { border: 0; background: none; padding: 7px 12px; border-right: 1px solid var(--grey-200); white-space: nowrap; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--cupi-blue); color: var(--cupi-white); }
.seg--full { display: flex; }
.seg--full button { flex: 1; }
.btn { border: 1px solid var(--cupi-blue); background: var(--cupi-blue); color: var(--cupi-white); border-radius: 8px; padding: 7px 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn[aria-pressed="true"] { background: var(--cupi-orange); border-color: var(--cupi-orange); color: var(--cupi-black); }
.btn--ghost { background: var(--cupi-white); color: var(--cupi-blue); border-color: var(--grey-300); }
.btn--ghost b { display: inline-block; min-width: 22px; margin-left: 4px; padding: 0 6px; border-radius: 11px; background: var(--cupi-blue); color: var(--cupi-white); font-size: 13px; text-align: center; }
.icon-btn { border: 0; background: none; font-size: 26px; line-height: 1; width: 40px; height: 40px; border-radius: 8px; }
.icon-btn:hover { background: var(--grey-100); }

/* ---------- Contents ---------- */
.toc { position: fixed; z-index: 10; top: 64px; bottom: 0; left: 0; width: 260px; overflow-y: auto; padding: 20px 12px 40px 20px;
  background: var(--cupi-white); border-right: 1px solid var(--grey-200); }
.toc h3 { font-size: 13px; font-weight: 600; color: var(--grey-700); margin: 18px 0 6px; }
.toc h3:first-child { margin-top: 0; }
.toc a { display: flex; gap: 10px; padding: 5px 8px; border-radius: 6px; text-decoration: none; color: var(--grey-900); }
.toc a i { font-style: normal; color: var(--grey-500); font-variant-numeric: tabular-nums; width: 20px; flex: none; }
.toc a:hover { background: var(--grey-50); }
.toc a[aria-current="true"] { background: var(--blue-50); color: var(--cupi-blue); font-weight: 600; }
.toc a b { margin-left: auto; font-size: 12px; color: var(--cupi-blue); font-weight: 600; }

/* ---------- Pages ---------- */
.pages { margin-left: 260px; padding: 32px 40px 120px; display: flex; flex-direction: column; align-items: center; gap: 32px; }
.sheet { width: 100%; max-width: 1280px; }
.sheet__frame { position: relative; aspect-ratio: 16 / 9; background: var(--cupi-white); box-shadow: 0 0 0 1px var(--grey-200); overflow: hidden; }
.sheet__frame iframe { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; border: 0; transform-origin: 0 0; pointer-events: none; }
.sheet__layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
body.commenting .sheet__layer { pointer-events: auto; cursor: crosshair; }
.sheet__label { display: flex; justify-content: space-between; margin-top: 8px; color: var(--grey-700); font-size: 13px; }

/* Pins: blue = Toasty, orange = CUPI */
.pin { position: absolute; z-index: 3; pointer-events: auto; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50% 50% 50% 4px;
  border: 2px solid var(--cupi-white); display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--cupi-blue); color: var(--cupi-white); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); }
.pin--cupi { background: var(--cupi-orange); color: var(--cupi-black); }
.pin--resolved { background: var(--grey-300); color: var(--grey-900); }
.pin--draft { background: var(--cupi-white); color: var(--cupi-blue); border-color: var(--cupi-blue); }

/* Popover */
.pop { position: absolute; z-index: 5; width: 340px; max-width: calc(100% - 16px); background: var(--cupi-white); border-radius: 10px;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.22), 0 0 0 1px var(--grey-200); padding: 14px; display: flex; flex-direction: column; gap: 10px; cursor: auto; }
.pop__msgs { display: flex; flex-direction: column; gap: 12px; max-height: 300px; overflow-y: auto; }
.msg__who { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.msg__who b { font-size: 14px; }
.msg__who span { color: var(--grey-700); }
.msg__body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.msg__del { border: 0; background: none; color: var(--grey-700); font-size: 12px; text-decoration: underline; margin-left: auto; }
.tag { font-style: normal; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--blue-50); color: var(--cupi-blue); }
.tag--cupi { background: var(--orange-100); color: var(--cupi-black); }
.pop textarea { width: 100%; min-height: 76px; resize: vertical; border: 1px solid var(--grey-300); border-radius: 8px; padding: 8px 10px; font-size: 16px; }
.pop input, .pop select { border: 1px solid var(--grey-300); border-radius: 8px; padding: 7px 10px; font-size: 16px; background: var(--cupi-white); }
.pop__id { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.pop__row { display: flex; gap: 8px; align-items: center; }
.pop__row .btn { margin-left: auto; }
.pop__resolved { font-size: 13px; color: var(--grey-700); }
.link { border: 0; background: none; color: var(--cupi-blue); font-weight: 600; padding: 0; }

/* Comments panel */
.panel { position: fixed; z-index: 20; top: 64px; right: 0; bottom: 0; width: 380px; background: var(--cupi-white); border-left: 1px solid var(--grey-200);
  display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.panel[hidden] { display: none; }
.panel__head { display: flex; align-items: center; justify-content: space-between; }
.panel__head h2 { font-size: 18px; }
.panel__me { font-size: 13px; color: var(--grey-700); }
.threads { list-style: none; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin: 0 -4px; padding: 0 4px 24px; }
.threads h4 { font-size: 13px; color: var(--grey-700); font-weight: 600; margin: 10px 0 2px; }
.thread { width: 100%; text-align: left; border: 1px solid var(--grey-200); background: var(--cupi-white); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.thread:hover { border-color: var(--blue-200); }
.thread p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.thread small { color: var(--grey-700); }
.empty { color: var(--grey-700); padding: 16px 0; }
body.panel-open .pages { margin-right: 380px; }

.hint { position: fixed; z-index: 25; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--grey-900); color: var(--cupi-white); padding: 10px 16px; border-radius: 8px; }
.toast { position: fixed; z-index: 40; left: 50%; top: 76px; transform: translateX(-50%); background: var(--grey-900); color: var(--cupi-white); padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.toast.show { opacity: 1; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1100px) {
  .bar__fonts > span, .bar__brand span, .bar__brand small { display: none; }
  .bar__menu { display: inline-block; border: 1px solid var(--grey-300); background: var(--cupi-white); border-radius: 8px; padding: 7px 12px; }
  .toc { transform: translateX(-100%); transition: transform 0.2s; box-shadow: 4px 0 20px rgba(0, 0, 0, 0.12); }
  body.toc-open .toc { transform: none; }
  .pages { margin-left: 0; padding: 16px 12px 100px; gap: 20px; }
  body.panel-open .pages { margin-right: 0; }
  .panel { width: 100%; }
}
@media (max-width: 640px) {
  .bar { height: auto; flex-wrap: wrap; row-gap: 8px; gap: 8px; padding: 8px 10px; }
  .bar__brand img { height: 22px; }
  .bar__actions { margin-left: auto; }
  .bar__fonts { order: 3; width: 100%; margin-left: 0; }
  .bar__fonts .seg { flex: 1; }
  .bar__fonts .seg button { flex: 1; padding: 7px 4px; }
  #pdfLink { display: none; }
  #panelBtn .lbl { display: none; }
  #panelBtn b { margin-left: 0; }
  .toc, .panel { top: 100px; }
  html { scroll-padding-top: 116px; }
  .pop { width: calc(100% - 16px); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
