/* Buttons */
.btn {
  height: 32px;
  border-radius: var(--r-control);
  padding: 0 14px;
  font: 500 13px/1 var(--font-sans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-primary { background: var(--foreground); color: #fff; }
.btn-secondary { background: var(--background); border: 1px solid var(--border); color: var(--foreground); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn-iris { background: var(--iris-9); color: #fff; }
/* Monochrome accent (Jul 11): needs-you outline buttons look like btn-secondary */
.btn-iris-outline { background: var(--background); border: 1px solid var(--border); color: var(--foreground); }

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-control);
  background: transparent;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--foreground);
}
.icon-btn:hover { background: var(--muted); }
.icon-btn svg { width: 16px; height: 16px; }

/* Inputs */
.input, .search {
  height: 36px;
  border-radius: var(--r-control);
  background: var(--background);
  border: 1px solid var(--border);
  padding: 0 12px;
  font: 400 13px/1 var(--font-sans);
  color: var(--foreground);
  width: 100%;
}
.input::placeholder, .search::placeholder { color: var(--muted-foreground); }

/* Pills */
.pill {
  height: 20px;
  border-radius: var(--r-pill);
  padding: 0 8px;
  font: 500 11px/1 var(--font-sans);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
}
.pill-gray { background: var(--muted); color: var(--foreground); }
.pill-outline { background: var(--background); border: 1px solid var(--border); color: var(--foreground); }
.pill-green { background: var(--green-3); color: var(--green-11); }
.pill-amber { background: var(--amber-3); color: var(--amber-11); }
.pill-red { background: var(--red-3); color: var(--red-9); }
.pill-iris { background: var(--iris-3); border: 1px solid var(--accent-border); color: var(--foreground); }
.pill-iris::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--foreground); flex-shrink: 0; }
.pill-mono { font-family: var(--font-mono); font-size: 10px; }
/* Citation chip — Figma: filled muted pill, book-open icon, mono muted text, no border */
.pill-cite {
  background: var(--muted);
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 10px;
  border: none;
}
.pill-cite svg { width: 12px; height: 12px; flex-shrink: 0; }

/* App shell — Figma: white page, sidebar is a 255px floating card at top-left */
.app {
  display: flex;
  align-items: flex-start;
  height: 100vh;
  background: var(--background);
}
.main {
  flex: 1;
  background: var(--background);
  overflow: auto;
  height: 100vh;
}

/* Sidebar — Figma master 41:56: 255w, #FAFAFA, 1px #E5E5E5, r10.
   Full viewport height with the profile footer pinned bottom-left (Javier, Jul 9). */
