/* ==========================================================================
   UpSurge client portal
   Black and gold, matching the UpSurge CRM. Dark is the default (:root),
   light is a warm paper inversion switched with [data-theme="light"].
   ========================================================================== */

:root {
  --bg: #0a0a0a;
  --bg-2: #121110;
  --bg-3: #1b1a16;
  --fg: #f4eedc;
  --fg-2: #d8d0b8;
  --surface: rgba(212, 175, 55, 0.045);
  --surface-2: rgba(212, 175, 55, 0.10);
  --surface-solid: #141310;
  --muted: #9a927a;
  --faint: #605a48;
  --rule: rgba(212, 175, 55, 0.14);
  --rule-strong: rgba(212, 175, 55, 0.32);
  --accent: #d4af37;
  --accent-lit: #f1d061;
  --accent-deep: #a8862b;
  --accent-solid: var(--accent);
  --accent-ink: #0a0a0a;
  --accent-soft: rgba(212, 175, 55, 0.13);
  --accent-grad: linear-gradient(135deg, #f3d66c 0%, #d4af37 52%, #b48d2c 100%);
  --ok: #3fbf6f;
  --warn: #e08a2e;
  --danger: #e5544b;
  --shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(212, 175, 55, 0.22);
  --shadow-lift: 0 22px 44px -14px rgba(212, 175, 55, 0.38), 0 0 0 1px rgba(212, 175, 55, 0.55);
  --pin-open: var(--accent);
  --pin-progress: #e08a2e;
  --pin-resolved: #605a48;

  --display: "Outfit", "DM Sans", system-ui, sans-serif;
  --body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gut: clamp(1.25rem, 4vw, 3.5rem);
  --radius: 12px;
  --radius-sm: 7px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #faf8f1;
  --bg-2: #f3f0e6;
  --bg-3: #eae6d8;
  --fg: #0a0a0a;
  --fg-2: #35322a;
  --surface: rgba(168, 134, 43, 0.05);
  --surface-2: rgba(168, 134, 43, 0.11);
  --surface-solid: #ffffff;
  --muted: #77705c;
  --faint: #aba48e;
  --rule: rgba(168, 134, 43, 0.16);
  --rule-strong: rgba(168, 134, 43, 0.36);
  --accent: #b8912e;
  --accent-lit: #d4af37;
  --accent-deep: #8c6c1f;
  --accent-soft: rgba(184, 145, 46, 0.12);
  --accent-grad: linear-gradient(135deg, #e9c95a 0%, #c9a233 52%, #a8862b 100%);
  --ok: #16a34a;
  --warn: #c9731e;
  --danger: #dc2626;
  --shadow: 0 12px 32px -8px rgba(10, 10, 10, 0.22), 0 0 0 1px rgba(168, 134, 43, 0.2);
  --shadow-lift: 0 22px 44px -14px rgba(184, 145, 46, 0.42), 0 0 0 1px rgba(184, 145, 46, 0.4);
  --pin-open: var(--accent);
  --pin-progress: #c9731e;
  --pin-resolved: #aba48e;
  color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s var(--ease), color 0.35s var(--ease);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; line-height: 1.1; }
p { margin: 0; }
.display { font-family: var(--display); font-weight: 600; letter-spacing: -0.025em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.8125rem; }
.micro { font-size: 0.6875rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.mono { font-family: var(--mono); font-size: 0.8125rem; }
.row { display: flex; align-items: center; gap: 0.75rem; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons, inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.6rem 1.05rem; border-radius: 999px; border: 1px solid var(--rule-strong);
  background: transparent; color: var(--fg); cursor: pointer; white-space: nowrap;
  font-size: 0.875rem; font-weight: 500; line-height: 1; min-height: 38px;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease), opacity 0.2s;
}
.btn:hover { background: var(--surface-2); border-color: var(--fg); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent-grad); border-color: transparent; color: var(--accent-ink); font-weight: 600; box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.35); }
.btn.primary:hover { background: var(--accent-grad); border-color: transparent; filter: brightness(1.07); box-shadow: var(--shadow-lift); }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { border-color: transparent; background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: transparent; }
.btn.danger:hover { background: rgba(255, 107, 107, 0.12); border-color: transparent; }
.btn.sm { padding: 0.4rem 0.8rem; min-height: 30px; font-size: 0.8125rem; }
.btn.xs { padding: 0.25rem 0.6rem; min-height: 24px; font-size: 0.75rem; }
.btn.icon { padding: 0; width: 38px; height: 38px; }
.btn.icon.sm { width: 30px; height: 30px; min-height: 30px; }

