/* WS DrawingHub — design system (tokens → components → workspace). Light/dark aware, responsive. */
:root {
  --brand: #1f4e79; --accent: #e87722;
  --bg: #f3f5f8; --surface: #ffffff; --surface-2: #f7f9fb; --line: #dfe4ea; --line-2: #c9d1da;
  --text: #17202b; --muted: #5d6b7a; --ok: #2e7d32; --warn: #b26a00; --err: #c62828; --info: #1565c0;
  --radius: 8px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --topbar: 52px; --rail: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b; --surface: #1a2027; --surface-2: #20272f; --line: #2c3540; --line-2: #3a4553;
    --text: #e7ecf1; --muted: #9aa8b6; --ok: #66bb6a; --warn: #ffb74d; --err: #ef5350; --info: #64b5f6;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 2px 10px rgba(0,0,0,.35); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-text-size-adjust: 100%; }
a { color: var(--brand); }
@media (prefers-color-scheme: dark) { a { color: #8bb8e8; } }
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 20px 0 10px; font-weight: 650; }
h3 { font-size: 14px; margin: 16px 0 8px; }
p { margin: 0 0 8px; }
code { font-family: var(--mono); font-size: 12px; }
.skip { position: absolute; left: -999px; top: 4px; background: var(--surface); padding: 6px 10px; z-index: 100; }
.skip:focus { left: 8px; }
.boot { padding: 40px; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .block { display: block; } .center { text-align: center; }
.grow { flex: 1; min-width: 0; } .spacer { flex: 1; } .pad { padding: 12px; } .num { text-align: right; font-variant-numeric: tabular-nums; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .pre { white-space: pre-wrap; }
.row { display: flex; align-items: center; gap: 8px; } .row.between { justify-content: space-between; } .row.end { justify-content: flex-end; } .row.gap { gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } .hide-sm { display: none !important; } }
.ic { flex: none; }

/* ---------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.btn.small { min-height: 28px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 36px; padding: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 8px 10px; min-height: 36px; width: 100%; }
input[type=checkbox] { width: 16px; min-height: 0; height: 16px; accent-color: var(--brand); }
input[type=range] { padding: 0; border: 0; min-height: 0; accent-color: var(--brand); }
input[type=color] { padding: 2px; height: 36px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 2px solid color-mix(in srgb, var(--brand) 25%, transparent); outline-offset: 0; }
input[readonly] { background: var(--surface-2); }
textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-weight: 600; font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.rev { background: var(--brand); color: #fff; border-color: var(--brand); }
.st-released, .st-approved, .st-active, .st-accepted, .st-sent, .st-resolved, .st-closed { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.st-in_review, .st-in_progress, .st-pending, .st-queued, .st-on_hold { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.st-superseded, .st-revoked, .st-expired, .st-suspended, .st-failed { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); background: color-mix(in srgb, var(--err) 9%, transparent); }
.badge, .mini-badge { display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; align-items: center; justify-content: center; }
.bell { position: relative; } .bell .badge { position: absolute; top: 2px; right: 0; }

/* ---------- top bar */
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar); display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-brand { text-decoration: none; color: inherit; display: flex; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.brand-logo { height: 30px; max-width: 160px; object-fit: contain; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 12px; letter-spacing: .5px; box-shadow: inset -4px 0 0 var(--accent); }
.brand-name { font-size: 15px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; border: 0; flex: none; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; margin-left: -6px; border: 2px solid var(--surface); cursor: pointer; }
.avatar.self { background: var(--accent); }
.avatar-btn { padding: 0 6px; }
.presence { display: flex; padding-left: 6px; }
.menu-wrap { position: relative; }
.menu { display: none; position: absolute; right: 0; top: calc(100% + 4px); min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; z-index: 40; }
.menu-wrap.open > .menu { display: block; }
.menu-wrap.up > .menu { top: auto; bottom: 0; left: calc(100% + 6px); right: auto; }
.menu a, .menu button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border: 0; background: none; font: inherit; color: var(--text); text-align: left; border-radius: 6px; cursor: pointer; text-decoration: none; }
.menu a:hover, .menu button:hover { background: var(--surface-2); }

/* ---------- pages */
.page-head { display: flex; align-items: center; gap: 10px; max-width: 1100px; margin: 0 auto; padding: 20px 16px 8px; }
.page-head.wide, .page.wide { max-width: 1480px; }
.page { max-width: 1100px; margin: 0 auto; padding: 8px 16px 40px; }
.toolbar-row { display: flex; gap: 10px; margin-bottom: 14px; }
.toolbar-row input { max-width: 420px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.project-card { padding: 14px 16px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 4px; border-top: 3px solid var(--brand); transition: transform .1s; }
.project-card:hover { transform: translateY(-1px); border-top-color: var(--accent); }
.project-card .code { font-family: var(--mono); font-weight: 700; color: var(--brand); }
.project-card .title { font-weight: 650; font-size: 15px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; border: 1px dashed var(--line-2); border-radius: 10px; background: var(--surface); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.split { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.split section > .row { margin-bottom: 12px; }
.split section > .row input { max-width: 360px; }
.folders { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--topbar) + 8px); }
.folders a { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.folders a:hover { background: var(--surface); }
.folders a.active { background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } .folders { position: static; flex-direction: row; overflow-x: auto; } .folders a { white-space: nowrap; } }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .strong { font-weight: 650; font-family: var(--mono); }
.table.compact td, .table.compact th { padding: 6px 8px; }
@media (max-width: 640px) {
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; padding: 8px 4px; border-bottom: 1px solid var(--line); }
  .table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 10px; }
  .table.responsive td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  .table.responsive td.actions { justify-content: flex-end; }
}

/* ---------- auth */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-brand { display: flex; justify-content: center; margin-bottom: 4px; }
.auth-card h1 { text-align: center; }
.auth-foot { color: var(--muted); font-size: 12px; margin-top: 16px; }
.form-error { color: var(--err); background: color-mix(in srgb, var(--err) 9%, transparent); border: 1px solid color-mix(in srgb, var(--err) 30%, transparent); padding: 8px 10px; border-radius: var(--radius); }
.ok-box { color: var(--ok); background: color-mix(in srgb, var(--ok) 9%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); padding: 10px; border-radius: var(--radius); }
.invite-box { background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 12px; border-radius: var(--radius); }
.invite-project { font-weight: 700; font-size: 16px; margin: 4px 0; }

/* ---------- dialogs & toasts */
.overlay { position: fixed; inset: 0; background: rgba(10, 16, 24, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.dialog { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.dialog.wide { max-width: 760px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 8px 16px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px 16px; flex-wrap: wrap; }
@media (max-width: 640px) { .overlay { align-items: flex-end; padding: 0; } .dialog, .dialog.wide { max-width: none; border-radius: 14px 14px 0 0; } }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 80; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--info); box-shadow: var(--shadow); padding: 10px 14px; border-radius: var(--radius); transition: opacity .3s; }
.toast.ok { border-left-color: var(--ok); } .toast.warn { border-left-color: var(--warn); } .toast.err { border-left-color: var(--err); }
.toast.out { opacity: 0; }
.upload-list, .upload-panel { display: flex; flex-direction: column; gap: 6px; }
.upload-panel { position: fixed; left: 16px; bottom: 16px; width: min(420px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 12px; z-index: 70; }
.upload-item { display: flex; gap: 8px; align-items: center; } .upload-item progress { width: 110px; } .upload-item.err .msg { color: var(--err); }
.logo-card img { max-height: 64px; max-width: 100%; object-fit: contain; align-self: flex-start; }
.logo-card { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.logo-card.dark { background: #1b2430; color: #e7ecf1; }
.notif-list { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.notif-list li a { display: block; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: inherit; text-decoration: none; }
.notif-list li.unread a { border-left: 4px solid var(--accent); }
.sess { padding: 8px 0; border-top: 1px solid var(--line); }
.checklist { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }

/* ---------- drawing workspace */
.workspace { position: fixed; top: var(--topbar); left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: var(--rail) 0 minmax(0, 1fr) 0;
  grid-template-areas: "rail left main right"; background: var(--bg); }
.workspace.show-left { grid-template-columns: var(--rail) 240px minmax(0, 1fr) 0; }
.workspace.show-right { grid-template-columns: var(--rail) 0 minmax(0, 1fr) 340px; }
.workspace.show-left.show-right { grid-template-columns: var(--rail) 240px minmax(0, 1fr) 340px; }
.toolrail { grid-area: rail; display: flex; flex-direction: column; gap: 6px; padding: 6px; background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; overflow-x: visible; }
.tool-group { display: flex; flex-direction: column; gap: 1px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.toolrail .menu-wrap.up > .menu { position: fixed; left: calc(var(--rail) + 6px); bottom: 56px; top: auto; right: auto; max-height: calc(100vh - 120px); overflow: auto; }
.tool-group.end { margin-top: auto; border: 0; }
.tool { width: 40px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; }
.tool:hover { background: var(--surface-2); }
.tool[aria-pressed=true] { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 40%, transparent); }
@media (prefers-color-scheme: dark) { .tool[aria-pressed=true] { color: #8bb8e8; } }
.ws-main { grid-area: main; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.panel { min-width: 0; overflow: hidden; display: flex; flex-direction: column; background: var(--surface); }
.panel.left { grid-area: left; border-right: 1px solid var(--line); }
.panel.right { grid-area: right; border-left: 1px solid var(--line); }
.workspace:not(.show-left) .panel.left, .workspace:not(.show-right) .panel.right { display: none; }
.panel-tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.panel-tabs button { flex: 1; padding: 10px 6px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.panel-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.panel-body { overflow: auto; flex: 1; min-height: 0; }
.scroller { flex: 1; overflow: auto; position: relative; background: color-mix(in srgb, var(--bg) 70%, #8a949f); touch-action: none; overscroll-behavior: contain; }
@media (prefers-color-scheme: dark) { .scroller { background: #0b0e12; } }
.stage { position: relative; margin: 12px auto; box-shadow: 0 2px 14px rgba(0,0,0,.25); background: #fff; }
.pdf-canvas { display: block; }

svg.markup-layer { position: absolute; inset: 0; overflow: visible; touch-action: none; }
.workspace[data-tool=pan] svg.markup-layer, .workspace[data-tool=select] svg.markup-layer { cursor: grab; }
.workspace:not([data-tool=pan]):not([data-tool=select]) svg.markup-layer { cursor: crosshair; }
svg .ann { cursor: pointer; }
svg .ann .hit { pointer-events: visiblePainted; }
svg .ann .hitpad { pointer-events: stroke; }
svg .ann.selected .sel-box, .sel-box { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; }
svg .ann.pending { opacity: .75; }
svg .draft { opacity: .8; pointer-events: none; }
svg .mlabel { fill: #0d47a1; paint-order: stroke; stroke: #fff; stroke-width: 4px; font-weight: 700; font-family: var(--font); }
svg .atext { font-family: var(--font); }
svg .count-no, svg .stamp-text { font-family: var(--font); font-weight: 700; pointer-events: none; }
svg .cal-line { stroke: #00897b; stroke-width: 2; stroke-dasharray: 6 4; pointer-events: none; }
.options-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--line); min-height: 44px; }
.options-bar .opt { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.options-bar .opt input[type=range] { width: 90px; } .options-bar select { min-height: 30px; padding: 2px 6px; width: auto; }
.swatches { display: flex; gap: 4px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--accent); }
.cal-info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.cal-info .ok { color: var(--ok); display: inline-flex; gap: 4px; align-items: center; } .cal-info .warn { color: var(--warn); display: inline-flex; gap: 4px; align-items: center; }
.viewer-nav { display: flex; align-items: center; gap: 2px; padding: 4px 8px; background: var(--surface); border-top: 1px solid var(--line); flex-wrap: nowrap; overflow-x: auto; }
.viewer-nav .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.page-input { width: 58px; min-height: 30px; padding: 2px 6px; text-align: center; }
.page-total { padding: 0 6px; color: var(--muted); white-space: nowrap; }
.zoom-label { width: 48px; text-align: center; font-variant-numeric: tabular-nums; font-size: 12px; }
.panel-toggles { display: flex; gap: 2px; margin-right: 6px; }
.doc-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.doc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }
.save-state { font-size: 12px; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.save-state.ok { color: var(--ok); } .save-state.busy { color: var(--muted); } .save-state.warn { color: #fff; background: var(--warn); } .save-state.err { color: #fff; background: var(--err); }
.feed-down .presence { opacity: .4; }
.banners { display: flex; flex-direction: column; }
.banner { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-weight: 600; flex-wrap: wrap; }
.banner.warn { background: #fff3cd; color: #6b4a00; border-bottom: 1px solid #f1d78a; }
.banner.info { background: #e3f0fd; color: #0d3c78; border-bottom: 1px solid #b6d4f5; }
.thumbs { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 10px; }
.thumb { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 2px solid transparent; border-radius: 8px; padding: 6px; background: var(--surface-2); cursor: pointer; }
.thumb canvas { max-width: 100%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); min-height: 60px; }
.thumb.active { border-color: var(--accent); }
.thumb-no { font-size: 12px; display: flex; gap: 6px; align-items: center; color: var(--muted); }
.results { display: flex; flex-direction: column; }
.result { text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 8px 12px; font: inherit; color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.result:hover { background: var(--surface-2); }
.mlist, .thread { list-style: none; margin: 0; padding: 0; }
.mlist li { border-bottom: 1px solid var(--line); }
.mlist li.sel { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.mitem { display: flex; gap: 8px; align-items: flex-start; width: 100%; padding: 8px 12px; border: 0; background: none; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.mdot { width: 10px; height: 10px; border-radius: 3px; margin-top: 4px; flex: none; }
.mtype { font-weight: 600; } .mtext { display: block; color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
.totals { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--line); }
.thread li { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.cbody { white-space: pre-wrap; margin: 4px 0; }
.compose { display: flex; flex-direction: column; gap: 8px; position: relative; }
.suggest { position: absolute; bottom: 100%; left: 12px; right: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.suggest button { text-align: left; padding: 8px 10px; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer; }
.suggest button:hover { background: var(--surface-2); }
.measure-box { padding: 8px 10px; border-radius: var(--radius); background: color-mix(in srgb, var(--info) 10%, transparent); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); }
.measure-box.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

/* Tablet: panels overlay the drawing. */
@media (max-width: 1099px) {
  .workspace, .workspace.show-left, .workspace.show-right, .workspace.show-left.show-right { grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-areas: "rail main"; }
  .panel { position: absolute; top: 0; bottom: 49px; width: min(340px, 86vw); z-index: 15; box-shadow: var(--shadow); }
  .panel.left { left: var(--rail); } .panel.right { right: 0; }
}
/* Phone: tools become a bottom bar; task-focused controls. */
@media (max-width: 640px) {
  :root { --rail: 0px; }
  .workspace, .workspace.show-left, .workspace.show-right, .workspace.show-left.show-right { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "main" "rail"; }
  .toolrail { flex-direction: row; overflow-x: auto; border-right: 0; border-top: 1px solid var(--line); padding: 4px; }
  .tool-group { flex-direction: row; border-bottom: 0; border-right: 1px solid var(--line); padding: 0 4px 0 0; }
  .tool-group.end { margin: 0; }
  .tool { width: 44px; height: 44px; }
  .toolrail .menu-wrap.up > .menu { left: 8px; right: 8px; bottom: 60px; }
  .panel { left: 0 !important; right: 0; width: auto; top: auto; bottom: 0; height: 60vh; border-radius: 14px 14px 0 0; z-index: 30; }
  .doc-name { max-width: 30vw; } .presence, .save-state.ok { display: none; }
  .brand-name { display: none; } .topbar { gap: 4px; padding: 0 6px; }
  .doc-title { gap: 4px; } .doc-title .chip { font-size: 11px; padding: 1px 6px; } .doc-title .menu-wrap .btn { padding: 0 2px; }
  .options-bar { gap: 6px; padding: 4px 8px; min-height: 40px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .options-bar .opt { font-size: 0; gap: 0; } .options-bar .opt input[type=range] { width: 64px; }
  .swatch { width: 26px; height: 26px; flex: none; }
  .viewer-nav { scrollbar-width: none; padding: 2px 4px; } .viewer-nav::-webkit-scrollbar, .options-bar::-webkit-scrollbar { display: none; }
  .viewer-nav .btn.icon-only { width: 34px; } .viewer-nav > .muted { display: none; }
  #toasts { bottom: 116px; }
}
@media print { .topbar, .toolrail, .panel, .options-bar, .viewer-nav { display: none !important; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
