/* ==========================================================================
   AffinityX — design system
   Minimal, premium, high legibility. Light + dark.
   ========================================================================== */

:root {
  --bg:        #F3F3F7;
  --surface:   #ffffff;
  --surface-2: #fafafb;
  --border:    #e6e6ea;
  --border-2:  #d9d9df;
  --text:      #111114;
  --text-2:    #5a5a63;
  --text-3:    #8a8a93;
  --accent:    #111114;
  --accent-fg: #ffffff;

  --new-bg:      #ffffff;
  --new-line:    #d9d9df;
  --prog-bg:     #fff8e8;
  --prog-line:   #f0c65a;
  --prog-text:   #8a6100;
  --done-bg:     #eefaf1;
  --done-line:   #63c07f;
  --done-text:   #1f6d3a;
  --danger:      #c0392b;

  /* Brand chrome — identical in light and dark themes */
  --chrome:        #030615;
  --chrome-2:      #0a0f24;
  --chrome-text:   #ffffff;
  --chrome-muted:  rgba(255, 255, 255, .62);
  --chrome-dim:    rgba(255, 255, 255, .42);
  --chrome-hover:  rgba(255, 255, 255, .07);
  --chrome-active: rgba(255, 255, 255, .12);
  --chrome-border: rgba(255, 255, 255, .11);

  --brand:         #26324a;
  --brand-hover:   #31405e;
  --brand-fg:      #ffffff;

  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(17,17,20,.05), 0 1px 3px rgba(17,17,20,.04);
  --shadow-2: 0 12px 32px rgba(17,17,20,.10), 0 2px 8px rgba(17,17,20,.06);
  --sidebar-w: 264px;
  --header-h: 84px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0e0e11;
    --surface:   #17171b;
    --surface-2: #1d1d22;
    --border:    #2a2a31;
    --border-2:  #35353d;
    --text:      #f2f2f4;
    --text-2:    #a6a6b0;
    --text-3:    #7c7c87;
    --accent:    #f2f2f4;
    --accent-fg: #0e0e11;

    --new-bg:    #17171b;
    --new-line:  #35353d;
    --prog-bg:   #241f10;
    --prog-line: #a37c1a;
    --prog-text: #e8c26a;
    --done-bg:   #10231a;
    --done-line: #2f7a4d;
    --done-text: #7fd4a0;
    --danger:    #ef6a5b;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 16px 40px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--text-3); font-size: 13.5px; }
.is-hidden { display: none !important; }

/* ------------------------------------------------------------------ brand */

.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand-logo { display: block; height: 40px; width: auto; }
.brand--auth { display: block; margin-bottom: 22px; }
.brand--auth .brand-logo { height: 42px; }

/* ----------------------------------------------------------------- topbar */

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  background: var(--chrome);
  color: var(--chrome-text);
  border-bottom: 1px solid var(--chrome-border);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-toggle { display: none; }

.topbar .btn-ghost { color: var(--chrome-muted); border-color: var(--chrome-border); background: transparent; }
.topbar .btn-ghost:hover { background: var(--chrome-hover); color: var(--chrome-text); }
.topbar .btn-ghost.is-active { background: var(--chrome-active); color: var(--chrome-text); border-color: transparent; }
.topbar .icon-btn { color: var(--chrome-muted); }
.topbar .icon-btn:hover { background: var(--chrome-hover); color: var(--chrome-text); }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--r-md);
  padding: 8px 14px;
  font: inherit; font-size: 13.5px; font-weight: 550;
  cursor: pointer; text-decoration: none;
  transition: background .14s ease, border-color .14s ease, color .14s ease, transform .06s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: var(--brand-fg); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.is-active { color: var(--text); border-color: var(--border-2); background: var(--surface-2); }
.btn-soft { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-soft:hover { border-color: var(--border-2); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger-ghost:hover { border-color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; padding: 11px 14px; font-size: 14px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent;
  color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn-sm { width: 28px; height: 28px; }
.icon-btn.is-copied { background: var(--done-bg); color: var(--done-line); border-color: var(--done-line); }

/* ---------------------------------------------------------------- layout */

.layout { display: flex; min-height: calc(100vh - var(--header-h)); align-items: stretch; margin-top: var(--header-h); }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--chrome-border);
  background: var(--chrome);
  color: var(--chrome-text);
  display: flex; flex-direction: column; justify-content: space-between;
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
}
.side-nav { padding: 14px 12px; }

.side-link {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--chrome-muted); text-decoration: none; font-size: 13.5px; font-weight: 500;
}
.side-link:hover { background: var(--chrome-hover); color: var(--chrome-text); }
.side-link.is-active { background: var(--chrome-active); color: var(--chrome-text); font-weight: 600; }
.side-link--top { margin-bottom: 6px; }

