/* app.css — Bayris collaboration SPA components.
   Built entirely on bayes-theme.css design tokens (--bg-*, --text-*, --border,
   --btn-blue, --radius-*, --shadow-*, --font-*), so every one of the 26 theme
   variants (light/dark × 13 palettes) styles these components automatically.
   Visual language mirrors the SimServer social pages: dense, card-based, a blue
   primary + monospace "scale" chips, thin borders, soft hover lifts. */

/* ───────────────────────── toolbar nav ───────────────────────── */
.toolbar-title span { color: var(--toolbar-muted); font-weight: 300; }
.toolbar-nav { display: flex; align-items: center; gap: 2px; }
.toolbar-nav a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: var(--radius-lg);
  font-size: 13px; font-weight: 600; text-decoration: none;
  color: var(--toolbar-link); background: transparent; border: 1px solid transparent;
  transition: all var(--transition);
}
.toolbar-nav a svg { width: 15px; height: 15px; opacity: .7; }
.toolbar-nav a:hover { color: var(--toolbar-link-hover); background: var(--toolbar-btn-bg); }
.toolbar-nav a.active {
  color: var(--toolbar-link-hover); background: var(--toolbar-btn-bg-hover);
  border-color: var(--toolbar-btn-border);
}
.toolbar-nav a.active svg { opacity: 1; }
.toolbar-user { display: flex; align-items: center; gap: 10px; }
.toolbar-user .u-email { font-size: 12px; color: var(--toolbar-muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar-user a { /* Log in / Sign up on the toolbar */ }
.link-btn { background: none; border: none; color: var(--toolbar-link); font: inherit; font-weight: 600; cursor: pointer; padding: 6px 8px; border-radius: var(--radius); transition: color var(--transition); }
.link-btn:hover { color: var(--toolbar-link-hover); }

/* ───────────────────────── page scaffolding ───────────────────────── */
.page { max-width: 1080px; margin: 0 auto; padding: 26px 20px 64px; }
.page-narrow { max-width: 900px; }
.page-head { margin-bottom: 18px; }
.page-title {
  font-family: var(--font-sans); font-weight: 900; letter-spacing: -0.5px;
  font-size: 26px; color: var(--text-heading); margin: 0;
}
.page-desc { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

.feed-layout { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 26px; align-items: start; }
@media (max-width: 900px) { .feed-layout { grid-template-columns: minmax(0,1fr); } .feed-aside { display: none; } }

/* ───────────────────────── tabs ───────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 6px 0 18px; }
.tab {
  appearance: none; background: none; border: none; cursor: pointer; font: inherit;
  padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--text-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--btn-blue); border-bottom-color: var(--btn-blue); }
.tab .count {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; line-height: 1;
  padding: 2px 6px; border-radius: 10px; background: var(--bg-hover); color: var(--text-muted);
}
.tab.active .count { background: rgba(33,150,243,0.14); color: var(--btn-blue); }

/* ───────────────────────── avatar ───────────────────────── */
.avatar {
  --sz: 40px; --fs: 15px;
  width: var(--sz); height: var(--sz); min-width: var(--sz);
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs); font-weight: 700; color: #fff; letter-spacing: .3px;
  background: linear-gradient(135deg, hsl(var(--h,210) 70% 52%), hsl(calc(var(--h,210) + 40) 66% 44%));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); user-select: none; flex-shrink: 0;
}
.avatar.sm { --sz: 26px; --fs: 11px; }
.avatar.md { --sz: 34px; --fs: 13px; }
.avatar.lg { --sz: 44px; --fs: 16px; }
.avatar.xl { --sz: 68px; --fs: 25px; }

/* ───────────────────────── generic card ───────────────────────── */
.card {
  background: var(--bg-white); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 16px 18px; }

/* ───────────────────────── scale / meta chips ───────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 10px; background: var(--bg-hover); color: var(--text-secondary);
  letter-spacing: .02em; white-space: nowrap;
}
.chip-scale { font-family: var(--font-mono); font-weight: 700; font-size: 10.5px; text-transform: lowercase;
  background: rgba(33,150,243,0.12); color: var(--btn-blue); }
.chip-vis-public  { background: rgba(22,163,74,0.12); color: var(--success-green); }
.chip-vis-organization { background: rgba(33,150,243,0.12); color: var(--btn-blue); }
.chip-vis-private, .chip-vis-group { background: var(--bg-hover); color: var(--text-tertiary); }

/* ───────────────────────── compose box ───────────────────────── */
.compose { padding: 14px; margin-bottom: 18px; }
.compose-row { display: flex; gap: 12px; }
.compose-input {
  width: 100%; min-height: 62px; resize: vertical; font: inherit; font-size: 14px;
  padding: 10px 12px; border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text-primary); transition: border-color var(--transition), box-shadow var(--transition);
}
.compose-input:focus { outline: none; border-color: var(--btn-blue); box-shadow: var(--focus-ring); background: var(--bg-white); }
.compose-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-left: 46px; gap: 12px; }
.compose-tools { display: flex; align-items: center; gap: 6px; }
.compose-scope { font-size: 12px; font-weight: 600; color: var(--text-muted); font-family: var(--font-sans);
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: var(--radius-lg); border: 1px solid transparent; background: transparent;
  color: var(--text-tertiary); cursor: pointer; transition: all var(--transition);
}
.icon-btn:hover { color: var(--btn-blue); background: var(--bg-hover); }
.icon-btn svg { width: 17px; height: 17px; }