.input, .select, .textarea {
  width: 100%; padding: 0.7rem 0.9rem; border-radius: var(--radius-sm);
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--fg);
  transition: border-color 0.2s, background 0.2s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); background: var(--surface-2); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.select { appearance: none; padding-right: 2.2rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; cursor: pointer; }
.select.inline { width: auto; padding: 0.35rem 2rem 0.35rem 0.7rem; font-size: 0.8125rem; border-radius: 999px; }
.select option { background: var(--surface-solid); color: var(--fg); }
label.field { display: flex; flex-direction: column; gap: 0.4rem; }
label.field > span { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.input.sm { padding: 0.4rem 0.7rem; font-size: 0.875rem; }

/* ---------- chips, badges, pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.6rem;
  border-radius: 999px; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; border: 1px solid var(--rule); color: var(--muted); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.open { color: var(--pin-open); border-color: var(--pin-open); }
.badge.in_progress { color: var(--pin-progress); border-color: var(--pin-progress); }
.badge.resolved { color: var(--ok); border-color: var(--ok); }
.badge.submitted { color: var(--warn); border-color: var(--warn); }
.badge.approved { color: var(--ok); border-color: var(--ok); }
.badge.closed { color: var(--faint); }
.badge.plain::before { display: none; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); font-size: 0.6875rem; font-weight: 600; }
.count.hot { background: var(--accent); color: var(--accent-ink); }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 1rem;
  padding: 0 var(--gut); height: 64px; border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 0.7rem; font-weight: 600; letter-spacing: 0.02em; color: inherit; }
a.brand:hover { text-decoration: none; }
.brand .logo { width: 34px; height: 34px; object-fit: contain; }
.brand .name { font-family: var(--display); font-weight: 600; letter-spacing: 0.01em; font-size: 1.05rem; }
.brand .sub { color: var(--muted); font-weight: 400; }
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 0.25rem; }
.topbar nav a { padding: 0.45rem 0.8rem; border-radius: 999px; color: var(--muted); font-size: 0.875rem; }
.topbar nav a.active, .topbar nav a:hover { color: var(--accent-lit); background: var(--accent-soft); text-decoration: none; }
.userchip { display: flex; align-items: center; gap: 0.6rem; font-size: 0.875rem; color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 0.75rem; font-weight: 600; color: var(--fg); border: 1px solid var(--rule); }
.avatar.admin { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.brand-mark { width: 22px; height: 22px; object-fit: contain; opacity: 0.8; }
.brand-watermark { position: fixed; right: -5vw; bottom: -7vh; width: min(64vh, 680px); aspect-ratio: 1; background: url("/logo.png") center / contain no-repeat; opacity: 0.06; pointer-events: none; z-index: 0; }
:root[data-theme="light"] .brand-watermark { opacity: 0.08; }
.brand-corner { position: fixed; width: 22px; height: 22px; background: url("/logo.png") center / contain no-repeat; opacity: 0.5; pointer-events: none; z-index: 5; }
.brand-corner.bl { left: 18px; bottom: 14px; }
.brand-corner.br { right: 18px; bottom: 14px; }
.page { position: relative; z-index: 1; }

.theme-toggle { position: relative; width: 52px; height: 28px; border-radius: 999px; border: 1px solid var(--rule-strong); background: var(--surface); cursor: pointer; padding: 0; }
.theme-toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--fg); transition: transform 0.3s var(--ease); }
:root[data-theme="light"] .theme-toggle::after { transform: translateX(24px); }
.theme-toggle::after { background: var(--accent); }
.theme-toggle svg { position: absolute; top: 7px; width: 13px; height: 13px; color: var(--muted); }
.theme-toggle .sun { right: 7px; }
.theme-toggle .moon { left: 7px; }

.page { padding: clamp(1.5rem, 4vw, 3rem) var(--gut) 6rem; max-width: 1560px; margin: 0 auto; }
.page.narrow { max-width: 1100px; }

/* ---------- notifications bell ---------- */
.bell { position: relative; }
.bell .dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.625rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }
.popover {
  position: absolute; right: 0; top: calc(100% + 10px); width: min(380px, calc(100vw - 2rem)); max-height: 70vh; overflow: auto;
  background: var(--surface-solid); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 60;
  animation: pop 0.22s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
.popover .head { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 1rem; border-bottom: 1px solid var(--rule); font-weight: 600; }
.notif { display: block; padding: 0.8rem 1rem; border-bottom: 1px solid var(--rule); color: inherit; cursor: pointer; }
.notif:hover { background: var(--surface); text-decoration: none; }
.notif.unread { box-shadow: inset 3px 0 0 var(--accent); }
.notif .t { font-weight: 500; font-size: 0.875rem; }
.notif .b { color: var(--muted); font-size: 0.8125rem; margin-top: 0.15rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif .when { color: var(--faint); font-size: 0.6875rem; margin-top: 0.3rem; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .art { position: relative; overflow: hidden; background: #0a0a0a; color: #f4eedc; padding: var(--gut); display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid rgba(212, 175, 55, 0.2); }
.auth .art .big-logo { position: absolute; right: -6%; top: 50%; width: min(70vh, 640px); aspect-ratio: 1; transform: translateY(-50%); background: url("/logo.png") center / contain no-repeat; opacity: 0.14; pointer-events: none; }
.auth .art .brand .logo { width: 44px; height: 44px; }
.auth .art em { color: var(--accent-lit); font-style: normal; }
.auth .form .logo-sm { width: 40px; height: 40px; object-fit: contain; }
.auth .art h1 { font-size: clamp(2.6rem, 5vw, 5rem); line-height: 0.98; max-width: 12ch; }
.auth .art .orb { position: absolute; border-radius: 50%; background: radial-gradient(circle at 30% 30%, rgba(241, 208, 97, 0.32), transparent 62%); filter: blur(6px); animation: drift 14s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translate(6%, -8%) scale(1.08); } }
.auth .form { display: grid; place-items: center; padding: var(--gut); }
.auth .card { width: min(420px, 100%); }
.auth .card h2 { font-size: 2.2rem; margin-bottom: 0.25rem; }
.tabs { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); gap: 2px; }
.tabs button { border: 0; background: transparent; padding: 0.45rem 0.95rem; border-radius: 999px; color: var(--muted); cursor: pointer; font-size: 0.8125rem; font-weight: 500; }
.tabs button.active { background: var(--accent-grad); color: var(--accent-ink); }
.alert { padding: 0.75rem 0.95rem; border-radius: var(--radius-sm); border: 1px solid var(--rule); background: var(--surface); font-size: 0.875rem; }
.alert.error { border-color: var(--danger); color: var(--danger); }
.alert.ok { border-color: var(--ok); color: var(--ok); }
.alert.warn { border-color: var(--warn); color: var(--warn); }
@media (max-width: 820px) { .auth { grid-template-columns: 1fr; } .auth .art { min-height: 38vh; } }

/* ---------- project header ---------- */
.project-head { display: grid; grid-template-columns: 1fr auto; gap: 2rem; align-items: end; margin-bottom: 2rem; }
.project-head h1 { font-size: clamp(2.2rem, 4.2vw, 3.6rem); }
.project-head .company { color: var(--muted); margin-top: 0.4rem; }
.project-head .actions { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 820px) { .project-head { grid-template-columns: 1fr; } .project-head .actions { justify-content: flex-start; } }

/* stage tracker */
.tracker { position: relative; display: grid; grid-template-columns: repeat(7, 1fr); gap: 0; margin: 1.5rem 0 2.25rem; }
.tracker::before { content: ""; position: absolute; left: calc(100% / 14); right: calc(100% / 14); top: 9px; height: 2px; background: var(--rule); }
.tracker .fill { position: absolute; left: calc(100% / 14); top: 9px; height: 2px; background: var(--accent); transition: width 0.8s var(--ease); }
.tracker .step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.7rem; text-align: center; font-size: 0.75rem; color: var(--faint); letter-spacing: 0.02em; }
.tracker .step .dot { width: 20px; height: 20px; border-radius: 50%; background: var(--bg); border: 2px solid var(--rule); transition: all 0.4s var(--ease); display: grid; place-items: center; }
.tracker .step.done { color: var(--muted); }
.tracker .step.done .dot { border-color: var(--accent); background: var(--accent); }
.tracker .step.done .dot::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-ink); }
.tracker .step.current { color: var(--fg); font-weight: 600; }
.tracker .step.current .dot { border-color: var(--accent); background: var(--bg); box-shadow: 0 0 0 5px var(--accent-soft); }
.tracker .step.current .dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(0.7); opacity: 0.6; } }
@media (max-width: 720px) { .tracker { grid-template-columns: repeat(7, minmax(72px, 1fr)); overflow-x: auto; padding-bottom: 0.5rem; } }

