/* ==========================================================================
   Skill Hub — design system
   Minimal / calm SaaS aesthetic. Warm near-monochrome neutrals + one deep
   teal accent. Hairline borders instead of shadows. Sans for reading,
   monospace for identity/technical tokens (@handles, vN, timestamps).
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  /* ---- neutrals (warm, not clinical gray) ---- */
  --gray-950: #201f1c;
  --gray-900: #262420;
  --gray-800: #37352f;
  --gray-700: #4a4844;
  --gray-600: #6b6862;
  --gray-500: #8c8983;
  --gray-400: #aca9a3;
  --gray-300: #cdc9c2;
  --gray-250: #ddd9d2;
  --gray-200: #e6e2db;
  --gray-150: #edeae4;
  --gray-100: #f5f2ed;
  --gray-50:  #fbf9f6;
  --white:    #ffffff;

  /* ---- accent: deep, calm teal ---- */
  --accent-900: #073b35;
  --accent-800: #0a544a;
  --accent-700: #0d6e63;
  --accent-600: #128577;
  --accent-500: #17998a;
  --accent-soft: #e6f3f0;
  --accent-soft-border: #bfe0da;
  --accent-contrast: #ffffff;

  /* ---- semantic ---- */
  --success: #1e7a4c;
  --success-soft: #e5f3ea;
  --success-border: #bfe0cd;
  --warning: #93630f;
  --warning-soft: #faf1de;
  --warning-border: #edd9ac;
  --danger: #ab3a2c;
  --danger-soft: #fbeae6;
  --danger-border: #f0c9bf;
  --info: #305f96;
  --info-soft: #e8eff8;
  --info-border: #c4d6ec;

  /* ---- surface / text roles ---- */
  --bg: var(--gray-50);
  --surface: var(--white);
  --surface-sunken: var(--gray-100);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --text: var(--gray-800);
  --text-strong: var(--gray-950);
  --text-muted: var(--gray-600);
  --text-faint: var(--gray-500);

  /* ---- type ---- */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas,
    "Liberation Mono", monospace;

  /* ---- spacing scale ---- */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;
  --sp-9: 48px; --sp-10: 64px; --sp-11: 80px;

  /* ---- radius ---- */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;

  /* ---- shadow (used sparingly: popovers/toasts/dialogs only) ---- */
  --shadow-sm: 0 1px 2px rgba(32,31,28,0.05);
  --shadow-md: 0 10px 30px -8px rgba(32,31,28,0.16), 0 2px 8px -2px rgba(32,31,28,0.08);

  --sidebar-w: 252px;
  color-scheme: light;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; color: var(--text-strong); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
svg { display: block; }

::selection { background: var(--accent-soft-border); }

a.link {
  color: var(--accent-700);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft-border);
}
a.link:hover { border-color: var(--accent-700); }

:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent-700);
  color: #fff;
  padding: 10px 16px;
  z-index: 1000;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }

.mono { font-family: var(--font-mono); font-variant-ligatures: none; }

/* ==========================================================================
   App shell: sidebar + main
   ========================================================================== */

.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.topbar-mobile {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  align-items: center;
  gap: var(--sp-3);
  height: 56px;
  padding: 0 var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-mobile__logo { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-strong); flex: 1; }
.topbar-mobile__logo .org-tag { margin-left: 4px; }

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(32,31,28,0.32);
  z-index: 39;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--gray-150); color: var(--text-strong); }

.logo-mark {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--accent-700);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  background: var(--gray-50);
  border-right: 1px solid var(--border);
  padding: var(--sp-5) var(--sp-3) var(--sp-4);
  overflow-y: auto;
  z-index: 40;
}

.sidebar__brand { display: flex; align-items: center; gap: 8px; padding: 0 var(--sp-2) var(--sp-4); }
.brand { display: flex; align-items: center; gap: 8px; }
.brand__name { font-weight: 600; font-size: 15px; color: var(--text-strong); letter-spacing: -0.01em; }
.org-tag {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--text-muted); background: var(--gray-150);
  border: 1px solid var(--border); border-radius: var(--radius-full);
  padding: 2px 8px; text-transform: uppercase;
}

.search-entry {
  display: flex; align-items: center; gap: 8px;
  margin: 0 var(--sp-2) var(--sp-5);
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-faint);
  font-size: 13px;
}
.search-entry:hover { border-color: var(--border-strong); color: var(--text-muted); }
.search-entry span { flex: 1; }
.search-entry kbd {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-faint);
  border: 1px solid var(--border-strong); border-radius: 4px; padding: 1px 6px;
  background: var(--gray-100);
}

