/* =========================================================
   Web Review – app styles
   ========================================================= */
:root {
  --accent: #6c5ce7;
  --accent-600: #5a4bd4;
  --accent-50: #f0eefe;
  --green: #00b894;
  --green-50: #e6fbf5;
  --red: #e17055;
  --red-50: #fdeeea;
  --amber: #fdcb6e;
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e4e6f0;
  --text: #2d3436;
  --muted: #74798c;
  --shadow: 0 10px 30px rgba(30, 30, 60, .08);
  --radius: 10px;
  --topbar-h: 56px;
  --pages-w: 240px;
  --panel-w: 360px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; white-space: nowrap; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-600); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 34px; padding: 0; }
.btn:disabled { opacity: .5; cursor: default; }
.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
textarea.input { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; }
.input:focus { outline: 2px solid var(--accent-50); border-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 11px; border-radius: 7px; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.seg.mode button.on[data-mode="comment"] { background: var(--accent); color: #fff; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; height: 20px; line-height: 20px; border-radius: 10px; font-size: 11px; font-weight: 600; text-align: center; background: var(--accent-50); color: var(--accent); }
.badge.green { background: var(--green-50); color: var(--green); }
.badge.red { background: var(--red-50); color: var(--red); }
.badge.gray { background: var(--surface-2); color: var(--muted); }
.avatar { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--surface); color: var(--muted); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 380px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.logo svg { width: 24px; height: 24px; }
.card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; }
.card h2 { margin: 18px 0 18px; font-size: 20px; }
.error { background: var(--red-50); color: var(--red); padding: 9px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }

/* ---------- dashboard ---------- */
.shell-top { height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; padding: 0 20px; }
.shell-top nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; }
.shell-top nav a.on, .shell-top nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.page { max-width: 1100px; margin: 0 auto; padding: 28px 20px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.project-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.project-card h3 { margin: 0; font-size: 16px; }
.project-card .url { color: var(--muted); font-size: 12px; word-break: break-all; }
.project-card .stats { display: flex; gap: 8px; align-items: center; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; background: var(--surface); border: 1px dashed var(--border); border-radius: 12px; }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
table.list th, table.list td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
table.list th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }

