/* Claude Panel — diện mạo theo app Claude trên iOS (tab Code). Thiết kế cho điện thoại trước; máy tính = 2 cột. */
:root {
  --bg: #0e0e0d;            /* nền màn hình chính */
  --bg2: #151514;           /* nền màn chat */
  --sheet: #1c1c1a;         /* nền bảng trượt */
  --card: #262624;          /* nhóm thẻ, khung soạn tin */
  --card2: #30302e;         /* bong bóng tin, nút trong khung soạn */
  --line: #3a3a37;
  --hair: rgba(255, 255, 255, .09);
  --glass: rgba(44, 44, 42, .78);
  --text: #f7f6f1; --muted: #8f8d86;
  --accent: #d97757; --blue: #4d9bff; --green: #4caf50; --amber: #e8a33d; --bad: #f0585d; --ok: #2fb344;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --st-good: #0ca30c; --st-warning: #fab219; --st-serious: #ec835a; --st-critical: #d03b3b; --gridc: #2e2e2c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top); --sab: env(safe-area-inset-bottom);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf9f5; --bg2: #faf9f5; --sheet: #f3f1ea; --card: #ffffff; --card2: #ebe9e1; --line: #dcd9ce; --hair: rgba(0, 0, 0, .09);
    --glass: rgba(255, 255, 255, .8); --text: #1a1a18; --muted: #77746c; --blue: #2a78d6;
    --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --gridc: #e6e3da;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font: 17px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13.5px; }
.grow { flex: 1; min-width: 0; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.small { font-size: 14px; }
a { color: var(--blue); }
button, select, input, textarea { font: inherit; color: var(--text); }
button { cursor: pointer; }
input, select, textarea { background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 10px 14px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
svg.ic { width: 22px; height: 22px; display: block; flex: none; }

/* nút */
.circle { width: 48px; height: 48px; border-radius: 50%; flex: none; padding: 0; display: inline-flex; align-items: center; justify-content: center; color: var(--text);
  background: var(--glass); border: 1px solid var(--hair); -webkit-backdrop-filter: blur(22px) saturate(1.5); backdrop-filter: blur(22px) saturate(1.5); }
.circle:active { transform: scale(.94); }
.circle.spin { position: relative; }
.circle.spin::after { content: ""; width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--hair); border-top-color: var(--blue); border-right-color: var(--blue); animation: rot .9s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.btn { background: var(--card); border: 1px solid var(--hair); border-radius: 999px; padding: 10px 18px; white-space: nowrap; font-size: 16px; }
.btn.sm { padding: 6px 13px; font-size: 14px; }
.btn.white { background: var(--text); color: var(--bg); border-color: transparent; font-weight: 600; }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; background: var(--line); vertical-align: 2px; margin-left: 6px; }
.dot.on { background: var(--green); } .dot.off { background: var(--bad); } .dot.busy { background: var(--accent); }
.spark { color: var(--accent); display: flex; justify-content: center; }
.spark .ic, .spark svg.ic { width: 1em; height: 1em; }

/* đăng nhập */
#login { height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.logincard { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.logincard .spark { font-size: 44px; line-height: 1; }
.logincard h1 { margin: 0; font-size: 28px; font-weight: 600; }
.logincard p { margin: 0 0 10px; }
.logincard input { padding: 15px 18px; border-radius: 999px; }
.logincard .btn { padding: 15px; }

/* khung 2 màn hình */
#app { height: 100dvh; display: flex; overflow: hidden; position: relative; }
#side { width: 380px; flex: none; background: var(--bg); display: flex; flex-direction: column; min-height: 0; position: relative; border-right: 1px solid var(--hair); }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; background: var(--bg2); position: relative; }

/* header: nút tròn trái — tiêu đề giữa — cụm phải */
.hd { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--sat)) 16px 10px; min-height: calc(68px + var(--sat)); position: relative; z-index: 5; }
.hd-title { position: absolute; left: 0; right: 0; text-align: center; font-size: 18px; font-weight: 600; pointer-events: none; }
.hd > .circle, .hd > .pillgroup { position: relative; z-index: 1; }
.pillgroup { margin-left: auto; display: inline-flex; height: 48px; border-radius: 999px; background: var(--glass); border: 1px solid var(--hair); -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px); padding: 0 6px; }
.pillgroup button { width: 54px; height: 100%; background: none; border: 0; display: inline-flex; align-items: center; justify-content: center; }
.pillgroup button:active { opacity: .6; }
#top .titles { flex: 1; min-width: 0; text-align: center; padding: 0 4px; }
.hd-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#viewTitle { font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; }
#viewSub { font-size: 15px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; }
#main > .hd { background: linear-gradient(var(--bg2) 55%, transparent); margin-bottom: -14px; padding-bottom: 20px; }

