/* Funcell Knowledge Hub — light, professional UI */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --surface-3: #eceef2;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-ring: rgba(79, 70, 229, .18);
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --success: #079455;
  --success-soft: #ecfdf3;
  --warning: #dc6803;
  --code-bg: #f8f9fb;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 8px 24px -6px rgba(16, 24, 40, .12), 0 2px 6px rgba(16, 24, 40, .05);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .22);
  --sidebar-w: 256px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img, video { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; color: var(--text); letter-spacing: -0.015em; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
code, pre, .mono { font-family: var(--mono); }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }

.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }

/* ───────── Layout shell ───────── */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
  overflow-y: auto;
}
.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.content { max-width: 1200px; margin: 0 auto; padding: 32px 40px 96px; }
.mobile-bar { display: none; }
body.is-auth .sidebar, body.is-auth .mobile-bar { display: none; }
body.is-auth .main { margin-left: 0; }
body.is-auth .content { max-width: none; padding: 0; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 4px 8px 16px; }
.brand:hover { color: var(--text); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #6366f1, #4338ca); display: grid; place-items: center; box-shadow: inset 0 -1px 0 rgba(0,0,0,.15), 0 1px 2px rgba(67,56,202,.35); flex: none; }
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.1; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted); font-weight: 500; }

.sb-new { width: 100%; margin-bottom: 16px; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--text-2); font-weight: 500; font-size: 14px; position: relative;
}
.sb-link .icon { color: var(--faint); }
.sb-link:hover { background: var(--surface-2); color: var(--text); }
.sb-link.active { background: var(--accent-soft); color: var(--accent-hover); }
.sb-link.active .icon { color: var(--accent); }
.sb-link .count { margin-left: auto; }
.sb-section { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 20px 10px 6px; display: flex; align-items: center; }
.sb-section a { margin-left: auto; color: var(--faint); display: grid; }
.sb-section a:hover { color: var(--accent); }
.sb-team .swatch { width: 8px; height: 8px; border-radius: 3px; flex: none; margin: 0 4px; }
.sb-team .num { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.sb-empty { padding: 6px 10px; color: var(--faint); font-size: 13px; }
.sb-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); position: relative; }
.user-card { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: 10px; border: none; background: none; font: inherit; cursor: pointer; text-align: left; color: var(--text); }
.user-card:hover { background: var(--surface-2); }
.user-card .who { min-width: 0; flex: 1; }
.user-card .who b { display: block; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .who span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.popover { position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); padding: 6px; z-index: 50; }
.popover a, .popover button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 7px; border: none; background: none; font: inherit; color: var(--text-2); cursor: pointer; text-align: left; }
.popover a:hover, .popover button:hover { background: var(--surface-2); color: var(--text); }
.popover .icon { color: var(--muted); }
.popover hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ───────── Primitives ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-xs); transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(67,56,202,.3), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: #fecdca; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #b42318; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; gap: 6px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn.is-on { background: var(--accent-soft); border-color: #c7d2fe; color: var(--accent-hover); }

.count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.count.muted { background: var(--surface-3); color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge .icon { width: 12px; height: 12px; color: var(--muted); }
.badge-new { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; font-size: 11px; letter-spacing: .02em; height: 20px; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: #abefc6; }
.team-badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px 0 7px; border-radius: 6px; font-size: 12px; font-weight: 600; border: 1px solid; white-space: nowrap; }
.team-badge .swatch { width: 7px; height: 7px; border-radius: 2px; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface-2); }
.tag:hover { color: var(--accent-hover); background: var(--accent-soft); }