.side-heading {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 10px 6px;
  font-size: 11px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
  color: var(--chrome-dim);
}
.side-add {
  border: none; background: transparent; color: var(--chrome-dim);
  font-size: 17px; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 5px;
}
.side-add:hover { color: var(--chrome-text); background: var(--chrome-hover); }

.project-list { list-style: none; margin: 0; padding: 0; }
.project-item { margin-bottom: 1px; }
.project-link .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255, 255, 255, .28); flex: 0 0 6px;
}
.project-link.is-active .dot { background: var(--chrome-text); }
.project-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-empty { padding: 8px 10px; color: var(--chrome-dim); font-size: 13px; }

.submenu { list-style: none; margin: 2px 0 8px; padding: 0 0 0 25px; position: relative; }
.submenu::before {
  content: ''; position: absolute; left: 14px; top: 4px; bottom: 4px;
  width: 1px; background: var(--chrome-border);
}
.sub-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; border-radius: var(--r-sm);
  color: var(--chrome-dim); text-decoration: none; font-size: 13px;
}
.sub-count {
  font-size: 11px; font-weight: 650; color: var(--chrome-muted);
  background: var(--chrome-hover); border: 1px solid var(--chrome-border);
  border-radius: 999px; padding: 0 6px; min-width: 20px; text-align: center;
}
.sub-link.is-active .sub-count { color: var(--chrome-text); background: var(--chrome-active); }
.sub-link:hover { background: var(--chrome-hover); color: var(--chrome-text); }
.sub-link.is-active { color: var(--chrome-text); font-weight: 600; background: var(--chrome-active); }

