/* ============ Stride — universal dark theme (design tokens) ============ */
:root {
  --bg: #0f1117; --surface: #171a22; --surface-2: #1e222d; --surface-3: #262b38;
  --border: #2a2f3e; --text: #e8eaf0; --muted: #8a91a5;
  --accent: #6c5ce7; --accent-soft: rgba(108, 92, 231, .16);
  --success: #00b894; --warn: #fdcb6e; --danger: #e17055; --info: #0984e3;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 9px 12px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label { font-size: 12px; color: var(--muted); display: block; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .4px; }
a { color: var(--accent); text-decoration: none; }

/* ---- buttons / chips ---- */
.btn { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); padding: 8px 14px; border-radius: var(--radius-sm); font-size: 14px; transition: filter .15s, transform .1s; }
.btn:hover { filter: brightness(1.2); }
.btn:active { transform: scale(.97); }
.btn-accent { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.btn-success { background: var(--success); border-color: transparent; color: #06281f; font-weight: 600; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.chip-open { background: rgba(9, 132, 227, .18); color: #74b9ff; }
.chip-in_progress { background: rgba(253, 203, 110, .15); color: var(--warn); }
.chip-closed { background: rgba(0, 184, 148, .15); color: var(--success); }
.chip-role { background: var(--accent-soft); color: var(--accent); }

/* ---- layout shell ---- */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 4px 10px 18px; }
.logo img, .logo svg { width: 30px; height: 30px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted); font-size: 14px; font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .ico { width: 20px; text-align: center; }
.nav .badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; border-radius: 99px; padding: 1px 7px; }
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 17px; flex: 1; }
.content { padding: 24px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ---- XP / game ---- */
.xp { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.xp-level { background: linear-gradient(135deg, var(--accent), #a29bfe); color: #fff; font-weight: 800; font-size: 12px; padding: 4px 9px; border-radius: 8px; white-space: nowrap; box-shadow: 0 0 12px var(--accent-soft); }
.xp-track { flex: 1; height: 9px; background: var(--surface-3); border-radius: 99px; overflow: hidden; min-width: 90px; }
.xp-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #a29bfe); border-radius: 99px; transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.xp-label { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 1000; }
.levelup { position: fixed; inset: 0; background: rgba(10, 11, 16, .8); display: grid; place-items: center; z-index: 999; animation: fadein .3s; }
.levelup-card { background: var(--surface); border: 1px solid var(--accent); border-radius: 20px; padding: 40px 56px; text-align: center; box-shadow: 0 0 60px var(--accent-soft); animation: pop .45s cubic-bezier(.2, 1.4, .3, 1); }
.levelup-burst { font-size: 48px; color: var(--accent); animation: bounce 1s infinite alternate; }
.levelup-card h2 { letter-spacing: 4px; margin: 8px 0; }
.levelup-lv { font-size: 30px; font-weight: 800; color: var(--accent); margin-bottom: 8px; }
.levelup-card p { color: var(--muted); margin-bottom: 18px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes fadein { from { opacity: 0; } }
@keyframes bounce { to { transform: translateY(-8px); } }

/* ---- cards / grids ---- */
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.stat { font-size: 30px; font-weight: 800; }
.stat small { font-size: 13px; color: var(--muted); font-weight: 400; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex-shrink: 0; font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---- task board ---- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 120px; }
.col h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; padding: 2px 6px 10px; display: flex; justify-content: space-between; }
.col-todo h4 { color: #74b9ff; } .col-working h4 { color: var(--warn); }
.col-stuck h4 { color: var(--danger); } .col-done h4 { color: var(--success); }
.task { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; animation: slidein .25s; }
.task .pts { float: right; color: var(--accent); font-weight: 700; font-size: 12px; }
.task .t-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.task .t-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
@keyframes slidein { from { transform: translateY(6px); opacity: 0; } }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--surface-2); }

/* ---- roster ---- */
.roster-grid { overflow-x: auto; }
.roster-cell { min-width: 86px; text-align: center; border-radius: 6px; padding: 6px 4px; font-size: 12px; cursor: pointer; border: 1px dashed var(--border); color: var(--muted); user-select: none; }
.roster-cell.filled { border-style: solid; color: #fff; font-weight: 600; }

/* ---- leaderboard ---- */
.lb-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 6px; background: var(--surface); border: 1px solid var(--border); animation: slidein .3s; }
.lb-rank { font-size: 18px; font-weight: 800; width: 34px; text-align: center; }
.lb-row.top1 { border-color: #fdcb6e; box-shadow: 0 0 18px rgba(253, 203, 110, .12); }
.lb-row.top2 { border-color: #b2bec3; } .lb-row.top3 { border-color: #e17055; }
.lb-info { flex: 1; min-width: 0; }
.lb-pts { font-weight: 800; color: var(--accent); white-space: nowrap; }

/* ---- notices ---- */
.notice { border-left: 3px solid var(--accent); }
.notice.unacked { border-left-color: var(--danger); box-shadow: 0 0 14px rgba(225, 112, 85, .08); }

/* ---- toast / overlay / modal ---- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--surface-3); border: 1px solid var(--border); padding: 11px 20px; border-radius: 10px; opacity: 0; transition: all .3s; z-index: 1001; box-shadow: var(--shadow); font-size: 14px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-err { border-color: var(--danger); }
.modal-bg { position: fixed; inset: 0; background: rgba(10, 11, 16, .7); display: grid; place-items: center; z-index: 100; animation: fadein .2s; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); animation: pop .3s cubic-bezier(.2, 1.2, .3, 1); }
.modal h2 { font-size: 17px; margin-bottom: 6px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1100px 500px at 50% -10%, var(--accent-soft), transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 34px; box-shadow: var(--shadow); animation: pop .4s cubic-bezier(.2, 1.2, .3, 1); }
.login-card .logo { justify-content: center; font-size: 22px; padding-bottom: 6px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: none; border: none; color: var(--muted); padding: 10px 16px; font-size: 14px; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---- header bits ---- */
.bell { position: relative; background: none; border: none; font-size: 19px; color: var(--muted); padding: 6px; }
.bell .badge { position: absolute; top: 0; right: -2px; background: var(--danger); color: #fff; border-radius: 99px; font-size: 10px; padding: 1px 5px; font-weight: 700; }
.notif-panel { position: absolute; right: 16px; top: 56px; width: 340px; max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 50; padding: 8px; }
.notif-item { padding: 10px 12px; border-radius: 8px; font-size: 13.5px; }
.notif-item.unread { background: var(--accent-soft); }
.notif-item .muted { font-size: 11.5px; }

/* ---- mobile ---- */
/* ---- mobile bar + More sheet ---- */
.mobilebar { display: none; }
.more-sheet { display: none; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobilebar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 4px 6px calc(6px + env(safe-area-inset-bottom)); }
  .mobilebar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10px; color: var(--muted); padding: 6px 2px; border-radius: 10px; position: relative; font-weight: 500; }
  .mobilebar a.active { color: var(--accent); background: var(--accent-soft); }
  .mobilebar a .ico { font-size: 19px; }
  .mobilebar .badge { position: absolute; top: 0; right: 18%; background: var(--danger); color: #fff;
    font-size: 10px; border-radius: 99px; padding: 1px 5px; font-weight: 700; }
  .more-sheet { display: block; position: fixed; inset: 0; z-index: 60; background: rgba(10,11,16,.6);
    opacity: 0; pointer-events: none; transition: opacity .25s; }
  .more-sheet.open { opacity: 1; pointer-events: auto; }
  .sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface);
    border-top: 1px solid var(--border); border-radius: 22px 22px 0 0;
    padding: 10px 16px calc(86px + env(safe-area-inset-bottom));
    transform: translateY(100%); transition: transform .35s cubic-bezier(.22, 1.2, .36, 1); }
  .more-sheet.open .sheet-panel { transform: translateY(0); }
  body.lively .more-sheet.open .sheet-panel { transition-timing-function: cubic-bezier(.34, 1.56, .64, 1); }
  .sheet-handle { width: 42px; height: 4px; border-radius: 99px; background: var(--border); margin: 4px auto 14px; }
  .sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .sheet-tile { display: flex; flex-direction: column; align-items: center; gap: 8px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px;
    padding: 18px 8px; color: var(--text); font-size: 12.5px; font-weight: 600;
    transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), border-color .15s; }
  .sheet-tile:active { transform: scale(.92); }
  .sheet-tile.active { border-color: var(--accent); color: var(--accent); }
  .tile-ico { font-size: 30px; }
  body.lively .more-sheet.open .sheet-tile { animation: lv-tilein .4s cubic-bezier(.34, 1.56, .64, 1) backwards; }
  body.lively .more-sheet.open .sheet-tile:nth-child(2) { animation-delay: .04s; }
  body.lively .more-sheet.open .sheet-tile:nth-child(3) { animation-delay: .08s; }
  body.lively .more-sheet.open .sheet-tile:nth-child(4) { animation-delay: .12s; }
  body.lively .more-sheet.open .sheet-tile:nth-child(5) { animation-delay: .16s; }
  body.lively .more-sheet.open .sheet-tile:nth-child(6) { animation-delay: .2s; }
  body.lively .more-sheet.open .sheet-tile:nth-child(7) { animation-delay: .24s; }
  body.lively .more-sheet.open .sheet-tile:nth-child(8) { animation-delay: .28s; }
  .content { padding: 16px 14px 90px; }
  .board { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; }
  .xp { min-width: 120px; }
  .xp-label { display: none; }
}
@keyframes lv-tilein { from { opacity: 0; transform: translateY(16px) scale(.85); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* badges */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.badge-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 8px; text-align: center; opacity: .55; transition: transform .15s; }
.badge-tile.unlocked { opacity: 1; border-color: var(--accent); box-shadow: 0 0 14px var(--accent-soft); }
.badge-tile:hover { transform: translateY(-2px); }
.badge-icon { font-size: 28px; margin-bottom: 4px; }
.badge-name { font-size: 12px; font-weight: 600; }
/* chat */
.chat-wrap { display: grid; grid-template-columns: 210px 1fr; gap: 14px; height: calc(100vh - 160px); min-height: 380px; }
.chat-channels { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.chat-chan { display: flex; justify-content: space-between; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; text-align: left; }
.chat-chan.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.chat-main { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { display: flex; gap: 8px; max-width: 85%; animation: slidein .2s; }
.chat-msg.mine { flex-direction: row-reverse; align-self: flex-end; }
.chat-bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.chat-msg.mine .chat-bubble { background: var(--accent-soft); border-color: var(--accent); }
.chat-meta { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
@media (max-width: 820px) {
  .chat-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: calc(100vh - 220px); }
  .chat-channels { flex-direction: row; overflow-x: auto; }
  .chat-chan { flex-shrink: 0; }
}