/* ───────────────────────── feed post ───────────────────────── */
.feed-list { display: flex; flex-direction: column; }
.post { display: flex; gap: 12px; padding: 16px 4px; border-bottom: 1px solid var(--border); transition: background var(--transition); }
.post:hover { background: var(--bg-surface); }
.post:first-child { padding-top: 4px; }
.post-body-col { flex: 1; min-width: 0; }
.post-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.post-author { font-size: 13px; font-weight: 700; color: var(--text-heading); background: none; border: none; padding: 0; cursor: pointer; font-family: inherit; }
.post-author:hover { color: var(--btn-blue); }
.post-org { font-size: 12px; color: var(--text-tertiary); }
.post-time { font-size: 12px; color: var(--text-muted); margin-left: auto; font-family: var(--font-mono); }
.post-text { font-size: 14px; line-height: 1.55; color: var(--text-primary); margin: 7px 0; white-space: pre-wrap; word-wrap: break-word; }
.post-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.post-actions { display: flex; gap: 20px; margin-top: 10px; }
.post-action { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; cursor: pointer;
  color: var(--text-tertiary); font-size: 12.5px; font-weight: 600; font-family: inherit; padding: 2px; transition: color var(--transition); }
.post-action:hover { color: var(--btn-blue); }
.post-action svg { width: 15px; height: 15px; }