.side-foot { padding: 12px; border-top: 1px solid var(--chrome-border); }
.side-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); border: 1px solid var(--chrome-border); color: var(--brand-fg);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 650; flex: 0 0 30px;
}
.side-user-meta { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.side-user-meta strong { font-size: 13px; font-weight: 600; color: var(--chrome-text); }
.side-user-meta small { font-size: 11.5px; color: var(--chrome-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-signout {
  width: 100%; padding: 7px; border-radius: var(--r-sm);
  border: 1px solid var(--chrome-border); background: transparent;
  color: var(--chrome-muted); font: inherit; font-size: 12.5px; cursor: pointer;
}
.side-signout:hover { background: var(--chrome-hover); color: var(--chrome-text); }

.main { flex: 1 1 auto; min-width: 0; }
.page { max-width: 1080px; margin: 0 auto; padding: 28px 28px 72px; }
.page--narrow { max-width: 720px; }

/* Entry list pages (Build Tasks / Marketing Tasks / Notes / Research):
   the header + filter/search toolbar stick under the fixed topbar so only
   the task list itself scrolls underneath them. z-index needs to clear the
   task rows' own stacking (.person avatars go up to z-index 30 on hover),
   but stay below the fixed topbar (40), so scrolled-under rows never poke
   through the sticky band. */
.page-sticky {
  position: sticky; top: var(--header-h); z-index: 35;
  background: var(--bg);
  padding-top: 6px; margin-top: -6px;
}

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-head-title { display: flex; align-items: flex-start; gap: 16px; }
.page-icon { width: 100px; height: 100px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); object-fit: cover; flex: 0 0 auto; }

.env-toggle {
  display: inline-flex; gap: 2px; padding: 3px; margin-right: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
}
.env-btn {
  border: none; background: transparent; color: var(--text-3);
  font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 5px 12px; border-radius: 8px; cursor: pointer;
}
.env-btn:hover { color: var(--text); }
.env-btn:disabled { cursor: default; opacity: .6; }
.env-btn.is-active[data-env="dev"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.env-btn.is-active[data-env="live"] { background: var(--done-line); color: #ffffff; box-shadow: var(--shadow-1); }
.page-title { font-size: 25px; line-height: 1.2; }
.page-sub { color: var(--text-3); font-size: 13.5px; margin-top: 4px; }
.page-sub a { color: var(--text-2); }
.breadcrumb { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-bottom: 4px; }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }

/* ------------------------------------------------------------- panels etc */

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow-1);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-title { font-size: 14px; font-weight: 650; margin-bottom: 12px; }
.panel-head .panel-title { margin-bottom: 12px; }
.sub-title { font-size: 13px; font-weight: 650; color: var(--text-2); }
.link-sm { font-size: 12.5px; color: var(--text-3); text-decoration: none; }
.link-sm:hover { color: var(--text); }
.divider { height: 1px; background: var(--border); margin: 6px 0; }
.platform-text { white-space: pre-wrap; color: var(--text-2); font-size: 14px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.split > .panel { margin-bottom: 16px; }

.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 900px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow-1);
}
.stat-value { display: block; font-size: 24px; font-weight: 680; letter-spacing: -0.02em; }
.stat-label { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.stat--progress { border-color: var(--prog-line); }
.stat--complete { border-color: var(--done-line); }
.stat--link { display: block; text-decoration: none; transition: border-color .14s ease, transform .14s ease; }
.stat--link:hover { border-color: var(--border-2); transform: translateY(-1px); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project-card {
  display: block; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-1);
  transition: border-color .14s ease, transform .14s ease;
}
.project-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.project-card h3 { font-size: 15.5px; }
.project-card-domain { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.project-card-go { display: block; margin-top: 14px; font-size: 12.5px; color: var(--text-3); }
.project-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.project-card-icon-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 0 0 auto; }
.project-card-icon { width: 90px; height: 90px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); object-fit: cover; flex: 0 0 auto; }
.project-card-icon-col .status-pill { font-size: 10.5px; padding: 2px 8px; }

.empty-state {
  background: var(--surface); border: 1px dashed var(--border-2);
  border-radius: var(--r-lg); padding: 44px 24px; text-align: center;
}
.empty-state h2 { font-size: 16px; }
.empty-state p { color: var(--text-3); font-size: 13.5px; margin: 6px 0 16px; }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-top: 1px solid var(--border); font-size: 13.5px;
}
.mini-row:first-child { border-top: none; }
.mini-title { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ forms */

.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: block; }
.label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field-check {
  display: flex; align-items: flex-start; gap: 9px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.field-check input[type="checkbox"] { margin-top: 3px; width: 15px; height: 15px; flex: 0 0 auto; accent-color: var(--brand); cursor: pointer; }
.field-check small.label-hint { display: block; font-weight: 450; margin-left: 0; }
.label-hint { font-weight: 450; color: var(--text-3); font-size: 11.5px; margin-left: 6px; }
.input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border-2); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.input:focus {
  outline: none; border-color: var(--text-3);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-3) 18%, transparent);
}
.input:disabled { background: var(--surface-2); color: var(--text-3); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.textarea-lg { min-height: 180px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.input-sm { padding: 7px 10px; font-size: 13px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-hint { font-size: 12.5px; color: var(--text-3); }
.form-error { font-size: 13px; color: var(--danger); }

.alert { padding: 10px 13px; border-radius: var(--r-md); font-size: 13.5px; margin-bottom: 14px; border: 1px solid; }
.alert-ok { background: var(--done-bg); border-color: var(--done-line); color: var(--done-text); }
.alert-err { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border-color: var(--danger); color: var(--danger); }

/* ------------------------------------------------------------------- tags */

.tag-picker { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; min-height: 30px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border-2); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.tag-chip:hover { border-color: var(--text-3); }
.tag-chip.is-selected { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.tag-chip .tag-x {
  border: none; background: transparent; color: inherit; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0; opacity: .5;
}
.tag-chip .tag-x:hover { opacity: 1; }
.tag-chip input.tag-edit {
  border: none; background: transparent; color: inherit; font: inherit; font-size: 12.5px;
  width: 90px; outline: none;
}
.icon-upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.icon-upload-row .input { flex: 1 1 160px; }
.icon-preview {
  display: inline-flex; width: 64px; height: 64px; flex: 0 0 64px;
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface-2);
  overflow: hidden;
}
.icon-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tag-add { display: flex; gap: 8px; }
.tag-add .input { flex: 1 1 auto; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-block; padding: 5px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-2);
}

/* ------------------------------------------------------------------ tasks */

.task-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.filter-group {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
}
.filter {
  border: none; background: transparent; color: var(--text-3);
  font: inherit; font-size: 12.5px; font-weight: 550;
  padding: 5px 11px; border-radius: 8px; cursor: pointer;
}
.filter:hover { color: var(--text); }
.filter.is-active { background: var(--surface-2); color: var(--text); }

.search-field {
  position: relative; display: flex; align-items: center;
  color: var(--text-3); flex: 1 1 200px; max-width: 280px;
}
.search-field svg { position: absolute; left: 10px; pointer-events: none; }
.search-input {
  width: 100%; padding: 7px 10px 7px 30px; font: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text);
}
.search-input:focus { outline: none; border-color: var(--text-3); }
.search-input::-webkit-search-cancel-button { cursor: pointer; }

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task-row {
  padding: 11px 14px;
  border: 1px solid var(--new-line); border-left-width: 3px;
  border-radius: var(--r-md); background: var(--new-bg);
  box-shadow: var(--shadow-1);
  transition: background .16s ease, border-color .16s ease, opacity .16s ease;
}
.task-main { display: flex; align-items: flex-start; gap: 12px; }
.task-row.status-in_progress { background: var(--prog-bg); border-color: var(--prog-line); }
.task-row.status-complete { background: var(--done-bg); border-color: var(--done-line); }
.task-row.status-complete .task-title { color: var(--done-text); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--done-text) 45%, transparent); }
.task-row.is-archived { opacity: .58; background: var(--surface-2); border-color: var(--border); border-left-color: var(--border-2); }
.task-row.is-archived:hover { opacity: .85; }
.archived-pill {
  flex: 0 0 auto; display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-2);
  color: var(--text-3); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.archived-note { font-size: 12px; color: var(--text-3); }