.sidebar__section { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--sp-4); }
.sidebar__section--admin { padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.sidebar__label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-faint); padding: 0 var(--sp-3) 6px;
}
.sidebar__spacer { flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
}
.nav-item .icon { color: var(--text-faint); }
.nav-item:hover { background: var(--gray-150); color: var(--text-strong); }
.nav-item:hover .icon { color: var(--text-muted); }
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-800);
  font-weight: 600;
}
.nav-item.is-active .icon { color: var(--accent-700); }
.nav-item__badge {
  margin-left: auto;
  font-size: 11px; font-weight: 700;
  background: var(--accent-700); color: #fff;
  border-radius: var(--radius-full);
  min-width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu__trigger {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: var(--radius-md);
}
.user-menu__trigger:hover { background: var(--gray-150); }
.user-menu__info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-menu__name { font-size: 13px; font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu__handle { font-size: 12px; color: var(--text-faint); font-family: var(--font-mono); }
.user-menu .chev { color: var(--text-faint); }
.user-menu__panel {
  position: absolute; bottom: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  padding: 6px; display: flex; flex-direction: column; gap: 1px;
}
.user-menu__panel a { padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text); }
.user-menu__panel a:hover { background: var(--gray-100); }
.user-menu__panel a.danger { color: var(--danger); }
.user-menu__panel a.danger:hover { background: var(--danger-soft); }
.user-menu__panel form { margin: 0; }
.user-menu__panel button.link-button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13px; color: var(--danger); cursor: pointer;
}
.user-menu__panel button.link-button:hover { background: var(--danger-soft); }

.main { flex: 1; min-width: 0; }
.main-inner { max-width: 1080px; margin: 0 auto; padding: var(--sp-8) var(--sp-7) var(--sp-11); }
.main-inner--wide { max-width: 1280px; }
.main-inner--narrow { max-width: 720px; }

/* ==========================================================================
   Page header
   ========================================================================== */

.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-5); margin-bottom: var(--sp-7); flex-wrap: wrap; }
.page-header h1 { font-size: 24px; }
.page-header .subtitle { color: var(--text-muted); margin-top: 6px; max-width: 62ch; font-size: 14px; }
.page-header__actions { display: flex; gap: 10px; flex-shrink: 0; }

.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-faint); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent-700); }
.breadcrumb .icon { width: 14px; height: 14px; }
.breadcrumb .current { color: var(--text-strong); font-weight: 500; }

.section-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: var(--sp-3); display: flex; align-items: center; gap: 8px;
}
.section-label .count { font-family: var(--font-mono); font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-faint); }

.divider { height: 1px; background: var(--border); border: none; margin: var(--sp-7) 0; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 var(--sp-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  white-space: nowrap;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--accent-700); border-color: var(--accent-700); color: #fff; }
.btn-primary:hover { background: var(--accent-800); border-color: var(--accent-800); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text-strong); }
.btn-secondary:hover { background: var(--gray-100); border-color: var(--gray-400); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--gray-150); color: var(--text-strong); }
.btn-danger { background: var(--surface); border-color: var(--danger-border); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #8f2f24; }
.btn-sm { height: 30px; padding: 0 var(--sp-3); font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==========================================================================
   Forms
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-5); }
.field__label { font-size: 13px; font-weight: 600; color: var(--text-strong); }
.field__hint { font-size: 12.5px; color: var(--text-faint); }
.field__row { display: flex; gap: var(--sp-4); }
.field__row > .field { flex: 1; }