/* ───────────────────────── side cards ───────────────────────── */
.feed-aside { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 80px; }
.side-card { padding: 15px 16px; }
.side-card h3 { font-size: 13px; font-weight: 800; color: var(--text-heading); margin: 0 0 10px; letter-spacing: -.2px; }
.side-card p { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; margin: 0; }
.side-stat { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.side-stat + .side-stat { border-top: 1px solid var(--border); }
.side-stat b { font-family: var(--font-mono); color: var(--text-heading); }

/* ───────────────────────── profile ───────────────────────── */
.profile-head { display: flex; gap: 20px; align-items: flex-start; padding: 6px 2px 18px; }
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 24px; font-weight: 900; letter-spacing: -.5px; color: var(--text-heading); margin: 0; }
.profile-sub { color: var(--text-secondary); font-size: 13px; margin-top: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-expertise { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.profile-stats { display: flex; gap: 22px; margin-top: 14px; }
.profile-stats .st b { font-family: var(--font-mono); font-weight: 700; color: var(--text-heading); font-size: 15px; }
.profile-stats .st span { color: var(--text-muted); font-size: 12px; margin-left: 5px; }
.profile-actions { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.profile-bio { color: var(--text-secondary); font-size: 14px; line-height: 1.6; padding: 0 2px 18px; border-bottom: 1px solid var(--border); margin-bottom: 4px; white-space: pre-wrap; }

/* iOS-style toggle */
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.toggle input { display: none; }
.toggle .track { width: 34px; height: 20px; border-radius: 999px; background: var(--border); position: relative; transition: background var(--transition); }
.toggle .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--transition); }
.toggle input:checked + .track { background: var(--btn-blue); }
.toggle input:checked + .track::after { transform: translateX(14px); }

/* follow button (display-affordance, faithful to SimServer) */
.follow-btn { font-size: 12px; font-weight: 700; padding: 6px 16px; border-radius: 999px; cursor: pointer; font-family: inherit; transition: all var(--transition); background: var(--btn-blue); color: #fff; border: 1px solid var(--btn-blue); }
.follow-btn:hover { background: var(--btn-blue-hover); }
.follow-btn.following { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.follow-btn.following:hover { color: var(--error-red); border-color: var(--error-red); }

/* ───────────────────────── list rows (people, activity, projects) ───────────────────────── */
.row-list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 14px; padding: 13px 12px; border-radius: var(--radius-lg);
  cursor: pointer; transition: background var(--transition); text-align: left; width: 100%; background: none; border: none; font: inherit;
}
.list-row:hover { background: var(--bg-surface); }
.list-row + .list-row { border-top: 1px solid var(--border); }
.list-row:hover + .list-row, .list-row:hover { border-color: transparent; }
.lr-main { flex: 1; min-width: 0; }
.lr-name { font-size: 14px; font-weight: 700; color: var(--text-heading); }
.lr-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.lr-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.lr-right { text-align: right; color: var(--text-muted); font-size: 12px; font-family: var(--font-mono); flex-shrink: 0; }

/* ───────────────────────── discover grid ───────────────────────── */
.discover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.proj-card { padding: 16px; cursor: pointer; transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition); display: flex; flex-direction: column; gap: 8px; }
.proj-card:hover { border-color: var(--btn-blue); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.proj-card-head { display: flex; align-items: center; gap: 9px; }
.proj-owner { font-size: 12px; color: var(--text-tertiary); }
.proj-name { font-size: 15.5px; font-weight: 800; color: var(--text-heading); letter-spacing: -.2px; }
.proj-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.proj-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.proj-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }
.proj-open { font-size: 12px; font-weight: 700; color: var(--btn-blue); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.proj-open:hover { text-decoration: underline; }

/* ───────────────────────── search bar ───────────────────────── */
.searchbar { display: flex; align-items: center; gap: 8px; background: var(--bg-white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 0 12px; height: 40px; transition: border-color var(--transition), box-shadow var(--transition); }
.searchbar:focus-within { border-color: var(--btn-blue); box-shadow: var(--focus-ring); }
.searchbar svg { width: 16px; height: 16px; color: var(--text-tertiary); flex-shrink: 0; }
.searchbar input { flex: 1; border: none; background: none; font: inherit; font-size: 14px; color: var(--text-primary); outline: none; }
.filter-bar { display: flex; gap: 10px; align-items: center; margin: 4px 0 16px; }
.filter-bar .searchbar { flex: 1; }
.select {
  height: 40px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-white);
  color: var(--text-primary); font: inherit; font-size: 13px; font-weight: 600; padding: 0 12px; cursor: pointer;
}
.select:focus { outline: none; border-color: var(--btn-blue); box-shadow: var(--focus-ring); }

/* ───────────────────────── auth card ───────────────────────── */
.auth-wrap { display: flex; justify-content: center; padding-top: 6vh; }
.auth-card { width: 100%; max-width: 400px; padding: 30px 30px 26px; position: relative; overflow: hidden; }
.auth-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--btn-blue), var(--orange)); }
.auth-card h1 { font-size: 24px; font-weight: 900; letter-spacing: -.5px; color: var(--text-heading); margin: 6px 0 4px; }
.auth-card .sub { color: var(--text-secondary); font-size: 13.5px; margin-bottom: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 6px; }
.field .text-input { font-size: 14px; }
.auth-alt { text-align: center; font-size: 13px; color: var(--text-secondary); margin-top: 16px; }
.auth-alt a { color: var(--btn-blue); font-weight: 600; text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }
.btn-block { width: 100%; padding: 11px; font-size: 14px; margin-top: 4px; }

