/* ==========================================================================
   Bachelor Hub — design system
   Feature-specific styles live in /assets/css/<module>.css and are imported
   at the bottom of this file. Use the tokens below; never hard-code colors.
   ========================================================================== */

/* Feature module styles (must stay at the top: @import is ignored after rules) */
@import url("board.css");
@import url("supervisor.css");
@import url("knowledge.css");
@import url("planning.css");
@import url("library.css");
@import url("chat.css");
@import url("settings.css");

:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --sidebar-w: 248px;
  --topbar-h: 56px;
  --content-max: 1200px;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-fast: 120ms;
  --t: 200ms;

  /* light */
  --bg: #f7f7f8;
  --bg-elev: #ffffff;
  --bg-sunken: #f0f0f2;
  --bg-hover: rgba(15, 15, 30, .045);
  --bg-active: rgba(15, 15, 30, .075);
  --sidebar-bg: #fbfbfc;
  --border: #e6e6ea;
  --border-strong: #d4d4da;
  --text: #17171c;
  --text-2: #55555f;
  --text-3: #8a8a96;
  --accent: #5b4cf0;
  --accent-hover: #4b3cdf;
  --accent-soft: rgba(91, 76, 240, .10);
  --accent-text: #4a3bd6;
  --on-accent: #ffffff;
  --focus: 0 0 0 3px rgba(91, 76, 240, .25);
  --shadow-sm: 0 1px 2px rgba(16, 16, 32, .05);
  --shadow: 0 1px 2px rgba(16, 16, 32, .04), 0 4px 16px rgba(16, 16, 32, .06);
  --shadow-lg: 0 8px 28px rgba(16, 16, 32, .14), 0 2px 6px rgba(16, 16, 32, .06);
  --overlay: rgba(10, 10, 20, .38);

  --gray: #6b6b78;   --gray-soft: rgba(107, 107, 120, .12);
  --blue: #2f6fec;   --blue-soft: rgba(47, 111, 236, .11);
  --green: #16a34a;  --green-soft: rgba(22, 163, 74, .11);
  --yellow: #b7791f; --yellow-soft: rgba(234, 179, 8, .15);
  --orange: #e8590c; --orange-soft: rgba(232, 89, 12, .11);
  --red: #dc2626;    --red-soft: rgba(220, 38, 38, .10);
  --purple: #7c3aed; --purple-soft: rgba(124, 58, 237, .11);
  --pink: #db2777;   --pink-soft: rgba(219, 39, 119, .10);
  --teal: #0d9488;   --teal-soft: rgba(13, 148, 136, .11);

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b0b0f;
  --bg-elev: #141419;
  --bg-sunken: #0f0f13;
  --bg-hover: rgba(255, 255, 255, .05);
  --bg-active: rgba(255, 255, 255, .085);
  --sidebar-bg: #0e0e12;
  --border: #24242c;
  --border-strong: #33333d;
  --text: #ececf1;
  --text-2: #a5a5b2;
  --text-3: #6e6e7c;
  --accent: #7c6cff;
  --accent-hover: #8f81ff;
  --accent-soft: rgba(124, 108, 255, .16);
  --accent-text: #a89eff;
  --on-accent: #ffffff;
  --focus: 0 0 0 3px rgba(124, 108, 255, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4);
  --overlay: rgba(0, 0, 0, .6);

  --gray: #9a9aa8;   --gray-soft: rgba(154, 154, 168, .14);
  --blue: #6b9cff;   --blue-soft: rgba(107, 156, 255, .15);
  --green: #4ade80;  --green-soft: rgba(74, 222, 128, .13);
  --yellow: #facc15; --yellow-soft: rgba(250, 204, 21, .13);
  --orange: #fb923c; --orange-soft: rgba(251, 146, 60, .14);
  --red: #f87171;    --red-soft: rgba(248, 113, 113, .14);
  --purple: #b79aff; --purple-soft: rgba(183, 154, 255, .15);
  --pink: #f472b6;   --pink-soft: rgba(244, 114, 182, .14);
  --teal: #2dd4bf;   --teal-soft: rgba(45, 212, 191, .13);

  color-scheme: dark;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