.sidebar {
  position: relative;
  width: 255px;
  flex-shrink: 0;
  height: 100vh;
  background: #FAFAFA;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  transition: width .15s ease;
}
.sidebar-workspace-header { cursor: pointer; border-radius: 8px; }
.sidebar-workspace-header:hover { background: #F0F2F4; }
.sidebar-collapse, .sidebar-expand { cursor: pointer; }
.sidebar-collapse:hover, .sidebar-expand:hover { background: var(--muted); }

/* Workspace Switcher Popover — Figma 43:131: 240w, r10, pad 12/8, gap 6, 46px rows */
.workspace-popover {
  display: none;
  position: absolute;
  top: 64px;
  left: 8px;
  width: 240px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  z-index: 50;
}
.workspace-popover.open { display: block; }
.workspace-popover-label { font: 500 10px/12px var(--font-sans); color: #737373; padding: 0 8px 6px; }
.workspace-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
}
.workspace-row:hover { background: #F0F2F4; }
.workspace-tile {
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font: 500 12px/1 var(--font-sans);
  flex-shrink: 0;
}
.workspace-tile.tile-p { background: #F0F0F3; color: #60646C; }
.workspace-tile.tile-h { background: #FFF7C2; color: #AB6400; }
.workspace-tile.tile-kredi { background: #FFFFFF; border: 1px solid var(--border); }
.workspace-tile.tile-kredi img { width: 16px; height: 16px; }
.workspace-row-text { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.workspace-row-name { font: 600 14px/17px var(--font-sans); color: #000; }
.workspace-row-sub { font: 400 10px/12px var(--font-sans); color: #737373; }
.workspace-row svg.check { width: 14px; height: 14px; color: #000; flex-shrink: 0; }

/* Collapsed rail — Figma "Sidebar Rail" 128:363: 56w, pad 16/0, icon buttons 28×28 r6 */
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .sidebar-workspace { padding: 16px 12px 0; }
.sidebar.collapsed .sidebar-workspace-header { padding: 0; height: auto; pointer-events: none; }
.sidebar.collapsed .sidebar-workspace-name,
.sidebar.collapsed .sidebar-workspace-header > svg { display: none; }
.sidebar.collapsed .sidebar-logo-tile { border: 1px solid var(--border); }
.sidebar.collapsed .sidebar-collapse { position: static; margin: 14px auto 0; }
.sidebar.collapsed .sidebar-collapse svg { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-section { display: none; }
.sidebar.collapsed .sidebar-group { padding: 8px 14px; }
.sidebar.collapsed .sidebar-nav { gap: 14px; }
.sidebar.collapsed .nav-item {
  width: 28px; height: 28px; padding: 0; justify-content: center; gap: 0;
  border-radius: 6px; font-size: 0;
}
.sidebar.collapsed .nav-item.active { background: #F0F2F5; }
.sidebar.collapsed .sidebar-footer { padding: 8px 12px 16px; }
.sidebar.collapsed .sidebar-footer-header { padding: 0; justify-content: center; height: auto; }
.sidebar.collapsed .sidebar-avatar { width: 28px; height: 28px; border-radius: 9999px; }
.sidebar.collapsed .sidebar-footer-name,
.sidebar.collapsed .sidebar-footer-header svg.gear { display: none; }
.sidebar.collapsed .workspace-popover { display: none !important; }
/* Workspace Switcher Card: pad 8 / Header: h48 pad 8 gap 8 */
.sidebar-workspace { padding: 8px; }
.sidebar-workspace-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  height: 48px;
}
.sidebar-logo-tile {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-tile img { width: 20px; height: 20px; }
/* Workspace re-skin (Decision 27A) — Personal/HandyPass letter tiles */
.sidebar-logo-tile.tile-p { background: #F0F0F3; color: #60646C; font: 500 14px/1 var(--font-sans); }
.sidebar-logo-tile.tile-h { background: #FFF7C2; color: #AB6400; font: 500 14px/1 var(--font-sans); }
.sidebar-workspace-name { font: 600 16px/20px var(--font-sans); color: #0A0A0A; }
.sidebar-workspace-header > svg { width: 16px; height: 16px; color: #0A0A0A; flex-shrink: 0; }
/* Collapse handle: 24×24 circle straddling the sidebar's right border,
   centered on the workspace row (Javier, Jul 9) */
.sidebar-collapse {
  position: absolute;
  top: 28px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.sidebar-collapse svg { width: 14px; height: 14px; color: #000; }

/* Section: pad 8; label row h32 padL/R 8; menu gap 4 */
.sidebar-group { padding: 8px; }
.sidebar-section {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 8px;
  font: 400 12px/16px var(--font-sans);
  color: #0A0A0A;
  opacity: 0.7;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
/* Nav item: h32 pad 8 gap 8 r8; label 14 Regular lh20 #0A0A0A; active #F0F2F4 + Medium */
.nav-item {
  height: 32px;
  border-radius: 8px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 400 14px/20px var(--font-sans);
  color: #0A0A0A;
  text-decoration: none;
}
.nav-item svg { width: 16px; height: 16px; stroke-width: 1.5; flex-shrink: 0; }
.nav-item:hover { background: #F0F2F4; }
.nav-item.active { background: #F0F2F4; font-weight: 500; color: #000; }

/* Profile Footer: pad 8 / header h48 pad 8 gap 8; avatar 32 r8; name 14 SemiBold.
   Pinned to the bottom of the full-height sidebar. */
.sidebar-footer { padding: 8px; margin-top: auto; }
.sidebar-footer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  height: 48px;
}
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: cover;
}
.sidebar-footer-name { font: 600 14px/20px var(--font-sans); color: #0A0A0A; flex: 1; }
.sidebar-footer-header svg.gear { width: 16px; height: 16px; color: #0A0A0A; flex-shrink: 0; }

/* Toast — fixed bottom-center, darkest neutral surface */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 8px);
  background: var(--foreground);
  color: #fff;
  font: 500 13px/1.4 var(--font-sans);
  border-radius: 8px;
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.16);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Popover menu — toggled via [data-menu], see app.js */
.menu-popover {
  display: none;
  position: absolute;
  min-width: 200px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  z-index: 100;
}
.menu-popover.open { display: block; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font: 400 13px/1.4 var(--font-sans);
  color: var(--foreground);
  cursor: pointer;
  text-decoration: none;
}
.menu-item:hover { background: var(--muted); }
.menu-item.danger { color: var(--red-9); }
.menu-separator { height: 1px; background: var(--border); margin: 4px 6px; }

/* Sidebar footer settings menu opens upward above the footer header */
.sidebar-footer { position: relative; }
.sidebar-footer .menu-popover { bottom: 60px; left: 8px; right: 8px; }
.sidebar.collapsed .sidebar-footer .menu-popover { left: 4px; right: auto; min-width: 200px; }

/* ===== Shared page layer — consolidation sprint (Jul 10, decisions R1+R2) ===== */

/* Page wrapper + header (R1-D3) */
.page-wrap { padding: 32px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-sub { font: 400 13px/1.4 var(--font-sans); color: var(--muted-foreground); margin: 2px 0 0; }

/* Breadcrumb — full detail pages only (R1-D6) */
.crumb { display: flex; align-items: center; gap: 6px; font: 400 13px/1 var(--font-sans); color: var(--muted-foreground); }
.crumb a { color: var(--muted-foreground); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.crumb .cur { color: var(--foreground); font-weight: 500; }

/* Toolbar: icon search + filter chips (R1-D4) */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-wrap { position: relative; width: 280px; }
.search-wrap .search { padding-left: 34px; }
.search-icon { width: 14px; height: 14px; color: var(--muted-foreground); position: absolute; margin: 11px 0 0 12px; pointer-events: none; }
.filter-chip {
  height: 26px; border-radius: var(--r-pill); padding: 0 12px;
  display: inline-flex; align-items: center;
  font: 400 12px/1 var(--font-sans); color: #000;
  border: 1px solid var(--border); background: var(--background);
  text-decoration: none; cursor: pointer;
}
.filter-chip.active { background: #F0F2F4; border-color: transparent; font-weight: 500; }
/* Groups a set of .filter-chip as one unit so [data-workspace] can show/hide
   them together (e.g. visibility chips hidden in Personal — Decision 53A). */
.chip-group { display: flex; align-items: center; gap: 8px; }

/* Decision 53A/55A — below ~900px, search claims its own row so it never
   squeezes chips/source/sort into an overflowing single line. flex-basis:100%
   on a wrapped flex item forces the line break; the rest reflows below it.
   Scoped to toolbars running the facet-filter engine (app.js) so unrelated
   .toolbar usages (tasks, skills, knowledge-review, etc.) are unaffected. */
@media (max-width: 900px) {
  .toolbar:has([data-facet-filter]) .search-wrap { flex-basis: 100%; width: 100%; }
}

/* Files' compact Source control (Decision 55A, amended) — a real <button> +
   chevron with the .menu-popover as a sibling (same shape as every other
   [data-menu] trigger, e.g. row-menu) so it stays a valid, keyboard-focusable
   button rather than nesting interactive popover items inside one. */
.source-control { position: relative; }
.source-btn {
  height: 26px; border-radius: 6px; padding: 0 8px 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
  font: 400 12px/1 var(--font-sans); color: #000;
  border: 1px solid var(--border); background: var(--background);
  cursor: pointer;
}
.source-btn:hover { background: var(--muted); }
.source-btn .chevron { width: 12px; height: 12px; color: var(--muted-foreground); flex-shrink: 0; }
.source-control .menu-popover { top: calc(100% + 6px); left: 0; min-width: 180px; }
.source-control .menu-item.facet-option { cursor: pointer; justify-content: space-between; }
.source-control .menu-item svg.check { width: 14px; height: 14px; color: #000; flex-shrink: 0; visibility: hidden; }
.source-control .menu-item.active svg.check { visibility: visible; }

/* Data table — grid engine; page sets grid-template-columns on both head + rows
   via one page-local .cols-* class so headers align with content (R2-D10) */
.table-head {
  display: grid; align-items: center; height: 32px; gap: 12px; padding: 0 12px;
  border-bottom: 1px solid var(--border);
  font: 500 11px/1 var(--font-sans); color: var(--muted-foreground);
}
.table-row {
  display: grid; align-items: center; min-height: 56px; gap: 12px; padding: 0 12px;
  border-bottom: 1px solid var(--border); text-decoration: none; color: inherit;
}
.table-row:hover { background: var(--muted); }
.table-row:last-child { border-bottom: none; }
.cell-title { font: 500 13px/1.3 var(--font-sans); }
.cell-dim { font: 400 12px/1.4 var(--font-sans); color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-head { display: flex; align-items: center; gap: 6px; height: 28px; padding: 8px 4px 0; font: 500 12px/1 var(--font-sans); color: var(--muted-foreground); }

/* Card list — content you read: knowledge, meetings (R1-D1 option C) */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.card { border: 1px solid var(--border); border-radius: 8px; padding: 16px; background: var(--background); }
a.card { display: block; text-decoration: none; color: inherit; }
a.card:hover { background: var(--muted); }

/* Empty category state — product-voice glyph + two lines (R5-D26 option B) */
.list-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 0; color: var(--muted-foreground); }
.list-empty-glyph { width: 20px; height: 20px; }
.list-empty-line1 { font: 400 13px/1.4 var(--font-sans); color: var(--foreground); }
.list-empty-line2 { font: 400 12px/1.4 var(--font-sans); color: var(--muted-foreground); }
/* Clear-filters action inside a filtered-zero empty state (Decision 53A) */
.list-empty-reset { margin-top: 2px; background: none; border: none; padding: 0; cursor: pointer; font: 500 13px/1.4 var(--font-sans); color: var(--iris-11); }
.list-empty-reset:hover { text-decoration: underline; }

/* Drawer — the one detail overlay (R1-D5) + light scrim (R2-D9) */
.drawer-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .15); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 480px;
  background: var(--background); border-left: 1px solid var(--border);
  padding: 24px; display: flex; flex-direction: column; gap: 20px;
  overflow-y: auto; z-index: 41;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-title { font: 600 16px/1.3 var(--font-sans); margin: 0; }

/* Avatars — circle = person, square = company; 32 rows / 20 stacks (R1-D7) */
.avatar { width: 32px; height: 32px; border-radius: var(--r-pill); flex-shrink: 0; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; background: var(--muted); font: 600 11px/1 var(--font-sans); color: var(--muted-foreground); }
.avatar-sq { border-radius: 8px; }
.avatar-20 { width: 20px; height: 20px; font-size: 8px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar-20 { border: 2px solid var(--background); }
.avatar-stack .avatar-20 + .avatar-20 { margin-left: -6px; }
.avatar-stack.lg .avatar { width: 28px; height: 28px; background: var(--muted); font: 500 11px/1 var(--font-sans); color: #000; border: 2px solid var(--background); }
.avatar-stack.lg .avatar + .avatar { margin-left: -8px; }
.people-row { display: flex; align-items: center; gap: 10px; }
.view-all { font: 500 12px/1.2 var(--font-sans); color: var(--muted-foreground); text-decoration: none; }

/* Small muted chip — the one chip (replaces chip-project/tag-chip/project-chip/note-meta-chip/pill-muted) */
.chip { height: 16px; padding: 2px 6px; border-radius: 4px; background: var(--muted); font: 500 10px/1 var(--font-sans); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

/* Needs-you signal (R1-D8): card when it IS the item, link when it references.
   Monochrome accent (Jul 11): flat 3% ink wash + 14% border, ink dot marker. */
.attention-card { display: flex; align-items: center; justify-content: flex-start; gap: 10px; min-height: 46px; padding: 10px 16px; background: var(--iris-3); border: 1px solid var(--accent-border); border-radius: 10px; text-decoration: none; color: inherit; }
.attention-card::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--foreground); flex-shrink: 0; }
.attention-card > :last-child:not(:first-child) { margin-left: auto; }
.attention-link { color: var(--iris-11); font-weight: 500; text-decoration: none; }
/* ponytail: nowrap keeps dot+label on one line; scope it off if a long prose link ever overflows */
.attention-link { white-space: nowrap; }
.attention-link::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 999px; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.attention-link:hover { text-decoration: underline; }

/* Creation dialog — promoted from persons/companies/notes inline copies */
.modal-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .5); display: flex; align-items: center; justify-content: center; }
.modal-overlay[hidden] { display: none; }
[hidden] { display: none !important; } /* hidden attribute must beat display rules like a.card / .drawer */
.create-dialog { width: 400px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 20px; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.create-dialog-title { font: 600 16px/1.2 var(--font-sans); color: #000; margin: 0; }
.create-fields { display: flex; flex-direction: column; gap: 14px; }
.create-field { display: flex; flex-direction: column; gap: 6px; }
.create-field label { font: 500 12px/1.4 var(--font-sans); color: var(--foreground); }
.create-field input, .create-field select, .create-field textarea { border: 1px solid var(--border); border-radius: var(--r-control); padding: 0 10px; font: 400 13px/1.4 var(--font-sans); color: var(--foreground); background: var(--background); }
.create-field input, .create-field select { height: 32px; }
.create-field textarea { padding: 8px 10px; resize: none; }
.create-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.row-menu { position: relative; display: inline-flex; }
.row-menu .menu-popover { right: 0; top: 32px; }

/* Provenance tooltip (D22, option A) — hover AND keyboard-focus reveal, no
   always-visible second line. Trigger needs tabindex="0" to be focusable. */
.tip { position: relative; cursor: help; outline: none; border-radius: 4px; }
.tip:focus-visible { box-shadow: 0 0 0 2px var(--iris-9); }
.tip-bubble {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  min-width: 200px; max-width: 280px;
  background: var(--foreground); color: #fff;
  font: 400 11px/1.4 var(--font-sans);
  padding: 8px 10px; border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
  opacity: 0; visibility: hidden; transform: translateY(2px);
  transition: opacity .12s ease, transform .12s ease;
  z-index: 60; pointer-events: none;
}
.tip:hover .tip-bubble, .tip:focus .tip-bubble, .tip:focus-within .tip-bubble {
  opacity: 1; visibility: visible; transform: translateY(0);
}

/* List pane — shared master-detail left column (decision 16, option A: chat's style) */
.list-pane {
  width: 280px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex; flex-direction: column;
  height: 100vh; overflow: auto;
}
.list-pane > .btn { width: 100%; margin-bottom: 12px; }
.pane-row {
  display: block; font: 400 13px/1.3 var(--font-sans);
  padding: 8px 10px; border-radius: var(--r-control);
  color: var(--foreground); text-decoration: none; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pane-row:hover { background: var(--muted); }
.pane-row.active { background: var(--muted); font-weight: 500; }
.pane-row-sub { display: block; font: 400 11px/1.3 var(--font-sans); color: var(--muted-foreground); font-weight: 400; margin-top: 2px; }
