html, body { height: 100%; background: var(--bg); overflow: hidden; }
body { font-size: 13px; }

#app { display: grid; grid-template-columns: 64px 1fr; height: 100vh; }
#app.gate { display: block; }

/* --------------------------------------------- sidebar (Teams-style rail) -- */
aside { border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 0 0 12px; background: var(--sunk); overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
aside::-webkit-scrollbar { display: none; }
.brand { display: flex; align-items: center; justify-content: center; height: 52px; width: 100%; -webkit-app-region: drag; flex: none; }
.brand img { width: 15px; height: 20px; }
.nav { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.nav button {
  position: relative; display: flex; align-items: center; justify-content: center; width: 44px; height: 40px; padding: 0; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.nav button svg { width: 21px; height: 21px; color: var(--muted); stroke-width: 1.6; }
.nav button:hover { background: var(--hover); }
.nav button:hover svg { color: var(--fg); }
.nav button.on { background: var(--green-wash); }
.nav button.on svg { color: var(--green-ink); stroke-width: 2; }
.nav button.on::before { content: ""; position: absolute; left: -10px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--green-ink); }
.nav .count { position: absolute; top: 2px; right: 1px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--red-ink); color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--sunk); line-height: 1; }
.rail-sep { width: 28px; height: 1px; background: var(--line-2); margin: 10px 0; flex: none; }
.side-sp { flex: 1; min-height: 16px; }
.rail-me { position: relative; margin-top: 10px; display: flex; cursor: default; }
.rail-me .avatar { width: 34px; height: 34px; font-size: 12px; }
.rail-me .conn-dot { position: absolute; left: -2px; top: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px var(--sunk); }
.rail-me .conn-dot.off { background: var(--amber-ink); }
.rail-tip { position: fixed; z-index: 80; transform: translateY(-50%); background: var(--fg); color: var(--bg); font-size: 12px; font-weight: 550; padding: 5px 10px; border-radius: 6px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.08s; box-shadow: var(--shadow-pop); }
.rail-tip.show { opacity: 1; transition-delay: 0.25s; }

/* ------------------------------------------------------------- main ---- */
main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.top {
  height: 52px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 150px 0 32px;
  border-bottom: 1px solid var(--line); -webkit-app-region: drag;
}
.top h1 { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; }
.top .sp { flex: 1; }
.top button, .top .seg, .top select { -webkit-app-region: no-drag; }
#page { flex: 1; overflow-y: auto; }
.wrap { max-width: 1180px; padding: 26px 32px 56px; }
.demo-note {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; margin-bottom: 22px; border: 1px dashed var(--line-2);
  border-radius: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap;
}
.demo-note b { color: var(--fg); font-weight: 600; }
.demo-note .sp { flex: 1; }
.demo-note select { height: 28px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--bg); padding: 0 8px; font-size: 12px; }

/* sections & panels */
.sec { margin-bottom: 30px; }
.sec-h { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.sec-h h2 { margin: 0; font-size: 13.5px; font-weight: 650; letter-spacing: -0.005em; }
.sec-h .note { font-size: 12px; color: var(--faint); }
.sec-h .sp { flex: 1; }
.panel { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); min-width: 0; }
.panel.pad { padding: 16px 18px; }
.cols { display: grid; gap: 22px; }
.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.c-wide { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }

