/* 247 Review */

:root {
  --paper: #F2F4F6;
  --surface: #FFFFFF;
  --ink: #1B2533;
  --muted: #5D6878;
  --line: #D9DEE5;
  --line-strong: #B9C1CC;
  --pin: #D6246E;
  --pin-soft: #FBE7EF;
  --ok: #2E7D5B;
  --ok-soft: #E3F1EA;
  --danger: #B42318;
  --focus: #1B2533;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: inherit; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: .9375rem; margin-top: 1.5rem; }
p { margin: 0 0 .75rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .8125rem; }
.error { color: var(--danger); font-size: .8125rem; }
[hidden] { display: none !important; }

/* Wordmark: the pin is the brand. */
.wordmark { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; text-decoration: none; letter-spacing: -0.01em; margin: 0; }
.wordmark-pin { width: 20px; height: 20px; border-radius: 10px 10px 10px 2px; background: var(--pin); flex: none; }

/* Controls */
input, textarea, select { font: inherit; color: inherit; }
input:not([type=checkbox]), textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  background: var(--surface);
}
input:focus, textarea:focus { outline: 2px solid var(--pin); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 2.5rem; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; white-space: nowrap;
  padding: .5rem .9rem; border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink); font: 600 .875rem/1.2 var(--font); text-decoration: none; cursor: pointer;
}
.button:hover { border-color: var(--ink); }
.button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.button.primary:hover { background: #2C3A4D; }
.button.ghost { background: transparent; border-color: transparent; }
.button.ghost:hover { background: rgba(27, 37, 51, .06); }
.button.small { padding: .35rem .7rem; font-size: .8125rem; }
.button.resolve { color: var(--ok); border-color: #A9D2BE; }
.button.resolve:hover { background: var(--ok-soft); border-color: var(--ok); }
.button:disabled { opacity: .55; cursor: progress; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-button:hover { color: var(--ink); }
.link-button.danger:hover { color: var(--danger); }
.field { display: grid; gap: .3rem; }
.field > span:first-child { font-weight: 600; font-size: .8125rem; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: .4rem; font-size: .8125rem; color: var(--muted); cursor: pointer; }
kbd { font: 600 .6875rem/1 var(--font); padding: .15rem .3rem; border: 1px solid currentColor; border-radius: 4px; opacity: .6; }

.segmented { display: inline-flex; padding: 2px; background: rgba(27, 37, 51, .06); border-radius: 8px; }
.segmented button {
  border: 0; background: none; padding: .4rem .7rem; border-radius: 6px; cursor: pointer;
  font: 500 .8125rem/1.2 var(--font); color: var(--muted); display: inline-flex; gap: .35rem; align-items: center;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed=true] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(27, 37, 51, .15); }
.segmented button[data-mode=comment][aria-pressed=true] { background: var(--pin); color: #fff; }
.segmented.small button { padding: .3rem .6rem; }
.segmented button span:empty { display: none; }
.segmented button span { font-size: .75rem; color: var(--pin); font-weight: 700; }

/* --- Staff pages --------------------------------------------------------- */

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-user { display: flex; align-items: center; gap: 1rem; font-size: .875rem; color: var(--muted); }
.topbar-user a { color: var(--muted); }
.topbar-user form { margin: 0; }
.content { max-width: 68rem; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }
.lede { color: var(--muted); max-width: 38rem; }
.flash { background: var(--ok-soft); border: 1px solid #A9D2BE; color: #1E5A40; padding: .6rem .9rem; border-radius: var(--radius-s); margin-bottom: 1.5rem; }
.flash p { margin: 0; }

.new-project { margin-bottom: 3rem; }
.new-project-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto; gap: .75rem; align-items: end; margin-top: 1.25rem; }
.new-project-form select { height: 2.45rem; }
.new-project-form .button { height: 2.45rem; }

.projects-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.filters { display: flex; gap: .9rem; font-size: .875rem; align-items: center; }
.filters a { color: var(--muted); text-decoration: none; }
.filters a[aria-current] { color: var(--ink); font-weight: 600; }
.filters .sep { width: 1px; height: 1em; background: var(--line-strong); }

.project-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.project-table th { text-align: left; font-weight: 600; font-size: .8125rem; color: var(--muted); padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.project-table td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.project-table tr:last-child td { border-bottom: 0; }
.project-table tbody tr:hover { background: #F8F9FB; }
.project-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.project-name { font-weight: 600; text-decoration: none; }
.project-name:hover { text-decoration: underline; }
.count-open { display: inline-block; min-width: 1.6rem; padding: .05rem .45rem; border-radius: 999px; background: var(--pin-soft); color: var(--pin); font-weight: 700; text-align: center; }
.row-actions { display: flex; gap: 1rem; justify-content: flex-end; font-size: .875rem; }
.row-actions a { color: var(--muted); }
.row-actions form { margin: 0; }
.empty { color: var(--muted); padding: 2rem 0; }

.crumbs { font-size: .875rem; margin-bottom: .5rem; }
.crumbs a { color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.5rem; margin-top: 1.25rem; max-width: 44rem; }
.panel > p { color: var(--muted); }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { font-size: .875rem; }
.inline-form { margin-top: 1rem; display: flex; gap: .75rem; align-items: baseline; flex-wrap: wrap; font-size: .875rem; }
.stack { display: grid; gap: 1rem; justify-items: start; }
.stack .field { width: 100%; }
.invite-list { list-style: none; margin: 0; padding: 0; font-size: .875rem; }
.invite-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-top: 1px solid var(--line); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 24rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 2rem; }
.login-card h1 { font-size: 1.375rem; margin: 1.25rem 0 1rem; }
.login-card form { display: grid; gap: .9rem; margin-bottom: 1.25rem; }
.login-card label { display: grid; gap: .3rem; font-weight: 600; font-size: .8125rem; }
.login-card .hint { margin: 0; }

@media (max-width: 760px) {
  .new-project-form { grid-template-columns: 1fr; }
  .project-table thead { display: none; }
  .project-table, .project-table tbody, .project-table tr, .project-table td { display: block; }
  .project-table tr { padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
  .project-table td { padding: .1rem 0; border: 0; text-align: left !important; }
  .project-table td.num { display: inline-block; margin-right: 1rem; }
  .project-table td.num:first-of-type::after { content: " open"; }
  .row-actions { justify-content: flex-start; padding-top: .4rem !important; }
  .copy-row { flex-direction: column; }
}

/* --- Viewer ------------------------------------------------------------------ */

.viewer { height: 100vh; height: 100dvh; overflow: hidden; }
.viewer-main { height: 100%; display: flex; flex-direction: column; }
.viewer .flash { display: none; }

.vbar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 1rem;
  padding: .55rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); flex: none;
}
.vbar-left { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.vbar-title { display: grid; min-width: 0; line-height: 1.25; }
.vbar-title strong { font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-address { font-size: .75rem; color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-address:hover { text-decoration: underline; color: var(--ink); }
.vbar-center { display: flex; gap: .5rem; }
.vbar-right { display: flex; justify-content: flex-end; gap: .4rem; align-items: center; }
#identity-button { font-weight: 500; color: var(--muted); max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }

.stage { flex: 1; display: flex; min-height: 0; }
.canvas { flex: 1; position: relative; min-width: 0; display: flex; justify-content: center; background: var(--paper); overflow: auto; }
.frame-box { position: relative; width: 100%; height: 100%; flex: none; }
.canvas iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
/* A fixed screen width: viewer.js sizes the box and scales the iframe inside it. */
.canvas.framed { padding: 1.25rem; overflow: hidden; }
.canvas.framed .frame-box { border-radius: var(--radius-m); overflow: hidden; box-shadow: 0 0 0 1px var(--line), 0 12px 32px rgba(27, 37, 51, .12); }
.canvas.framed iframe { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.zoom-note { position: absolute; right: 1.5rem; bottom: .6rem; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; pointer-events: none; }
.segmented-select { border: 0; background: transparent; font: 500 .8125rem/1.2 var(--font); color: var(--muted); padding: .4rem .3rem; border-radius: 6px; cursor: pointer; max-width: 7.5rem; }
.segmented-select:hover { color: var(--ink); }
select { font: inherit; color: inherit; padding: .5rem .6rem; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); }
body.commenting .canvas { box-shadow: inset 0 0 0 3px var(--pin); }
.frame-loading { position: absolute; top: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: .8125rem; padding: .35rem .8rem; border-radius: 999px; pointer-events: none; }

.sidebar { width: 22rem; flex: none; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); min-height: 0; }
body.sidebar-closed .sidebar { display: none; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sidebar-body { flex: 1; overflow-y: auto; padding: .5rem; }
.sidebar-body .empty { padding: 1.5rem .75rem; font-size: .875rem; }

.thread { border-radius: var(--radius-m); margin-bottom: 2px; }
.thread.active { background: #F7F8FA; box-shadow: inset 0 0 0 1px var(--line); margin: .25rem 0; }
.thread-head { display: flex; gap: .7rem; align-items: flex-start; width: 100%; padding: .7rem .6rem; background: none; border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; border-radius: var(--radius-m); }
.thread-head:hover { background: rgba(27, 37, 51, .04); }
.thread-head.static { cursor: default; }
.thread-head.static:hover { background: none; }
.thread-summary { display: grid; gap: .15rem; min-width: 0; flex: 1; font-size: .875rem; }
.thread-meta { display: flex; justify-content: space-between; gap: .5rem; }
.thread-meta time, .comment-meta time { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.thread-excerpt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: #36414F; }
.thread-foot { display: flex; gap: .6rem; flex-wrap: wrap; font-size: .75rem; color: var(--muted); }
.thread-foot:empty { display: none; }
.thread-page { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12rem; }
.resolved-note { color: var(--ok); font-weight: 600; }
.thread.is-resolved:not(.active) .thread-excerpt { color: var(--muted); }

.badge { flex: none; width: 24px; height: 24px; border-radius: 12px 12px 12px 2px; background: var(--pin); color: #fff; font: 700 11px/24px var(--font); text-align: center; margin-top: 1px; }
.badge.resolved { background: var(--ok); }
.badge.draft { background: var(--ink); }

.thread-comments { padding: 0 .75rem 0 2.6rem; }
.comment { padding: .5rem 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: 0; padding-top: 0; }
.comment-meta { display: flex; align-items: baseline; gap: .4rem; font-size: .8125rem; }
.comment-meta time { margin-left: auto; }
.comment-body { margin: .2rem 0 0; font-size: .875rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.tag { font-size: .6875rem; font-weight: 700; color: var(--pin); background: var(--pin-soft); padding: 0 .35rem; border-radius: 4px; }

.composer { padding: .5rem .75rem .5rem 2.6rem; display: grid; gap: .45rem; }
.composer textarea { font-size: .875rem; }
.composer-actions { display: flex; justify-content: flex-end; gap: .4rem; }
.thread-actions { display: flex; justify-content: space-between; align-items: center; padding: .1rem .75rem .75rem 2.6rem; font-size: .8125rem; }

.dialog { border: 0; border-radius: var(--radius-m); padding: 1.5rem; width: min(24rem, calc(100vw - 2rem)); box-shadow: 0 24px 64px rgba(27, 37, 51, .3); color: var(--ink); }
.dialog::backdrop { background: rgba(27, 37, 51, .45); }
.dialog form { display: grid; gap: .9rem; }
.dialog p { color: var(--muted); font-size: .875rem; margin: 0; }
.dialog h2 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; }

.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .55rem 1rem; border-radius: var(--radius-s); font-size: .875rem; z-index: 10; max-width: calc(100vw - 2rem); }
.toast.error { background: var(--danger); }

@media (max-width: 1000px) {
  .vbar { grid-template-columns: minmax(0, 1fr) auto; }
  .vbar-center { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
}
@media (max-width: 760px) {
  .vbar { padding: .5rem .75rem; gap: .5rem; }
  .vbar-center [data-device=tablet] { display: none; }
  #identity-button { display: none; }
  .sidebar { position: fixed; left: 0; right: 0; bottom: 0; width: auto; height: 55vh; border-left: 0; border-top: 1px solid var(--line); box-shadow: 0 -12px 32px rgba(27, 37, 51, .15); border-radius: 14px 14px 0 0; z-index: 5; }
  .canvas.framed { padding: 0; }
  .canvas.framed .frame-box { border-radius: 0; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