/* stat strip */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; margin-bottom: 2rem; }
.stat { background: var(--surface-solid); padding: 1.1rem 1.3rem; }
.stat .v { font-family: var(--display); font-weight: 600; font-size: 1.9rem; line-height: 1; margin-top: 0.4rem; letter-spacing: -0.02em; }
.stat .v small { font-size: 1rem; color: var(--muted); font-family: var(--body); }
.meter { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 0.8rem; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); transition: width 0.6s var(--ease); }
.meter.full i { background: var(--warn); }

/* notice bands */
.band { border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.1rem 1.3rem; display: flex; gap: 1rem; align-items: center; margin-bottom: 1.5rem; background: var(--surface); }
.band.accent { border-color: var(--accent); background: var(--accent-soft); }
.band.warn { border-color: var(--warn); }
.band.ok { border-color: var(--ok); }
.band h4 { font-size: 0.95rem; font-weight: 600; }
.band p { color: var(--muted); font-size: 0.875rem; }

/* ---------- section tabs ---------- */
.sectabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.5rem; overflow-x: auto; overflow-y: hidden; }
.sectabs button { border: 0; background: none; padding: 0.8rem 1rem; color: var(--muted); cursor: pointer; font-weight: 500; position: relative; white-space: nowrap; display: inline-flex; gap: 0.5rem; align-items: center; }
.sectabs button.active { color: var(--fg); }
.sectabs button.active::after { content: ""; position: absolute; left: 0.6rem; right: 0.6rem; bottom: 0; height: 2px; background: var(--accent); }