.archived-note a { color: var(--text-2); }
.task-title {
  flex: 1 1 auto; min-width: 0; font-size: 14px;
  word-break: break-word; white-space: pre-wrap; padding-top: 2px;
}
.assignee-tag {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text-2);
  font-size: 11.5px; font-weight: 550; white-space: nowrap;
}
.task-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; opacity: 1; }
.status-btn { border: none; background: transparent; padding: 0; cursor: pointer; flex: 0 0 auto; }
.inline-edit { flex: 1 1 auto; font-size: 14px; }

/* ---------------------------------------------------------- drag to reorder */

.drag-handle {
  flex: 0 0 auto; display: inline-grid; place-items: center;
  width: 20px; height: 24px; margin-left: -4px;
  color: var(--text-3); opacity: 0; cursor: grab;
  border-radius: 5px; transition: opacity .14s ease, color .12s ease;
}
.task-row:hover .drag-handle { opacity: .55; }
.drag-handle:hover { opacity: 1 !important; color: var(--text-2); }
.drag-handle:focus-visible {
  opacity: 1; outline: none; color: var(--text);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 55%, transparent);
}
.drag-handle:active { cursor: grabbing; }

.task-row.is-dragging { opacity: .45; box-shadow: var(--shadow-2); cursor: grabbing; }
.task-list.is-reordering { cursor: grabbing; }
.task-list.is-reordering .task-row { transition: transform .12s ease; }
.task-list.is-reordering .task-actions { opacity: 0 !important; }
.task-list.is-saving { opacity: .75; pointer-events: none; }

/* ------------------------------------------------------------ entry notes */

.note-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--border-2); background: var(--surface);
  color: var(--text-3); font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: color .12s ease, border-color .12s ease;
}
.note-toggle:hover { color: var(--text); border-color: var(--text-3); }
.note-toggle.has-any { color: var(--text-2); border-color: var(--border-2); }

.note-panel {
  margin: 12px 0 2px 0; padding: 12px 14px;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  border: 1px solid var(--border);
}
.note-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.note-empty { font-size: 13px; }
.note-item {
  position: relative; padding: 9px 30px 9px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.note-body { font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.note-meta { display: block; margin-top: 4px; font-size: 11px; color: var(--text-3); }
.note-del {
  position: absolute; top: 6px; right: 8px;
  border: none; background: transparent; color: var(--text-3);
  font-size: 15px; line-height: 1; cursor: pointer; padding: 2px 4px; border-radius: 5px; opacity: 0;
}
.note-item:hover .note-del { opacity: 1; }
.note-del:hover { color: var(--danger); background: var(--surface-2); }
.note-form { display: flex; gap: 8px; align-items: flex-end; }
.note-input { flex: 1 1 auto; min-height: 44px; font-size: 13.5px; }

/* --------------------------------------------------------- entry attachments */

.attach-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--border-2); background: var(--surface);
  color: var(--text-3); font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: color .12s ease, border-color .12s ease;
}
.attach-toggle:hover { color: var(--text); border-color: var(--text-3); }
.attach-toggle.has-any { color: var(--text-2); border-color: var(--border-2); }