/* ---------- review layout ---------- */
.review { display: grid; height: 100vh; grid-template-rows: var(--topbar-h) 1fr; grid-template-columns: var(--pages-w) 1fr var(--panel-w); grid-template-areas: "top top top" "pages stage panel"; }
.review.no-pages { grid-template-columns: 0 1fr var(--panel-w); }
.review.no-pages .pages { visibility: hidden; }
.review.no-panel { grid-template-columns: var(--pages-w) 1fr 0; }
.review.no-pages.no-panel { grid-template-columns: 0 1fr 0; }
.review.no-panel .panel { visibility: hidden; }
.topbar { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); min-width: 0; }
.topbar .proj { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.urlbar { flex: 1; min-width: 120px; max-width: 560px; display: flex; align-items: center; height: 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.urlbar .origin { padding: 0 2px 0 11px; color: var(--muted); white-space: nowrap; font-size: 13px; }
.urlbar input { flex: 1; border: 0; background: transparent; height: 100%; outline: none; padding: 0 8px 0 0; font-size: 13px; min-width: 40px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 8px; }
.dot.on { background: var(--green); }
.dot.warn { background: var(--amber); }

.pages { grid-area: pages; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.pages-head { padding: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.pages-head .title { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pages-list { overflow: auto; flex: 1; padding: 6px; }
.page-item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 7px; cursor: pointer; position: relative; }
.page-item:hover { background: var(--surface-2); }
.page-item.on { background: var(--accent-50); color: var(--accent); }
.page-item .t { flex: 1; min-width: 0; }
.page-item .t b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-item .t small { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-item .del { display: none; position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.page-item:hover .del { display: inline-flex; }
.page-item:hover .badge { visibility: hidden; }

.stage { grid-area: stage; position: relative; overflow: auto; display: flex; justify-content: center; background: repeating-conic-gradient(#eceef5 0% 25%, #f4f5fb 0% 50%) 50% / 22px 22px; min-width: 0; }
.frame-wrap { position: relative; height: 100%; width: 100%; background: #fff; transition: width .25s ease; box-shadow: 0 0 0 1px var(--border); }
.frame-wrap.tablet, .frame-wrap.mobile { margin: 16px 0; height: calc(100% - 32px); border-radius: 14px; overflow: hidden; box-shadow: 0 0 0 8px #2d3436, var(--shadow); }
.frame-wrap iframe { border: 0; width: 100%; height: 100%; display: block; }
.frame-wrap.commenting { box-shadow: 0 0 0 3px var(--accent); }
.frame-wrap.commenting.tablet, .frame-wrap.commenting.mobile { box-shadow: 0 0 0 8px var(--accent), var(--shadow); }
.frame-banner { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 5; width: min(560px, calc(100% - 32px)); background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 16px 18px; border-left: 4px solid var(--amber); }
.frame-banner h4 { margin: 0 0 6px; }
.frame-banner pre { background: var(--surface-2); border: 1px solid var(--border); padding: 8px 10px; border-radius: 6px; overflow: auto; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.mode-hint { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 6px 14px; border-radius: 20px; font-size: 12px; z-index: 4; pointer-events: none; box-shadow: var(--shadow); }

.composer { position: absolute; z-index: 6; width: 300px; background: var(--surface); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.22); padding: 12px; border: 1px solid var(--border); }
.composer textarea { min-height: 84px; }
.composer .row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.composer .row select { height: 30px; font-size: 12px; padding: 0 6px; }

.panel { grid-area: panel; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel-head { padding: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.tabs { display: flex; gap: 4px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tabs button.on { background: var(--accent-50); color: var(--accent); }
.filters { display: flex; gap: 8px; align-items: center; }
.filters select { height: 30px; font-size: 12px; padding: 0 6px; }
.panel-body { flex: 1; overflow: auto; }
.c-item { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; gap: 10px; }
.c-item:hover { background: var(--surface-2); }
.c-item.on { background: var(--accent-50); }
.c-num { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50% 50% 50% 0; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.c-num.resolved { background: var(--green); }
.c-num.high { background: var(--red); }
.c-main { flex: 1; min-width: 0; }
.c-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.c-meta b { color: var(--text); font-weight: 600; }
.c-text { margin-top: 4px; white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.c-foot { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 11px; color: var(--muted); }

.thread { display: flex; flex-direction: column; height: 100%; }
.thread-head { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.thread-body { flex: 1; overflow: auto; padding: 14px; }
.thread-props { display: grid; grid-template-columns: 90px 1fr; gap: 8px 10px; align-items: center; font-size: 12px; background: var(--surface-2); border-radius: 10px; padding: 12px; margin-bottom: 14px; }
.thread-props select { height: 30px; font-size: 12px; padding: 0 6px; }
.msg { display: flex; gap: 10px; margin-bottom: 14px; }
.msg .bubble { flex: 1; min-width: 0; }
.msg .bubble .who { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.msg .bubble .who b { color: var(--text); }
.msg .bubble .txt { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.msg .x { opacity: 0; }
.msg:hover .x { opacity: 1; }
.thread-reply { border-top: 1px solid var(--border); padding: 12px; }
.thread-reply textarea { min-height: 60px; }
.resolved-note { background: var(--green-50); color: #00845e; border-radius: 8px; padding: 8px 10px; font-size: 12px; margin-bottom: 14px; }

/* ---------- modal & toasts ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 20, 40, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { padding: 18px 22px 0; display: flex; align-items: center; }
.modal header h3 { margin: 0; flex: 1; font-size: 18px; }
.modal .body { padding: 18px 22px; }
.modal footer { padding: 0 22px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.copy-row { display: flex; gap: 6px; }
.copy-row .input { font-size: 12px; font-family: ui-monospace, monospace; }
pre.snippet { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 6px 0 14px; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: #fff; padding: 9px 16px; border-radius: 9px; box-shadow: var(--shadow); font-size: 13px; animation: tin .2s ease-out; }
.toast.err { background: var(--red); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  :root { --pages-w: 200px; --panel-w: 320px; }
  .topbar .hide-md { display: none; }
}
@media (max-width: 800px) {
  .review { grid-template-columns: 0 1fr 0; }
  .review .pages, .review .panel { position: fixed; top: var(--topbar-h); bottom: 0; z-index: 20; width: min(320px, 90vw); box-shadow: var(--shadow); }
  .review .pages { left: 0; }
  .review .panel { right: 0; }
  .review.no-pages .pages, .review.no-panel .panel { display: none; }
  .topbar .hide-sm { display: none; }
  .urlbar .origin { display: none; }
}