/* ---------- annotation workspace ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1.5rem; align-items: start; }
@media (max-width: 1000px) { .workspace { grid-template-columns: 1fr; } .workspace .threads { position: static; max-height: none; } }

.canvas-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.pagetabs { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.pagetabs button { border: 1px solid var(--rule); background: transparent; color: var(--muted); padding: 0.4rem 0.8rem; border-radius: 999px; cursor: pointer; font-size: 0.8125rem; display: inline-flex; gap: 0.45rem; align-items: center; }
.pagetabs button.active { border-color: var(--accent); color: var(--accent-lit); background: var(--accent-soft); }
.canvas-head .mode { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.hint { font-size: 0.8125rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.4rem; }
.hint kbd { font-family: var(--mono); font-size: 0.7rem; border: 1px solid var(--rule-strong); border-radius: 4px; padding: 0 5px; }

.canvas { position: relative; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.canvas.locked { cursor: default; }
.canvas .stage { position: relative; display: block; width: 100%; user-select: none; }
.canvas .stage img { width: 100%; height: auto; display: block; cursor: crosshair; }
.canvas.locked .stage img { cursor: default; }
.canvas .stage .layer { position: absolute; inset: 0; pointer-events: none; }

.pin {
  position: absolute; width: 30px; height: 30px; margin: -30px 0 0 -6px; pointer-events: auto; cursor: pointer;
  border-radius: 50% 50% 50% 4px; background: var(--pin-open); color: var(--accent-ink); border: 2px solid var(--bg);
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; box-shadow: 0 6px 16px rgba(0,0,0,0.35);
  transition: transform 0.2s var(--ease), background 0.2s; transform-origin: 6px 30px; animation: drop 0.35s var(--ease);
}
@keyframes drop { from { transform: translateY(-14px) scale(0.6); opacity: 0; } }
.pin:hover { transform: scale(1.12); z-index: 3; }
.pin.active { transform: scale(1.25); z-index: 4; box-shadow: 0 0 0 5px var(--accent-soft), 0 6px 16px rgba(0,0,0,0.35); }
.pin.in_progress { background: var(--pin-progress); color: #0a0a0a; }
.pin.resolved { background: var(--pin-resolved); color: var(--fg); }
.pin.admin { border-radius: 50% 50% 4px 50%; }
.pin.draft { background: var(--fg); color: var(--bg); animation: none; }

/* pin composer bubble */
.composer {
  position: absolute; z-index: 5; width: min(320px, 90vw); background: var(--surface-solid); border: 1px solid var(--rule-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.85rem; pointer-events: auto; animation: pop 0.2s var(--ease);
}
.composer .textarea { min-height: 76px; background: var(--surface); }
.composer .foot { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; }
.composer .foot .grow { flex: 1; }
.attach-list { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.attach-list .thumb { position: relative; width: 52px; height: 52px; border-radius: 6px; overflow: hidden; border: 1px solid var(--rule); background: var(--surface-2); }
.attach-list .thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-list .thumb button { position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; border-radius: 50%; border: 0; background: rgba(0,0,0,0.7); color: #fff; font-size: 10px; cursor: pointer; line-height: 1; padding: 0; }
.attach-list .thumb .doc { display: grid; place-items: center; width: 100%; height: 100%; font-size: 0.6rem; color: var(--muted); text-align: center; padding: 3px; word-break: break-all; }

.canvas .empty-canvas { padding: 5rem 2rem; text-align: center; color: var(--muted); }
.canvas .empty-canvas .display { font-size: 1.8rem; color: var(--fg); margin-bottom: 0.5rem; }

/* thread panel */
.threads { position: sticky; top: 84px; max-height: calc(100vh - 100px); display: flex; flex-direction: column; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.threads .head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.9rem 1rem; border-bottom: 1px solid var(--rule); }
.threads .head h3 { font-size: 0.95rem; font-weight: 600; }
.threads .filters { display: flex; gap: 0.25rem; }
.threads .filters button { border: 0; background: transparent; color: var(--muted); font-size: 0.75rem; padding: 0.3rem 0.55rem; border-radius: 999px; cursor: pointer; }
.threads .filters button.active { background: var(--surface-2); color: var(--fg); }
.threads .list { overflow: auto; flex: 1; }
.thread { border-bottom: 1px solid var(--rule); }
.thread > .summary { display: flex; gap: 0.75rem; padding: 0.85rem 1rem; cursor: pointer; align-items: flex-start; }
.thread > .summary:hover { background: var(--surface); }
.thread.active > .summary { background: var(--accent-soft); }
.thread .num { flex: none; width: 24px; height: 24px; border-radius: 50% 50% 50% 3px; background: var(--pin-open); color: var(--accent-ink); font-size: 0.7rem; font-weight: 700; display: grid; place-items: center; }
.thread .num.in_progress { background: var(--pin-progress); color: #0a0a0a; }
.thread .num.resolved { background: var(--pin-resolved); color: var(--fg); }
.thread .who { font-size: 0.75rem; color: var(--muted); display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.thread .who b { color: var(--fg); font-weight: 600; }
.thread .excerpt { font-size: 0.875rem; margin-top: 0.15rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.thread.active .excerpt { display: block; white-space: pre-wrap; }
.thread .body { padding: 0 1rem 1rem 3rem; }
.thread .replies { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.3rem; }
.reply { font-size: 0.875rem; }
.reply .who { margin-bottom: 0.15rem; }
.reply .text { white-space: pre-wrap; }
.reply.admin .text { border-left: 2px solid var(--accent); padding-left: 0.6rem; }
.thread .tools { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 0.6rem 0 0.3rem; align-items: center; }
.thread .status-btns { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.thread .status-btns button { border: 0; background: transparent; color: var(--muted); padding: 0.3rem 0.65rem; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; }
.thread .status-btns button.active { background: var(--surface-2); color: var(--fg); }
.thread .status-btns button.active.open { color: var(--pin-open); }
.thread .status-btns button.active.in_progress { color: var(--pin-progress); }
.thread .status-btns button.active.resolved { color: var(--ok); }
.reply-box { margin-top: 0.75rem; }
.reply-box .textarea { min-height: 60px; font-size: 0.875rem; }
.reply-box .foot { display: flex; gap: 0.4rem; margin-top: 0.4rem; align-items: center; }
.att-grid { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.45rem; }
.att-grid a { display: block; width: 72px; height: 72px; border-radius: 6px; overflow: hidden; border: 1px solid var(--rule); background: var(--surface-2); }
.att-grid a img { width: 100%; height: 100%; object-fit: cover; }
.att-grid a .doc { display: grid; place-items: center; height: 100%; font-size: 0.6rem; color: var(--muted); padding: 4px; text-align: center; word-break: break-all; }

/* ---------- version history ---------- */
.versions { display: grid; gap: 1rem; }
.version { border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.1rem 1.3rem; display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; transition: border-color 0.2s; }
.version:hover { border-color: var(--rule-strong); }
.version.current { border-color: var(--accent); }
.version h3 { font-family: var(--display); font-size: 1.35rem; font-weight: 600; }
.version .meta { color: var(--muted); font-size: 0.8125rem; margin-top: 0.3rem; display: flex; gap: 0.9rem; flex-wrap: wrap; }
.version .thumbs { display: flex; gap: 0.4rem; margin-top: 0.8rem; }
.version .thumbs img { width: 64px; height: 44px; object-fit: cover; object-position: top; border-radius: 4px; border: 1px solid var(--rule); }

/* ---------- assets ---------- */
.dropzone { border: 1px dashed var(--rule-strong); border-radius: var(--radius); padding: 2rem; text-align: center; color: var(--muted); transition: all 0.2s; cursor: pointer; background: var(--surface); }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--fg); }
.dropzone strong { color: var(--fg); }
.asset-cats { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 1.25rem 0 1rem; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.9rem; }
.asset { border: 1px solid var(--rule); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; transition: border-color 0.2s, transform 0.2s var(--ease); }
.asset:hover { border-color: var(--rule-strong); transform: translateY(-2px); }
.asset .prev { height: 130px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.asset .prev img { width: 100%; height: 100%; object-fit: cover; }
.asset .prev .ext { font-family: var(--display); font-weight: 600; font-size: 1.4rem; color: var(--accent); }
.asset .info { padding: 0.7rem 0.8rem; font-size: 0.8125rem; }
.asset .info .n { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset .info .m { color: var(--muted); font-size: 0.75rem; margin-top: 0.2rem; }
.asset .foot { display: flex; gap: 0.3rem; padding: 0 0.5rem 0.5rem; }

/* ---------- admin ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th { text-align: left; font-size: 0.6875rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 500; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--rule); }
.table td { padding: 0.85rem 0.8rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface); }
.table td .name { font-weight: 500; }
.table td .sub { color: var(--muted); font-size: 0.8125rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.card { border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.2rem 1.3rem; background: var(--surface); }
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.9rem; }
.card .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.card.form .stack { gap: 0.9rem; }

.admin-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 2rem; }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 80; display: grid; place-items: center; padding: 1rem; animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: var(--surface-solid); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; animation: pop 0.25s var(--ease); }
.modal h2 { font-size: 1.6rem; margin-bottom: 1rem; }
.modal .foot { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }
.filelist { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.6rem; }
.filelist .f { display: flex; align-items: center; gap: 0.6rem; font-size: 0.8125rem; }
.filelist .f .input { padding: 0.35rem 0.6rem; font-size: 0.8125rem; }
.filelist .f .fn { color: var(--muted); flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast-wrap { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; padding: 0.7rem 1.1rem; border-radius: 999px; background: var(--accent-grad); color: var(--accent-ink); font-size: 0.875rem; font-weight: 500; box-shadow: var(--shadow); animation: pop 0.25s var(--ease); }
.toast.error { background: var(--danger); color: #fff; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 0 0 1.25rem; }
.section-title h2 { font-size: clamp(1.8rem, 3vw, 2.6rem); }
.divider { height: 1px; background: var(--rule); margin: 2.5rem 0; }

.loading { padding: 4rem; text-align: center; color: var(--muted); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--rule-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; margin: 0 auto 0.75rem; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- live website review ---------- */
.live-wrap { border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.live-bar { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.mode-toggle, .devices { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); gap: 2px; }
.mode-toggle button, .devices button { border: 0; background: transparent; padding: 0.35rem 0.8rem; border-radius: 999px; color: var(--muted); cursor: pointer; font-size: 0.8125rem; font-weight: 500; }
.devices button { padding: 0.3rem 0.65rem; font-size: 0.75rem; }
.mode-toggle button.active { background: var(--accent-grad); color: var(--accent-ink); }
.devices button.active { background: var(--bg); color: var(--fg); }
.mode-toggle.disabled { opacity: 0.45; pointer-events: none; }
.live-path { color: var(--muted); font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
.live-viewport { background: #ffffff; height: calc(100vh - 190px); min-height: 520px; display: flex; justify-content: center; overflow: hidden; }
.live-viewport.framed { background: var(--bg-2); padding: 1rem 0; }
.live-viewport iframe { border: 0; width: 100%; height: 100%; background: #ffffff; display: block; box-shadow: 0 0 0 1px var(--rule); }
.pagetabs button.virtual { border-style: dashed; }
.panel-composer { padding: 0.9rem 1rem; border-bottom: 1px solid var(--rule); background: var(--accent-soft); }
.panel-composer .textarea { background: var(--surface-solid); min-height: 76px; }
.panel-composer .foot { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; }
@media (max-width: 1000px) { .live-viewport { height: 70vh; min-height: 420px; } }

/* ---------- full screen review page ---------- */
body.review-page { overflow: hidden; }
.review { position: fixed; inset: 0; display: grid; grid-template-rows: 56px minmax(0, 1fr); background: var(--bg); z-index: 1; }
.review-top { display: flex; align-items: center; gap: 0.75rem; padding: 0 0.9rem; border-bottom: 1px solid var(--rule); background: var(--bg); min-width: 0; }
.review-top .brand .logo { width: 30px; height: 30px; }
.review-top .tb-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.review-top .tb-title b { font-family: var(--display); font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.review-top .tb-title .badge { align-self: flex-start; }
.review-top .tb-center { display: flex; align-items: center; gap: 0.6rem; margin: 0 auto; min-width: 0; }
.review-top .tb-center .live-path { max-width: 220px; }
.review-top .tb-right { display: flex; align-items: center; gap: 0.5rem; flex: none; }
.review-top .btn.icon { position: relative; }
.review-top .btn.icon .dot { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.625rem; font-weight: 700; display: grid; place-items: center; }
.review-body { display: grid; grid-template-columns: 360px minmax(0, 1fr); min-height: 0; }
.review-body.collapsed { grid-template-columns: minmax(0, 1fr); }
.review-body.collapsed .review-drawer { display: none; }
.review-drawer { border-right: 1px solid var(--rule); background: var(--surface-solid); overflow: hidden; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.review-body.collapsed .review-drawer { border-right: 0; }
.review-drawer > * { min-width: 360px; }
.review-drawer .drawer-head { display: flex; align-items: center; padding: 0.75rem 1rem 0.35rem; }
.review-drawer .pages { padding: 0 0.85rem 0.75rem; border-bottom: 1px solid var(--rule); }
.review-drawer .drawer-note { padding: 0.75rem 1rem; border-bottom: 1px solid var(--rule); background: var(--surface); }
.review-drawer .drawer-note p { margin-top: 0.3rem; color: var(--fg-2); }
.review-drawer .threads { position: static; max-height: none; flex: 1; min-height: 0; border: 0; border-radius: 0; background: transparent; }
.review-main { min-width: 0; min-height: 0; position: relative; display: flex; justify-content: center; background: #ffffff; overflow: hidden; }
.review-main.framed { background: var(--bg-2); padding: 1rem 0; }
.review-main iframe { border: 0; width: 100%; height: 100%; display: block; background: #ffffff; box-shadow: 0 0 0 1px var(--rule); }
.review-main.shots { background: var(--bg-2); overflow: auto; padding: 1.25rem; align-items: flex-start; }
.review-main.shots .review-canvas { width: 100%; max-width: 1400px; margin: 0 auto; transition: max-width 0.3s var(--ease); }
.drawer-handle { position: fixed; left: 0; top: 50%; transform: translateY(-50%); z-index: 30; display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.7rem 0.8rem 0.7rem 0.7rem; border-radius: 0 999px 999px 0; border: 1px solid var(--rule-strong); border-left: 0; background: var(--accent-grad); color: var(--accent-ink); font-weight: 600; font-size: 0.8125rem; cursor: pointer; box-shadow: var(--shadow); }
.drawer-handle:hover { filter: brightness(1.06); }
@media (max-width: 900px) {
  .review-top .tb-title, .review-top .tb-right .avatar, .review-top .tb-center .live-path { display: none; }
  .review-body { grid-template-columns: min(360px, 88vw) minmax(0, 1fr); }
  .review-drawer { position: absolute; top: 56px; bottom: 0; left: 0; width: min(360px, 88vw); z-index: 20; box-shadow: var(--shadow); }
  .review-body { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- live round card on the dashboard ---------- */
.live-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.5rem; align-items: center; border: 1px solid var(--rule-strong); border-radius: var(--radius); padding: 1.5rem 1.75rem; background: var(--surface); position: relative; overflow: hidden; }
.live-card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 120% at 100% 50%, var(--accent-soft), transparent 70%); pointer-events: none; }
.live-card > * { position: relative; }
.live-card h3 { font-family: var(--display); font-size: clamp(1.4rem, 2.4vw, 2rem); font-weight: 600; margin: 0.2rem 0 0.35rem; }
.live-card .live-pages { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 1rem; }
.live-card .cta { display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; text-align: right; }
.live-card .cta .btn.primary { padding: 0.85rem 1.5rem; font-size: 0.95rem; }
@media (max-width: 720px) { .live-card { grid-template-columns: 1fr; } .live-card .cta { align-items: flex-start; text-align: left; } }

/* per device comment counts on the width switcher */
.devices button .cnt { display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; margin-left: 0.35rem; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.625rem; font-weight: 700; vertical-align: 1px; }
.devices button .cnt:empty { display: none; }