.attach-panel {
  margin: 12px 0 2px 0; padding: 12px 14px;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  border: 1px solid var(--border);
}
.attach-panel .file-list { margin-bottom: 10px; }
.attach-panel .file-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); margin-bottom: 6px; padding: 8px 10px; }
.attach-panel .file-row:first-child { border-top: 1px solid var(--border); }
.attach-upload-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.attach-upload-form .input { flex: 1 1 auto; }

.convert-select { width: auto; max-width: 160px; }

/* ------------------------------------------------------- people / avatars */

.people-stack { display: inline-flex; align-items: center; flex: 0 0 auto; padding-left: 4px; }
.people-stack .person + .person { margin-left: -8px; }

.person {
  position: relative;
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
  border: 2px solid var(--surface);
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  transition: transform .14s ease;
}
.person--author { background: var(--brand); color: var(--brand-fg); border-color: var(--surface); }
.person--pending { background: transparent; border: 2px dashed var(--border-2); color: var(--text-3); }
.person--sm { width: 22px; height: 22px; flex: 0 0 22px; font-size: 9px; }
.person--lg { width: 34px; height: 34px; flex: 0 0 34px; font-size: 12px; border-width: 0; }
.person-initials { line-height: 1; }
.people-stack .person:hover { transform: translateY(-2px); z-index: 30 !important; }

/* status rows tint the surface, so match the avatar ring to the row */
.task-row.status-in_progress .person { border-color: var(--prog-bg); }
.task-row.status-complete .person { border-color: var(--done-bg); }

.person-tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--chrome); color: var(--chrome-text);
  padding: 6px 10px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 550; line-height: 1.35; letter-spacing: 0;
  white-space: nowrap; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .12s ease, transform .12s ease;
  z-index: 60; box-shadow: var(--shadow-2);
}
.person-tip small { display: block; font-size: 10.5px; font-weight: 500; color: var(--chrome-dim); }
.person-tip::after {
  content: ''; position: absolute; top: 100%; left: 50%; margin-left: -4px;
  border: 4px solid transparent; border-top-color: var(--chrome);
}
.person:hover .person-tip, .person:focus-visible .person-tip { opacity: 1; transform: translateX(-50%) translateY(-2px); }

/* ------------------------------------------------------------ files panel */

.file-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.file-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px; border-top: 1px solid var(--border);
}
.file-row:first-child { border-top: none; }
.file-icon {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--text-3);
  background: var(--surface-2); border: 1px solid var(--border);
}
.file-icon--image { color: var(--text-2); }
.file-name {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13.5px; font-weight: 600; color: var(--text); text-decoration: none;
}
.file-name:hover { text-decoration: underline; }
.file-meta { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.file-upload-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.file-upload-form .input { flex: 1 1 auto; }

/* ------------------------------------------------------------ team panel */

.member-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.member-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 4px; border-top: 1px solid var(--border);
}
.member-row:first-child { border-top: none; }
.member-list--pending { margin-top: -12px; }
.member-row.is-pending .member-meta strong { color: var(--text-2); font-weight: 550; }
.member-meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.member-meta strong { font-size: 13.5px; font-weight: 600; }
.member-meta strong a { text-decoration: none; }
.member-meta strong a:hover { text-decoration: underline; }
.member-meta small { font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.role-tag {
  flex: 0 0 auto; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 650; letter-spacing: .02em;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3);
}
.role-tag--owner { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.role-select { width: auto; min-width: 84px; padding: 5px 8px; font-size: 12.5px; }

.mail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.mail-result {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 13px; line-height: 1.5;
}
.mail-result strong { display: block; margin-bottom: 6px; font-size: 13.5px; }
.mail-result p { margin: 3px 0; color: var(--text-2); word-break: break-word; }
.mail-result.is-ok { background: var(--done-bg); border-color: var(--done-line); }
.mail-result.is-ok strong { color: var(--done-text); }
.mail-result.is-err { background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border-color: var(--danger); }
.mail-result.is-err strong { color: var(--danger); }

.invite-fallback { display: block; margin-top: 6px; color: var(--text-2); }
.invite-fallback code {
  display: inline-block; margin-top: 3px; padding: 3px 7px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11.5px; word-break: break-all; user-select: all;
}

.invite-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.invite-form .input[type=email] { flex: 1 1 220px; }
.leave-form { margin-top: 12px; }

.shared-tag {
  display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3);
  font-size: 10.5px; font-weight: 600; letter-spacing: .03em; text-transform: none;
}
.shared-icon { flex: 0 0 auto; color: var(--chrome-dim); }
.dot--shared { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--chrome-dim); }
.dot--live { background: var(--done-line) !important; box-shadow: 0 0 0 2px rgba(99, 192, 127, .3) !important; }