[hidden] { display: none !important; }
/* :where() = zero specificity, so module icon sizes (".x svg", imported before this file's rules) still win */
:where(i[data-lucide], svg.lucide) { width: 16px; height: 16px; stroke-width: 2; flex-shrink: 0; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- boot ---------- */
.boot-loader { position: fixed; inset: 0; display: grid; place-items: center; }

/* ==========================================================================
   Layout
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  transition: transform var(--t) var(--ease);
}
.sidebar-head { padding: 14px 12px 8px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--radius);
  color: var(--text); text-decoration: none !important;
}
.brand-logo {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #8b6cff, #4f46e5);
  box-shadow: 0 2px 8px rgba(91, 76, 240, .35);
}
.brand-logo i, .brand-logo svg { width: 17px; height: 17px; }
.brand-text { min-width: 0; }
.brand-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-search {
  margin: 6px 12px 4px; display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-3);
  font-size: 13px; text-align: left; width: calc(100% - 24px);
  transition: border-color var(--t-fast);
}
.sidebar-search:hover { border-color: var(--border-strong); }
.sidebar-search span { flex: 1; }
@media (hover: none) and (pointer: coarse) { .sidebar-search .kbd { display: none; } }

.nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; }
.nav-section { margin-top: 16px; }
.nav-section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 0 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
  text-decoration: none !important;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-active); color: var(--text); }
.nav-item.active i, .nav-item.active svg { color: var(--accent-text); }
.nav-item .nav-count { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-weight: 500; }

.sidebar-foot { border-top: 1px solid var(--border); padding: 10px 12px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 8px; border-radius: var(--radius-sm); border: 0; background: none; text-align: left;
}
.user-chip:hover { background: var(--bg-hover); }
.user-chip-text { min-width: 0; flex: 1; }
.user-chip-name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-mail { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t);
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13.5px; min-width: 0; }
.topbar-crumbs a { color: var(--text-3); }
.topbar-crumbs .current { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }
.topbar .menu-btn { display: none; }

.content { flex: 1; width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 8px 24px 64px; }
.content.full { max-width: none; }
.content.flush { padding: 0; max-width: none; }
.view-enter { animation: viewIn .22s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.sidebar-backdrop { display: none; }

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .app-shell.nav-open .sidebar { transform: none; }
  .app-shell.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 35; animation: fadeIn var(--t) ease; }
  .main { margin-left: 0; }
  .topbar { padding: 0 12px; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 4px 16px 48px; }
}

/* ==========================================================================
   Page header
   ========================================================================== */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 20px 0 20px; }