input[type="text"], input[type="email"], input[type="search"], input[type="date"],
textarea, select {
  width: 100%;
  font: inherit; font-size: 13.5px;
  color: var(--text-strong);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  appearance: none;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, textarea:focus, select:focus { border-color: var(--accent-600); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238c8983' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.input-icon-wrap { position: relative; }
.input-icon-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.input-icon-wrap input { padding-left: 38px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }

/* ==========================================================================
   Badges / tags
   ========================================================================== */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: var(--radius-full);
  border: 1px solid transparent;
  line-height: 1.4;
  white-space: nowrap;
}
.badge .icon { width: 12px; height: 12px; }
.badge--public { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge--unlisted { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge--private { background: var(--gray-150); color: var(--gray-700); border-color: var(--border-strong); }
.badge--neutral { background: var(--gray-150); color: var(--text-muted); border-color: var(--border); }
.badge--info { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.badge--success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge--warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge--danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.badge--admin { background: var(--accent-900); color: #fff; border-color: var(--accent-900); }

.tag-version {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  color: var(--text-muted); background: var(--gray-150);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 2px 7px;
}

/* ==========================================================================
   Avatars
   ========================================================================== */

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; flex-shrink: 0;
  font-weight: 600; font-family: var(--font-sans);
  color: var(--text-strong);
  background: var(--gray-200);
}
.avatar--sm { width: 24px; height: 24px; font-size: 11px; }
.avatar--md { width: 32px; height: 32px; font-size: 13px; }
.avatar--lg { width: 56px; height: 56px; font-size: 21px; }
.avatar--xl { width: 84px; height: 84px; font-size: 30px; }

.avatar.c1 { background: #dfe7fb; color: #33478f; }
.avatar.c2 { background: #d9f0e7; color: #1c6b52; }
.avatar.c3 { background: #faecd2; color: #93630f; }
.avatar.c4 { background: #fbe2df; color: #a3412f; }
.avatar.c5 { background: #dcf0f4; color: #276077; }
.avatar.c6 { background: #ece0f7; color: #6743a1; }
.avatar.c7 { background: #e3f0d8; color: #4a7327; }
.avatar.c8 { background: #e6e3db; color: #55524a; }

/* ==========================================================================
   Cards / list rows
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
}
.card + .card { margin-top: var(--sp-4); }
.card__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-4); }
.card__header h2, .card__header h3 { font-size: 15px; }

.panel-list { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.panel-list__row {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.panel-list__row:last-child { border-bottom: none; }
a.panel-list__row { color: inherit; }
a.panel-list__row:hover { background: var(--gray-50); }

.stat-row { display: flex; gap: var(--sp-7); flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__value { font-size: 21px; font-weight: 700; color: var(--text-strong); letter-spacing: -0.01em; }
.stat__label { font-size: 12.5px; color: var(--text-faint); }

/* ==========================================================================
   Empty state
   ========================================================================== */

.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--sp-3); padding: var(--sp-11) var(--sp-6);
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--gray-50);
}
.empty-state .icon-lg { width: 34px; height: 34px; color: var(--text-faint); margin-bottom: 4px; }
.empty-state h3 { font-size: 15px; color: var(--text-strong); }
.empty-state p { max-width: 42ch; font-size: 13.5px; }

/* ==========================================================================
   Filter bar (Explore, Audit log)
   ========================================================================== */

.filter-bar {
  display: flex; align-items: center; gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.filter-bar .input-icon-wrap { flex: 1; min-width: 220px; }
.filter-select { width: auto; min-width: 132px; }
.filter-bar__group { display: flex; align-items: center; gap: 8px; }
.filter-bar__label { font-size: 12.5px; color: var(--text-faint); display: flex; align-items: center; gap: 5px; white-space: nowrap; }

.result-count { font-size: 13px; color: var(--text-faint); margin-bottom: var(--sp-4); }
.result-count strong { color: var(--text-strong); font-weight: 600; }

/* ==========================================================================
   Skill result / list item (Explore, Profile, Dashboard)
   ========================================================================== */

.skill-row {
  display: flex; flex-direction: column; gap: 8px;
  padding: var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.skill-row:last-child { border-bottom: none; }
.skill-row:hover { background: var(--gray-50); }
.skill-row__top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.skill-row__name { font-size: 15px; font-weight: 600; color: var(--text-strong); font-family: var(--font-mono); letter-spacing: -0.01em; }
.skill-row__name:hover { color: var(--accent-700); }
.skill-row__desc { color: var(--text-muted); font-size: 13.5px; max-width: 74ch; }
.skill-row__meta { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; font-size: 12.5px; color: var(--text-faint); }
.skill-row__meta a:hover { color: var(--accent-700); }
.meta-item { display: flex; align-items: center; gap: 5px; }
.meta-item .icon { width: 14px; height: 14px; }
.owner-chip { display: inline-flex; align-items: center; gap: 6px; }
.owner-chip span.handle { font-family: var(--font-mono); }

/* ==========================================================================
   Load more / pagination
   ========================================================================== */

.load-more-wrap { display: flex; justify-content: center; margin-top: var(--sp-6); }

.action-row { display: flex; gap: 10px; margin-bottom: var(--sp-7); flex-wrap: wrap; }

/* ==========================================================================
   Table (Audit log, Sessions)
   ========================================================================== */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.data-table th {
  text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-faint); padding: 10px var(--sp-4); border-bottom: 1px solid var(--border); background: var(--gray-50);
  white-space: nowrap;
}
table.data-table td { padding: 11px var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--gray-50); }
.cell-actor { display: flex; align-items: center; gap: 8px; }
.cell-time { font-family: var(--font-mono); color: var(--text-muted); white-space: nowrap; }

/* ==========================================================================
   Diff view
   ========================================================================== */

.diff {
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  overflow: hidden; background: var(--surface);
}
.diff__line { padding: 2px var(--sp-4); white-space: pre-wrap; word-break: break-word; }
.diff__line[data-diff="added"] { background: var(--success-soft); color: #1a5c3a; }
.diff__line[data-diff="removed"] { background: var(--danger-soft); color: #8f2f24; text-decoration: line-through; text-decoration-color: rgba(143,47,36,0.35); }
.diff__line[data-diff="context"] { color: var(--text-faint); }

/* ==========================================================================
   Markdown rendered content (skill detail)
   ========================================================================== */

.md-content { font-size: 14.5px; line-height: 1.75; color: var(--text); max-width: 74ch; }
.md-content h1, .md-content h2, .md-content h3 { margin: var(--sp-6) 0 var(--sp-3); }
.md-content h1 { font-size: 19px; }
.md-content h2 { font-size: 16.5px; }
.md-content h3 { font-size: 14.5px; }
.md-content > *:first-child { margin-top: 0; }
.md-content p { margin: 0 0 var(--sp-4); }
.md-content ul, .md-content ol { margin: 0 0 var(--sp-4); padding-left: 1.4em; list-style: disc; }
.md-content ol { list-style: decimal; }
.md-content li { margin-bottom: 4px; }
.md-content code { font-family: var(--font-mono); background: var(--gray-150); padding: 1px 6px; border-radius: 4px; font-size: 0.9em; }
.md-content pre {
  background: var(--gray-950); color: #e9e6df; padding: var(--sp-4); border-radius: var(--radius-md);
  overflow-x: auto; margin: 0 0 var(--sp-4); font-size: 13px; line-height: 1.6;
}
.md-content pre code { background: none; padding: 0; color: inherit; }
.md-content blockquote { border-left: 3px solid var(--accent-soft-border); padding-left: var(--sp-4); color: var(--text-muted); margin: 0 0 var(--sp-4); }

/* ==========================================================================
   Detail layout (skill detail / settings): content + right rail
   ========================================================================== */

.detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: var(--sp-8); align-items: start; }
.rail { display: flex; flex-direction: column; gap: var(--sp-4); position: sticky; top: var(--sp-6); }
.rail__row { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rail__row:last-child { border-bottom: none; }
.rail__row .label { color: var(--text-faint); }
.rail__row .value { color: var(--text-strong); font-weight: 500; text-align: right; }

.file-list { display: flex; flex-direction: column; }
.file-list__row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.file-list__row:last-child { border-bottom: none; }
.file-list__row .icon { color: var(--text-faint); }
.file-list__row .path { font-family: var(--font-mono); font-size: 12.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list__row .size { color: var(--text-faint); font-size: 11.5px; }
.file-preview {
  margin-top: 6px; padding: var(--sp-3); background: var(--gray-950); color: #d8d4cb;
  font-family: var(--font-mono); font-size: 12px; border-radius: var(--radius-sm);
  overflow-x: auto; white-space: pre;
}

/* ==========================================================================
   Version history timeline
   ========================================================================== */

.timeline { display: flex; flex-direction: column; }
.timeline__item { display: flex; gap: var(--sp-4); padding-bottom: var(--sp-6); position: relative; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__rail { display: flex; flex-direction: column; align-items: center; }
.timeline__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gray-400); margin-top: 6px; flex-shrink: 0; }
.timeline__item--current .timeline__dot { background: var(--accent-700); box-shadow: 0 0 0 3px var(--accent-soft); }
.timeline__line { flex: 1; width: 1px; background: var(--border); margin-top: 4px; }
.timeline__body { flex: 1; }
.timeline__head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; flex-wrap: wrap; }
.timeline__title { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.timeline__meta { font-size: 12px; color: var(--text-faint); }
.timeline__desc { font-size: 13px; color: var(--text-muted); }

/* ==========================================================================
   Proposal / inbox card
   ========================================================================== */

.proposal-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-5); background: var(--surface); }
.proposal-card + .proposal-card { margin-top: var(--sp-4); }
.proposal-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.proposal-card__who { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.proposal-card__who .handle { color: var(--text-faint); font-family: var(--font-mono); font-size: 12.5px; }
.proposal-card__time { font-size: 12px; color: var(--text-faint); flex-shrink: 0; }
.proposal-card__summary { font-size: 13.5px; color: var(--text); margin-bottom: var(--sp-3); }
.proposal-card__actions { display: flex; gap: 8px; margin-top: var(--sp-4); }

/* ==========================================================================
   Network graph page
   ========================================================================== */

.network-canvas {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background:
    radial-gradient(var(--gray-200) 1px, transparent 1px) 0 0/22px 22px,
    var(--surface);
  padding: var(--sp-4);
}
.network-node { cursor: pointer; }
.network-node circle { transition: stroke .12s ease; }
.network-node:hover circle, .network-node.is-selected circle { stroke: var(--accent-700); stroke-width: 2.5; }
.network-node text { font-family: var(--font-sans); pointer-events: none; }
.network-edge { stroke: var(--gray-300); stroke-width: 1.5; fill: none; }
.network-detail__link { margin-top: 10px; }
.network-legend { display: flex; gap: var(--sp-6); flex-wrap: wrap; margin-top: var(--sp-4); font-size: 12.5px; color: var(--text-muted); }
.network-legend__item { display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* ==========================================================================
   Settings layout
   ========================================================================== */

.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: var(--sp-8); align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: var(--sp-6); }
.settings-nav a { padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13.5px; color: var(--text-muted); font-weight: 500; }
.settings-nav a:hover { background: var(--gray-150); color: var(--text-strong); }
.settings-nav a.is-active { background: var(--accent-soft); color: var(--accent-800); font-weight: 600; }
.settings-section { display: none; }
.settings-section.is-active { display: block; }
.settings-section h2 { font-size: 17px; margin-bottom: 4px; }
.settings-section .section-intro { color: var(--text-muted); font-size: 13.5px; margin-bottom: var(--sp-6); }

.device-row { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4) 0; border-bottom: 1px solid var(--border); }
.device-row:last-child { border-bottom: none; }
.device-row__icon { width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--gray-100); display: flex; align-items: center; justify-content: center; color: var(--text-muted); flex-shrink: 0; }
.device-row__body { flex: 1; min-width: 0; }
.device-row__title { font-size: 13.5px; font-weight: 600; color: var(--text-strong); display: flex; align-items: center; gap: 8px; }
.device-row__meta { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }

.danger-zone { border: 1px solid var(--danger-border); background: var(--danger-soft); border-radius: var(--radius-lg); padding: var(--sp-5); }
.danger-zone h3 { color: var(--danger); font-size: 14px; margin-bottom: 4px; }
.danger-zone p { font-size: 13px; color: #7a3226; margin-bottom: var(--sp-4); max-width: 60ch; }

dialog.confirm-dialog {
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: var(--sp-6); max-width: 420px; width: 90vw;
}
dialog.confirm-dialog::backdrop { background: rgba(32,31,28,0.4); }
.confirm-dialog h3 { font-size: 16px; margin-bottom: 8px; }
.confirm-dialog p { font-size: 13.5px; color: var(--text-muted); margin-bottom: var(--sp-5); }
.confirm-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ==========================================================================
   Auth pages (login / authorize) — standalone, no shell
   ========================================================================== */

.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6);
  background:
    radial-gradient(var(--gray-200) 1px, transparent 1px) 0 0/24px 24px,
    var(--gray-50);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-8) var(--sp-7);
}
.auth-card__brand { display: flex; align-items: center; gap: 9px; justify-content: center; margin-bottom: var(--sp-6); }
.auth-card h1 { font-size: 19px; text-align: center; }
.auth-card .subtitle { text-align: center; color: var(--text-muted); font-size: 13.5px; margin: 8px 0 var(--sp-7); line-height: 1.6; }
.auth-footnote { text-align: center; font-size: 12.5px; color: var(--text-faint); margin-top: var(--sp-6); line-height: 1.6; }

.success-panel { text-align: center; padding: var(--sp-5) 0; }
.success-panel .check-circle {
  width: 48px; height: 48px; border-radius: 50%; background: var(--success-soft); color: var(--success);
  display: flex; align-items: center; justify-content: center; margin: 0 auto var(--sp-4);
}
.success-panel h2 { font-size: 16px; margin-bottom: 6px; }
.success-panel p { font-size: 13.5px; color: var(--text-muted); }

.error-banner {
  background: var(--danger-soft); border: 1px solid var(--danger-border); color: var(--danger);
  border-radius: var(--radius-md); padding: var(--sp-3) var(--sp-4); font-size: 13px; margin-bottom: var(--sp-5);
}
.notice-banner {
  background: var(--info-soft); border: 1px solid var(--info-border); color: var(--info);
  border-radius: var(--radius-md); padding: var(--sp-3) var(--sp-4); font-size: 13px; margin-bottom: var(--sp-5);
}

/* authorize page */
.consent-app-row { display: flex; align-items: center; justify-content: center; gap: var(--sp-4); margin-bottom: var(--sp-6); }
.consent-app-icon { width: 52px; height: 52px; border-radius: var(--radius-md); background: var(--gray-900); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.consent-arrow { color: var(--text-faint); }
.consent-org-icon { width: 52px; height: 52px; border-radius: var(--radius-md); background: var(--accent-700); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.scope-list { display: flex; flex-direction: column; gap: var(--sp-3); margin: var(--sp-6) 0; }
.scope-item { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.scope-item .icon { color: var(--success); margin-top: 2px; }
.consent-actions { display: flex; gap: 10px; }
.consent-actions .btn { flex: 1; }

/* ==========================================================================
   Profile page
   ========================================================================== */

.profile-header { display: flex; gap: var(--sp-6); align-items: flex-start; margin-bottom: var(--sp-7); flex-wrap: wrap; }
.profile-header__body { flex: 1; min-width: 240px; }
.profile-header__name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.profile-header__name { font-size: 22px; }
.profile-header__handle { color: var(--text-faint); font-family: var(--font-mono); font-size: 14px; }
.profile-header__role { color: var(--text-muted); font-size: 13.5px; margin-bottom: var(--sp-4); }
.profile-header__actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ==========================================================================
   Invite recently-sent list
   ========================================================================== */

.invite-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.invite-row:last-child { border-bottom: none; }
.invite-row__email { font-family: var(--font-mono); font-size: 13px; color: var(--text-strong); }
.invite-row__meta { color: var(--text-faint); font-size: 12px; }

/* ==========================================================================
   Two column generic
   ========================================================================== */

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6); align-items: start; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 980px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; height: 100vh; box-shadow: var(--shadow-md); }
  .sidebar.is-open { transform: translateX(0); }
  .nav-backdrop.is-open { display: block; }
  .topbar-mobile { display: flex; }
  .main-inner { padding: var(--sp-6) var(--sp-5) var(--sp-9); }
  .detail-grid { grid-template-columns: 1fr; }
  .rail { position: static; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; position: static; padding-bottom: 4px; }
}

@media (max-width: 720px) {
  .two-col { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .field__row { flex-direction: column; gap: 0; }
  .profile-header { flex-direction: column; }
  .consent-app-row { gap: var(--sp-3); }
}

/* ==========================================================================
   Utility classes
   ------------------------------------------------------------------------
   The app's CSP (default-src 'self', no style-src override) has no
   'unsafe-inline' for styles, so a style="..." HTML attribute is silently
   dropped by the browser (it still parses, but never applies) - every
   layout tweak needs a real class instead of an inline style attribute.
   ========================================================================== */

.d-none { display: none; }
.d-inline { display: inline; }
.flex-1 { flex: 1; min-width: 0; }
.flex-row-wrap { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.text-center { text-align: center; }
.text-faint { color: var(--text-faint); }
.mt-sm { margin-top: 10px; }
.mb-0 { margin-bottom: 0; }
.max-w-sm { max-width: 220px; }
.max-w-md { max-width: 320px; }
.max-w-lg { max-width: 480px; }
.min-h-lg { min-height: 220px; }
.title-lg { font-size: 25px; }
.title-md { font-size: 19px; }
.payload-cell { max-width: 320px; overflow-wrap: break-word; }
.legend-dot--visible { background: #4a90d9; }
.legend-dot--anon { background: #ccc; }
.no-scroll { overflow: hidden; }
.mt-lg { margin-top: var(--sp-6); }
.fw-600 { font-weight: 600; }
.hint-text { font-size: 13px; color: var(--text-faint); }
.hint-text-sm { font-size: 13.5px; color: var(--text-faint); }
.intro-text { font-size: 13px; color: var(--text-muted); margin-bottom: var(--sp-4); max-width: 60ch; }