/* ------------------------------------------------------------------ pills */

.pill-group { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 15px; border-radius: 999px;
  border: 1px solid var(--border-2); background: var(--surface);
  color: var(--text-2); font: inherit; font-size: 13px; font-weight: 550;
  cursor: pointer;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.pill:hover { border-color: var(--text-3); color: var(--text); }
.pill.is-active { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.pill--toggle { font-size: 12.5px; padding: 6px 12px; }
.pill--toggle .toggle-box {
  width: 13px; height: 13px; border-radius: 4px; flex: 0 0 13px;
  border: 1.5px solid var(--border-2); background: transparent;
  display: inline-grid; place-items: center;
}
.pill--toggle .toggle-box svg { opacity: 0; }
.pill--toggle.is-active .toggle-box { border-color: var(--brand-fg); background: var(--brand-fg); color: var(--brand); }
.pill--toggle.is-active .toggle-box svg { opacity: 1; }
.split-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: -4px; }

.type-tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid var(--border-2); color: var(--text-3); background: var(--surface-2);
  flex: 0 0 auto;
}
.type-tag--research { border-color: var(--text-3); color: var(--text-2); }

.status-pill {
  display: inline-block; min-width: 92px; text-align: center;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2);
}
.status-pill--in_progress { background: var(--prog-line); border-color: var(--prog-line); color: #1c1400; }
.status-pill--complete { background: var(--done-line); border-color: var(--done-line); color: #04220f; }

/* ----------------------------------------------------------------- modals */

.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10,10,14,.5); backdrop-filter: blur(3px); }
.modal-panel {
  position: relative; width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  animation: pop .16s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 12px;
}
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 0 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

/* ------------------------------------------------------------------- auth */

body.auth {
  display: grid; place-items: center; min-height: 100vh; padding: 28px;
  background: var(--chrome); color: var(--chrome-text);
}
.auth-wrap { width: 100%; max-width: 410px; }
.brand--auth { display: block; text-align: center; margin-bottom: 22px; }
.brand--auth .brand-logo { height: 46px; margin: 0 auto; }
.auth-card {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 30px; box-shadow: var(--shadow-2);
}
.auth-title { font-size: 21px; }
.auth-sub { color: var(--text-3); font-size: 13.5px; margin: 6px 0 20px; }
.invite-kicker { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; font-weight: 650; margin-bottom: 4px; }
.auth-foot { margin-top: 18px; font-size: 13px; color: var(--text-3); text-align: center; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.auth-foot a { color: var(--text-2); }

/* ------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .split, .two-col { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  :root { --header-h: 66px; }
  .nav-toggle { display: inline-grid; order: -1; }
  .brand-logo { height: 30px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .sidebar {
    position: fixed; left: 0; top: var(--header-h); z-index: 50;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: var(--shadow-2);
  }
  .sidebar.is-open { transform: none; }
  .page { padding: 20px 16px 64px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .status-pill { min-width: 78px; }

  /* Header: icon-only "My Profile" button, so it doesn't crowd the toggle/logo. */
  .topbar-actions .btn-label { display: none; }
  .topbar-actions .btn-ghost { padding-left: 10px; padding-right: 10px; }

  /* Entry rows: the entry text drops to its own full-width line below the
     status pill / assignee tag / action buttons (which are always visible
     at every width — see .task-actions above). */
  .task-main { flex-wrap: wrap; }
  .task-title { order: 5; flex-basis: 100%; width: 100%; }
}