/* stat strip: numbers in a row, hairlines between */
.strip { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.strip > div { flex: 1; padding: 13px 16px 14px; min-width: 0; }
.strip > div + div { border-left: 1px solid var(--line); }
.strip .l { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.strip .v { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; margin-top: 3px; line-height: 1.1; white-space: nowrap; }
.strip .v small { font-size: 12px; font-weight: 550; color: var(--muted); letter-spacing: 0; margin-left: 3px; }
.strip .s { font-size: 11.5px; color: var(--faint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .v.green { color: var(--green-ink); }

/* leaders: top three in one panel */
.leaders { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 30px; }
.leader { display: grid; grid-template-columns: auto auto 1fr auto; gap: 14px; align-items: center; padding: 18px 20px; }
.leader + .leader { border-left: 1px solid var(--line); }
.leader .pos { font-size: 30px; font-weight: 800; letter-spacing: -0.04em; width: 26px; }
.leader .pos.p1 { color: var(--gold); } .leader .pos.p2 { color: var(--silver); } .leader .pos.p3 { color: var(--bronze); }
.leader .nm { font-weight: 620; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leader .sc { font-size: 26px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.15; margin-top: 2px; }
.leader .sc small { font-size: 12px; color: var(--muted); font-weight: 520; letter-spacing: 0; margin-left: 4px; }
.leader .ex { font-size: 11.5px; color: var(--faint); margin-top: 1px; }
.leader.empty { color: var(--faint); }

.goal { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.goal .track { width: 160px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.goal .track i { display: block; height: 100%; background: var(--green); border-radius: 4px; }
.goal b { color: var(--fg); font-weight: 650; }

/* tables */
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; color: var(--faint); font-weight: 520; padding: 10px 12px; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.t td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
table.t tr:first-child td { border-top: 0; }
table.t tr.me td { background: var(--green-wash); }
table.t td.r, table.t th.r { text-align: right; }
table.t td.wrap-ok { white-space: normal; }
table.t tbody tr:hover td { background: var(--hover); }
table.t tbody tr.me:hover td { background: var(--green-wash); }
.member { display: flex; align-items: center; gap: 9px; min-width: 0; }
.member b { font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member .sub, td .sub { display: block; font-size: 11.5px; color: var(--faint); font-weight: 450; }
.rkn { font-weight: 650; color: var(--faint); }
.rkn.p1 { color: var(--gold); font-weight: 800; } .rkn.p2 { color: var(--silver); font-weight: 800; } .rkn.p3 { color: var(--bronze); font-weight: 800; }
.you-tag { font-size: 11px; color: var(--green-ink); font-weight: 650; }
.crown { color: var(--gold); display: inline-flex; }
.crown svg { width: 13px; height: 13px; }
.meter { display: inline-flex; align-items: center; gap: 8px; }
.panel:has(> table) { overflow-x: auto; }
.meter .track { width: 64px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter .track i { display: block; height: 100%; background: var(--fg-2); border-radius: 4px; }
.meter span { font-size: 11.5px; color: var(--faint); }
.streak { color: #e8590c; font-weight: 650; }
.tag { display: inline-block; font-size: 11px; font-weight: 550; color: var(--muted); border: 1px solid var(--line-2); border-radius: 5px; padding: 0 5px; line-height: 17px; }
.tag.gold { color: var(--gold); border-color: rgba(217, 164, 0, 0.45); }

/* charts */
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart text { font-family: inherit; fill: var(--faint); font-size: 10px; }
svg.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.hbar { display: grid; grid-template-columns: 120px 1fr 30px; align-items: center; gap: 10px; margin: 8px 0; font-size: 12.5px; }
.hbar .track { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 6px; background: var(--fg-2); }
.hbar .n { text-align: right; font-weight: 650; }
.hbar .lab { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--fg-2); }

/* me: header */
.me-head { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; }
.me-head h2 { margin: 0; font-size: 22px; font-weight: 720; letter-spacing: -0.025em; display: flex; align-items: center; gap: 8px; }
.me-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.me-head .sp { flex: 1; }
.target { text-align: right; }
.target .v { font-size: 22px; font-weight: 720; letter-spacing: -0.03em; }
.target .l { font-size: 11.5px; color: var(--muted); }
.target .track { width: 180px; height: 5px; background: var(--line); border-radius: 5px; overflow: hidden; margin-top: 6px; }
.target .track i { display: block; height: 100%; background: var(--green); }

/* level ladder */
.level { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.level h3 { margin: 0; font-size: 18px; font-weight: 720; letter-spacing: -0.02em; }
.level .d { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.ladder { position: relative; margin-top: 18px; height: 34px; }
.ladder .rail { position: absolute; left: 0; right: 0; top: 7px; height: 4px; background: var(--line); border-radius: 4px; }
.ladder .fill { position: absolute; left: 0; top: 7px; height: 4px; background: var(--fg); border-radius: 4px; }
.ladder .stop { position: absolute; top: 0; transform: translateX(-50%); text-align: center; font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.ladder .stop .tier { display: block; margin: 0 auto 3px; }
.risk-line { margin-top: 14px; padding: 9px 12px; border-radius: 8px; background: rgba(217, 140, 0, 0.09); color: var(--amber-ink); font-size: 12.5px; }
.kept { display: flex; flex-direction: column; }
.kept > div { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.kept > div:first-child { border-top: 0; padding-top: 0; }
.kept b { font-size: 13px; font-weight: 640; }
.kept .now { font-size: 12.5px; color: var(--fg-2); margin-top: 1px; }
.kept .rule { font-size: 11.5px; color: var(--faint); margin-top: 3px; }

/* badges */
.tiers-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tier-col { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 8px 14px; text-align: center; min-width: 0; }
.tier-col + .tier-col { border-left: 1px solid var(--line); }
.tier-col.mine { background: var(--green-wash); }
.tier-col b { font-size: 13.5px; font-weight: 680; margin-top: 6px; }
.tier-col .faint { margin-top: 2px; }
.tier-col .faint { font-size: 11.5px; }
.holders { display: flex; flex-wrap: wrap; justify-content: center; margin-top: 10px; min-height: 24px; padding-left: 6px; }
.holders > span { margin-left: -3px; border-radius: 50%; box-shadow: 0 0 0 2px var(--bg); display: inline-flex; }
.holders > span.slip { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--amber-ink); }
.award-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.award-grid.ended { opacity: 0.6; }
.award-strip { display: flex; flex-wrap: wrap; gap: 10px; }
.award-chip { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); min-width: 0; }
.award-chip b { font-size: 13.5px; font-weight: 660; }
.award-chip .muted { font-size: 12px; }
.award-chip .note-t { font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.achv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.achv-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.achv-item b { font-size: 13px; font-weight: 640; }
.achv-item div div { font-size: 11.5px; }
.achv-item.locked b { color: var(--muted); font-weight: 560; }
.mini-achv { display: flex; gap: 2px; flex-wrap: nowrap; align-items: center; }
.mini-achv.wrap { flex-wrap: wrap; }
.award-designer { display: flex; gap: 18px; align-items: flex-start; }
.award-designer .preview { width: 168px; height: 168px; border-radius: 14px; background: radial-gradient(circle at 50% 40%, #2a2d33, #141518); display: grid; place-items: center; flex: none; }
.award-designer .striking { color: #a1a1aa; font-size: 12px; text-align: center; padding: 0 14px; }
.icon-pick { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; }
.icon-pick label { position: relative; cursor: pointer; }
.icon-pick input { position: absolute; opacity: 0; }
.icon-pick span { display: grid; place-items: center; height: 34px; border-radius: 8px; border: 1px solid var(--line-2); color: var(--muted); }
.icon-pick input:checked + span { border-color: var(--fg); color: var(--fg); background: var(--hover); }
.pips { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: 1px; }
.pips i { width: 14px; height: 4px; border-radius: 2px; background: var(--line-2); }
.pips i.on { background: var(--green); }
.achv { display: flex; flex-wrap: wrap; gap: 8px; }
.achv span { font-size: 12px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--fg-2); }
.achv span b { font-weight: 620; color: var(--fg); margin-right: 4px; }

/* rows (review, feed, links, wins) */
.rows { border: 1px solid var(--line); border-radius: 12px; }
.rw { display: grid; gap: 14px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }
.rw:first-child { border-top: 0; }
.rw .k { font-size: 11.5px; color: var(--faint); }
.rw .v { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) minmax(0, 1fr) auto; align-items: start; }
.rv .qa { font-size: 12px; color: var(--fg-2); }
.rv .qa div + div { margin-top: 4px; }
.rv .qa i { font-style: normal; color: var(--faint); }
.rv .acts { display: flex; flex-direction: column; gap: 6px; align-items: stretch; min-width: 150px; }
.rv .acts select { height: 28px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--bg); padding: 0 6px; font-size: 12px; }
.rv .acts .pair { display: flex; gap: 6px; }
.rv .acts .pair .btn { flex: 1; }
.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: text; }
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; background: none; padding: 8px 0 9px; font-size: 13px; font-weight: 520; color: var(--muted); border-bottom: 1.5px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--fg); border-bottom-color: var(--fg); }
.tabs button b { font-weight: 650; margin-left: 4px; color: var(--faint); }
.tabs button.on b { color: var(--fg); }
.lede { color: var(--muted); font-size: 12.5px; margin: -4px 0 16px; max-width: 760px; }
.empty { padding: 34px 16px; text-align: center; color: var(--faint); }

.link-item { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 16px; border-top: 1px solid var(--line); }
.link-item:first-child { border-top: 0; }
.pf { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; font-size: 10px; font-weight: 750; color: #fff; background: var(--faint); }
.pf.linkedin { background: #0a66c2; } .pf.instagram { background: #c13584; } .pf.tiktok { background: #111113; }
.pf.facebook { background: #1877f2; } .pf.x { background: #111113; } .pf.website { background: var(--green); }
:root[data-theme="dark"] .pf.tiktok, :root[data-theme="dark"] .pf.x { background: #3a3a40; }

.win-row { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto; }
.win-row .client { font-size: 14px; font-weight: 650; }

/* forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.row-flex { display: flex; align-items: center; gap: 10px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; padding-top: 0; }
.setting b { display: block; font-size: 13px; font-weight: 600; }
.setting .d { font-size: 12px; color: var(--muted); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches label { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; position: relative; }
.swatches input { position: absolute; opacity: 0; }
.swatches input:checked + i { position: absolute; inset: -3px; border-radius: 50%; box-shadow: 0 0 0 2px var(--fg); }
.photo-edit { display: flex; align-items: center; gap: 14px; }

/* modal */
#modal { position: fixed; inset: 0; display: none; place-items: center; background: rgba(10, 10, 12, 0.36); z-index: 50; }
#modal.open { display: grid; }
.modal { width: min(540px, calc(100vw - 40px)); max-height: calc(100vh - 80px); overflow-y: auto; background: var(--bg); border-radius: 14px; padding: 22px 22px 18px; box-shadow: var(--shadow-pop); border: 1px solid var(--line); }
.modal h3 { margin: 0 0 4px; font-size: 15.5px; font-weight: 680; letter-spacing: -0.01em; }
.modal .lede { margin: 0 0 18px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.err { color: var(--red-ink); font-size: 12.5px; margin-top: 10px; }

/* gate (setup + sign in) */
/* Only a top strip drags the window. A full-window drag area with a no-drag "hole" for the card
   breaks on Windows at 125%/150% display scaling: clicks on the fields grab the window instead. */
.gate-wrap { height: 100vh; display: grid; place-items: center; }
.gate-drag { position: fixed; top: 0; left: 0; right: 150px; height: 40px; -webkit-app-region: drag; }
.gate-card { width: min(380px, calc(100vw - 40px)); }
.gate-card .logo { width: 16px; height: 21px; }
.gate-card h1 { margin: 16px 0 4px; font-size: 20px; font-weight: 720; letter-spacing: -0.02em; }
.gate-card p { margin: 0 0 22px; color: var(--muted); }
.gate-card form { display: flex; flex-direction: column; gap: 12px; }
.gate-card .btn { height: 36px; }
.gate-card .alt { display: flex; justify-content: space-between; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

@media (max-width: 1150px) {
  .c-wide, .c3 { grid-template-columns: 1fr; }
  .rv { grid-template-columns: 1fr 1fr; }
  .tiers-row { grid-template-columns: repeat(3, 1fr); }
  .tier-col:nth-child(4) { border-left: 0; }
  .tier-col:nth-child(n+4) { border-top: 1px solid var(--line); }
  .icon-pick { grid-template-columns: repeat(6, 1fr); }
}

/* Working time */
table.t.work th, table.t.work td { padding-left: 8px; padding-right: 8px; }
table.t.work td:first-child, table.t.work th:first-child { padding-left: 14px; }
table.t.work td:last-child, table.t.work th:last-child { padding-right: 14px; }

/* Screenshots */
.shot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.shot { display: flex; flex-direction: column; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel, transparent); cursor: pointer; text-align: left; color: inherit; font: inherit; }
.shot:hover { border-color: var(--muted); }
.shot img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; display: block; background: var(--line); }
.shot .cap { font-size: 12px; color: var(--muted); padding: 0 2px 2px; }
.modal.wide { width: min(1180px, 94vw); max-width: none; }
.shot-big img { width: 100%; max-height: 74vh; object-fit: contain; border-radius: 8px; display: block; background: #000; }

/* Productivity */
.pbar { display: inline-flex; width: 150px; height: 8px; border-radius: 8px; overflow: hidden; background: var(--line); vertical-align: middle; }
.pbar i { display: block; height: 100%; }
.pbar i.p, .app-chip.productive i { background: var(--green); }
.pbar i.n, .app-chip.neutral i { background: #A8B0BA; }
.pbar i.u, .app-chip.unproductive i { background: #E5484D; }
.app-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.app-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
.app-chip i { width: 7px; height: 7px; border-radius: 50%; display: block; }
.cat-sel { width: 140px; height: 28px; font-size: 12.5px; }
.cat-sel.productive { color: var(--green-ink); }
.cat-sel.unproductive { color: var(--red-ink); }

.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.pick { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 7px; border: 0; background: transparent; text-align: left; color: var(--fg); font-size: 13px; cursor: pointer; width: 100%; }
.pick:hover { background: var(--hover); }
.pick .nm { flex: 1; }
.pick input { width: 16px; height: 16px; }
/* =====================================================================
   Look & feel: Microsoft Teams layout with Claude's calm, flat surfaces.
   Devaspir green is the only accent colour.
   ===================================================================== */
html, body { background: var(--app); }
main { background: var(--app); }

/* ------------------------------------------------------------- rail -- */
#app { grid-template-columns: 60px 1fr; }
aside.rail { background: var(--rail); border-right: 0; padding: 0 0 10px; align-items: center; }
.brand { height: 48px; }
.brand img { width: 14px; height: 19px; }
.nav { gap: 2px; }
.nav button { width: 44px; height: 40px; border-radius: var(--r); }
.nav button svg { width: 20px; height: 20px; color: var(--muted); stroke-width: 1.6; }
.nav button:hover { background: var(--hover); }
.nav button:hover svg { color: var(--fg); }
.nav button.on { background: var(--bg); box-shadow: var(--shadow-card); }
.nav button.on svg { color: var(--green-ink); stroke-width: 2; }
.nav button.on::before { left: -8px; top: 11px; bottom: 11px; background: var(--green); }
.nav .count { top: 3px; right: 3px; box-shadow: 0 0 0 2px var(--rail); min-width: 16px; height: 16px; font-size: 9.5px; background: #c4314b; }
.rail-sep { width: 24px; background: var(--line-2); margin: 8px 0; }
.rail-me { cursor: pointer; border-radius: 50%; }
.rail-me:hover .avatar { box-shadow: 0 0 0 2px var(--line-2); }
.rail-me .avatar { width: 32px; height: 32px; }
.rail-me .conn-dot { box-shadow: 0 0 0 2px var(--rail); }
.rail-me .pres { border-color: var(--rail); }
.rail-tip { background: var(--bg); color: var(--fg); box-shadow: var(--shadow-pop); border: 1px solid var(--line); font-weight: 600; }
@media (max-height: 820px) { .nav button { height: 34px; } .brand { height: 42px; } .rail-sep { margin: 5px 0; } }

/* ------------------------------------------------------- page header -- */
.top { height: 52px; background: var(--app); border-bottom: 1px solid var(--line); padding-left: 24px; }
.top h1 { font-size: 16px; font-weight: 700; }
.wrap { padding: 20px 24px 48px; }
.demo-note { border: 1px solid var(--line); background: var(--bg); border-radius: var(--r-lg); padding: 6px 8px 6px 12px; margin-bottom: 18px; color: var(--muted); }
.demo-note b { color: var(--green-ink); }
.demo-note select { border-radius: var(--r); border-color: var(--line-2); background: var(--bg); color: var(--fg); }

/* ------------------------------------------------------------ cards -- */
.panel, .rows, .leaders, .strip, .tiers-row, .award-chip, .achv-item, .shot { background: var(--bg); border: 1px solid var(--line); box-shadow: none; }
.panel, .rows, .leaders, .strip, .tiers-row { border-radius: var(--r-lg); }
.sec { margin-bottom: 26px; }
.sec-h { margin-bottom: 10px; align-items: center; }
.sec-h h2 { font-size: 14px; font-weight: 700; }
.sec-h .note { color: var(--muted); }
.leader { padding: 16px 18px; }
.leader .pos { font-size: 26px; }
.leader .sc { font-size: 22px; }
.strip .v { font-size: 22px; }

table.t th { font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 12px; }
table.t td { padding: 8px 12px; }
table.t tbody tr:hover td { background: var(--hover); }
table.t tr.me td, table.t tbody tr.me:hover td { background: var(--green-wash); }
.rw:hover { background: var(--hover); }
.rows > .rw:first-child { border-top-left-radius: var(--r-lg); border-top-right-radius: var(--r-lg); }
.rows > .rw:last-child { border-bottom-left-radius: var(--r-lg); border-bottom-right-radius: var(--r-lg); }
.meter .track i, .hbar .track i, .ladder .fill { background: var(--green); }

.tabs { gap: 20px; }
.tabs button { font-weight: 600; padding: 9px 2px 10px; border-bottom-width: 2px; }
.tabs button:hover { color: var(--fg); }
.tabs button.on { color: var(--fg); border-bottom-color: var(--green); }

.field > label { font-weight: 600; }
.rv .acts select, .cat-sel { border: 1px solid var(--line-2); border-radius: var(--r); background: var(--bg); color: var(--fg); }
#modal { background: rgba(0, 0, 0, 0.4); }
.modal { border-radius: 10px; padding: 22px 22px 18px; border: 1px solid var(--line); }
.modal h3 { font-size: 16px; font-weight: 700; }
.gate-wrap { background: var(--app); }
.gate-card { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 28px 26px; box-shadow: var(--shadow-card); }
.gate-card .btn { height: 36px; }

/* ============================================================== chat == */
#page.page-chat { overflow: hidden; display: flex; }
#page.page-chat .wrap { max-width: none; padding: 0; display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%; }
#page.page-chat .demo-note { margin: 8px 12px; }
.chat { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px minmax(0, 1fr); }
.chat-wait { padding: 40px 32px; color: var(--muted); }

/* list pane */
.chat-list { background: var(--pane); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.cl-head { display: flex; align-items: center; gap: 2px; padding: 12px 10px 6px 18px; }
.cl-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.cl-head .sp { flex: 1; }
.cl-head .icon-btn { width: 32px; height: 32px; color: var(--muted); }
.cl-head .icon-btn svg { width: 18px; height: 18px; }
.cl-head .icon-btn.on { color: var(--green-ink); background: var(--hover); }
.chat-find { display: flex; align-items: center; gap: 6px; margin: 2px 12px 6px; border: 1px solid var(--line-2); border-radius: var(--r); padding: 0 8px; background: var(--bg); }
.chat-find svg { width: 14px; height: 14px; color: var(--faint); flex: none; }
.chat-find input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--fg); font: inherit; font-size: 13px; padding: 6px 0; min-width: 0; }
.chat-find:focus-within { border-color: var(--green-ink); border-bottom-width: 2px; }
.chips { display: flex; gap: 6px; padding: 4px 16px 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: transparent; color: var(--fg-2); border-radius: 999px; padding: 2px 11px; font-size: 12px; font-weight: 600; line-height: 18px; }
.chip:hover { background: var(--hover); }
.chip.on { background: var(--green-wash); border-color: var(--green-ink); color: var(--green-ink); }
.chat-items { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.chat-sec { display: flex; align-items: center; gap: 4px; width: 100%; border: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 10px 8px 4px; text-align: left; }
.chat-sec svg { width: 13px; height: 13px; transition: transform 0.12s; }
.chat-sec.shut svg { transform: rotate(-90deg); }
.chat-sec:hover { color: var(--fg); }
.chat-sec .ro { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-weight: 500; color: var(--faint); font-size: 11.5px; }
.chat-sec .ro svg { width: 11px; height: 11px; transform: none !important; }
.chat-none { padding: 24px 12px; color: var(--faint); text-align: center; font-size: 12.5px; }
.chat-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; background: transparent; border-radius: var(--r); text-align: left; color: var(--fg); }
.chat-item:hover { background: var(--hover); }
.chat-item.on { background: var(--bg); box-shadow: var(--shadow-card); }
:root[data-theme="dark"] .chat-item.on { background: var(--select); box-shadow: none; }
.chat-item > .avatar, .chat-item > .pres-wrap .avatar, .chat-ic { width: 32px; height: 32px; font-size: 11.5px; }
.chat-item .t { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.chat-item .n { display: flex; align-items: baseline; gap: 6px; }
.chat-item .n b { flex: 1; min-width: 0; font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .n i { font-style: normal; font-size: 11.5px; color: var(--muted); flex: none; }
.chat-item .p { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); min-width: 0; }
.chat-item .pt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.new .n b, .chat-item.new .n i, .chat-item.new .pt { font-weight: 700; color: var(--fg); }
.chat-item.typing .pt { color: var(--green-ink); font-style: italic; }
.chat-item .flag { display: inline-flex; flex: none; }
.chat-item .flag svg { width: 12px; height: 12px; color: var(--faint); }
.chat-item .at { flex: none; color: #c4314b; font-weight: 800; font-size: 12.5px; }
.udot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.chat-item mark, .chat-items mark { background: rgba(232, 163, 23, 0.35); color: inherit; border-radius: 2px; }
.chat-ic { border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--green-wash); color: var(--green-ink); flex: none; }
.chat-ic.group { background: rgba(98, 100, 167, 0.16); color: #6264a7; }
:root[data-theme="dark"] .chat-ic.group { color: #a6a8e6; }
.chat-ic svg { width: 16px; height: 16px; }
.chat-ic.md { width: 32px; height: 32px; }
.chat-sub { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px 8px 4px; }
.chat-sub .faint { font-weight: 500; margin-left: auto; }
.chat-privacy { display: flex; gap: 7px; align-items: flex-start; font-size: 11px; color: var(--faint); padding: 8px 16px 10px; border-top: 1px solid var(--line); line-height: 1.4; }
.chat-privacy svg { width: 12px; height: 12px; flex: none; margin-top: 1px; }

/* presence dots */
.pres-wrap { position: relative; display: inline-flex; flex: none; }
.pres { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--pane); flex: none; }
.pres-wrap .pres { position: absolute; right: -2px; bottom: -2px; }
.pres.available { background: #6bb700; }
.pres.busy { background: #c4314b; }
.pres.dnd { background: #c4314b; box-shadow: inset 0 0 0 2px #c4314b, inset 0 0 0 3.5px #fff; }
.pres.away { background: #f8d22a; }
.pres.offline { background: var(--pane); box-shadow: inset 0 0 0 1.5px var(--faint); }
.chat-item.on .pres { border-color: var(--bg); }
.msg-av .pres { border-color: var(--app); }

/* conversation */
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--app); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 0 16px 0 20px; height: 56px; border-bottom: 1px solid var(--line); flex: none; background: var(--app); }
.chat-head .t { display: flex; flex-direction: column; min-width: 0; }
.chat-head .t b { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .t .sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .t .sub .pres { width: 8px; height: 8px; border: 0; }
.chat-head .sp { flex: 1; }
.chat-head .icon-btn { width: 32px; height: 32px; color: var(--muted); }
.chat-head .icon-btn svg { width: 17px; height: 17px; }
.chat-head .icon-btn.on { color: var(--green-ink); background: var(--green-wash); }
.ro-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); padding: 0 8px; }
.ro-tag svg { width: 12px; height: 12px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px 24px 10px; display: flex; flex-direction: column; }
.chat-empty { margin: auto; color: var(--muted); padding: 40px; text-align: center; }
.chat-day { display: flex; align-items: center; gap: 12px; margin: 14px 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.chat-day::before, .chat-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.msg { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; position: relative; }
.msg.cont { margin-top: 2px; }
.msg-av { width: 32px; flex: none; }
.msg-av .avatar { width: 32px; height: 32px; font-size: 11.5px; }
.msg-b { min-width: 0; max-width: min(680px, 80%); display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.msg-h { display: flex; gap: 8px; align-items: baseline; font-size: 12px; padding: 0 2px; }
.msg-h b { font-weight: 600; }
.msg-h .num { color: var(--muted); font-size: 11.5px; }
.bubble { background: var(--bg); border: 0; border-radius: var(--r); padding: 7px 12px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; font-size: 13.5px; user-select: text; box-shadow: var(--shadow-card); }
.bubble a { color: var(--green-ink); text-decoration: underline; text-underline-offset: 2px; }
.bubble.del { color: var(--faint); font-style: italic; background: transparent; box-shadow: none; padding-left: 2px; }
.bubble code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; background: var(--sunk); border-radius: 4px; padding: 1px 4px; }
.bubble .edited { font-size: 11px; color: var(--faint); margin-left: 8px; white-space: nowrap; }
.bubble.big { font-size: 32px; line-height: 1.15; background: transparent; box-shadow: none; padding: 0 2px; }
.msg.mine { justify-content: flex-end; }
.msg.mine .msg-b { align-items: flex-end; }
.msg.mine .bubble { background: var(--mine); box-shadow: none; }
.msg.mine .bubble.big, .msg.mine .bubble.del { background: transparent; }
.msg.pending .bubble { opacity: 0.6; }
.msg.imp .bubble { box-shadow: inset 3px 0 0 #c4314b, var(--shadow-card); }
.msg.at-me .bubble { box-shadow: inset 3px 0 0 var(--green), var(--shadow-card); }
.msg.flash .bubble { animation: msgflash 1.6s ease; }
@keyframes msgflash { 0%, 40% { box-shadow: 0 0 0 3px rgba(232, 163, 23, 0.55); } 100% { box-shadow: 0 0 0 0 transparent; } }
.imp-tag { font-size: 11px; font-weight: 700; color: #c4314b; padding: 0 2px; }
.mention { color: var(--green-ink); font-weight: 600; }
.mention.me { background: var(--green-wash); border-radius: 3px; padding: 0 2px; }
.quote { display: flex; flex-direction: column; gap: 1px; text-align: left; border: 0; border-left: 3px solid var(--line-2); background: var(--sunk); border-radius: 4px; padding: 5px 10px; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; max-width: 440px; min-width: 0; }
.msg.mine .quote { background: rgba(0, 0, 0, 0.04); }
:root[data-theme="dark"] .msg.mine .quote { background: rgba(255, 255, 255, 0.05); }
.quote b { color: var(--fg); font-size: 11.5px; font-weight: 600; }
.quote span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: pre-wrap; }
.quote.gone { cursor: default; font-style: italic; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; }
.react { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 0 8px 0 6px; height: 24px; font-size: 13px; cursor: pointer; color: var(--fg); }
.react .num { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.react:hover { border-color: var(--line-2); }
.react.mine { border-color: var(--green-ink); background: var(--green-wash); }
.react.mine .num { color: var(--green-ink); }
.seen { font-size: 11.5px; color: var(--muted); align-self: flex-end; margin-top: 3px; }
.seen.ok { color: var(--green-ink); }
.seen.bad { color: #c4314b; }
.seen a { color: inherit; font-weight: 600; }
.msg-tools { position: absolute; top: -18px; right: 8px; display: none; align-items: center; gap: 0; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 2px; box-shadow: var(--shadow-pop); z-index: 3; }
.msg:hover .msg-tools { display: flex; }
.msg-tools .qr { border: 0; background: transparent; font-size: 16px; width: 28px; height: 28px; border-radius: 4px; cursor: pointer; line-height: 1; transition: transform 0.1s; }
.msg-tools .qr:hover { background: var(--hover); transform: scale(1.15); }
.msg-tools .icon-btn { width: 28px; height: 28px; border-radius: 4px; }
.msg-tools .icon-btn svg { width: 15px; height: 15px; }
.chat-img { border: 1px solid var(--line); border-radius: var(--r); padding: 0; background: var(--bg); overflow: hidden; display: block; min-width: 120px; min-height: 60px; }
.chat-img img { display: block; max-width: 340px; max-height: 260px; }
.chat-img .faint { display: block; padding: 20px; font-size: 12px; }
.chat-file { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; background: var(--bg); }
.chat-file > svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.chat-file .t { display: flex; flex-direction: column; min-width: 0; }
.chat-file .t b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.chat-file .t .faint { font-size: 11px; }

/* message box, Teams-style: one rounded field, icons inside */
.chat-compose { padding: 0 24px 16px; flex: none; }
.chat-typing { height: 20px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.chat-typing .dots { display: inline-flex; gap: 3px; }
.chat-typing .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: tdot 1.2s infinite ease-in-out; }
.chat-typing .dots i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes tdot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-3px); opacity: 1; } }
.chat-ctx { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; min-width: 0; }
.chat-ctx > svg { width: 14px; height: 14px; flex: none; }
.chat-ctx .quote { flex: 1; max-width: none; }
.chat-ctx .icon-btn { width: 24px; height: 24px; }
.chat-ctx.edit { color: var(--green-ink); font-weight: 600; }
.chat-ctx .link-btn { font-size: 12px; }
.chat-att { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--bg); border-radius: var(--r); padding: 4px 4px 4px 10px; margin-bottom: 6px; font-size: 12px; max-width: 100%; }
.chat-att svg { width: 14px; height: 14px; }
.chat-att b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.chat-att .icon-btn { width: 22px; height: 22px; }
.chat-box { background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r); border-bottom: 2px solid var(--line-2); overflow: hidden; transition: border-color 0.12s; }
.chat-box:focus-within { border-bottom-color: var(--green); }
.chat-box.imp { border-left: 3px solid #c4314b; }
.fmt-bar { display: none; align-items: center; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.chat-box.fmt .fmt-bar { display: flex; }
.cb-row { display: flex; align-items: flex-end; gap: 4px; padding: 4px 4px 4px 12px; }
.cb-row textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: var(--fg); font: inherit; font-size: 13.5px; line-height: 1.45; padding: 6px 0; max-height: 200px; min-height: 30px; }
.cb-tools { display: flex; align-items: center; gap: 1px; flex: none; padding-bottom: 1px; }
.cb-sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 4px; }
.tb { min-width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); border-radius: var(--r); cursor: pointer; font: inherit; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.tb:hover { background: var(--hover); color: var(--fg); }
.tb.on { color: var(--green-ink); background: var(--green-wash); }
.tb svg { width: 17px; height: 17px; }
.tb.at { font-weight: 700; font-size: 15px; }
.tb.wide { font-size: 12px; font-weight: 600; }
.fmt-bar .tb.on { color: #c4314b; background: rgba(196, 49, 75, 0.1); }
.tb.send { color: var(--green-ink); }
.tb.send:hover { background: var(--green-wash); color: var(--green-ink); }
.chat-ro { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; padding: 12px 0 0; }
.chat-ro svg { width: 14px; height: 14px; }

/* popovers: emoji, menus, @mentions, status */
.chat-pop { position: fixed; z-index: 60; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); color: var(--fg); }
.chat-pop.emo { width: 340px; max-height: 320px; overflow-y: auto; padding: 4px 8px 8px; }
.emo-h { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 8px 4px 4px; position: sticky; top: -4px; background: var(--bg); }
.emo-row { display: grid; grid-template-columns: repeat(9, 1fr); }
.emo-row button { border: 0; background: transparent; font-size: 20px; height: 34px; border-radius: var(--r); cursor: pointer; padding: 0; }
.emo-row button:hover { background: var(--hover); }
.chat-pop .menu { display: flex; flex-direction: column; padding: 4px; min-width: 190px; }
.chat-pop .menu button, .men-list button { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 13px; text-align: left; padding: 7px 10px; border-radius: var(--r); cursor: pointer; }
.chat-pop .menu button:hover, .men-list button:hover, .men-list button.on { background: var(--hover); }
.chat-pop .menu button svg { width: 15px; height: 15px; color: var(--muted); }
.chat-pop .menu button.danger, .chat-pop .menu button.danger svg { color: #c4314b; }
.status-menu { min-width: 240px !important; }
.status-menu .menu-h { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.status-menu .menu-h span { display: flex; flex-direction: column; }
.status-menu .menu-h b { font-size: 13px; font-weight: 600; }
.status-menu .menu-h i { font-style: normal; font-size: 12px; color: var(--muted); }
.status-menu .pres { border-color: var(--bg); }
.status-menu button span:not(.ok) { flex: 1; }
.status-menu .ok { color: var(--green-ink); display: inline-flex; }
.status-menu .ok svg { color: var(--green-ink) !important; }
.menu-note { font-size: 11px; color: var(--faint); padding: 6px 10px 4px; border-top: 1px solid var(--line); margin-top: 4px; line-height: 1.4; }
.men-list { display: flex; flex-direction: column; padding: 4px; min-width: 220px; }
.men-list .avatar { width: 24px; height: 24px; font-size: 9.5px; }
.men-list .pres { border-color: var(--bg); }
main.on-chat .top { height: 36px; border-bottom: 0; background: var(--pane); }
main.on-chat .top h1 { display: none; }
main.on-chat #page.page-chat .demo-note { margin: 0 12px 8px; }
.rail-me .conn-dot:not(.off) { display: none; }
.rail-me .avatar { box-shadow: 0 0 0 1px var(--line-2); }

/* Linear-style buttons across the dashboard */
.nav button { border-radius: var(--r-btn); }
.nav button.on { background: var(--btn-2); box-shadow: 0 0 0 1px var(--btn-2-edge), 0 1px 2px rgba(0, 0, 0, 0.06); }
.demo-note select, .rv .acts select { height: 28px; border-radius: var(--r-btn-sm); border: 1px solid var(--btn-2-edge); background: var(--btn-2); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.cl-head .icon-btn, .chat-head .icon-btn { border-radius: var(--r-btn); }
.chip { border-radius: 999px; border-color: var(--btn-2-edge); background: var(--btn-2); color: var(--fg-2); font-weight: 550; padding: 3px 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); transition: background 0.12s, border-color 0.12s; cursor: pointer; }
.chip:hover { background: var(--btn-2-hover); border-color: var(--line-2); }
.chip.on { background: var(--green-wash); border-color: var(--green-ink); color: var(--green-ink); box-shadow: none; }
.tb { border-radius: var(--r-btn-sm); }
.tb.send { background: var(--brand); color: var(--brand-fg); border: 1px solid var(--brand-edge); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 1px 2px rgba(0, 0, 0, 0.12); min-width: 32px; }
.tb.send:hover { background: var(--brand-hover); color: var(--brand-fg); }
.msg-tools .icon-btn { border-radius: var(--r-btn-sm); }
.chat-pop .menu button, .men-list button, .emo-row button { border-radius: var(--r-btn-sm); }

/* =====================================================================
   Phone app (the web version): bottom tab bar like Teams mobile, one
   pane at a time, thumb-sized touch targets. Desktop never matches.
   ===================================================================== */
.nav .lbl, .more-btn { display: none; }
.chat-head .chat-back { display: none; }

@media (max-width: 760px) {
  html, body { height: 100%; overscroll-behavior: none; }
  body { font-size: 14px; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
  #app { display: flex; flex-direction: column-reverse; height: 100dvh; }
  main { height: auto; flex: 1; min-height: 0; }

  /* bottom bar */
  aside.rail {
    flex: none; flex-direction: row; align-items: stretch; justify-content: space-around; height: calc(58px + env(safe-area-inset-bottom));
    padding: 0 4px env(safe-area-inset-bottom); overflow: visible; background: var(--pane); border-top: 1px solid var(--line);
  }
  aside.rail .brand, aside.rail .rail-sep, aside.rail .side-sp, aside.rail .rail-me, aside.rail .nav button.nav-more, aside.rail [data-act="theme"] { display: none; }
  aside.rail .nav { display: contents; }
  aside.rail .nav button, aside.rail .more-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; flex: 1; width: auto; height: 100%;
    padding: 6px 0 4px; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--muted); position: relative; cursor: pointer;
  }
  aside.rail .nav button svg, aside.rail .more-btn svg { width: 22px; height: 22px; color: var(--muted); stroke-width: 1.7; }
  aside.rail .nav button.on, aside.rail .more-btn.on { background: transparent; box-shadow: none; color: var(--green-ink); }
  aside.rail .nav button.on svg, aside.rail .more-btn.on svg { color: var(--green-ink); stroke-width: 2.1; }
  aside.rail .nav button.on::before { display: none; }
  aside.rail .lbl { display: block; font-size: 10.5px; font-weight: 600; line-height: 1; }
  aside.rail .nav .count { top: 3px; right: calc(50% - 22px); box-shadow: 0 0 0 2px var(--pane); }

  /* header */
  .top { height: calc(48px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0 16px; gap: 10px; background: var(--pane); }
  .top h1 { font-size: 18px; white-space: nowrap; }
  .top .seg { overflow-x: auto; max-width: 62vw; scrollbar-width: none; }
  .top .seg::-webkit-scrollbar { display: none; }
  .top .seg button { padding: 5px 9px; font-size: 12.5px; white-space: nowrap; }
  .top .btn { display: none; }
  .wrap { padding: 14px 12px calc(28px + env(safe-area-inset-bottom)); max-width: none; }
  #page { -webkit-overflow-scrolling: touch; }
  .demo-note { gap: 8px; }
  .demo-note > span:nth-of-type(1) { display: none; }

  /* everything in one column */
  .cols, .c2, .c3, .c-wide, .form-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .leaders { grid-template-columns: 1fr; }
  .leader { padding: 12px 14px; gap: 12px; }
  .leader + .leader { border-left: 0 !important; border-top: 1px solid var(--line); }
  .tiers-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rv, .win-row { grid-template-columns: minmax(0, 1fr) !important; gap: 12px; }
  .hbar { grid-template-columns: 92px 1fr 28px; }
  .award-grid, .achv-grid, .shot-grid { grid-template-columns: minmax(0, 1fr); }
  .panel.pad { padding: 14px; }
  .sec { margin-bottom: 22px; }
  /* wide tables scroll sideways inside their card */
  .panel:has(> table.t), .panel:has(table.t) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.t th, table.t td { padding: 9px 10px; }
  .setting { gap: 12px; }
  .modal { width: 100vw; max-width: none; max-height: 92dvh; border-radius: 16px 16px 0 0; align-self: end; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
  #modal.open { place-items: end center; }
  .modal .foot .btn { flex: 1; height: 40px; }

  /* bigger touch targets */
  .btn { height: 38px; padding: 0 16px; font-size: 14px; }
  .btn.sm { height: 34px; font-size: 13.5px; }
  .input { height: 42px; font-size: 16px; } /* 16px stops iPhone zooming into fields */
  textarea, select, input { font-size: 16px; }

  /* chat: the list, or one chat full screen */
  main.on-chat .top { display: none; }
  #page.page-chat .wrap { padding: 0; }
  .chat { grid-template-columns: minmax(0, 1fr); }
  .chat.thread .chat-list { display: none; }
  .chat:not(.thread) .chat-main { display: none; }
  .chat-list { border-right: 0; padding-top: env(safe-area-inset-top); }
  .cl-head { padding: 10px 10px 6px 16px; }
  .cl-head h2 { font-size: 22px; }
  .cl-head .icon-btn { width: 40px; height: 40px; }
  .cl-head .icon-btn svg { width: 21px; height: 21px; }
  .chips { padding: 4px 16px 10px; }
  .chip { padding: 6px 14px; font-size: 13px; }
  .chat-item { padding: 10px 14px; gap: 12px; }
  .chat-item .avatar, .chat-item .chat-ic { width: 44px; height: 44px; }
  .chat-item .n b { font-size: 15px; }
  .chat-item .p { font-size: 13.5px; }
  .chat-privacy { padding-bottom: 10px; }
  .chat-main { padding-top: env(safe-area-inset-top); }
  .chat-head { height: 56px; padding: 0 6px 0 2px; gap: 8px; background: var(--pane); }
  .chat-head .chat-back { display: inline-grid; width: 40px; height: 40px; color: var(--fg); }
  .chat-head .chat-back svg { transform: rotate(90deg); width: 22px; height: 22px; }
  .chat-head .icon-btn { width: 40px; height: 40px; }
  .chat-head .t b { font-size: 15.5px; }
  .chat-msgs { padding-left: 10px !important; padding-right: 10px !important; }
  .msg .bubble { max-width: 84vw; font-size: 15px; }
  .msg-tools { display: none !important; }
  .msg.tools-open .msg-tools { display: flex !important; }
  .chat-compose { padding: 6px 8px calc(8px + env(safe-area-inset-bottom)) !important; }
  .chat-box textarea { font-size: 16px; }
  .cb-tools .tb { min-width: 36px; height: 36px; }
  .cb-tools .tb[data-act="chat-fmt-toggle"], .cb-tools .tb.at { display: none; }
  .chat-pop { max-width: calc(100vw - 16px); }
  body:has(.chat.thread) aside.rail { display: none; }

  /* the More sheet */
  #more-sheet { position: fixed; inset: 0; z-index: 60; }
  #more-sheet .more-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.35); }
  #more-sheet .more-card {
    position: absolute; left: 0; right: 0; bottom: 0; background: var(--bg); border-radius: 16px 16px 0 0; padding: 6px 8px calc(12px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; box-shadow: var(--shadow-pop); animation: sheet-up 0.18s ease-out;
  }
  #more-sheet .more-grip { grid-column: 1 / -1; width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 4px auto 8px; }
  #more-sheet button {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border: 0; border-radius: 12px;
    background: transparent; color: var(--fg); font: inherit; font-size: 12px; font-weight: 550; text-align: center; cursor: pointer;
  }
  #more-sheet button:active, #more-sheet button.on { background: var(--hover); }
  #more-sheet button.on { color: var(--green-ink); }
  #more-sheet button svg { width: 24px; height: 24px; color: var(--muted); stroke-width: 1.7; }
  #more-sheet button.on svg { color: var(--green-ink); }
  #more-sheet button .avatar { width: 24px; height: 24px; font-size: 9px; }
  #more-sheet .count { position: absolute; top: 6px; right: calc(50% - 22px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #c4314b; color: #fff; font-size: 9.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* web (browser) version on a big screen: no Windows title-bar space */
html.web .top { padding-right: 24px; }
html.web .brand, html.web .top { -webkit-app-region: none; }
@media (max-width: 760px) {
  .msg { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .msg.tools-open .msg-tools { top: auto; bottom: calc(100% - 6px); left: 0 !important; right: auto !important; padding: 4px; border-radius: 14px; }
  .msg.mine.tools-open .msg-tools { left: auto !important; right: 0 !important; }
  .msg.tools-open .msg-tools .qr { width: 38px; height: 38px; font-size: 22px; }
  .msg.tools-open .msg-tools .icon-btn { width: 36px; height: 36px; }
  .msg.tools-open .bubble { box-shadow: 0 0 0 2px var(--green); }
}
@media (max-width: 760px) {
  aside.rail .nav button[data-act="theme"] { display: none; }
  .sec-h { flex-wrap: wrap; row-gap: 4px; }
  .sec-h .note { flex-basis: 100%; order: 3; }
  .sec-h > :not(h2):not(.note):not(.sp) { flex-shrink: 1; min-width: 0; }
}
/* the app icon (as on the taskbar) instead of the bare D */
.brand img, aside.rail .brand img { width: 30px; height: 30px; border-radius: 7px; }
.gate-card .logo { width: 48px; height: 48px; border-radius: 11px; }
#more-sheet ~ .chat-pop, body > .chat-pop { z-index: 70; }

/* =====================================================================
   Linear-style spacing and type, desktop and phone: medium weights,
   one 4px grid, smaller headings, hairlines instead of heavy blocks.
   ===================================================================== */
.top { height: 48px; padding-left: 24px; gap: 12px; }
.top h1 { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.wrap { padding: 20px 24px 40px; max-width: 1200px; }
.demo-note { margin-bottom: 16px; font-size: 12.5px; }
.sec { margin-bottom: 24px; }
.sec-h { margin-bottom: 8px; gap: 10px; }
.sec-h h2 { font-size: 13px; font-weight: 600; letter-spacing: -0.005em; }
.sec-h .note { font-size: 12px; color: var(--faint); }
.cols { gap: 16px; }
.panel { border-radius: var(--r-lg); }
.panel.pad { padding: 14px 16px; }
.muted, .hint, .d { color: var(--muted); }

/* the top three */
.leaders { border-radius: var(--r-lg); margin-bottom: 20px; }
.leader { padding: 14px 16px; gap: 12px; }
.leader .pos { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; width: 18px; }
.leader .sc { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.leader b, .leader .nm { font-weight: 600; }
.strip .v { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.me-head h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
.target .v { font-size: 18px; font-weight: 600; }
.level h3 { font-size: 15px; font-weight: 600; }
.rkn.p1, .rkn.p2, .rkn.p3 { font-weight: 600; }

/* tables: compact rows, quiet headers */
table.t th { font-size: 12px; font-weight: 500; color: var(--faint); padding: 8px 12px; letter-spacing: 0; }
table.t td { padding: 7px 12px; font-size: 13px; }
table.t td b { font-weight: 600; }

/* tabs, modals, sign-in */
.tabs button { font-size: 13px; font-weight: 500; padding: 8px 2px 9px; }
.tabs button.on { font-weight: 600; }
.modal { border-radius: 12px; padding: 20px 20px 16px; }
.modal h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.gate-card h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
.setting b { font-weight: 500; }
.setting .d { font-size: 12px; }

/* chat */
.cl-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.chat-sec { font-size: 12px; font-weight: 500; }
.chat-item .n b { font-weight: 500; }
.chat-item.new .n b, .chat-item.new .n i, .chat-item.new .pt { font-weight: 600; }
.chat-head .t b { font-size: 14px; font-weight: 600; }
.msg .who b, .msg .nm { font-weight: 600; }
.bubble { font-size: 13.5px; line-height: 1.45; }
.imp-tag, .tb.at { font-weight: 600; }

@media (max-width: 760px) {
  body { font-size: 14px; }
  .top h1 { font-size: 17px; font-weight: 600; }
  .wrap { padding: 12px 12px calc(24px + env(safe-area-inset-bottom)); }
  .sec { margin-bottom: 20px; }
  .cl-head h2 { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
  .chat-head .t b { font-size: 15.5px; }
  .bubble { font-size: 15px; }
  .chat-item .n b { font-size: 15px; }
}
@media (max-width: 760px) {
  .leader { padding: 10px 12px; }
  .leader .medal { width: 44px !important; height: 44px !important; }
  .leader .avatar { width: 36px; height: 36px; font-size: 12.5px; }
  .leader .sc { font-size: 18px; }
}

/* Screenshot thumbnails: a quiet placeholder until the picture arrives. */
.shot-ph, .shot-na { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 6px; background: var(--line); }
.shot-ph { background: linear-gradient(90deg, var(--line) 0%, var(--line-2, var(--line)) 50%, var(--line) 100%); background-size: 200% 100%; animation: shot-wait 1.2s ease-in-out infinite; }
.shot-na { display: grid; place-items: center; font-size: 12px; }
@keyframes shot-wait { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .shot-ph { animation: none; } }

/* Sign in: no box, a clear brand line, roomy fields (Linear-style). */
#app.gate .gate-wrap { padding: 32px 24px; }
.gate-card.signin { width: min(360px, 100%); background: transparent; border: 0; box-shadow: none; padding: 0; }
.gate-card.signin .gate-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 44px; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; color: var(--fg); }
.gate-card.signin .gate-brand .logo { width: 28px; height: 28px; border-radius: 7px; }
.gate-card.signin h1 { margin: 0 0 6px; font-size: 24px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; }
.gate-card.signin > p { margin: 0 0 28px; font-size: 13.5px; color: var(--muted); }
.gate-card.signin form { gap: 16px; }
.gate-card.signin .field { gap: 6px; }
.gate-card.signin .field label { font-size: 12.5px; font-weight: 500; color: var(--fg-2); }
.gate-card.signin .input { height: 40px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.gate-card.signin .btn[type="submit"] { height: 40px; margin-top: 6px; font-size: 14px; }
.gate-card.signin .btn[disabled] { opacity: 0.7; cursor: default; }
.pw-wrap { position: relative; }
.pw-wrap .input { width: 100%; padding-right: 64px; }
.pw-show { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; }
.pw-show:hover { background: var(--hover); color: var(--fg); }
.gate-card.signin .err { margin: 0; }
.gate-foot { margin-top: 24px; font-size: 12.5px; color: var(--faint); }
.gate-card.signin .alt { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .gate-card.signin .input { font-size: 16px; }
  .gate-card.signin .gate-brand { margin-bottom: 36px; }
}

/* Message tools sit on the message itself: from the bubble's left edge for
   others, its right edge for mine, just over its top. */
.msg-b { position: relative; }
.msg-tools { top: -20px; left: 0; right: auto; white-space: nowrap; }
.msg.mine .msg-tools { left: auto; right: 0; }