/* ───────────────────────── states + misc ───────────────────────── */
.state { text-align: center; color: var(--text-secondary); font-size: 14px; padding: 60px 20px; }
.state .big { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.skeleton { border-radius: var(--radius-lg); background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-surface) 50%, var(--bg-hover) 75%); background-size: 200% 100%; animation: sk 1.3s ease-in-out infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.err { color: var(--error-red); font-size: 13px; margin: 8px 0; font-weight: 600; }
.ok { color: var(--success-green); font-size: 13px; margin: 8px 0; font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ───────────────────────── markdown editor + article ───────────────────────── */
.md-hint { font-size: 11px; font-weight: 700; color: var(--text-muted); background: var(--bg-hover); padding: 4px 9px; border-radius: 10px; letter-spacing: .02em; }
/* Live-preview composer/editor surfaces (contenteditable .md-editor). */
.compose-input.md-editor { min-height: 62px; }
.md-editor { outline: none; }
.md-editor.md-editing { background: var(--bg-white); }
/* Rendered markdown density inside feed posts + editors. */
.post-text.md > *:first-child { margin-top: 0; }
.post-text.md > *:last-child { margin-bottom: 0; }
.post-text.md pre, .article-body.md pre { background: var(--code-bg); border: 1px solid var(--border); }
.post-text.md code, .article-body.md code { background: var(--code-bg); }

.pub-title { font-size: 22px; font-weight: 800; letter-spacing: -.3px; padding: 12px 14px; }
.pub-editor { min-height: 340px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-white); font-size: 15px; line-height: 1.65; cursor: text; }
.pub-editor.md-editing { box-shadow: var(--focus-ring); border-color: var(--btn-blue); }

.article { padding: 8px 2px 40px; }
.article-head { padding-bottom: 18px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.article-title { font-size: 34px; font-weight: 900; letter-spacing: -.8px; line-height: 1.15; color: var(--text-heading); margin: 0 0 14px; }
.article-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; color: var(--text-muted); }
.article-meta .post-author { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.article-body.md { font-size: 16.5px; line-height: 1.75; color: var(--text-primary); }
.article-body.md h1 { font-size: 27px; }
.article-body.md h2 { font-size: 22px; }
.article-body.md h1, .article-body.md h2, .article-body.md h3 { font-weight: 800; letter-spacing: -.3px; color: var(--text-heading); margin: 1.4em 0 .5em; }
.article-body.md p { margin: 0 0 1em; }
.article-body.md ul, .article-body.md ol { margin: 0 0 1em; padding-left: 1.5em; }
.article-body.md blockquote { border-left: 3px solid var(--btn-blue); background: var(--bg-surface); padding: 8px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin: 1em 0; }
.article-body.md pre { padding: 14px 16px; border-radius: var(--radius-lg); margin: 1.2em 0; }
.article-body.md .katex-display { margin: 1.2em 0; }

/* ───────────────────────── organization RAM settings (layer 6b) ───────────────────────── */
.ram-link { text-decoration: none; }
.ram-link svg { width: 15px; height: 15px; }
.ram-card { margin-bottom: 16px; }
.ram-card + .ram-card { margin-top: 0; }
.ram-h { margin: 0 0 4px; font-size: 15px; font-weight: 800; color: var(--text-heading); }
.ram-sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
.ram-row-org { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.ram-row-org .field { margin-bottom: 0; flex: 1 1 160px; }
.ram-row-org .ram-save { flex: 0 0 auto; }
.ram-input { font-family: var(--font-mono); font-size: 13.5px; }
#org-fb, .ram-fb { margin-top: 10px; }
.ram-table-wrap { overflow-x: auto; }
.ram-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ram-table th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 0 12px 8px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ram-table td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ram-table tr:last-child td { border-bottom: none; }
.ram-table .ram-input { width: 130px; max-width: 100%; }
.ram-email { font-weight: 600; color: var(--text-primary); word-break: break-all; min-width: 160px; }
.ram-cell-save { white-space: nowrap; }
.ram-cell-save .ram-fb { display: inline-block; margin: 0 0 0 10px; font-size: 12px; }

@media (max-width: 640px) {
  .toolbar-title span { display: none; }
  .article-title { font-size: 26px; }
  .page { padding: 18px 14px 48px; }
  .profile-head { flex-direction: column; }
  .profile-actions { flex-direction: row; align-items: center; }
  .compose-actions { padding-left: 0; }
  .ram-row-org .ram-save, .ram-row-org .ram-save .btn { width: 100%; }
}