/* màn hình chính */
#homeScroll { flex: 1; overflow: auto; min-height: 0; padding: 4px 18px 110px; }
.sec-label { color: var(--muted); font-size: 16px; margin: 22px 2px 12px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--hair); border-radius: 999px; padding: 11px 18px; font-size: 17px; }
.pill.sel { background: var(--text); color: var(--bg); border-color: transparent; font-weight: 600; }
.pill svg.ic { width: 18px; height: 18px; }
#sessions { display: flex; flex-direction: column; }
.sess { display: flex; gap: 16px; align-items: flex-start; padding: 13px 2px; cursor: pointer; border-radius: 16px; }
.sess:active { opacity: .6; }
.sess.active .t1 { color: var(--blue); }
.sess .st { width: 26px; height: 26px; flex: none; display: flex; align-items: center; justify-content: center; margin-top: 3px; color: var(--muted); }
.sess .st .ring { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--muted); }
.sess .st .load { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--muted); border-right-color: transparent; animation: rot 1s linear infinite; }
.sess .st.wait { color: var(--amber); }
.sess .t { flex: 1; min-width: 0; }
.sess .t1 { font-size: 19px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess .t2 { font-size: 16px; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.sess .t2 svg.ic { width: 18px; height: 18px; }
.sess .t2 .live { color: var(--green); }
.fabrow { position: absolute; left: 18px; right: 18px; bottom: calc(18px + var(--sab)); display: flex; align-items: center; pointer-events: none; }
.fabrow > * { pointer-events: auto; }
.fab { display: inline-flex; align-items: center; gap: 10px; background: var(--text); color: var(--bg); border: 0; border-radius: 999px; padding: 0 22px; height: 50px; font-size: 17px; font-weight: 500; box-shadow: 0 8px 28px rgba(0, 0, 0, .4); }
.fab:active { transform: scale(.96); }

/* các view chung */
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--hair); flex-wrap: wrap; font-size: 15px; }
.scroll { flex: 1; overflow: auto; min-height: 0; }
.pad { padding: 8px 16px 28px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
h2 { margin: 0; font-size: 19px; font-weight: 600; }
h3 { margin: 16px 0 8px; font-size: 14px; font-weight: 500; color: var(--muted); }
.cardbox { background: var(--card); border: 1px solid var(--hair); border-radius: 24px; padding: 16px 18px; margin-bottom: 12px; min-width: 0; font-size: 15.5px; }
.cardbox > h3:first-child { margin-top: 0; }
.cardhead { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cardbox input, .cardbox select, .cardbox textarea { background: var(--bg2); }

/* chat */
#msgs { flex: 1; overflow: auto; padding: 22px 18px 20px; display: flex; flex-direction: column; gap: 18px; min-height: 0; }
.msg { max-width: 780px; width: 100%; margin: 0 auto; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.msg.user .bubble { background: var(--card); border-radius: 26px; padding: 13px 20px; max-width: 86%; white-space: pre-wrap; word-break: break-word; font-size: 18px; line-height: 1.42; }
.msg.user .imgnote { font-size: 14px; color: var(--muted); }
.md { word-break: break-word; font-size: 18px; line-height: 1.6; }
.md p { margin: .5em 0; } .md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 { margin: 1em 0 .4em; font-size: 1.08em; color: var(--text); font-weight: 600; }
.md pre { background: var(--bg); border: 1px solid var(--hair); border-radius: 14px; padding: 12px 14px; overflow: auto; font-size: 13.5px; }
.md code { font-family: var(--mono); font-size: .82em; background: var(--card); padding: 2px 6px; border-radius: 6px; }
.md pre code { background: transparent; padding: 0; font-size: 13.5px; }
.md table { border-collapse: collapse; display: block; overflow: auto; font-size: 15.5px; } .md th, .md td { border: 1px solid var(--line); padding: 6px 10px; }
.md ul, .md ol { padding-left: 1.3em; }
.toolline { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 2px 0; color: var(--muted); font-size: 16px; text-align: left; }
.toolline .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.toolline svg.ic { width: 18px; height: 18px; }
.toolline.err { color: var(--bad); }
.toolline:active { opacity: .6; }
.meta { text-align: center; font-size: 13px; color: var(--muted); }
.meta.err { color: var(--bad); }
.thinking { display: flex; gap: 12px; align-items: center; max-width: 780px; width: 100%; margin: 0 auto; color: var(--muted); font-size: 17px; }
.thinking .dots { display: inline-flex; gap: 6px; }
.thinking .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bob 1.1s ease-in-out infinite; }
.thinking .dots i:nth-child(2) { animation-delay: .18s; }
@keyframes bob { 50% { transform: translateY(-4px); opacity: .5; } }
.empty { margin: auto; text-align: center; max-width: 420px; padding: 20px; }
.empty .spark { font-size: 40px; } .empty h2 { font-size: 28px; font-weight: 500; margin: 10px 0 8px; }
#perms { padding: 0 14px; display: flex; flex-direction: column; }
.perm { max-width: 780px; width: 100%; margin: 0 auto 10px; border: 1px solid var(--amber); border-radius: 24px; background: var(--card); padding: 14px 16px; font-size: 16px; }
.perm pre { background: var(--bg); border-radius: 12px; padding: 10px 12px; overflow: auto; max-height: 220px; font-size: 13px; white-space: pre-wrap; word-break: break-word; margin: 10px 0; }
.perm .q { margin: 12px 0 8px; font-weight: 600; }
.perm .opts { display: flex; gap: 6px; flex-wrap: wrap; }
.perm .opts .btn.sel { border-color: var(--blue); color: var(--blue); }

/* khung soạn tin */
#composer { max-width: 800px; width: calc(100% - 24px); margin: 0 auto calc(10px + var(--sab)); background: var(--card); border: 1px solid var(--hair); border-radius: 32px; padding: 16px 12px 12px; display: flex; flex-direction: column; gap: 12px; }
#composer textarea { border: 0; background: transparent; resize: none; max-height: 220px; padding: 0 10px; outline: none; font-size: 18px; line-height: 1.4; }
#composer textarea::placeholder { color: var(--muted); }
.comp-row { display: flex; align-items: center; gap: 10px; }
#composer .circle { width: 46px; height: 46px; background: var(--card2); border-color: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
#composer .sendbtn { background: var(--accent); color: #fff; }
#composer .stopbtn { background: #5a5955; color: #fff; }
#composer #btnMic.rec { background: var(--bad); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.chip { background: var(--card2); border: 0; border-radius: 999px; height: 46px; padding: 0 18px; font-size: 16px; font-weight: 500; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .muted { margin-left: 7px; font-weight: 400; }
#attach { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 6px; }
.thumb { position: relative; width: 68px; height: 68px; border-radius: 14px; overflow: hidden; border: 1px solid var(--hair); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .7); color: #fff; font-size: 12px; line-height: 1; padding: 0; }

/* menu popover (☰ và ⋯) */
.popmask { position: fixed; inset: 0; z-index: 90; }
.popmenu { position: fixed; z-index: 95; top: calc(66px + var(--sat)); min-width: 270px; max-width: calc(100vw - 28px); background: var(--glass); border: 1px solid var(--hair); border-radius: 30px; padding: 10px; -webkit-backdrop-filter: blur(30px) saturate(1.6); backdrop-filter: blur(30px) saturate(1.6); box-shadow: 0 20px 56px rgba(0, 0, 0, .5); animation: pin .15s ease-out; }
.popmenu.right { right: 14px; transform-origin: top right; } .popmenu.left { left: 14px; transform-origin: top left; }
@keyframes pin { from { opacity: 0; transform: scale(.9); } }
.poprow { display: flex; align-items: center; gap: 18px; width: 100%; background: none; border: 0; border-radius: 20px; padding: 13px 16px; font-size: 19px; text-align: left; color: var(--text); }
.poprow:active { background: var(--hair); }
.poprow svg.ic { width: 24px; height: 24px; }
.poprow.danger { color: var(--bad); }
.poprow.sel { color: var(--blue); }
.popsep { height: 1px; background: var(--hair); margin: 8px 16px; }

/* bảng trượt */
#overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end; justify-content: center; }
#sheet { background: var(--sheet); border: 1px solid var(--hair); border-bottom: 0; border-radius: 34px 34px 0 0; width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; padding: 10px 16px calc(22px + var(--sab)); animation: sup .22s cubic-bezier(.2, .8, .2, 1); min-height: 40dvh; }
#sheet.wide { max-width: 900px; }
#sheet.auto { min-height: 0; }
@keyframes sup { from { transform: translateY(100%); } }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; margin-bottom: 18px; min-height: 48px; position: relative; }
.sheet-head h2 { position: absolute; left: 56px; right: 56px; text-align: center; font-size: 18px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-head .circle { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
#sheet p { margin: 0 4px 14px; white-space: pre-wrap; word-break: break-word; }
#sheet .field { width: 100%; margin-bottom: 14px; background: var(--card); border-radius: 18px; padding: 14px 16px; }
#sheet textarea.field { min-height: 130px; font-family: var(--mono); font-size: 13.5px; }
#sheet textarea.field.tall { min-height: 56dvh; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; padding: 14px; font-size: 17px; }
.sheet-label { font-size: 15px; color: var(--muted); margin: 6px 6px 8px; }
.group { background: var(--card); border-radius: 26px; padding: 0 20px; margin-bottom: 14px; }
.grow-row { display: flex; align-items: center; gap: 16px; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--hair); padding: 15px 0; text-align: left; color: var(--text); }
.grow-row:last-child { border-bottom: 0; }
.grow-row:active { opacity: .6; }
.grow-row .b { flex: 1; min-width: 0; }
.grow-row .r1 { font-size: 18px; line-height: 1.3; }
.grow-row .r2 { font-size: 15.5px; color: var(--muted); line-height: 1.35; }
.grow-row .check { color: var(--blue); }
.grow-row .ico { flex: none; display: flex; }
.c-purple { color: #8b7cf6; } .c-blue { color: var(--blue); } .c-orange { color: var(--accent); } .c-red { color: var(--bad); }
.optrow { display: flex; align-items: center; gap: 14px; width: 100%; background: var(--card); border: 0; border-radius: 999px; padding: 17px 22px; margin-bottom: 12px; text-align: left; font-size: 18px; color: var(--text); }
.optrow:active { opacity: .6; }
.optrow .v { color: var(--muted); margin-left: auto; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.optrow .chev { color: var(--muted); display: flex; }
.optrow.blue { color: var(--blue); }
.tilesrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.bigtile { background: var(--card); border: 0; border-radius: 28px; padding: 26px 6px; display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 18px; color: var(--text); }
.bigtile:active { opacity: .6; }
.bigtile svg.ic { width: 28px; height: 28px; }
.emptybox { text-align: center; padding: 34px 12px 8px; color: var(--muted); }
.emptybox .big { width: 64px; height: 64px; border-radius: 50%; background: var(--card); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.emptybox h4 { margin: 0 0 4px; font-size: 18px; font-weight: 500; color: var(--muted); }
.kv { margin-bottom: 14px; }
.kv .k { font-size: 15px; font-weight: 600; margin: 0 4px 6px; }
.kv pre { margin: 0; background: var(--bg); border: 1px solid var(--hair); border-radius: 12px; padding: 12px; overflow: auto; max-height: 46dvh; font-size: 13px; white-space: pre-wrap; word-break: break-word; }

/* thông báo */
#toasts { position: fixed; top: calc(10px + var(--sat)); left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 24px); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; background: var(--glass); color: var(--text); border: 1px solid var(--hair); border-radius: 20px; padding: 12px 20px 12px 14px; -webkit-backdrop-filter: blur(26px) saturate(1.5); backdrop-filter: blur(26px) saturate(1.5); box-shadow: 0 10px 32px rgba(0, 0, 0, .4); max-width: min(520px, calc(100vw - 24px)); animation: tin .18s ease-out; cursor: pointer; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .2s; }
.toast .tic { width: 22px; height: 22px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; margin-top: 2px; }
.toast.ok .tic { background: var(--ok); } .toast.err .tic { background: var(--bad); } .toast.info .tic { background: var(--blue); }
.toast .tx { white-space: pre-wrap; word-break: break-word; max-height: 40vh; overflow: auto; font-size: 16.5px; }
@keyframes tin { from { opacity: 0; transform: translateY(-12px); } }

/* file */
.split { flex: 1; display: flex; min-height: 0; }
#fileList { width: 340px; flex: none; overflow: auto; border-right: 1px solid var(--hair); }
#fileList.full { width: 100%; border-right: 0; }
.fitem { display: flex; align-items: center; gap: 6px; padding: 10px 18px; cursor: pointer; border-bottom: 1px solid var(--hair); font-size: 16.5px; }
.fitem:active { opacity: .6; } .fitem .sz { color: var(--muted); font-size: 13px; margin-left: auto; white-space: nowrap; }
.fitem.heavy { opacity: .5; }
.fchev { width: 16px; height: 16px; flex: none; color: var(--muted); transition: transform .15s; }
.fchev svg.ic { width: 16px; height: 16px; }
.fchev.open { transform: rotate(90deg); }
#crumbs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; } #crumbs a { cursor: pointer; }
#editorWrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#editorWrap .CodeMirror { flex: 1; min-height: 0; height: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.5; }
.CodeMirror-gutters { border-right: 1px solid var(--hair) !important; }

/* trình soạn file — theme kiểu VS Code Dark+ cho CodeMirror */
.cm-s-vscode-dark.CodeMirror { background: #1e1e1e; color: #d4d4d4; }
.cm-s-vscode-dark .CodeMirror-gutters { background: #1e1e1e; }
.cm-s-vscode-dark .CodeMirror-linenumber { color: #858585; }
.cm-s-vscode-dark .CodeMirror-cursor { border-left: 1px solid #aeafad; }
.cm-s-vscode-dark div.CodeMirror-selected, .cm-s-vscode-dark .CodeMirror-line::selection, .cm-s-vscode-dark .CodeMirror-line > span::selection, .cm-s-vscode-dark .CodeMirror-line > span > span::selection { background: #264f78; }
.cm-s-vscode-dark .CodeMirror-activeline-background { background: #2a2d2e; }
.cm-s-vscode-dark .CodeMirror-matchingbracket { color: #d4d4d4 !important; background: #3a3d41; }
.cm-s-vscode-dark .cm-keyword { color: #569cd6; }
.cm-s-vscode-dark .cm-atom { color: #569cd6; }
.cm-s-vscode-dark .cm-number { color: #b5cea8; }
.cm-s-vscode-dark .cm-def { color: #dcdcaa; }
.cm-s-vscode-dark .cm-variable { color: #9cdcfe; }
.cm-s-vscode-dark .cm-variable-2 { color: #9cdcfe; }
.cm-s-vscode-dark .cm-variable-3, .cm-s-vscode-dark .cm-type { color: #4ec9b0; }
.cm-s-vscode-dark .cm-property { color: #9cdcfe; }
.cm-s-vscode-dark .cm-operator { color: #d4d4d4; }
.cm-s-vscode-dark .cm-comment { color: #6a9955; font-style: italic; }
.cm-s-vscode-dark .cm-string { color: #ce9178; }
.cm-s-vscode-dark .cm-string-2 { color: #ce9178; }
.cm-s-vscode-dark .cm-meta { color: #569cd6; }
.cm-s-vscode-dark .cm-qualifier { color: #d7ba7d; }
.cm-s-vscode-dark .cm-builtin { color: #4ec9b0; }
.cm-s-vscode-dark .cm-bracket { color: #ffd700; }
.cm-s-vscode-dark .cm-tag { color: #569cd6; }
.cm-s-vscode-dark .cm-attribute { color: #9cdcfe; }
.cm-s-vscode-dark .cm-header { color: #569cd6; }
.cm-s-vscode-dark .cm-link { color: #569cd6; text-decoration: underline; }
.cm-s-vscode-dark .cm-error { color: #f44747; }

/* git / lệnh */
pre.block { background: var(--card); border: 1px solid var(--hair); border-radius: 16px; padding: 12px 14px; overflow: auto; font-size: 13px; margin: 10px 16px; white-space: pre-wrap; word-break: break-word; }
.cardbox pre.block { margin: 10px 0 0; background: var(--bg2); }
.diff .add { color: #3fb950; } .diff .del { color: var(--bad); } .diff .hunk { color: var(--blue); } .diff .file { font-weight: 700; }
.bigcode { font-size: 24px; font-weight: 700; letter-spacing: 2px; }
.job { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border: 1px solid var(--hair); border-radius: 16px; margin-bottom: 6px; cursor: pointer; background: var(--bg2); }
.job .c { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .job .dot { margin: 0; }
#jobView { border: 1px solid var(--hair); border-radius: 20px; overflow: hidden; }
#jobOut { margin: 0; padding: 14px; background: #0a0a09; color: #dedcd3; max-height: 55vh; overflow: auto; font-size: 13px; white-space: pre-wrap; word-break: break-word; }

/* skill & mcp */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--hair); border-radius: 18px; background: var(--bg2); }
.item .i1 { font-weight: 600; } .item .i2 { font-size: 14px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.item .body { flex: 1; min-width: 0; }

/* tổng quan */
.dash h2 { margin: 20px 0 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { background: var(--card); border: 1px solid var(--hair); border-radius: 22px; padding: 14px 16px; min-width: 0; }
.tile-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.tile-v { font-size: 30px; font-weight: 600; line-height: 1.25; }
.tile-s { font-size: 13px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { height: 6px; border-radius: 3px; background: var(--card2); overflow: hidden; margin-top: 4px; }
.meter-fill { height: 100%; border-radius: 3px; }
.meter-fill.good { background: var(--st-good); } .meter-fill.warning { background: var(--st-warning); } .meter-fill.serious { background: var(--st-serious); } .meter-fill.critical { background: var(--st-critical); }
/* tile dạng vòng tròn phần trăm kiểu aaPanel */
.tile-ring { display: flex; align-items: center; gap: 18px; }
.tile-ring .tile-body { flex: 1; min-width: 0; }
.tile-ring .tile-h { font-size: 16px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.tile-ring .badge { font-weight: 400; }
.ring-wrap { position: relative; flex: none; width: 96px; height: 96px; }
.ring-wrap .ring { display: block; }
.ring-bg { fill: none; stroke: var(--card2); }
.ring-fg { fill: none; stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring-fg.good { stroke: var(--st-good); } .ring-fg.warning { stroke: var(--st-warning); } .ring-fg.serious { stroke: var(--st-serious); } .ring-fg.critical { stroke: var(--st-critical); }
.ring-val { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; }
.tile-ring .tile-s { margin-top: 0; white-space: normal; font-size: 14px; }
.badge { font-size: 13px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--hair); color: var(--text); white-space: nowrap; }
.badge::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.badge.good::before { background: var(--st-good); } .badge.warning::before { background: var(--st-warning); } .badge.serious::before { background: var(--st-serious); } .badge.critical::before { background: var(--st-critical); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin-bottom: 12px; }
.cards .cardbox { margin-bottom: 0; }
.chartbox { position: relative; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--gridc); stroke-width: 1; stroke-dasharray: 4 4; }
svg.chart .axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
svg.chart .axis.lbl { fill: var(--text); }
svg.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
svg.chart .pt { stroke: var(--card); stroke-width: 1.5; }
.tip { position: absolute; top: 4px; background: var(--sheet); border: 1px solid var(--hair); border-radius: 12px; padding: 7px 11px; font-size: 13px; pointer-events: none; white-space: nowrap; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); z-index: 2; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.tablewrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--hair); white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.tbl .num, .tbl th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }

/* điện thoại: 2 màn hình chồng nhau — danh sách ở dưới, chi tiết trượt vào từ phải */
@media (max-width: 860px) {
  #side { width: 100%; border-right: 0; }
  #main { position: absolute; inset: 0; z-index: 20; transform: translateX(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); will-change: transform; }
  #app.show-main #main { transform: none; }
  .cards { grid-template-columns: 1fr; } .tiles { grid-template-columns: 1fr; } .tile-v { font-size: 26px; }
  /* tiêu đề header luôn canh giữa thật, không lệch khi nút bên phải (btnMore) bị ẩn ở các tab không phải chat */
  #top .titles { position: absolute; left: 0; right: 0; margin: 0; padding: 0 52px; pointer-events: none; }
  /* nút tròn ở header hơi lớn so với chữ trên điện thoại — thu nhỏ lại gần bằng máy tính */
  .hd > .circle, .hd-right .circle { width: 40px; height: 40px; }
  .hd > .circle svg.ic, .hd-right .circle svg.ic { width: 19px; height: 19px; }
  #topBusy::after { width: 19px; height: 19px; }
  #topBusy:not(.spin)::after { width: 20px; height: 20px; }
  .hd { min-height: calc(58px + var(--sat)); gap: 6px; }
  .split { flex-direction: column; } #fileList { width: 100%; border-right: 0; max-height: 42%; } #fileList.full { max-height: none; flex: 1; }
}
/* máy tính: 2 cột, bảng trượt thành hộp giữa màn hình */
@media (min-width: 861px) {
  body { font-size: 16px; }
  #btnBack { display: none; }
  #top .titles { text-align: left; padding-left: 6px; }
  .circle { width: 42px; height: 42px; } .pillgroup { height: 42px; } .pillgroup button { width: 46px; }
  .hd { min-height: 62px; }
  .sess .t1 { font-size: 16.5px; } .sess .t2 { font-size: 14px; } .sess { padding: 9px 8px; } .sess:hover { background: var(--card); }
  .pill { font-size: 15px; padding: 8px 14px; } .sec-label { font-size: 14px; margin: 18px 2px 10px; }
  .msg.user .bubble, .md { font-size: 16.5px; } .toolline, .thinking { font-size: 15px; }
  #composer textarea { font-size: 16.5px; } #composer .circle, .chip { width: 42px; height: 42px; } .chip { width: auto; }
  #overlay { align-items: center; padding: 20px; }
  #sheet, #sheet.wide { border-radius: 30px; border-bottom: 1px solid var(--hair); min-height: 0; animation: pin .16s ease-out; padding-bottom: 20px; }
  .grabber { display: none; }
  .popmenu { top: 62px; } .poprow { font-size: 16px; padding: 10px 14px; }
  .optrow, .grow-row .r1, .bigtile { font-size: 16.5px; } .grow-row .r2 { font-size: 14.5px; }
  .fab { height: 44px; font-size: 15.5px; }
}
@media (pointer: coarse) { input, textarea, select { font-size: 17px !important; } #editorWrap .CodeMirror { font-size: 16px !important; } }

/* ô model co giãn theo chỗ trống thay vì cắt ở 62% (đủ hiện "Opus 5.5 Trung bình" trên iPhone) */
.chip { max-width: none; flex: 0 1 auto; min-width: 0; padding: 0 15px; }
@media (max-width: 860px) { .chip { font-size: 15.5px; } .comp-row { gap: 8px; } }
@media (max-width: 860px) { .chip { font-size: 15px; padding: 0 13px; } .chip .muted { margin-left: 5px; } }

/* vòng tròn trạng thái ở header: vòng tĩnh khi rảnh, xoay khi Claude đang chạy; bấm mở "Mức sử dụng" */
#topBusy { cursor: pointer; position: relative; }
#topBusy::after { content: ""; width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--muted); opacity: .55; }
#topBusy.spin::after { border-color: var(--hair); border-top-color: var(--blue); border-right-color: var(--blue); opacity: 1; animation: rot .9s linear infinite; }
/* bảng Mức sử dụng */
.ucard { background: var(--card); border-radius: 24px; padding: 18px 20px; margin-bottom: 14px; }
.uhead { display: flex; align-items: center; gap: 10px; }
.uhead .ut { font-size: 18px; flex: 1; min-width: 0; }
.uhead .up { color: var(--muted); font-size: 16.5px; white-space: nowrap; }
.uchev { background: none; border: 0; color: var(--muted); padding: 0; display: flex; }
.ubar { height: 7px; border-radius: 4px; margin-top: 12px; overflow: hidden; background: rgba(77, 155, 255, .22); }
.ubar i { display: block; height: 100%; border-radius: 4px; background: var(--blue); }
.ubar.warn { background: rgba(250, 178, 25, .2); } .ubar.warn i { background: var(--st-warning); }
.ubar.crit { background: rgba(240, 88, 93, .2); } .ubar.crit i { background: var(--bad); }
.usub { color: var(--muted); font-size: 15.5px; margin-top: 10px; }
.ucats { margin-top: 12px; border-top: 1px solid var(--hair); padding-top: 8px; font-size: 15px; }
.ucats > div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; color: var(--muted); }
.ucats > div span:last-child { font-variant-numeric: tabular-nums; }

/* Mức sử dụng: thanh nhiều màu + bảng chi tiết */
.useg { display: flex; height: 8px; border-radius: 4px; margin-top: 12px; overflow: hidden; background: var(--card2); gap: 1px; }
.useg i { display: block; height: 100%; min-width: 2px; }
.uchev { transition: transform .15s; } .uchev.open { transform: rotate(180deg); }
.udetail { margin-top: 14px; border-top: 1px solid var(--hair); padding-top: 12px; }
.ucat { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 16.5px; }
.ucat .sq { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ucat .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ucat .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.ucat .p { color: var(--muted); font-variant-numeric: tabular-nums; width: 58px; text-align: right; flex: none; }
.usec { border-top: 1px solid var(--hair); margin-top: 12px; padding-top: 12px; }
.usechead { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.usechead .cnt { background: var(--card2); border-radius: 999px; font-size: 13px; padding: 1px 9px; color: var(--muted); }
.usublist > div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 15px; color: var(--muted); }
.usublist .n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usublist .t { font-variant-numeric: tabular-nums; flex: none; }
.umore { background: none; border: 0; color: var(--blue); padding: 6px 0 0; font-size: 15px; }

/* nhóm nhiều dòng trong 1 thẻ (giới hạn tuần, tín dụng) */
.ugroup { padding: 0 20px; }
.ugroup .urow { padding: 18px 0; border-bottom: 1px solid var(--hair); }
.ugroup .urow:last-child { border-bottom: 0; }

/* khung xương nhấp nháy khi đang tải */
.sk { height: 15px; border-radius: 8px; margin: 10px 0; background: linear-gradient(90deg, var(--card) 25%, var(--card2) 45%, var(--card) 65%); background-size: 300% 100%; animation: shimmer 1.3s ease-in-out infinite; }
.sk.bub { height: 46px; border-radius: 24px; margin: 18px 0 18px auto; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.skelwrap { max-width: 780px; width: 100%; margin: 0 auto; }
.olderbtn { align-self: center; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

/* vòng tròn header = vòng tiến độ % ngữ cảnh (khi không xoay). --p: 0..100 */
#topBusy { --p: 0; --ringc: var(--blue); }
#topBusy[data-tone="warn"] { --ringc: var(--st-warning); }
#topBusy[data-tone="crit"] { --ringc: var(--bad); }
#topBusy:not(.spin)::after {
  border: 0; opacity: 1; width: 24px; height: 24px;
  background: conic-gradient(var(--ringc) calc(var(--p) * 1%), color-mix(in srgb, var(--muted) 38%, transparent) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3px));
}

/* thanh chọn dạng đoạn (ngưỡng đổi phiên) */
.seg { display: flex; background: var(--card); border-radius: 999px; padding: 4px; gap: 2px; margin-bottom: 14px; }
.seg button { flex: 1; background: none; border: 0; border-radius: 999px; padding: 11px 4px; font-size: 16px; color: var(--muted); }
.seg button.sel { background: var(--card2); color: var(--text); font-weight: 600; }

/* Trình duyệt VPS — khung giống Chrome: dải tab phía trên, thanh địa chỉ dạng omnibox bên dưới */
#view-browser { background: #000; }
.brtabstrip { display: flex; align-items: flex-end; gap: 2px; background: var(--bg); padding: 8px 8px 0; border-bottom: 1px solid var(--hair); }
.brtabs { flex: 1; min-width: 0; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.brtabs::-webkit-scrollbar { display: none; }
.brtab { display: flex; align-items: center; gap: 8px; max-width: 220px; min-width: 100px; flex: 1 1 180px; background: var(--bg2); color: var(--muted);
  border-radius: 10px 10px 0 0; padding: 9px 8px 9px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.brtab.active { background: var(--card); color: var(--text); }
.brtab-fav { flex: none; width: 16px; height: 16px; border-radius: 3px; object-fit: contain; }
.brtab-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.brtab-x { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 0; background: none; color: inherit; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; opacity: .6; }
.brtab-x:hover, .brtab-x:active { opacity: 1; background: var(--hair); }
.brtabnew { flex: none; width: 32px; height: 32px; margin: 0 0 4px 2px; border-radius: 50%; border: 0; background: none; color: var(--muted); font-size: 17px; display: inline-flex; align-items: center; justify-content: center; }
.brtabnew:active { background: var(--hair); }
.brbar { background: var(--card); gap: 8px; flex-wrap: nowrap; padding: 8px 12px; border-bottom: 1px solid var(--hair); }
.brnav { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 0; background: none; color: var(--text); font-size: 18px; display: inline-flex; align-items: center; justify-content: center; }
.brnav:active { background: var(--hair); }
.brcount { display: none; background: var(--bg2); font-size: 13px; font-weight: 700; }
.omnibox { display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px solid var(--hair); border-radius: 999px; padding: 0 14px; height: 36px; }
.omnibox-ic { flex: none; font-size: 12px; opacity: .7; }
.omnibox input { flex: 1; min-width: 0; width: 100%; background: none; border: 0; padding: 0; font-size: 14px; }
.omnibox input:focus { outline: none; }
#brStage { flex: 1; min-height: 0; overflow: hidden; position: relative; display: flex; align-items: flex-start; justify-content: center; background: #0a0a09; touch-action: none; }
#brImg { max-width: 100%; max-height: 100%; display: block; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; cursor: default; transform-origin: 0 0; }
#brStatus { position: absolute; top: 16px; left: 0; right: 0; text-align: center; z-index: 2; padding: 0 16px; }
/* ô hứng phím: vô hình nhưng vẫn phải "có mặt" thì điện thoại mới chịu bật bàn phím */
#brKb { position: absolute; top: 0; left: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; resize: none; pointer-events: none; outline: none; }
#brKbBtn { position: absolute; right: 14px; bottom: calc(14px + var(--sab)); z-index: 3; }
#brKbBtn.on { background: var(--text); color: var(--bg); }
@media (pointer: fine) { #brKbBtn { display: none; } }
@media (max-width: 860px) {
  /* điện thoại: ẩn dải tab ngang kiểu desktop, thay bằng 1 nút đếm tab mở bảng chọn tab (giống Chrome di động) */
  .brtabstrip { display: none; }
  .brcount { display: inline-flex; }
}
.item.active { border-color: var(--blue); }