.page-header-text { min-width: 0; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.page-subtitle { color: var(--text-2); margin-top: 4px; font-size: 14px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-title .muted { font-weight: 400; }
@media (max-width: 640px) {
  .page-header { margin: 12px 0 16px; align-items: stretch; flex-direction: column; }
  .page-title { font-size: 21px; }
  .page-actions > .btn { flex: 1; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
  font-weight: 500; font-size: 13.5px; white-space: nowrap; user-select: none;
  box-shadow: var(--shadow-sm);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  text-decoration: none !important;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.loading { opacity: .6; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(60, 40, 200, .25), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); background: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: transparent; }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); box-shadow: none; }
.btn-soft:hover { background: var(--accent-soft); filter: brightness(.97); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14.5px; border-radius: var(--radius); }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-block { width: 100%; }
.btn.loading::after { content: ""; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.active { background: var(--bg-active); color: var(--text); }

/* ==========================================================================
   Forms
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.label, .field > label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 7px 11px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text);
  font-size: 14px; line-height: 1.45;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.textarea { resize: vertical; min-height: 88px; }
.textarea.mono { font-family: var(--mono); font-size: 13px; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8a96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.input-sm, .select-sm { min-height: 30px; height: 30px; padding: 4px 9px; font-size: 13px; }
.select-sm { padding-right: 28px; }
.input-icon { position: relative; }
.input-icon > i, .input-icon > svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon > .input { padding-left: 34px; }
.input-ghost { border-color: transparent; background: transparent; box-shadow: none; padding-left: 0; }
.input-ghost:hover { border-color: transparent; }
.input-ghost:focus { box-shadow: none; border-color: transparent; }
.title-input { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; } }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* markdown editor (ui.mdEditor) */
.md-editor { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elev); overflow: hidden; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.md-editor:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.md-editor-bar { display: flex; align-items: center; gap: 2px; padding: 4px; border-bottom: 1px solid var(--border); background: var(--bg-sunken); }
.md-editor-bar button { border: 0; background: none; padding: 4px 10px; border-radius: var(--radius-xs); font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.md-editor-bar button.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }
.md-editor-bar .md-hint { margin-left: auto; font-size: 11.5px; color: var(--text-3); padding-right: 6px; }
.md-editor textarea { display: block; width: 100%; border: 0; outline: none; resize: vertical; padding: 12px 14px; min-height: 160px; background: transparent; font-size: 14px; line-height: 1.6; }
.md-editor .md-preview { padding: 12px 14px; min-height: 160px; }

/* ==========================================================================
   Surfaces
   ========================================================================== */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad, .card-body { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); }
.card-hover { transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast); cursor: pointer; }
.card-hover:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.surface { background: var(--bg-sunken); border-radius: var(--radius); padding: 14px; }

.stat { padding: 16px 18px; }
.stat-label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); transition: background var(--t-fast); }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--bg-hover); }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr:hover { background: var(--bg-hover); }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; border: 0; background: none; color: var(--text-2); font-weight: 500; font-size: 13.5px; white-space: nowrap; text-decoration: none !important; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.tab .count { font-size: 11.5px; color: var(--text-3); background: var(--bg-active); padding: 0 6px; border-radius: 99px; }

/* segmented control */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.segmented button { border: 0; background: none; padding: 4px 10px; border-radius: var(--radius-xs); font-size: 12.5px; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.segmented button.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }

/* badges & chips */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 500; white-space: nowrap; background: var(--gray-soft); color: var(--gray); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge i, .badge svg { width: 12px; height: 12px; }
.badge-gray { background: var(--gray-soft); color: var(--gray); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-pink { background: var(--pink-soft); color: var(--pink); }
.badge-teal { background: var(--teal-soft); color: var(--teal); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--bg-elev); font-size: 12.5px; color: var(--text-2); }
button.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.kbd { display: inline-flex; align-items: center; height: 19px; padding: 0 5px; border-radius: 4px; border: 1px solid var(--border); border-bottom-width: 2px; font-family: var(--font); font-size: 11px; color: var(--text-3); background: var(--bg-elev); }

/* avatars */
.avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 600; color: #fff; overflow: hidden; background: var(--accent); object-fit: cover; }
.avatar-xs { width: 18px; height: 18px; font-size: 9px; }
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar-lg { width: 40px; height: 40px; font-size: 15px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--bg-elev); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }

/* empty state */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 14px; }
.empty-icon i, .empty-icon svg { width: 22px; height: 22px; }
.empty-title { font-weight: 600; color: var(--text); font-size: 15px; }
.empty-text { margin-top: 4px; max-width: 380px; font-size: 13.5px; }
.empty .btn { margin-top: 16px; }

/* loading */
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.skeleton { background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 37%, var(--bg-sunken) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: var(--radius-sm); }
.skeleton-line { height: 12px; margin: 10px 0; }
.skeleton-block { height: 80px; border-radius: var(--radius); }
.page-loading { padding: 24px 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* progress */
.progress { height: 6px; background: var(--bg-active); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s var(--ease); }

/* ==========================================================================
   Overlays: modal, menu, toast
   ========================================================================== */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: var(--overlay); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; overflow-y: auto; animation: fadeIn .15s ease; }
