:root {
  --bg: #f6f7f9; --card: #ffffff; --ink: #1b2430; --muted: #5d6b7a; --line: #dde2e8;
  --accent: #1f6feb; --accent-ink: #ffffff; --warn: #b54708; --ok: #067647; --danger: #b42318;
  --chip: #eef1f5; --mine: #e8f0fe;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c; --card: #1a2029; --ink: #e8edf2; --muted: #9aa8b6; --line: #2b3440;
    --accent: #5b9bff; --accent-ink: #0b1220; --warn: #f79009; --ok: #47cd89; --danger: #f97066;
    --chip: #232b36; --mine: #1c2b45;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
.top { padding: 8px 16px 0; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
h1 { font-size: 16px; margin: 0; }
.who { color: var(--muted); font-size: 12px; padding-bottom: 6px; }
.tabs { display: flex; gap: 4px; }
.tab { white-space: nowrap; border: 0; background: none; color: var(--muted); padding: 10px 14px; font: inherit; border-bottom: 3px solid transparent; cursor: pointer; }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 4px; }
main { padding: 12px 16px 96px; max-width: 920px; margin: 0 auto; }
.banner { background: #fff4ed; color: var(--danger); border: 1px solid var(--danger); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .banner { background: #3a1d17; } }
.bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.bar input { flex: 1 1 200px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 44px; }
textarea { width: 100%; resize: vertical; }
.btn { font: inherit; min-height: 44px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { min-height: 36px; padding: 4px 10px; }
.btn[disabled] { opacity: .5; cursor: default; }
.muted { color: var(--muted); font-size: 14px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; }
.item h3 { margin: 0; font-size: 16px; grid-column: 1; cursor: pointer; }
.item .meta { grid-column: 1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.item .ctl { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 4px; }
.chip { background: var(--chip); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.chip.stage { font-weight: 600; }
.chip.stage.Done { color: var(--ok); }
.chip.stage.InQA { color: var(--warn); }
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 10; display: flex; justify-content: flex-end; }
.drawer[hidden] { display: none; }
.drawer-inner { background: var(--card); width: min(640px, 100%); height: 100%; overflow-y: auto; padding: 16px; }
.close { float: right; }
.desc { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 8px 0; overflow-wrap: anywhere; }
.field { display: grid; gap: 4px; margin: 10px 0; }
.field label { font-size: 14px; color: var(--muted); }
.comment { border-top: 1px solid var(--line); padding: 8px 0; overflow-wrap: anywhere; }
.comment .who2 { font-size: 13px; color: var(--muted); }
.msgs { display: grid; gap: 8px; margin-bottom: 12px; }
.msg { position: relative; max-width: 85%; padding: 8px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); overflow-wrap: anywhere; white-space: pre-wrap; -webkit-touch-callout: none; }
.msg { cursor: pointer; scroll-margin-bottom: 110px; scroll-margin-top: 150px; }
.msg.open { box-shadow: 0 0 0 2px var(--accent); min-width: min(420px, 100%); }
.msg .actions { display: none; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); white-space: normal; cursor: default; }
.msg.open .actions { display: flex; }
.actions button { font: inherit; font-size: 14px; min-width: 36px; height: 36px; padding: 0 12px; background: var(--chip); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; color: var(--ink); line-height: 1; white-space: nowrap; }
.actions button:hover { border-color: var(--accent); }
.actions button.emo { width: 36px; padding: 0; font-size: 18px; }
.actions .sep { flex: 1 1 8px; }
.actions button.danger { color: var(--danger); border-color: var(--danger); background: none; }
.center { text-align: center; }
.msg.client { justify-self: end; background: var(--mine); }
.msg .by { font-size: 12px; color: var(--muted); display: block; }
.chat-form { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding: 8px 16px; display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: end; }
.file-pending { grid-column: 1 / -1; margin: 0; font-size: 13px; }
.file-pending:has(#chat-file-name:empty) { display: none; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.react { background: var(--chip); border: 1px solid transparent; border-radius: 999px; padding: 2px 8px; font-size: 14px; color: var(--ink); cursor: pointer; line-height: 1.4; }
.react.on { border-color: var(--accent); background: var(--mine); }
.react.ro { cursor: default; }
.file { margin-top: 6px; font-size: 14px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.thumb { padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--chip); cursor: zoom-in; width: 160px; height: 120px; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lightbox { position: fixed; inset: 0; z-index: 30; background: #0a0c10; display: flex; flex-direction: column; color: #fff; }
.lb-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; }
.lb-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.lb-count { opacity: .7; margin-left: 8px; }
.lb-btn { font: inherit; font-size: 14px; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .4); background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer; }
.lb-btn:hover { background: rgba(255, 255, 255, .2); }
.lb-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 0 56px 16px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lb-stage img:not([src]) { display: none; }
.lb-wait { position: absolute; opacity: .8; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .12); color: #fff; font-size: 38px; line-height: 1; cursor: pointer; }
.lb-nav:hover { background: rgba(255, 255, 255, .25); }
.lb-prev { left: 4px; }
.lb-next { right: 4px; }
@media (max-width: 600px) { .lb-stage { padding: 0 0 12px; } .lb-nav { width: 40px; height: 56px; background: rgba(0, 0, 0, .45); } .thumb { width: 46%; height: 110px; } }
.dot-count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; text-align: center; margin-left: 4px; }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