.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 600; flex: none; letter-spacing: .02em; }
.avatar-sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -6px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card-pad { padding: 20px 24px; }
.card-head { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-body { padding: 20px 24px; }

.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-tight { gap: 6px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.stack > * + * { margin-top: 16px; }
.loading { display: grid; place-items: center; padding: 96px 0; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────── Forms ───────── */
label, .label { display: block; font-weight: 500; font-size: 13.5px; color: var(--text-2); margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.help { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.input, input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; box-shadow: var(--shadow-xs);
  transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 96px; line-height: 1.55; }
select { 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='%23667085' 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 10px center; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: #a5b4fc; box-shadow: 0 0 0 4px var(--accent-ring); }
input[type=color] { width: 38px; height: 38px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); cursor: pointer; }
textarea.code { font-family: var(--mono); font-size: 13px; background: var(--code-bg); }
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 20px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; font-size: 13.5px; color: var(--text-2); cursor: pointer; margin: 0; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.form-error { color: var(--danger); font-size: 13px; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon input { padding-left: 36px; }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button { height: 28px; padding: 0 12px; border: none; background: none; border-radius: 6px; font: inherit; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented .count { height: 18px; min-width: 18px; font-size: 11px; }

/* ───────── Page header ───────── */
.page-header { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-header .titles { min-width: 0; flex: 1; }
.page-header .eyebrow { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.page-header .eyebrow a { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.page-header .eyebrow a:hover { color: var(--text); }
.page-header .sub { color: var(--muted); margin-top: 6px; font-size: 14px; max-width: 640px; }
.page-header .actions { display: flex; gap: 8px; align-items: center; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar .input-icon { width: 300px; max-width: 100%; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: all .12s; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.on { background: var(--text); border-color: var(--text); color: #fff; }
.chip .swatch { width: 8px; height: 8px; border-radius: 2px; }
.chip .x { display: grid; color: inherit; opacity: .7; }
.chip .x:hover { opacity: 1; }

/* ───────── Feed cards ───────── */
.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.post-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; color: inherit; box-shadow: var(--shadow-xs); transition: box-shadow .16s, transform .16s, border-color .16s; }
.post-card:hover { color: inherit; box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }
.post-card .cover { position: relative; aspect-ratio: 16 / 10; background: var(--surface-2); overflow: hidden; border-bottom: 1px solid var(--border); }
.post-card .cover img, .post-card .cover video { width: 100%; height: 100%; object-fit: cover; }
.post-card .cover .more { position: absolute; right: 10px; bottom: 10px; background: rgba(16,24,40,.72); color: #fff; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 6px; display: inline-flex; gap: 5px; align-items: center; backdrop-filter: blur(4px); }
.post-card .cover .more .icon { width: 12px; height: 12px; }
.post-card .cover .badge-new { position: absolute; top: 10px; left: 10px; box-shadow: 0 2px 8px rgba(79,70,229,.35); }
.cover-prompt { position: absolute; inset: 0; padding: 44px 18px 0;background: linear-gradient(180deg, #fafbfc, #f1f3f6); }
.cover-prompt .lbl { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.cover-prompt pre { margin: 0; font-size: 12px; line-height: 1.6; color: var(--text-2); white-space: pre-wrap; word-break: break-word; overflow: hidden; height: calc(100% - 26px); mask-image: linear-gradient(180deg, #000 55%, transparent); -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent); }
.cover-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); background: linear-gradient(135deg, #f8f9fb, #eef0f4); }
.cover-empty .icon { width: 28px; height: 28px; stroke-width: 1.5; }
.post-card .body { padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.post-card h3 { font-size: 15px; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card .summary { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card .foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.post-card .foot .author { color: var(--text-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-card .stats { margin-left: auto; display: flex; gap: 10px; color: var(--faint); }
.post-card .stats span { display: inline-flex; align-items: center; gap: 4px; }
.post-card .stats .icon { width: 13px; height: 13px; }
.post-card.is-read { opacity: .92; }
.post-card .read-mark { color: var(--success); display: inline-flex; align-items: center; gap: 3px; font-weight: 500; }
.post-card .read-mark .icon { width: 13px; height: 13px; }

.empty-state { text-align: center; padding: 64px 24px; }
.empty-state .ill { width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 16px; }
.empty-state .ill .icon { width: 24px; height: 24px; }
.empty-state h3 { margin-bottom: 6px; }
.empty-state p { color: var(--muted); max-width: 380px; margin: 0 auto 18px; }

/* ───────── Post detail ───────── */
.post-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
.post-main { min-width: 0; }
.post-title { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 10px; }
.post-summary { font-size: 16px; color: var(--muted); line-height: 1.6; }
.post-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.section { margin-top: 32px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-head h2 { font-size: 15px; }
.section-head .count { background: var(--surface-3); color: var(--muted); }

/* Carousel */
.carousel { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-xs); }
.carousel .stage { position: relative; background: #0c111d; aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; user-select: none; }
.carousel .stage img, .carousel .stage video { width: 100%; height: 100%; object-fit: contain; }
.carousel .stage img { cursor: zoom-in; }
.carousel .nav-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%; border: none; background: rgba(255,255,255,.94); color: var(--text); display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.25); transition: transform .12s, opacity .12s, background .12s; z-index: 2; }
.carousel .nav-btn:hover { background: #fff; transform: translateY(-50%) scale(1.06); }
.carousel .nav-btn:disabled { opacity: 0; pointer-events: none; }
.carousel .nav-btn .icon { width: 20px; height: 20px; }
.carousel .prev { left: 14px; }
.carousel .next { right: 14px; }
.carousel .counter { position: absolute; top: 14px; right: 14px; background: rgba(12,17,29,.72); color: #fff; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; font-variant-numeric: tabular-nums; backdrop-filter: blur(6px); z-index: 2; }
.carousel .expand { position: absolute; top: 12px; left: 12px; width: 32px; height: 32px; border-radius: 8px; border: none; background: rgba(12,17,29,.6); color: #fff; display: grid; place-items: center; cursor: pointer; z-index: 2; backdrop-filter: blur(6px); }
.carousel .expand:hover { background: rgba(12,17,29,.85); }
.carousel .caption-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); min-height: 46px; }
.carousel .caption-bar .caption { color: var(--text-2); font-size: 13.5px; flex: 1; }
.carousel .caption-bar .pos { color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.carousel .thumbs { display: flex; gap: 8px; padding: 0 16px 14px; overflow-x: auto; scrollbar-width: thin; }
.carousel .thumb { flex: none; width: 76px; height: 52px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; padding: 0; background: var(--surface-2); cursor: pointer; opacity: .65; transition: opacity .12s, border-color .12s; position: relative; }
.carousel .thumb:hover { opacity: 1; }
.carousel .thumb.on { border-color: var(--accent); opacity: 1; }
.carousel .thumb img, .carousel .thumb video { width: 100%; height: 100%; object-fit: cover; }
.carousel .thumb .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.25); }
.carousel .dots { display: none; }

/* Prompt blocks */
.prompt-block { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); margin-bottom: 12px; box-shadow: var(--shadow-xs); }
.prompt-block header { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.prompt-block header .lbl { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.prompt-block header .lbl .icon { color: var(--muted); width: 14px; height: 14px; }
.prompt-block pre { margin: 0; padding: 14px 16px; font-size: 13px; line-height: 1.65; color: var(--text); background: var(--code-bg); white-space: pre-wrap; word-break: break-word; max-height: 440px; overflow: auto; }

/* Markdown */
.markdown { font-size: 15px; line-height: 1.75; color: var(--text-2); overflow-wrap: anywhere; }
.markdown > *:first-child { margin-top: 0; }
.markdown h1, .markdown h2, .markdown h3 { margin: 1.4em 0 .5em; color: var(--text); }
.markdown h1 { font-size: 20px; } .markdown h2 { font-size: 18px; } .markdown h3 { font-size: 16px; }
.markdown p, .markdown ul, .markdown ol { margin: 0 0 1em; }
.markdown li + li { margin-top: .25em; }
.markdown img { border-radius: 8px; border: 1px solid var(--border); }
.markdown pre { background: var(--code-bg); border: 1px solid var(--border); padding: 14px 16px; border-radius: 8px; overflow: auto; font-size: 13px; }
.markdown code { font-size: .87em; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }
.markdown pre code { background: none; border: none; padding: 0; }
.markdown blockquote { margin: 0 0 1em; padding: 10px 16px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; color: var(--text-2); }
.markdown blockquote p:last-child { margin: 0; }
.markdown table { border-collapse: collapse; margin-bottom: 1em; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 12px; }
.markdown th { background: var(--surface-2); }
.markdown a { text-decoration: underline; text-underline-offset: 2px; }

/* Aside */
.post-aside { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 16px; }
.detail-list { display: grid; grid-template-columns: 88px 1fr; gap: 12px 12px; font-size: 13.5px; align-items: center; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; color: var(--text); min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.aside-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.aside-actions .btn { width: 100%; }
.reader-list { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow: auto; }
.reader-item { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.reader-item .when { margin-left: auto; color: var(--faint); font-size: 12px; }

/* Comments */
.comment { display: flex; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.comment:first-child { padding-top: 4px; }
.comment .content { flex: 1; min-width: 0; }
.comment .meta { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.comment .meta b { font-weight: 600; }
.comment .meta .del { margin-left: auto; opacity: 0; transition: opacity .12s; }
.comment:hover .meta .del { opacity: 1; }
.comment .text { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); font-size: 14px; }
.comment-form { display: flex; gap: 12px; margin-top: 16px; }
.comment-form .box { flex: 1; }
.comment-form textarea { min-height: 80px; }

/* ───────── Start Here ───────── */
.progress-card { display: flex; align-items: center; gap: 20px; padding: 20px 24px; margin-bottom: 20px; }
.progress-ring { width: 56px; height: 56px; flex: none; }
.progress-ring circle { fill: none; stroke-width: 6; }
.progress-ring .track { stroke: var(--surface-3); }
.progress-ring .bar { stroke: var(--success); stroke-linecap: round; transition: stroke-dashoffset .4s; transform: rotate(-90deg); transform-origin: 50% 50%; }
.progress-bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; flex: 1; }
.progress-bar > div { height: 100%; background: var(--success); border-radius: 99px; }
.steps { list-style: none; margin: 0; padding: 0; position: relative; }
.steps::before { content: ""; position: absolute; left: 35px; top: 28px; bottom: 28px; width: 2px; background: var(--border); }
.step { display: flex; gap: 16px; align-items: center; padding: 16px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); color: inherit; margin-bottom: 10px; position: relative; box-shadow: var(--shadow-xs); transition: border-color .12s, box-shadow .12s; }
.step:hover { color: inherit; border-color: #c7d2fe; box-shadow: var(--shadow-sm); }
.step-num { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; background: var(--surface); color: var(--accent); border: 2px solid #c7d2fe; flex: none; position: relative; z-index: 1; }
.step.done .step-num { background: var(--success); border-color: var(--success); color: #fff; }
.step .txt { flex: 1; min-width: 0; }
.step .txt p { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.step .go { color: var(--faint); }

/* ───────── Notifications ───────── */
.notif-group { font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 18px 20px 8px; }
.notif-group:first-child { padding-top: 14px; }
.notif { display: flex; gap: 14px; align-items: flex-start; padding: 14px 20px; color: inherit; border-top: 1px solid var(--border); position: relative; cursor: pointer; transition: background .1s; }
.notif:hover { background: var(--surface-2); color: inherit; }
.notif.unread { background: #f8f9ff; }
.notif.unread:hover { background: var(--accent-soft); }
.notif .ico-wrap { position: relative; flex: none; }
.notif .type-ico { position: absolute; right: -4px; bottom: -4px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; color: #fff; border: 2px solid var(--surface); }
.notif .type-ico .icon { width: 9px; height: 9px; stroke-width: 3; }
.notif .txt { flex: 1; min-width: 0; font-size: 14px; color: var(--text-2); }
.notif .txt b { color: var(--text); font-weight: 600; }
.notif .txt .title { color: var(--text); font-weight: 500; }
.notif .sub { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--faint); }
.notif .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 7px; }
.notif .dot.off { background: transparent; }

/* ───────── Team directory ───────── */
.team-block { margin-bottom: 28px; }
.team-block-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.team-block-head .swatch { width: 10px; height: 10px; border-radius: 3px; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.person { display: flex; gap: 12px; align-items: center; padding: 14px 16px; color: inherit; transition: border-color .12s, box-shadow .12s; }
.person:hover { color: inherit; border-color: #c7d2fe; box-shadow: var(--shadow-sm); }
.person .info { min-width: 0; }
.person b { font-weight: 600; display: block; }
.person span { font-size: 12.5px; color: var(--muted); }

/* ───────── Editor ───────── */
.editor { max-width: 860px; }
.editor .card { margin-bottom: 20px; }
.editor .card-head h2 { display: flex; align-items: center; gap: 8px; }
.editor .card-head .step-pill { width: 22px; height: 22px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.kind-select { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kind-option { display: flex; gap: 12px; padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; margin: 0; }
.kind-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.kind-option input { accent-color: var(--accent); margin-top: 3px; }
.kind-option b { display: block; font-weight: 600; color: var(--text); }
.kind-option span { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.prompt-edit { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; overflow: hidden; background: var(--surface); }
.prompt-edit .bar { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.prompt-edit .bar input { height: 32px; background: var(--surface); }
.prompt-edit textarea { border: none; border-radius: 0; box-shadow: none; min-height: 120px; }
.prompt-edit textarea:focus { box-shadow: inset 0 0 0 2px var(--accent-ring); }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 28px 20px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; background: var(--surface-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .ill { width: 40px; height: 40px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; margin: 0 auto 10px; color: var(--muted); box-shadow: var(--shadow-xs); }
.dropzone b { color: var(--accent); font-weight: 600; }
.media-edit { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 16px; }
.media-item { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow-xs); }
.media-item .thumb { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; position: relative; }
.media-item .thumb img, .media-item .thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-item .thumb .idx { position: absolute; top: 6px; left: 6px; background: rgba(12,17,29,.7); color: #fff; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 5px; }
.media-item .controls { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.media-item input { height: 32px; font-size: 13px; }
.media-item .row { gap: 2px; flex-wrap: nowrap; }
.media-item.uploading .thumb { color: var(--muted); }
.md-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.md-tabs button { border: none; background: none; font: inherit; font-weight: 500; font-size: 13px; color: var(--muted); padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.md-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.md-preview { min-height: 200px; padding: 4px 2px; }
.action-bar { position: sticky; bottom: 0; z-index: 5; margin: 0 -40px; padding: 14px 40px; background: rgba(247,248,250,.9); backdrop-filter: blur(10px); border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ───────── Tables ───────── */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table select { height: 32px; font-size: 13px; min-width: 140px; }
.table .who { display: flex; align-items: center; gap: 10px; }
.table .who b { font-weight: 600; display: block; white-space: nowrap; }
.table .who span { font-size: 12.5px; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.ok { color: var(--success); }
.status.warn { color: var(--warning); }
.status.off { color: var(--danger); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tabs a { padding: 10px 14px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }

/* ───────── Auth ───────── */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: radial-gradient(1200px 600px at -10% -20%, #6366f1 0%, transparent 60%), radial-gradient(800px 500px at 120% 120%, #0ea5e9 0%, transparent 55%), #1e1b4b; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side .brand { color: #fff; padding: 0; }
.auth-side .brand-sub { color: rgba(255,255,255,.7); }
.auth-side h2 { color: #fff; font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -0.025em; max-width: 440px; }
.auth-side p { color: rgba(255,255,255,.75); font-size: 15px; margin-top: 14px; max-width: 420px; line-height: 1.6; }
.auth-side ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.auth-side li { display: flex; gap: 10px; align-items: center; color: rgba(255,255,255,.88); font-size: 14px; }
.auth-side li .icon { color: #a5b4fc; }
.auth-side .foot { font-size: 12.5px; color: rgba(255,255,255,.55); }
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-form { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 26px; margin-bottom: 6px; }
.auth-form .sub { color: var(--muted); margin-bottom: 28px; }
.auth-form .btn { width: 100%; height: 42px; font-size: 14.5px; margin-top: 6px; }
.auth-form input { height: 42px; }
.auth-note { margin-top: 20px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 13px; display: flex; gap: 10px; }
.auth-note .icon { color: var(--faint); margin-top: 2px; }
.alert { padding: 12px 14px; border-radius: 10px; font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; }
.alert-error { background: var(--danger-soft); color: #b42318; border: 1px solid #fecdca; }
.alert-info { background: var(--accent-soft); color: var(--accent-hover); border: 1px solid #c7d2fe; }
.alert .icon { margin-top: 2px; }

/* ───────── Toast, lightbox, modal ───────── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #101828; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 500; font-size: 13.5px; z-index: 200; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px); animation: toast-in .18s ease-out; }
.toast .icon { color: #75e0a7; }
.toast.err .icon { color: #fda29b; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

.lightbox { position: fixed; inset: 0; background: rgba(8, 10, 18, .94); z-index: 150; display: flex; flex-direction: column; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.lightbox .lb-top { display: flex; align-items: center; gap: 12px; padding: 14px 18px; color: #fff; }
.lightbox .lb-top .pos { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: rgba(255,255,255,.75); }
.lightbox .lb-top .cap { flex: 1; font-size: 14px; color: rgba(255,255,255,.9); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lightbox .lb-btn { width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center; cursor: pointer; }
.lightbox .lb-btn:hover { background: rgba(255,255,255,.2); }
.lightbox .lb-btn:disabled { opacity: .25; pointer-events: none; }
.lightbox .lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 0 18px 24px; min-height: 0; }
.lightbox .lb-media { flex: 1; height: 100%; display: grid; place-items: center; min-width: 0; }
.lightbox .lb-media img, .lightbox .lb-media video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .5); backdrop-filter: blur(2px); z-index: 160; display: grid; place-items: center; padding: 16px; animation: fade .12s; }
.modal { width: 100%; max-width: 440px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 24px; animation: pop .15s ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.modal .m-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 16px; background: var(--accent-soft); color: var(--accent); border: 6px solid #f5f6ff; box-sizing: content-box; }
.modal .m-icon.danger { background: #fee4e2; color: var(--danger); border-color: var(--danger-soft); }
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal p { color: var(--muted); font-size: 14px; }
.modal .m-body { margin-top: 16px; }
.modal .m-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal .m-actions .btn { flex: 1; height: 40px; }
.creds { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; color: var(--text-2); margin: 0; }

/* ───────── Responsive ───────── */
@media (max-width: 1180px) {
  .post-layout { grid-template-columns: minmax(0, 1fr); }
  .post-aside { position: static; display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.4); z-index: 35; display: none; }
  body.nav-open .sidebar-backdrop { display: block; }
  .main { margin-left: 0; }
  .mobile-bar { display: flex; position: sticky; top: 0; z-index: 30; height: 56px; align-items: center; gap: 8px; padding: 0 12px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
  .mobile-bar .brand { padding: 0; flex: 1; }
  .mobile-bar .brand-mark { width: 28px; height: 28px; }
  .mobile-bar .bell { position: relative; }
  .mobile-bar .bell .count { position: absolute; top: 0; right: -2px; height: 17px; min-width: 17px; font-size: 10px; padding: 0 4px; }
  .content { padding: 24px 16px 80px; }
  .action-bar { margin: 0 -16px; padding: 12px 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 640px) {
  h1 { font-size: 21px; }
  .post-title { font-size: 22px; }
  .grid-2, .grid-3, .kind-select { grid-template-columns: 1fr; }
  .feed { grid-template-columns: 1fr; }
  .post-aside { grid-template-columns: 1fr; }
  .toolbar .input-icon { width: 100%; }
  .carousel .stage { aspect-ratio: 4 / 3; }
  .carousel .nav-btn { width: 36px; height: 36px; }
  .carousel .prev { left: 8px; } .carousel .next { right: 8px; }
  .card-head, .card-body { padding-left: 16px; padding-right: 16px; }
  .page-header .actions { width: 100%; }
  .lightbox .lb-stage { padding: 0 6px 16px; gap: 6px; }
}

/* ───────── Permissions ───────── */
.perm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.perm-option { display: flex; gap: 10px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; margin: 0; font-weight: 400; }
.perm-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.perm-option input { accent-color: var(--accent); margin-top: 3px; }
.perm-option b { display: block; font-weight: 600; color: var(--text); font-size: 13.5px; }
.perm-option span span { font-size: 12.5px; color: var(--muted); }
.perm-toggle { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); font-size: 12px; font-weight: 500; color: var(--muted); cursor: pointer; margin: 0; white-space: nowrap; }
.perm-toggle input { width: 13px; height: 13px; margin: 0; accent-color: var(--accent); }
.perm-toggle.on { border-color: #c7d2fe; background: var(--accent-soft); color: var(--accent-hover); }
select:disabled { background-color: var(--surface-2); color: var(--muted); cursor: not-allowed; box-shadow: none; }
@media (max-width: 640px) { .perm-grid { grid-template-columns: 1fr; } }