.modal { width: 100%; max-width: 520px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: modalIn .2s var(--ease); display: flex; flex-direction: column; max-height: 84vh; }
.modal-sm { max-width: 400px; }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1000px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-weight: 600; font-size: 15px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.modal-backdrop.side { padding: 0; justify-content: flex-end; align-items: stretch; }
.modal-backdrop.side .modal { max-width: 640px; max-height: none; height: 100%; border-radius: 0; border-width: 0 0 0 1px; animation: sideIn .25s var(--ease); }
.modal-backdrop.closing { animation: fadeOut .15s ease forwards; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes sideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal-lg, .modal-xl, .modal-sm { max-width: none; max-height: 92dvh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; animation: sheetIn .25s var(--ease); }
  .modal-backdrop.side .modal { max-width: none; height: 100%; border-radius: 0; }
  .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
}
@keyframes sheetIn { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.menu { position: fixed; z-index: 120; min-width: 190px; max-width: 300px; padding: 5px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: modalIn .12s var(--ease); }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: var(--radius-sm); font-size: 13.5px; color: var(--text); text-align: left; text-decoration: none !important; }
.menu-item:hover, .menu-item.focus { background: var(--bg-hover); }
.menu-item i, .menu-item svg { color: var(--text-2); }
.menu-item.danger { color: var(--red); }
.menu-item.danger i, .menu-item.danger svg { color: var(--red); }
.menu-item .check-mark { margin-left: auto; color: var(--accent-text); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 0; }
.menu-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; padding: 6px 10px 4px; }

.toasts { position: fixed; z-index: 200; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px; padding: 11px 14px; border-radius: var(--radius); background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; animation: toastIn .25s var(--ease); }
.toast.success i, .toast.success svg { color: #4ade80; }
.toast.error i, .toast.error svg { color: #f87171; }
.toast.out { animation: toastOut .2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }
@media (max-width: 640px) { .toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); } .toast { max-width: none; } }

/* ==========================================================================
   Markdown content
   ========================================================================== */
.prose { font-size: 14.5px; line-height: 1.7; color: var(--text); overflow-wrap: anywhere; }
.prose > *:first-child { margin-top: 0; }
.prose > *:last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table { margin: 0 0 .9em; }
.prose h1 { font-size: 1.6em; margin: 1.2em 0 .5em; font-weight: 700; }
.prose h2 { font-size: 1.3em; margin: 1.3em 0 .5em; font-weight: 650; }
.prose h3 { font-size: 1.1em; margin: 1.2em 0 .4em; font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: .2em 0; }
.prose li > input[type="checkbox"] { margin: 0 8px 0 0; vertical-align: -2px; accent-color: var(--accent); }
.prose li:has(> input[type="checkbox"]) { list-style: none; }
.prose ul:has(> li > input[type="checkbox"]) { padding-left: .4em; }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--bg-active); padding: .12em .4em; border-radius: 5px; }
.prose pre { background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; font-size: 12.5px; }
.prose blockquote { border-left: 3px solid var(--accent); padding: 2px 0 2px 14px; color: var(--text-2); }
.prose table { border-collapse: collapse; width: 100%; font-size: .93em; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.prose th { background: var(--bg-sunken); font-weight: 600; }
.prose img { border-radius: var(--radius); }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose hr { margin: 1.4em 0; }
.prose-sm { font-size: 13.5px; line-height: 1.6; }

/* ==========================================================================
   Utilities
   ========================================================================== */
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: 12.5px; }
.xsmall { font-size: 11.5px; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.text-red { color: var(--red); } .text-green { color: var(--green); } .text-yellow { color: var(--yellow); } .text-accent { color: var(--accent-text); }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; } }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.hide-mobile { }
@media (max-width: 640px) { .hide-mobile { display: none !important; } }
.show-mobile { display: none !important; }
@media (max-width: 640px) { .show-mobile { display: initial !important; } }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
