:root {
  --bg: #f6f5f2; --panel: #ffffff; --panel-2: #f0eee9; --line: #e3e0d8; --text: #1d1c1a; --muted: #6f6b63;
  --claude: #d97757; --claude-bg: #fbeee8; --codex: #0f8f6e; --codex-bg: #e3f4ee;
  --ok: #1f9d55; --warn: #b7791f; --warn-bg: #fdf3e1; --err: #c53030; --err-bg: #fdeaea; --accent: #2b2a27;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514; --panel: #1f1e1c; --panel-2: #272623; --line: #34322e; --text: #ecebe7; --muted: #9b968c;
    --claude: #e08a6b; --claude-bg: #3a2620; --codex: #2fbf95; --codex-bg: #173229;
    --ok: #48bb78; --warn: #ecc94b; --warn-bg: #3a3120; --err: #fc8181; --err-bg: #3b2222; --accent: #ecebe7;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
kbd { font: 11px var(--mono); opacity: .6; margin-left: 6px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .grow { flex: 1; } .mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* ---------- Header ---------- */
.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.logo { position: relative; width: 26px; height: 18px; display: inline-block; }
.logo i { position: absolute; top: 0; width: 18px; height: 18px; border-radius: 50%; }
.logo .c-claude { left: 0; background: var(--claude); }
.logo .c-codex { left: 8px; background: var(--codex); opacity: .85; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-size: 12.5px; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.pill.down .dot { background: var(--err); } .pill.cool .dot { background: var(--warn); }
.pill b { font-weight: 600; }
.usage { margin-left: auto; font-size: 12px; color: var(--muted); }
.icon-btn { border: 1px solid transparent; background: none; border-radius: 8px; padding: 4px 8px; cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: var(--panel-2); border-color: var(--line); }
.only-mobile { display: none; }

/* ---------- Layout ---------- */
.layout { flex: 1; display: grid; grid-template-columns: 270px 1fr auto; min-height: 0; }
.side { border-right: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0; background: var(--panel); }
.task-list { overflow: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -6px; }
.task-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.task-item:hover { background: var(--panel-2); }
.task-item.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.task-item .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-item .m { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.dots i.claude { background: var(--claude); } .dots i.codex { background: var(--codex); }
.dots i.running { animation: pulse 1s infinite; } .dots i.error { outline: 2px solid var(--err); }
.dots i.queued, .dots i.interrupted, .dots i.cancelled { opacity: .35; }
@keyframes pulse { 50% { opacity: .3; } }
.main { overflow: auto; min-width: 0; }
.files { width: 300px; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.files-head { display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.file-list { overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.file { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.file:hover { background: var(--panel-2); }
.file .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .s { font-size: 11px; color: var(--muted); }
.file-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 8px 4px; }

/* ---------- Controls ---------- */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 7px 14px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: var(--err); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 8px 10px; outline: none; }
.input:focus { border-color: var(--muted); }
textarea.input { resize: vertical; min-height: 44px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--bg); }

/* ---------- Composer (nhiệm vụ mới) ---------- */
.wrap { max-width: 920px; margin: 0 auto; padding: 28px 24px 60px; }
.hero h1 { font-size: 24px; margin: 0 0 4px; font-weight: 650; letter-spacing: -.01em; }
.hero p { margin: 0 0 18px; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.composer { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.composer textarea { border: 0; padding: 4px 2px; min-height: 110px; font-size: 15px; background: transparent; resize: vertical; outline: none; width: 100%; }
.composer.drag { outline: 2px dashed var(--codex); outline-offset: -6px; }
.att-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.att { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; background: var(--panel-2); max-width: 260px; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 4px; }
.att.up { opacity: .6; }
.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.mode { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 11px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.mode:hover { border-color: var(--muted); }
.mode.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mode .h { font-weight: 600; font-size: 13px; }
.mode .d { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.route { font-size: 12.5px; padding: 8px 11px; border-radius: 9px; background: var(--panel-2); color: var(--muted); }
.route b { color: var(--text); }
.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tiers-hint { font-size: 11.5px; color: var(--muted); }
.label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.tips { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 22px; }
.tip { padding: 12px 14px; font-size: 13px; }
.tip b { display: block; margin-bottom: 3px; }

/* ---------- Task view ---------- */
.task-head { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.task-head h2 { margin: 0; font-size: 19px; flex: 1; min-width: 240px; font-weight: 620; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.chip { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.chip.claude { background: var(--claude-bg); color: var(--claude); border-color: transparent; }
.chip.codex { background: var(--codex-bg); color: var(--codex); border-color: transparent; }
.st-running { color: var(--warn); } .st-done { color: var(--ok); } .st-error { color: var(--err); } .st-cancelled, .st-interrupted, .st-queued { color: var(--muted); }
.request { padding: 12px 14px; margin-bottom: 14px; white-space: pre-wrap; font-size: 13.5px; max-height: 220px; overflow: auto; }
.route-box { font-size: 12.5px; color: var(--muted); margin: -6px 0 14px; }
.track { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.track .node { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); }
.track .node .dot { width: 8px; height: 8px; border-radius: 50%; }
.track .arrow { color: var(--muted); }
.steps { display: flex; flex-direction: column; gap: 12px; }
.step { border-left: 3px solid var(--line); }
.step.claude { border-left-color: var(--claude); } .step.codex { border-left-color: var(--codex); }
.step-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.step-head .who { font-weight: 600; }
.step-head .meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.step-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.note { font-size: 12.5px; padding: 6px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); }
.err { font-size: 13px; padding: 8px 12px; border-radius: 8px; background: var(--err-bg); color: var(--err); white-space: pre-wrap; word-break: break-word; }
details.fold { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
details.fold > summary { cursor: pointer; padding: 6px 10px; font-size: 12.5px; color: var(--muted); list-style: none; display: flex; gap: 8px; align-items: center; }
details.fold > summary::before { content: "▸"; transition: transform .15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > .in { padding: 4px 10px 10px; font-size: 12.5px; }
.thinking { white-space: pre-wrap; color: var(--muted); max-height: 260px; overflow: auto; }
.tool { padding: 5px 0; border-top: 1px dashed var(--line); }
.tool:first-child { border-top: 0; }
.tool .tn { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.tool .td { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; color: var(--muted); }
.tool pre { margin: 4px 0 0; max-height: 180px; }
.tool .ts { font-size: 11px; margin-left: 6px; }
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 14px 0 6px; line-height: 1.3; }
.md h1 { font-size: 18px; } .md h2 { font-size: 16px; } .md h3 { font-size: 14.5px; } .md h4 { font-size: 14px; }
.md p { margin: 6px 0; } .md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md code { font-family: var(--mono); font-size: 12.5px; background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow: auto; font: 12.5px/1.5 var(--mono); }
pre code { background: none; padding: 0; }
.md blockquote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md table { border-collapse: collapse; margin: 8px 0; font-size: 13px; display: block; overflow: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.md img { max-width: 100%; border-radius: 8px; }
.msg + .msg { border-top: 1px dashed var(--line); padding-top: 10px; }
.live { white-space: pre-wrap; }
.cursor::after { content: "▍"; animation: pulse 1s infinite; color: var(--muted); }
.step-foot { display: flex; gap: 6px; padding: 0 14px 12px; flex-wrap: wrap; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--warn); border-radius: 50%; animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.follow { margin-top: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; position: sticky; bottom: 12px; }
.follow textarea { border: 0; background: transparent; outline: none; resize: vertical; min-height: 46px; width: 100%; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; font-size: 13px; }

/* ---------- Dialog ---------- */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 0; width: min(860px, 94vw); max-height: 90vh; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.dlg-head b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-body { padding: 16px; overflow: auto; }
.preview img, .preview video { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; border-radius: 8px; }
.preview iframe { width: 100%; height: 70vh; border: 0; background: #fff; border-radius: 8px; }
.form { display: grid; grid-template-columns: 200px 1fr; gap: 10px 14px; align-items: center; }
.form .full { grid-column: 1 / -1; }
.form h4 { grid-column: 1 / -1; margin: 12px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.form .hint { grid-column: 2; font-size: 12px; color: var(--muted); margin-top: -6px; }
.tier-grid { display: grid; grid-template-columns: 90px repeat(4, 1fr); gap: 6px; align-items: center; font-size: 12.5px; }
.tier-grid .h { color: var(--muted); font-size: 11.5px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--accent); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 13px; z-index: 50; box-shadow: 0 8px 30px rgba(0,0,0,.25); max-width: 90vw; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .files { position: fixed; right: 0; top: 52px; bottom: 0; z-index: 20; box-shadow: -10px 0 30px rgba(0,0,0,.15); } }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 52px; bottom: 0; width: 280px; z-index: 30; transform: translateX(-105%); transition: transform .2s; box-shadow: 10px 0 30px rgba(0,0,0,.15); }
  .side.open { transform: none; }
  .only-mobile { display: inline-block; } .hide-mobile { display: none; }
  .top { flex-wrap: nowrap; gap: 8px; padding: 8px 12px; }
  .brand b { display: none; }
  .pills { flex: 1; min-width: 0; flex-wrap: nowrap; overflow: hidden; }
  .pill > span { display: none; }
  .wrap { padding: 18px 16px 50px; }
  .form { grid-template-columns: 1fr; } .form .hint { grid-column: 1; }
  .files { width: 100%; }
}

/* ---------- Đăng nhập ---------- */
.auth-page { align-items: center; justify-content: center; padding: 24px 16px; min-height: 100%; }
.auth-card { width: min(420px, 100%); padding: 28px 26px 18px; display: flex; flex-direction: column; gap: 14px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form h1 { font-size: 21px; margin: 4px 0 0; font-weight: 650; letter-spacing: -.01em; }
.auth-form p { margin: 0; font-size: 13.5px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.auth-form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--text); font-size: 13px; }
.auth-form .input { font-size: 15px; padding: 10px 12px; }
.otp { text-align: center; letter-spacing: .45em; font: 600 24px var(--mono) !important; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 12.5px; padding: 0; align-self: center; }
.meter { height: 4px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-top: -4px; }
.meter i { display: block; height: 100%; width: 0; transition: width .2s; }
.qr { align-self: center; background: #fff; padding: 6px; border-radius: 10px; line-height: 0; }
.qr svg { width: 210px; height: 210px; }
.secret { font-size: 13px; word-break: break-all; user-select: all; }
.steps-list { margin: 0; padding-left: 20px; font-size: 13.5px; }
.codes { font-size: 15px; columns: 2; text-align: center; letter-spacing: .05em; user-select: all; }
.auth-foot { text-align: center; margin: 4px 0 0; }
.user-btn { font-size: 13px; }
.dev-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.dev-row:first-child { border-top: 0; }
.dev-row .ua { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
