/* Every colour is a variable; [data-theme="dark"] on <html> swaps the set. */
:root {
  --bg: #f5f4f0; --panel: #ffffff; --panel-2: #faf9f6; --soft: #f1efe9; --hover: #efede7;
  --line: #e4e1da; --line-strong: #c9c4b9; --ink: #1c1b19; --muted: #6b6760; --chip-ink: #4b4741;
  --blue: #2563eb; --blue-soft: #dbe7ff; --on-blue: #ffffff; --bubble-them: #efede8; --sys-bg: #f7f6f2;
  --input-bg: #ffffff; --overlay: rgba(20, 18, 15, .35); --shadow: 0 1px 2px rgba(0, 0, 0, .05);
  --pop-shadow: 0 6px 20px rgba(0, 0, 0, .1); --error: #b91c1c; --warn: #b45309;
  --banner-bg: #fef3c7; --banner-line: #fcd34d;
  --green: #15803d; --orange: #c2410c;
  --s-waiting-bg: #f1f0ec; --s-waiting: #6b6760;   --s-active-bg: #dbeafe; --s-active: #1d4ed8;
  --s-review-bg: #fef3c7; --s-review: #92400e;     --s-done-bg: #dcfce7; --s-done: #166534;
  --s-redo-bg: #ede9fe; --s-redo: #5b21b6;         --s-needs-bg: #ffedd5; --s-needs: #c2410c;
  --s-error-bg: #fee2e2; --s-error: #b91c1c;
  --radius: 10px; color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[data-theme="dark"] {
  --bg: #141413; --panel: #1d1c1a; --panel-2: #191917; --soft: #2a2926; --hover: #2a2926;
  --line: #34322e; --line-strong: #4a4741; --ink: #ecebe7; --muted: #a29e96; --chip-ink: #cfcbc3;
  --blue: #3b82f6; --blue-soft: #1e3a8a; --on-blue: #ffffff; --bubble-them: #2a2926; --sys-bg: #1f1e1c;
  --input-bg: #161614; --overlay: rgba(0, 0, 0, .6); --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --pop-shadow: 0 6px 24px rgba(0, 0, 0, .5); --error: #f87171; --warn: #fbbf24;
  --banner-bg: #3a2e0b; --banner-line: #6b5414;
  --green: #16a34a; --orange: #ea580c;
  --s-waiting-bg: #2a2926; --s-waiting: #a29e96;   --s-active-bg: #172554; --s-active: #93c5fd;
  --s-review-bg: #3a2e0b; --s-review: #fcd34d;     --s-done-bg: #0f2e1a; --s-done: #86efac;
  --s-redo-bg: #2e1065; --s-redo: #c4b5fd;         --s-needs-bg: #431407; --s-needs: #fdba74;
  --s-error-bg: #450a0a; --s-error: #fca5a5;
  color-scheme: dark;
}
html { color: var(--ink); background: var(--bg); }
* { box-sizing: border-box; }
body { margin: 0; font-size: 14px; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .row.end { justify-content: flex-end; }
.error { color: var(--error); } .warn { color: var(--warn); font-weight: 600; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--soft); padding: 1px 4px; border-radius: 4px; }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 7px 14px; font: inherit; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--line-strong); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--error); }
.btn.approve { background: var(--green); color: #fff; border-color: var(--green); font-weight: 600; }
.btn.post { background: var(--orange); color: #fff; border-color: var(--orange); font-weight: 600; }
.link { background: none; border: 0; font: inherit; cursor: pointer; color: var(--muted); padding: 4px 6px; }
.link:hover, .link.on { color: var(--ink); }

/* header */
.top { display: flex; align-items: center; gap: 16px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.tab { border: 0; background: none; font: inherit; padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.tab:hover { background: var(--soft); }
.tab.on { background: var(--ink); color: var(--bg); }
.tab.on[style*="--c"] { background: var(--c); color: #fff; }
.top-right { display: flex; align-items: center; gap: 10px; }
.agent { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.agent i { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; display: inline-block; }
.agent.on i { background: #16a34a; } .agent.off i { background: #dc2626; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--sys-bg); }
.lang button { border: 0; background: none; font: inherit; font-size: 12px; padding: 3px 10px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.lang button.on { background: var(--ink); color: var(--bg); }
.theme-btn { border: 1px solid var(--line); background: var(--sys-bg); color: var(--ink); border-radius: 999px; width: 32px; height: 28px; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; }
.theme-btn:hover { border-color: var(--line-strong); }
.approve-badge { font-size: 12px; font-weight: 700; background: var(--s-review-bg); color: var(--s-review); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.row.between { justify-content: space-between; }
.el { display: flex; flex-direction: column; gap: 12px; max-width: 1100px; }
.el > .box { max-width: 640px; }
.el textarea { resize: vertical; }
.meter { height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.gate { margin: 4px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--s-review-bg); color: var(--s-review); }
.tts-lines { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.tts-lines audio { width: 100%; height: 34px; margin-top: 4px; }
.banner { background: var(--banner-bg); border-bottom: 1px solid var(--banner-line); padding: 6px 18px; font-size: 12px; }
.banner a { text-decoration: underline; margin-left: 6px; }

/* layout */
.layout { display: grid; grid-template-columns: 270px 1fr; min-height: calc(100vh - 53px); }
.side { border-right: 1px solid var(--line); padding: 16px 12px; background: var(--panel-2); display: flex; flex-direction: column; gap: 22px; }
.main { padding: 18px 22px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.main.empty { align-items: flex-start; justify-content: center; }

/* sidebar */
.plist, .wlist { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.plist a { display: grid; grid-template-columns: 10px 1fr; column-gap: 8px; padding: 7px 8px; border-radius: 8px; }
.plist li.on a, .plist a:hover, .wlist li.on a, .wlist a:hover { background: var(--hover); }
.plist .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; grid-row: span 2; }
.ptitle { font-weight: 600; } .psub { font-size: 11.5px; color: var(--muted); }
.wlist a { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; }
.wlist small { display: block; color: var(--muted); font-size: 11.5px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; }

/* project title */
.ptitle-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.round { font-size: 12px; background: var(--s-redo-bg); color: var(--s-redo); padding: 2px 8px; border-radius: 999px; vertical-align: middle; font-weight: 600; }
.niche-tag { font-size: 12px; font-weight: 600; color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--panel)); padding: 2px 8px; border-radius: 999px; }
[data-theme="dark"] .niche-tag { color: color-mix(in srgb, var(--c) 55%, white); }
.fmt-tag { font-size: 12px; background: var(--soft); padding: 2px 8px; border-radius: 999px; }

/* phase cards */
.cards { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.card { flex: 1 1 0; min-width: 128px; max-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.card:hover { border-color: var(--line-strong); }
.card.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.pno { white-space: nowrap; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.card-name { font-weight: 600; }
.card-worker { display: flex; gap: 6px; align-items: center; font-size: 12.5px; }
.card-mode { font-size: 11px; color: var(--muted); margin-top: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 10.5px; background: var(--soft); border-radius: 4px; padding: 1px 6px; color: var(--chip-ink); }

/* status pills */
.pill { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.s-waiting { background: var(--s-waiting-bg); color: var(--s-waiting); }
.s-active { background: var(--s-active-bg); color: var(--s-active); }
.s-review { background: var(--s-review-bg); color: var(--s-review); }
.s-done { background: var(--s-done-bg); color: var(--s-done); }
.s-redo { background: var(--s-redo-bg); color: var(--s-redo); }
.s-needs_you { background: var(--s-needs-bg); color: var(--s-needs); }
.s-error { background: var(--s-error-bg); color: var(--s-error); }

/* work area */
.work { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; min-height: 420px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; box-shadow: var(--shadow); }
.panel-head { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.panel-head.between { justify-content: space-between; }
.ph-title { font-weight: 600; }
.msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; max-height: 60vh; min-height: 300px; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.me { align-self: flex-end; background: var(--blue); color: var(--on-blue); border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--bubble-them); border-bottom-left-radius: 4px; }
.who { font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.sys { align-self: center; font-size: 12px; color: var(--muted); background: var(--sys-bg); border: 1px dashed var(--line); padding: 4px 10px; border-radius: 999px; text-align: center; }
.sys.working { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); position: relative; }
.composer input { flex: 1; }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--input-bg); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.picker { position: absolute; bottom: 100%; left: 10px; margin: 0 0 4px; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--pop-shadow); min-width: 260px; }
.picker li { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.picker li:hover { background: var(--soft); }

/* output */
.out-body { padding: 14px; overflow-y: auto; max-height: 66vh; display: flex; flex-direction: column; gap: 10px; }
.out-summary { margin: 0; font-size: 12.5px; color: var(--muted); }
.out-body audio, .out-body video, .out-body img { width: 100%; border-radius: 8px; }
.out-body video { max-height: 60vh; background: #000; }
.md h1 { font-size: 18px; } .md h2 { font-size: 15px; margin: 14px 0 4px; } .md h3 { text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 14px; }
.md p { margin: 4px 0 8px; } .md hr { border: 0; border-top: 1px solid var(--line); }
.md table, .tbl { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.md th, .md td, .tbl th, .tbl td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.md li.check { list-style: none; } .md li.check::before { content: "☐ "; } .md li.check.on::before { content: "☑ "; }
pre.raw, .md pre { background: var(--sys-bg); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 12px; }

/* action box */
.action { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; flex-wrap: wrap; }
.action p { margin: 0; }
.tag-m { margin-left: 6px; background: var(--soft); border-radius: 4px; padding: 1px 6px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(520px, 100%); display: flex; flex-direction: column; gap: 8px; box-shadow: var(--pop-shadow); }
.modal label { font-weight: 600; font-size: 12.5px; margin-top: 6px; }
.choice { display: flex; gap: 8px; flex-wrap: wrap; }
.choice-btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; }
.choice-btn.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--panel)); font-weight: 600; }

/* setup */
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.subtabs a { padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); }
.subtabs a.on { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.box h3 { text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 14px; }
.steps { margin: 0; padding-left: 18px; font-size: 12.5px; }

.grid.wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 560px), 1fr)); }
.btn.danger-solid { background: var(--error); color: #fff; border-color: var(--error); }
.icon-btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 6px; width: 26px; height: 26px; cursor: pointer; padding: 0; font-size: 13px; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn.danger { color: var(--error); }

/* pipeline editor */
.pe { display: flex; flex-direction: column; gap: 6px; }
.pe-head, .pe-row { display: grid; grid-template-columns: 22px minmax(110px, 1.3fr) minmax(110px, 1.2fr) minmax(95px, 1fr) minmax(95px, 1fr) 26px 88px; gap: 6px; align-items: center; }
.pe-row input:not([type=checkbox]), .pe-row select { width: 100%; padding: 5px 7px; font-size: 12.5px; }
.pe-no { font-weight: 700; color: var(--muted); font-size: 12px; text-align: center; }
.pe-btns { display: flex; gap: 3px; }

/* worker / skill forms */
.wform { gap: 10px; }
.wform label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; }
.wform-grid { display: grid; grid-template-columns: 1fr 1fr 90px; gap: 10px; align-items: start; }
.wform-grid.even { grid-template-columns: 1fr 1fr 1fr; }
.wform input[type=color] { padding: 2px; height: 36px; width: 100%; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 0; }
legend { font-size: 12.5px; font-weight: 600; padding: 0 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check-chip { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 5px !important; font-weight: 400 !important; font-size: 12px !important; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 6px; cursor: pointer; background: var(--panel); }
.check-chip.on { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, var(--panel)); }
.check-chip input { margin: 0; }

/* login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: 10px; }
.login-card .err { color: var(--error); min-height: 1em; margin: 0; font-size: 12.5px; }

/* phone: sidebar stacks above main */
@media (max-width: 860px) {
  .top { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .tabs { order: 3; flex-basis: 100%; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--line); gap: 12px; min-width: 0; }
  .ptitle, .psub { overflow-wrap: anywhere; }
  .bubble { max-width: 88%; }
  .main { padding: 14px 12px; }
  .work { grid-template-columns: 1fr; }
  .msgs { max-height: 50vh; }
  .agent { display: none; }
  .pe-head { display: none; }
  .pe-row { grid-template-columns: 22px 1fr 1fr; padding: 6px 0; border-bottom: 1px solid var(--line); }
  .wform-grid { grid-template-columns: 1fr; }
}

/* progress page */
.progress-md { max-width: 980px; padding: 20px 24px; }
.progress-md h1 { font-size: 22px; } .progress-md h2 { font-size: 16px; margin-top: 22px; }
.progress-md ul { padding-left: 4px; } .progress-md li.check { margin: 2px 0; }
.progress-md li.check.on { color: var(--muted); }

/* M2: live worker replies */
.sys.err { border-color: var(--s-error); color: var(--s-error); background: var(--s-error-bg); border-style: solid; }
.sys.notice { border-style: solid; }
.sys-btn { margin-left: 6px; font: inherit; font-size: 11.5px; font-weight: 600; border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 999px; padding: 1px 9px; cursor: pointer; }
.bubble .txt.md { white-space: normal; }
.bubble .txt.md p { margin: 0 0 6px; } .bubble .txt.md p:last-child { margin-bottom: 0; }
.bubble .txt.md h1, .bubble .txt.md h2, .bubble .txt.md h3 { font-size: 14px; margin: 8px 0 4px; }
.bubble .txt.md ul, .bubble .txt.md ol { margin: 4px 0; padding-left: 18px; }
.bubble.live { border: 1px dashed var(--line-strong); }
.acts { list-style: none; margin: 6px 0 0; padding: 0; font-size: 11.5px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }
.acts li::before { content: "› "; }
.working-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.dots { display: inline-flex; gap: 3px; } .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.needs { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--s-needs); }
.toast { background: var(--s-error-bg); color: var(--s-error); border-radius: 8px; padding: 8px 12px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.file-tabs { display: flex; gap: 4px; padding: 8px 14px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.file-tabs button { border: 1px solid var(--line); border-bottom: 0; background: var(--sys-bg); color: var(--muted); font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 6px 6px 0 0; cursor: pointer; white-space: nowrap; }
.file-tabs button.on { background: var(--panel); color: var(--ink); font-weight: 600; position: relative; top: 1px; }
.md blockquote { margin: 6px 0; padding: 4px 10px; border-left: 3px solid var(--line-strong); color: var(--muted); }
.md blockquote p { margin: 2px 0; }

/* M3: approval, send-back, notifications, compare */
.action { flex-direction: column; align-items: stretch; gap: 8px; }
.action-main { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mode-sel { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.mode-sel select { padding: 4px 8px; font-size: 12.5px; }
.checks-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; }
.checks-list li.ok { color: var(--s-done); } .checks-list li.bad { color: var(--s-error); } .checks-list li.warn { color: var(--s-review); }
.paused-banner { border-radius: 8px; border: 1px solid var(--banner-line); }
.run-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); animation: pulse 1.2s infinite; }
.modal.wide { width: min(640px, 100%); }
.sb-tbl td { vertical-align: middle; }
.radio { display: inline-flex; align-items: center; gap: 4px; font-weight: 400; margin-right: 12px; font-size: 13px; }
.bell-wrap { position: relative; }
.bell { border: 1px solid var(--line); background: var(--sys-bg); border-radius: 999px; height: 28px; padding: 0 9px; cursor: pointer; font-size: 13px; position: relative; color: var(--ink); }
.bell.has { border-color: var(--s-needs); }
.bell-n { position: absolute; top: -6px; right: -6px; background: var(--s-needs); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; min-width: 16px; height: 16px; display: grid; place-items: center; padding: 0 4px; }
.bell-pop { position: absolute; right: 0; top: 36px; width: 320px; max-height: 60vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--pop-shadow); padding: 10px; z-index: 30; display: flex; flex-direction: column; gap: 6px; }
.bell-item { display: flex; gap: 8px; align-items: flex-start; padding: 6px; border-radius: 8px; font-size: 13px; }
.bell-item:hover { background: var(--hover); }
.out-body.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.out-col { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.col-label { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.out-inner { display: flex; flex-direction: column; gap: 10px; }
.out-inner .dl { align-self: flex-start; }
.output .file-tabs { padding: 0; border-bottom: 1px solid var(--line); }
.work:has(.comparing) { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }

/* M3b: format details + references */
.fdetail { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.wform-grid.five { grid-template-columns: 1.2fr 1fr .7fr .7fr .6fr; }
.srow { display: grid; grid-template-columns: 1fr .6fr 2fr 88px; gap: 6px; margin-bottom: 6px; }
.srow input { padding: 5px 7px; font-size: 12.5px; }
textarea.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.pi { margin-bottom: 6px; font-weight: 400 !important; }
.refs { border-top: 1px dashed var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.ref { background: var(--sys-bg); border-radius: 8px; padding: 6px 8px; }
.ref p { margin: 2px 0 0; }
.ref-add { display: grid; grid-template-columns: 1fr 1fr 1.3fr auto; gap: 6px; }
.ref-add input { font-size: 12px; padding: 5px 7px; }
@media (max-width: 860px) { .ref-add, .srow, .wform-grid.five { grid-template-columns: 1fr; } }

/* M4: render progress */
.pbar { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.pbar.small { height: 5px; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), #60a5fa); border-radius: 999px; transition: width .6s; }
.job-box { align-self: stretch; border: 1px solid var(--line); background: var(--sys-bg); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.job-box.failed { border-color: var(--s-error); }
.job-box.done .pbar i { background: var(--green); }

/* M5: posting */
.post-modal { max-height: 90vh; overflow-y: auto; }
.psec { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.psec h3 { text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 14px; margin: 0; }
.pfield pre.raw { max-height: 140px; white-space: pre-wrap; margin: 4px 0 0; }

/* uploads */
.files-btn { margin-left: auto; }
.files-panel { border-bottom: 1px solid var(--line); padding: 8px 14px; display: flex; flex-direction: column; gap: 4px; background: var(--sys-bg); }
.attach { padding: 7px 10px; cursor: pointer; }
.modal .err { color: var(--error); } .modal ul { margin: 4px 0; padding-left: 18px; }

/* ---------- dashboard ---------- */
.dash { display: flex; flex-direction: column; gap: 14px; }
.dtiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.dtile { text-align: left; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 12px; padding: 12px 14px; cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: 2px; }
.dtile b { font-size: 26px; line-height: 1.1; } .dtile span { font-size: 12px; color: var(--muted); }
.dtile:hover { border-color: var(--line-strong); } .dtile.on { outline: 2px solid var(--line-strong); }
.dtile.t-review { background: var(--s-review-bg); } .dtile.t-review b { color: var(--s-review); }
.dtile.t-active { background: var(--s-active-bg); } .dtile.t-active b { color: var(--s-active); }
.dtile.t-done { background: var(--s-done-bg); } .dtile.t-done b { color: var(--s-done); }
.dtips { display: flex; flex-direction: column; gap: 6px; }
.dtip { border: 1px dashed var(--line-strong); border-radius: 10px; padding: 8px 12px; font-size: 13px; background: var(--panel-2); }
.dtip.k-error { border-color: var(--s-error); color: var(--s-error); }
.dgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 14px; }
.dlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.dlist li a { display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 8px 6px; border-radius: 8px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); }
.dlist li:last-child a { border-bottom: 0; } .dlist li a:hover { background: var(--hover); }
.dright { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.grow { flex: 1; min-width: 0; } .ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbar, .dcost { height: 6px; border-radius: 99px; background: var(--soft); overflow: hidden; margin: 5px 0 2px; position: relative; }
.dbar i { display: block; height: 100%; background: var(--s-active); }
.dcost { height: 18px; margin: 0; min-width: 90px; } .dcost i { display: block; height: 100%; background: color-mix(in srgb, var(--s-review) 35%, transparent); }
.dcost span { position: absolute; left: 6px; top: 0; font-size: 11.5px; line-height: 18px; }
.spin { width: 12px; height: 12px; border: 2px solid var(--s-active); border-right-color: transparent; border-radius: 50%; animation: dspin 1s linear infinite; }
@keyframes dspin { to { transform: rotate(360deg); } }
.dvideos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.dvideo { display: flex; flex-direction: column; gap: 6px; } .dvideo video { width: 100%; max-height: 260px; background: #000; border-radius: 8px; }
.dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.dtable th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line); }
.dtable td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dprojects tbody tr { cursor: pointer; } .dprojects tbody tr:hover { background: var(--hover); }
.ddots { display: inline-flex; gap: 3px; } .ddots i { width: 12px; height: 12px; border-radius: 3px; background: var(--s-waiting-bg); border: 1px solid var(--line); }
.ddots i.s-done { background: var(--s-done); border-color: var(--s-done); }
.ddots i.s-review, .ddots i.s-needs_you { background: var(--s-review); border-color: var(--s-review); }
.ddots i.s-error { background: var(--s-error); border-color: var(--s-error); }
.ddots i.s-active { background: var(--s-active-bg); border-color: var(--s-active); }
.ddots i.run { background: var(--s-active); animation: dpulse 1.2s ease-in-out infinite; } @keyframes dpulse { 50% { opacity: .35; } }
.dstate { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--soft); }
.st-needs { background: var(--s-review-bg); color: var(--s-review); } .st-running { background: var(--s-active-bg); color: var(--s-active); }
.st-done, .st-posted { background: var(--s-done-bg); color: var(--s-done); }
.chipbtn { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 99px; padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.chipbtn.on { color: var(--ink); border-color: var(--line-strong); background: var(--soft); }
@media (max-width: 700px) { .dprojects th:nth-child(4), .dprojects td:nth-child(4), .dprojects th:nth-child(5), .dprojects td:nth-child(5) { display: none; } }

/* ---------- schedule ---------- */
.sched { display: flex; flex-direction: column; gap: 14px; }
.plat { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; color: #fff; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.plat.sm { width: 16px; height: 16px; font-size: 10px; border-radius: 4px; }
.p-facebook { background: #1877f2; } .p-youtube { background: #e11d1d; } .p-tiktok { background: #0f0f0f; box-shadow: inset 0 0 0 1.5px #25f4ee; } .p-x { background: #3f3f46; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.day { border: 1px solid var(--line); border-radius: 10px; min-height: 140px; padding: 6px; display: flex; flex-direction: column; gap: 4px; background: var(--panel-2); }
.day.today { border-color: var(--s-active); box-shadow: inset 0 0 0 1px var(--s-active); }
.day-h { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.chip-post { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 7px; padding: 3px 5px; font: inherit; font-size: 11.5px; cursor: pointer; text-align: left; min-width: 0; }
.chip-post .ct { font-weight: 600; white-space: nowrap; } .chip-post .cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.chip-post.st-due { background: var(--s-review-bg); border-color: var(--s-review); } .chip-post.st-posted { opacity: .65; }
.chip-post.st-failed { border-color: var(--s-error); }
.due-box { border-color: var(--s-review); background: var(--s-review-bg); }
.due-list { display: flex; flex-wrap: wrap; gap: 8px; }
.due-item { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 10px; padding: 8px 10px; font: inherit; cursor: pointer; text-align: left; }
.st-scheduled { background: var(--s-active-bg); color: var(--s-active); } .st-due { background: var(--s-review-bg); color: var(--s-review); }
.st-failed { background: var(--s-error-bg); color: var(--s-error); } .st-posting { background: var(--soft); }
.plat-row { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.plat-row.on { border-color: var(--line-strong); } .plat-check { cursor: pointer; }
.plat-body { display: flex; flex-direction: column; gap: 6px; } .plat-body textarea { width: 100%; }
.sched-form { max-height: 90vh; overflow: auto; }
.modal.wide { width: min(640px, 100%); }
.box.soft { background: var(--panel-2); display: flex; flex-direction: column; gap: 6px; }
tr.clickable { cursor: pointer; } tr.clickable:hover { background: var(--hover); }
.err { color: var(--error); }
@media (max-width: 800px) { .week { grid-template-columns: 1fr; } .day { min-height: 0; } }
.sched-modal label:not(.plat-check) { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); } .sched-modal label input:not([type=checkbox]), .sched-modal label textarea, .sched-modal label select { color: var(--ink); width: 100%; } .sched-modal textarea { width: 100%; box-sizing: border-box; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--panel-2); }
.seg button { border: 0; background: none; font: inherit; font-size: 12.5px; padding: 4px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--ink); color: var(--panel); }
.chip-free { border-style: dashed; background: transparent; color: var(--muted); opacity: .85; }
.chip-free:hover { opacity: 1; border-color: var(--line-strong); }
.chip-free-key { display: inline-block; width: 14px; height: 10px; border: 1px dashed var(--line-strong); border-radius: 3px; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 10px; }
.mhead { font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 2px 4px; }
.mday { border: 1px solid var(--line); border-radius: 8px; min-height: 92px; padding: 4px; display: flex; flex-direction: column; gap: 3px; background: var(--panel-2); min-width: 0; }
.mday.other { opacity: .45; } .mday.today { border-color: var(--s-active); box-shadow: inset 0 0 0 1px var(--s-active); }
.mnum { align-self: flex-start; border: 0; background: none; font: inherit; font-size: 12px; font-weight: 600; color: var(--ink); cursor: pointer; padding: 0 2px; }
.mday .chip-post { padding: 2px 4px; font-size: 11px; }
.more { border: 0; background: none; font: inherit; font-size: 11px; color: var(--muted); cursor: pointer; text-align: left; padding: 0 2px; }
.dayview { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.dayrow { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 10px; padding: 10px 12px; font: inherit; cursor: pointer; text-align: left; }
.dayrow:hover { border-color: var(--line-strong); } .dayrow.free { border-style: dashed; background: transparent; }
.dayrow.st-due { background: var(--s-review-bg); } .dayrow .dt { font-weight: 700; min-width: 72px; }
.dayempty { margin-top: 10px; }
.slots { display: flex; flex-direction: column; gap: 6px; }
.slot { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; flex-wrap: wrap; }
.slot.off { opacity: .55; }
@media (max-width: 800px) { .month { grid-template-columns: repeat(7, minmax(0, 1fr)); } .mday { min-height: 60px; } .mday .chip-post .ct { display: none; } }

.chip-planned { border-style: dashed; border-color: var(--s-active); background: color-mix(in srgb, var(--s-active-bg) 55%, transparent); }
.chip-free-key.planned { border-color: var(--s-active); background: color-mix(in srgb, var(--s-active-bg) 55%, transparent); }
.dayrow.planned { border-color: var(--s-active); }
.queue { display: flex; flex-direction: column; gap: 6px; }
.qrow { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; flex-wrap: wrap; }
.qrow.off { opacity: .5; } .qnum { font-weight: 700; color: var(--muted); min-width: 22px; }
.qbtns { display: flex; flex-direction: column; gap: 2px; } .qbtns button { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 5px; font-size: 10px; line-height: 1; padding: 2px 6px; cursor: pointer; }
.qbtns button:disabled { opacity: .3; cursor: default; }
.qnext { display: flex; gap: 4px; flex-wrap: wrap; } .qnext span { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); border: 1px dashed var(--s-active); border-radius: 6px; padding: 1px 5px; }
.warn { color: var(--s-review); font-size: 11.5px; font-weight: 600; }

/* ---------- phone header + folding sidebar ---------- */
.top-links { display: flex; align-items: center; gap: 10px; }
.top-prefs { gap: 10px; }
.menu-btn { display: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; width: 38px; height: 34px; font-size: 18px; cursor: pointer; }
.side-toggle { display: none; }
@media (max-width: 860px) {
  .top { position: sticky; }
  .brand { flex: 1; }
  .top-right { gap: 8px; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .top-links { display: none; }
  .top-links.open { display: flex; flex-direction: column; align-items: stretch; gap: 4px; position: absolute; top: 100%; left: 8px; right: 8px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; box-shadow: var(--pop-shadow); z-index: 40; }
  .top-links.open .link { text-align: left; padding: 10px 8px; font-size: 15px; border-radius: 8px; }
  .top-links.open .link.on { background: var(--soft); }
  .top-links.open .btn.primary { margin-top: 6px; padding: 10px; }
  .top-links.open .top-prefs { justify-content: space-between; padding: 4px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .tabs { order: 3; flex-basis: 100%; }
  .side { padding: 8px 12px; gap: 10px; }
  .side-toggle { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; border: 0; background: none; color: var(--ink);
    font: inherit; font-weight: 600; padding: 6px 0; cursor: pointer; text-align: left; min-width: 0; }
  .side-toggle .ellip { max-width: 100%; font-weight: 400; }
  .side:not(.open) > section { display: none; }
  .main, .main * { min-width: 0; }
  .dtable { display: block; overflow-x: auto; }
  .row.between { flex-wrap: wrap; }
  .modal { max-height: 92vh; overflow: auto; }
}
@media (max-width: 860px) { .main .cards > .card { flex: 0 0 150px; min-width: 150px; } .main .cards { scroll-snap-type: x proximity; } .main .cards > .card { scroll-snap-align: start; } }
@media (max-width: 860px) { .subtabs { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; } .subtabs a { flex: 0 0 auto; white-space: nowrap; } }
