@import url('https://fonts.googleapis.com/css2?family=Special+Elite&family=Courier+Prime:ital,wght@0,400;0,700;1,400&display=swap');

/* ── Palette ──────────────────────────────────────────── */
:root {
  --parchment:       #F5EDD6;
  --parchment-light: #FBF6EA;
  --bark:            #2C1810;
  --earth:           #8B3A2A;
  --terracotta:      #C4714F;
  --ochre:           #C4956A;
  --sand:            #D4B896;
  --sage:            #5C7D61;
  --sage-light:      #A8C4AC;
  --rose:            #B87878;
  --rose-light:      #DEB8BA;
  --border:          #D4B896;
  --shadow:          rgba(44, 24, 16, 0.12);
  --shadow-md:       rgba(44, 24, 16, 0.2);
}

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ─────────────────────────────────────────────── */
body {
  font-family: 'Courier Prime', 'Courier New', monospace;
  background-color: var(--parchment);
  color: var(--bark);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 15% 60%, rgba(196,149,106,.26) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(92,125,97,.22)   0%, transparent 45%),
    radial-gradient(ellipse at 50% 95%, rgba(184,120,120,.20) 0%, transparent 40%);
}

h1, h2, h3, h4, h5 { font-family: 'Special Elite', cursive; letter-spacing: .03em; }

a { color: var(--earth); }
a:hover { color: var(--terracotta); }

/* ── Navigation ───────────────────────────────────────── */
.nav {
  background-color: var(--bark);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px var(--shadow-md);
}

.nav-brand {
  font-family: 'Special Elite', cursive;
  font-size: 1.35rem;
  color: var(--ochre);
  text-decoration: none;
  letter-spacing: .06em;
  flex-shrink: 0;
}
.nav-brand span { color: var(--rose-light); }

.nav-links {
  display: flex;
  gap: 1.4rem;
  align-items: center;
  list-style: none;
}
.nav-links a {
  color: var(--sand);
  text-decoration: none;
  font-size: .88rem;
  letter-spacing: .05em;
  transition: color .15s;
}
.nav-links a:hover { color: var(--ochre); }
.nav-logout { color: var(--rose-light) !important; }
.nav-user {
  font-size: .8rem;
  color: var(--sage-light);
  font-style: italic;
}
.nav-divider { width: 1px; height: 18px; background: rgba(255,255,255,.12); }

/* ── Flash messages ───────────────────────────────────── */
.flash-messages { max-width: 1100px; margin: 1rem auto 0; padding: 0 1.5rem; }
.flash {
  padding: .7rem 1.2rem;
  border-radius: 4px;
  margin-bottom: .4rem;
  font-size: .88rem;
  border-left: 4px solid;
}
.flash-success { background: rgba(92,125,97,.14); border-color: var(--sage); color: #2D5A32; }
.flash-error   { background: rgba(196,113,79,.14); border-color: var(--terracotta); color: var(--earth); }

/* ── Layout ───────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Page header ──────────────────────────────────────── */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.page-header h1 { font-size: 1.9rem; color: var(--earth); margin-bottom: .2rem; }
.page-subtitle   { color: var(--ochre); font-style: italic; font-size: .88rem; }

/* ── Dashboard topbar (tabs + stats) ─────────────────── */
.dashboard-topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.dashboard-stats {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding-bottom: .55rem;
}
.dash-stat-card {
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .3rem .8rem;
  text-align: center;
  min-width: 76px;
  flex-shrink: 0;
}
.dash-stat-num {
  font-family: 'Special Elite', cursive;
  font-size: 1.1rem;
  line-height: 1.2;
}
.dash-stat-lbl {
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--sand);
}

/* ── Stats row (kept for any existing references) ────── */
.stats-row { display: flex; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.stat-card {
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .9rem 1.4rem;
  text-align: center;
  flex: 1;
  min-width: 100px;
}
.stat-number { font-family: 'Special Elite', cursive; font-size: 1.9rem; color: var(--earth); line-height: 1; }
.stat-label  { font-size: .75rem; color: var(--ochre); text-transform: uppercase; letter-spacing: .1em; margin-top: .2rem; }

/* ── Toolbar ──────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}

/* ── Search bar ───────────────────────────────────────── */
.search-bar { display: flex; gap: .5rem; flex: 1; max-width: 520px; }
.search-input-wrap { position: relative; flex: 1; }
.search-input-wrap .form-control { width: 100%; padding-right: 2rem; }
.search-clear { position: absolute; right: .55rem; top: 50%; transform: translateY(-50%); color: var(--sand); font-size: 1.1rem; line-height: 1; text-decoration: none; }
.search-clear:hover { color: var(--earth); }

/* ── Grid ─────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.4rem;
}

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.4rem 1.4rem .6rem;
  box-shadow: 0 2px 6px var(--shadow);
  transition: box-shadow .2s, transform .15s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}
.card:hover {
  box-shadow: 0 5px 18px var(--shadow-md);
  transform: translateY(-2px);
}
.woman-card-name  { font-family: 'Special Elite', cursive; font-size: 1.15rem; color: var(--earth); margin-bottom: .18rem; }
.woman-card-dates { font-size: .78rem; color: var(--ochre); margin-bottom: .55rem; font-style: italic; }
.woman-card-summary {
  font-size: .84rem;
  line-height: 1.65;
  margin-bottom: .75rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Tags ─────────────────────────────────────────────── */
.tags-row { display: flex; flex-wrap: wrap; gap: .3rem; }
.card .tags-row { max-height: 6.6rem; overflow: hidden; }
.card .tags-row.tags-expanded { max-height: none; }
.tags-show-more {
  background: none; border: none; padding: .25rem 0 0;
  color: var(--sand); font-size: .74rem; cursor: pointer;
  text-decoration: underline; display: none;
}
.tag {
  display: inline-block;
  padding: .18rem .55rem;
  border-radius: 20px;
  font-size: .72rem;
  letter-spacing: .05em;
  font-weight: 700;
  text-decoration: none;
  transition: opacity .15s;
}
.tag:hover { opacity: .75; }
.tag-earth  { background: rgba(139,58,42,.14); color: var(--earth);        border: 1px solid rgba(139,58,42,.3);  }
.tag-sage   { background: rgba(92,125,97,.14);  color: var(--sage);         border: 1px solid rgba(92,125,97,.3);  }
.tag-rose   { background: rgba(184,120,120,.15);color: #7A3D40;             border: 1px solid rgba(184,120,120,.35);}
.tag-ochre  { background: rgba(196,149,106,.2); color: #7A5A30;             border: 1px solid rgba(196,149,106,.4); }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: .48rem 1.2rem;
  border-radius: 4px;
  font-family: 'Courier Prime', monospace;
  font-size: .88rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  transition: all .15s;
  line-height: 1.4;
}
.btn-primary  { background: var(--earth);  color: var(--parchment-light); border-color: var(--earth);  }
.btn-primary:hover  { background: var(--bark);  border-color: var(--bark);  color: var(--parchment-light); }
.btn-secondary{ background: transparent;   color: var(--earth);           border-color: var(--ochre);  }
.btn-secondary:hover{ background: var(--ochre); color: var(--bark);        border-color: var(--ochre);  }
.btn-danger   { background: transparent;   color: #922;                   border-color: #C88; font-size: .78rem; }
.btn-danger:hover   { background: rgba(150,50,50,.1); }
.btn-sm       { padding: .28rem .7rem; font-size: .78rem; }
.btn-ghost    { background: transparent; color: var(--ochre); border-color: transparent; font-size: .8rem; text-transform: none; letter-spacing: 0; }
.btn-ghost:hover { color: var(--earth); text-decoration: underline; }

/* ── Forms ────────────────────────────────────────────── */
.form-group  { margin-bottom: 1.5rem; }
.form-control, textarea, input[type="text"], input[type="email"], input[type="password"], select { scroll-margin-top: 5rem; }
.form-label  {
  display: block;
  font-family: 'Special Elite', cursive;
  font-size: .9rem;
  color: var(--earth);
  margin-bottom: .45rem;
  letter-spacing: .04em;
}
.form-hint   { font-size: .78rem; color: var(--ochre); font-style: italic; margin-top: .25rem; }
.form-control {
  width: 100%;
  padding: .55rem .8rem;
  font-family: 'Courier Prime', monospace;
  font-size: .95rem;
  background: var(--parchment-light);
  border: 1px solid var(--sand);
  border-bottom: 2px solid var(--ochre);
  border-radius: 4px 4px 0 0;
  color: var(--bark);
  transition: border-color .15s, background .15s;
}
.form-control:focus { outline: none; border-bottom-color: var(--earth); background: #fff; }
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: .5;
  filter: sepia(1) saturate(2) hue-rotate(330deg);
  cursor: pointer;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: .85; }
textarea.form-control       { resize: vertical; min-height: 160px; line-height: 1.7; }
textarea.form-control.short { min-height: 0; }

/* ── Source list in form ──────────────────────────────── */
.source-list  { display: flex; flex-direction: column; gap: .45rem; }
.source-item  { display: flex; gap: .45rem; align-items: flex-start; }
.source-item .form-control { flex: 1; }
.btn-remove-source {
  background: none; border: none; cursor: pointer;
  color: var(--rose); font-size: 1.1rem; padding: .4rem .5rem;
  line-height: 1; flex-shrink: 0; opacity: .7;
  transition: opacity .15s;
}
.btn-remove-source:hover { opacity: 1; }

/* ── Checkbox grid (theme selection) ─────────────────── */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .4rem;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .7rem;
  background: var(--parchment-light);
}
.checkbox-item { display: flex; align-items: center; gap: .45rem; font-size: .88rem; }
.checkbox-item input[type="checkbox"] { accent-color: var(--earth); width: 14px; height: 14px; }

/* ── Divider ──────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; position: relative; }
.divider::after {
  content: '✦';
  position: absolute; top: -9px; left: 50%;
  transform: translateX(-50%);
  background: var(--parchment);
  padding: 0 .5rem;
  color: var(--ochre); font-size: .75rem;
}

/* ── Section titles ───────────────────────────────────── */
.section-title {
  font-family: 'Special Elite', cursive;
  font-size: 1rem;
  font-weight: 700;
  color: var(--earth);
  margin-bottom: .9rem;
  padding-bottom: .45rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: .05em;
}

/* ── Profile view ─────────────────────────────────────── */
.profile-header { margin-bottom: 2.5rem; }
.profile-name   { font-family: 'Special Elite', cursive; font-size: 2.4rem; color: var(--earth); line-height: 1.1; }
.profile-dates      { font-size: .95rem; color: var(--ochre); font-style: italic; margin-top: .25rem; }
.profile-key-places { font-size: .88rem; color: var(--bark); margin-top: .45rem; line-height: 1.6; }
.added-by-badge {
  display: inline-block;
  margin-top: .6rem;
  font-size: .78rem;
  font-family: 'Special Elite', cursive;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--parchment-light);
  background: var(--ochre);
  padding: .2rem .65rem;
  border-radius: 20px;
}
.card-added-by {
  font-size: .75rem;
  color: var(--ochre);
  margin-top: auto;
  padding-top: .5rem;
  letter-spacing: .03em;
}
.card-added-by strong { font-weight: 700; color: var(--earth); }
.card-added-by { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .3rem; }
.card-timestamp { color: var(--sand); font-size: .72rem; }
.profile-actions{ display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }

.profile-summary {
  font-size: .97rem;
  line-height: 1.85;
  white-space: pre-wrap;
}

.sources-list { list-style: none; }
.sources-list li {
  padding: .4rem 0;
  border-bottom: 1px dotted var(--border);
  font-size: .88rem;
  line-height: 1.5;
}
.sources-list li:last-child { border-bottom: none; }
.sources-list li::before { content: '— '; color: var(--ochre); }

/* ── Notes ────────────────────────────────────────────── */
.notes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 10px;
  column-gap: 1rem;
  row-gap: 0;
  margin-bottom: 1rem;
  align-items: start;
}
@media (max-width: 640px) {
  .notes-grid { grid-template-columns: 1fr; }
}
.note-item {
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .9rem 1.1rem;
  margin-bottom: .75rem;
  box-shadow: 0 1px 4px var(--shadow-sm);
}
.note-badges { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-bottom: .35rem; }
.note-title-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .5rem;
  margin-bottom: .45rem;
}
.note-title-row .note-subject { margin-bottom: 0; }
.note-type-badge {
  display: inline-block;
  padding: .18rem .55rem;
  background: var(--bark);
  color: var(--ochre);
  font-family: 'Special Elite', cursive;
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-radius: 3px;
}
.note-subject { font-weight: 700; font-size: .88rem; margin-bottom: .25rem; color: var(--bark); }
.note-content { font-size: .9rem; line-height: 1.65; white-space: pre-wrap; margin-bottom: .35rem; }
.note-byline  { font-size: .72rem; color: var(--ochre); }
.note-refs    { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .45rem; margin-bottom: .35rem; padding-top: .4rem; border-top: 1px dotted var(--border); }
.note-refs-label { font-size: .72rem; color: var(--sand); letter-spacing: .04em; flex-shrink: 0; }
.note-ref-link {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .78rem; color: var(--earth);
  text-decoration: none; border-bottom: 1px dotted var(--ochre);
}
.note-ref-link:hover { color: var(--bark); border-color: var(--bark); }
.note-add-form { margin-top: 1.25rem; border-top: 1px solid var(--border); padding-top: 1.25rem; }

/* ── Theme cards ──────────────────────────────────────── */
.themes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 1rem; }
.theme-card {
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.1rem 1.3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  color: inherit;
  transition: all .15s;
}
.theme-card:hover { border-color: var(--ochre); box-shadow: 0 3px 10px var(--shadow); transform: translateY(-1px); }
.theme-card-name  { font-family: 'Special Elite', cursive; font-size: .95rem; color: var(--earth); }
.theme-card-count { font-size: .82rem; color: var(--ochre); font-style: italic; }

/* ── Login ────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.login-box {
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 36px var(--shadow-md);
  text-align: center;
}
.login-ornament { color: var(--ochre); font-size: 1.5rem; margin-bottom: .75rem; letter-spacing: .3em; }
.login-title    { font-family: 'Special Elite', cursive; font-size: 2.1rem; color: var(--earth); margin-bottom: .2rem; }
.login-subtitle { color: var(--ochre); font-style: italic; font-size: .88rem; margin-bottom: 2rem; }

/* ── Resource cards ───────────────────────────────────── */
.resources-list {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.resource-date-added {
  font-size: .72rem;
  color: var(--sand);
  font-style: italic;
}
.resources-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 10px;
  column-gap: .85rem;
  row-gap: 0;
  align-items: start;
}
@media (max-width: 600px) {
  .resources-grid { grid-template-columns: 1fr; }
}
.resource-tile {
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .75rem .9rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  transition: box-shadow .4s ease, border-color .4s ease;
}
.resource-tile:target {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--terracotta) 18%, transparent),
              0 4px 20px color-mix(in srgb, var(--terracotta) 15%, transparent);
  scroll-margin-top: 80px;
}
.resource-tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
  margin-bottom: .1rem;
}
.resource-tile-row {
  display: flex;
  align-items: baseline;
  gap: .4rem;
}
.resource-field-label {
  font-size: .68rem;
  color: var(--sand);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  flex-shrink: 0;
  min-width: 3.2rem;
}
.resource-tile-title {
  font-family: 'Special Elite', cursive;
  font-size: .92rem;
  color: var(--bark);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.resource-tile-meta {
  font-size: .78rem;
  color: var(--ochre);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.resource-desc-wrap { position: relative; }
.resource-tile-description {
  font-size: .85rem;
  line-height: 1.6;
  color: var(--bark);
  max-height: calc(1.6em * 2);
  overflow: hidden;
  margin-top: .1rem;
}
.resource-tile-description.expanded { max-height: none; overflow: visible; }
.resource-desc-wrap .ref-read-more {
  position: absolute;
  bottom: 0; right: 0;
  background: linear-gradient(to right, transparent, var(--parchment-light) 35%);
  padding-left: 2.5rem;
  font-size: .85rem;
  line-height: 1.6;
  margin-top: 0;
}
.resource-desc-wrap.expanded .ref-read-more {
  position: static;
  background: none;
  padding-left: 0;
}
.resource-tile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .4rem;
  padding-top: .45rem;
  border-top: 1px solid var(--border);
}
.resource-tile-icons {
  display: flex;
  gap: .5rem;
  font-size: .75rem;
  color: var(--sand);
}
.resource-tile-icon { cursor: default; }
.resource-card {
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.2rem;
}
.resource-card-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: .75rem;
  padding-top: .6rem;
  border-top: 1px solid var(--border);
}
.btn-remove-ref {
  background: none;
  border: none;
  padding: 0;
  font-size: .75rem;
  color: var(--sand);
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-remove-ref:hover { color: var(--terracotta); }
.resource-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}
.ref-type-badge {
  display: inline-block;
  padding: .18rem .6rem;
  background: var(--earth);
  color: var(--parchment-light);
  font-family: 'Special Elite', cursive;
  font-size: .7rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  border-radius: 3px;
}
.resource-title       { font-family: 'Special Elite', cursive; font-size: 1rem; color: var(--bark); margin-bottom: .25rem; }
.resource-meta-row    { font-size: .82rem; color: var(--ochre); display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .35rem; }
.resource-description { font-size: .88rem; line-height: 1.65; color: var(--bark); margin-top: .35rem; white-space: pre-wrap; }
.resource-links       { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.attachment-link {
  font-size: .82rem;
  color: var(--sage);
  text-decoration: none;
  border-bottom: 1px dotted var(--sage-light);
  word-break: break-all;
}
.attachment-link:hover { color: var(--earth); border-color: var(--earth); }
.file-input {
  display: block;
  width: 100%;
  padding: .5rem .6rem;
  font-family: 'Courier Prime', monospace;
  font-size: .88rem;
  background: var(--parchment-light);
  border: 1px dashed var(--sand);
  border-radius: 4px;
  color: var(--bark);
  cursor: pointer;
}
.file-input:hover { border-color: var(--ochre); }

/* ── Filter tabs ──────────────────────────────────────── */
.filter-tabs { display: flex; gap: 0; margin-bottom: 1.75rem; border-bottom: 2px solid var(--border); }
.filter-tab {
  font-family: 'Special Elite', cursive;
  font-size: .95rem;
  letter-spacing: .04em;
  padding: .55rem 1.4rem;
  text-decoration: none;
  color: var(--ochre);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.filter-tab:hover { color: var(--earth); }
.filter-tab.active { color: var(--earth); border-bottom-color: var(--earth); }

/* ── Empty states ─────────────────────────────────────── */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--ochre); }
.empty-state h3 { font-family: 'Special Elite', cursive; font-size: 1.4rem; color: var(--earth); margin-bottom: .4rem; }
.empty-state p  { margin-bottom: 1.5rem; }

/* ── Breadcrumb ───────────────────────────────────────── */
.breadcrumb { font-size: .82rem; color: var(--ochre); margin-bottom: 1.5rem; }
.breadcrumb a { color: var(--ochre); text-decoration: none; }
.breadcrumb a:hover { color: var(--earth); }
.breadcrumb span { margin: 0 .4rem; }

/* ── Back link ────────────────────────────────────────── */
.back-link { display: inline-block; font-size: .82rem; color: var(--ochre); text-decoration: none; margin-bottom: 1.5rem; }
.back-link:hover { color: var(--earth); }
.back-link::before { content: '← '; }

/* ── Two-col form layout ──────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Footer ───────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 2rem;
  color: var(--sand);
  font-size: .78rem;
  border-top: 1px solid var(--border);
  margin-top: 4rem;
  letter-spacing: .05em;
}

/* ── Utility ──────────────────────────────────────────── */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.text-muted { color: var(--ochre); font-style: italic; }
.inline-flex { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 680px) {
  .nav { padding: 0 1rem; }
  .nav-links { gap: .8rem; }
  .nav-links .nav-user, .nav-links .nav-divider { display: none; }
  .container { padding: 1.2rem 1rem; }
  .grid, .themes-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .profile-name { font-size: 1.7rem; }
  .stats-row { gap: .6rem; }
  .login-box { padding: 2rem 1.5rem; }
}

/* ── Profile image ────────────────────────────────────── */
.profile-image-circle {
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--ochre);
  background: var(--parchment-light);
  flex-shrink: 0;
}
.profile-header-text { flex: 1; min-width: 0; }
.profile-image-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-header-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .5rem;
}
.card-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--ochre);
  flex-shrink: 0;
}
.card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-image-thumb {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--ochre);
  display: block;
  margin-top: .5rem;
}

/* ── Resources index ──────────────────────────────────── */
.resource-profile-link {
  font-size: .8rem;
  font-style: italic;
  color: var(--earth);
}
.resource-profile-link:hover { color: var(--terracotta); }

/* ── Comments ─────────────────────────────────────────── */
.comments-thread {
  margin-top: 1rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.comment-item {
  padding: .5rem .65rem;
  background: var(--parchment-light);
  border-radius: 5px;
  border-left: 3px solid var(--sand);
}
.comment-content {
  font-size: .88rem;
  color: var(--bark);
  white-space: pre-wrap;
  margin-bottom: .2rem;
}
.comment-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.comment-byline {
  font-size: .71rem;
  color: var(--sand);
}
.comment-edited { font-style: italic; }
.comment-actions {
  display: flex;
  gap: .25rem;
  align-items: center;
  margin-left: auto;
}
.comment-add {
  margin-top: .75rem;
}

/* ── Reminders (on note card) ─────────────────────────── */
.reminder-block {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .65rem;
  border-radius: 5px;
  background: #fef9ee;
  border: 1px solid var(--ochre);
  margin-top: .75rem;
  font-size: .84rem;
  flex-wrap: wrap;
}
.reminder-block.reminder-overdue {
  background: #fdf0ee;
  border-color: var(--terracotta);
}
.reminder-block.reminder-done {
  background: var(--parchment-light);
  border-color: var(--border);
  opacity: .65;
}
.reminder-main { flex: 1; min-width: 0; }
.reminder-action { font-weight: 700; color: var(--bark); }
.reminder-due {
  font-size: .76rem;
  color: var(--sand);
  margin-left: .5rem;
}
.reminder-block.reminder-overdue .reminder-due {
  color: var(--terracotta);
  font-weight: 700;
}
.reminder-actions-row {
  display: flex;
  gap: .25rem;
  align-items: center;
  flex-shrink: 0;
}
.reminder-set-wrap { margin-top: .65rem; }
.reminder-form {
  display: flex;
  gap: .5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: .5rem;
  padding: .6rem;
  background: var(--parchment-light);
  border-radius: 5px;
  border: 1px dashed var(--border);
}
.reminder-form .form-control { flex: 1; min-width: 160px; }

/* ── Reminders page ───────────────────────────────────── */
.reminder-page-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: .85rem 1rem;
  background: #fef9ee;
  border: 1px solid var(--ochre);
  border-radius: 7px;
}
.reminder-page-card.reminder-page-overdue {
  background: #fdf0ee;
  border-color: var(--terracotta);
}
.reminder-page-card.reminder-page-done {
  background: var(--parchment-light);
  border-color: var(--border);
  opacity: .7;
}
.reminder-page-body { flex: 1; min-width: 0; }
.reminder-page-action {
  font-weight: 700;
  font-size: .95rem;
  color: var(--bark);
  margin-bottom: .2rem;
}
.reminder-page-meta {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .3rem;
}
.reminder-profile-link {
  font-size: .82rem;
  color: var(--earth);
  font-style: italic;
}
.reminder-due-label {
  font-size: .76rem;
  color: var(--sand);
}
.reminder-due-label.overdue {
  color: var(--terracotta);
  font-weight: 700;
}
.reminder-note-excerpt {
  font-size: .8rem;
  color: var(--sand);
  font-style: italic;
}
.reminder-page-actions {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  align-items: flex-end;
  flex-shrink: 0;
}

/* ── Search results ───────────────────────────────────── */
.search-results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.search-result {
  padding: 1rem 1.1rem;
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.search-result-name {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--bark);
  text-decoration: none;
  font-weight: 700;
  margin-bottom: .5rem;
}
.search-result-name:hover { color: var(--terracotta); }
.search-result-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--ochre);
}
.search-result-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.search-hints {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-top: .4rem;
}
.search-hint {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  font-size: .82rem;
  line-height: 1.4;
}
.search-hint-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--sand);
  white-space: nowrap;
  flex-shrink: 0;
  padding: .1em .4em;
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 3px;
}
.search-hint-snippet {
  color: var(--earth);
  text-decoration: none;
}
a.search-hint-snippet:hover { color: var(--terracotta); text-decoration: underline; }
mark.search-mark {
  background: #f5d87a;
  color: inherit;
  border-radius: 2px;
  padding: 0 .1em;
}

/* ── Note body clamp & actions ───────────────────────── */
.note-body-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-body-clamp.expanded {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}
.note-read-more {
  background: none;
  border: none;
  padding: 0;
  margin-top: .2rem;
  font-size: .78rem;
  color: var(--earth);
  cursor: pointer;
  font-family: inherit;
  display: block;
}
.note-read-more:hover,
.note-read-more-style:hover { color: var(--terracotta); }
.note-read-more-style {
  background: none;
  border: none;
  padding: 0;
  margin-top: .2rem;
  font-size: .78rem;
  color: var(--earth);
  cursor: pointer;
  font-family: inherit;
  display: block;
}
.note-footer-badges { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-right: auto; }
.note-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .35rem;
  margin-top: .55rem;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
}
.note-reminder-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .72rem;
  padding: .15rem .55rem;
  border-radius: 20px;
  border: 1px solid var(--ochre);
  background: var(--parchment);
  color: var(--earth);
  cursor: pointer;
  font-family: inherit;
  font-weight: normal;
}
.note-reminder-badge:hover { border-color: var(--terracotta); color: var(--terracotta); }
.note-reminder-badge--overdue { border-color: var(--terracotta); color: var(--terracotta); background: #fdf0ee; }
.note-reminder-badge--done   { opacity: .55; border-style: dashed; }

/* ── Reference picker (note form) ────────────────────── */
.ref-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
}
.ref-picker-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem .75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  background: var(--parchment-light);
  transition: background .1s;
}
.ref-picker-item:last-child { border-bottom: none; }
.ref-picker-item:hover { background: var(--parchment); }
.ref-picker-item input[type="checkbox"] { flex-shrink: 0; }
.ref-picker-text { flex: 1; font-size: .85rem; line-height: 1.4; }
.ref-picker-new-badge {
  font-size: .68rem;
  color: var(--sage);
  white-space: nowrap;
  opacity: .8;
  font-style: italic;
}
.ref-picker-item:has(input:checked) {
  background: #f0f5f0;
}

/* ── Theme typeahead ──────────────────────────────────── */
.theme-typeahead { position: relative; }
.theme-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .45rem;
}
.theme-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--earth);
  color: var(--parchment-light);
  border-radius: 20px;
  padding: .2rem .65rem .2rem .75rem;
  font-size: .8rem;
}
.theme-chip-remove {
  background: none;
  border: none;
  color: var(--parchment-light);
  cursor: pointer;
  font-size: .95rem;
  line-height: 1;
  padding: 0;
  opacity: .7;
}
.theme-chip-remove:hover { opacity: 1; }
.theme-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
}
.theme-dropdown-item {
  padding: .45rem .75rem;
  font-size: .85rem;
  cursor: pointer;
  color: var(--bark);
}
.theme-dropdown-item:hover { background: var(--parchment); }
.theme-dropdown-new {
  color: var(--earth);
  font-style: italic;
  border-top: 1px solid var(--border);
}
.theme-modal-item { cursor: pointer; }
.theme-modal-item.is-selected { background: var(--parchment); }
.theme-modal-item.is-selected .ref-picker-text { font-weight: 700; }
.theme-modal-check {
  font-size: .85rem;
  color: var(--sage);
  width: 1rem;
  flex-shrink: 0;
  visibility: hidden;
}
.theme-modal-item.is-selected .theme-modal-check { visibility: visible; }

/* ── Reference search modal ──────────────────────────── */
dialog.edit-note-dialog {
  border: none;
  border-radius: 10px;
  padding: 0;
  max-width: none;
  max-height: none;
  box-shadow: 0 8px 32px var(--shadow-md);
  overflow: hidden;
  transition: border-radius .15s;
}
dialog.edit-note-dialog[open] {
  display: flex;
  flex-direction: column;
}
dialog.edit-note-dialog::backdrop {
  background: rgba(44,24,16,0.45);
}
dialog.edit-note-dialog.is-fullscreen {
  width: 100vw !important;
  height: 100dvh !important;
  top: 0 !important;
  left: 0 !important;
  border-radius: 0;
}
dialog.edit-note-dialog.is-fullscreen .ref-modal-inner {
  width: 100% !important;
  max-height: 100dvh !important;
}
dialog.edit-note-dialog.is-fullscreen .edit-note-dialog-body {
  max-height: calc(100dvh - 3.5rem) !important;
}
dialog#ref-modal,
dialog#shared-edit-ref-modal,
dialog#theme-modal {
  border: none;
  border-radius: 10px;
  padding: 0;
  width: 80%;
  max-width: 1000px;
  min-height: 400px;
  max-height: 88vh;
  box-shadow: 0 8px 32px var(--shadow-md);
  overflow: hidden;
  margin: 0;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
dialog#theme-modal { max-width: 380px; }
dialog#ref-modal[open],
dialog#shared-edit-ref-modal[open],
dialog#theme-modal[open] {
  display: flex;
  flex-direction: column;
}
dialog#ref-modal::backdrop,
dialog#shared-edit-ref-modal::backdrop,
dialog#theme-modal::backdrop {
  background: rgba(44,24,16,0.45);
}
.ref-modal-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-height: 80vh;
  padding: 0 1.5rem;
  background: var(--parchment-light);
  box-sizing: border-box;
}
.ref-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.5rem .7rem;
  margin: 0 -1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  cursor: move;
  user-select: none;
}
.ref-modal-title {
  font-family: 'Special Elite', cursive;
  font-size: 1.05rem;
  color: var(--bark);
}
.ref-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--sand);
  cursor: pointer;
  padding: 0 .2rem;
}
.ref-modal-close:hover { color: var(--terracotta); }
.ref-modal-inner > .form-hint,
.ref-modal-inner > .form-control {
  flex-shrink: 0;
}
.ref-modal-inner > .form-hint { margin-top: .7rem; }
.ref-modal-inner > .form-control { margin-top: .4rem; }
#ref-modal-list,
#shared-edit-ref-list {
  flex: 1;
  overflow-y: auto;
  margin: .5rem 0 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: none;
}
.ref-modal-footer {
  display: flex;
  gap: .6rem;
  padding: .85rem 1.5rem;
  margin: 0 -1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ref-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--parchment-light);
  border: 1.5px solid var(--earth);
  border-radius: 7px;
  padding: .35rem .55rem .35rem .7rem;
  font-size: .82rem;
  color: var(--bark);
  box-shadow: 0 1px 4px var(--shadow);
}
.ref-chip-label {
  font-weight: 500;
}
.ref-chip-badge {
  font-size: .6rem !important;
  padding: .1rem .38rem !important;
  flex-shrink: 0;
}
.ref-chip-remove {
  background: none;
  border: none;
  color: var(--sand);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  margin-left: .1rem;
}
.ref-chip-remove:hover { color: var(--terracotta); }

/* ── Theme selector (account page) ───────────────────── */
.theme-radio-group {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.theme-radio-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .6rem .85rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  background: var(--parchment-light);
  transition: border-color .15s;
}
.theme-radio-item:hover { border-color: var(--ochre); }
.theme-radio-item:has(input:checked) { border-color: var(--earth); border-width: 2px; }
.theme-radio-item input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.theme-radio-swatch {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 6px;
  border-radius: 5px;
  border: 1px solid;
  flex-shrink: 0;
}
.theme-radio-swatch span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}
.theme-radio-name {
  font-family: 'Special Elite', cursive;
  font-size: .95rem;
  color: var(--bark);
}

/* ── Theme preview page ───────────────────────────────── */
.theme-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  align-items: start;
}
.theme-swatch {
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: 0 3px 14px var(--shadow);
}
.tp-label {
  font-family: 'Special Elite', cursive;
  font-size: 1rem;
  letter-spacing: .05em;
  padding: .65rem 1rem .5rem;
  background: var(--parchment-light);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .6rem;
}
.tp-current-badge {
  font-family: 'Courier Prime', monospace;
  font-size: .68rem;
  background: var(--earth);
  color: var(--parchment-light);
  border-radius: 3px;
  padding: .1em .45em;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.tp-demo {
  background: var(--tp-bg);
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: .82rem;
  color: var(--tp-dark);
}
.tp-nav {
  background: var(--tp-dark);
  padding: .55rem 1rem;
  display: flex;
  align-items: center;
  gap: 1.1rem;
}
.tp-nav-brand {
  font-family: 'Special Elite', cursive;
  font-size: .95rem;
  color: var(--tp-nav-brand);
  letter-spacing: .06em;
}
.tp-nav-link {
  font-size: .75rem;
  color: var(--tp-muted);
  opacity: .8;
}
.tp-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  background-image: var(--tp-bg-image, none);
}
.tp-card {
  background: var(--tp-bg);
  border: 1px solid var(--tp-border);
  border-radius: 6px;
  padding: .75rem .9rem;
}
.tp-card-title {
  font-family: 'Special Elite', cursive;
  font-size: .95rem;
  color: var(--tp-dark);
  margin-bottom: .15rem;
}
.tp-card-dates {
  font-size: .72rem;
  color: var(--tp-light);
  margin-bottom: .4rem;
}
.tp-card-text {
  font-size: .78rem;
  line-height: 1.55;
  color: var(--tp-dark);
  opacity: .85;
  margin-bottom: .5rem;
}
.tp-note-type {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--tp-light);
  margin-bottom: .35rem;
}
.tp-byline {
  font-size: .7rem;
  color: var(--tp-muted);
  margin-top: .35rem;
}
.tp-tags {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}
.tp-tag {
  font-size: .68rem;
  padding: .15em .5em;
  border-radius: 3px;
  letter-spacing: .04em;
}
.tp-buttons {
  display: flex;
  gap: .5rem;
}
.tp-btn-primary {
  font-size: .78rem;
  padding: .3em .85em;
  border-radius: 4px;
  background: var(--tp-primary);
  color: #fff;
  cursor: default;
}
.tp-btn-secondary {
  font-size: .78rem;
  padding: .3em .85em;
  border-radius: 4px;
  background: transparent;
  color: var(--tp-primary);
  border: 1px solid var(--tp-border);
  cursor: default;
}
.tp-palette-row {
  display: flex;
  gap: .4rem;
  align-items: center;
  padding-top: .5rem;
  border-top: 1px solid var(--tp-border);
  margin-top: .25rem;
}
.tp-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Password toggle ─────────────────────────────────── */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 2.5rem !important; }
.pw-toggle {
  position: absolute;
  right: .45rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sand);
  padding: .2rem;
  line-height: 0;
  border-radius: 4px;
  transition: color .12s;
}
.pw-toggle:hover { color: var(--earth); }
.pw-toggle.is-visible { color: var(--earth); }

/* ── Lace ─────────────────────────────────────────────── */
.lace-page {
  position: fixed;
  top: 58px; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  background-color: var(--parchment);
  background-image:
    radial-gradient(ellipse at 15% 60%, rgba(196,149,106,.14) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(92,125,97,.11)   0%, transparent 45%),
    radial-gradient(ellipse at 50% 95%, rgba(184,120,120,.10) 0%, transparent 40%);
}
#lace-svg { width: 100%; height: 100%; display: block; }

.lace-controls {
  position: absolute;
  top: 1rem; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: .65rem;
  z-index: 10;
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: .35rem .9rem;
  box-shadow: 0 2px 12px var(--shadow);
  white-space: nowrap;
}
.lace-breadcrumb {
  font-family: 'Special Elite', cursive;
  font-size: .85rem;
  color: var(--bark);
  min-width: 80px;
  text-align: center;
}
.lace-sep { color: var(--border); }
.lace-hub-toggle.lace-hub-active {
  color: var(--terracotta) !important;
  font-weight: 700;
}

.lace-loading {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Special Elite', cursive;
  font-size: 1.1rem; color: var(--sand);
  pointer-events: none;
}

.lace-tooltip {
  position: absolute;
  background: var(--bark); color: var(--parchment-light);
  font-family: 'Courier Prime', monospace;
  font-size: .78rem;
  padding: .4rem .65rem;
  border-radius: 5px;
  pointer-events: none;
  z-index: 20;
  max-width: 220px;
  line-height: 1.5;
}

/* SVG text */
.lace-node-label {
  font-family: 'Courier Prime', monospace;
  fill: var(--bark);
  pointer-events: none;
  user-select: none;
}
.lace-theme-text {
  font-family: 'Courier Prime', monospace;
  font-size: 11.5px;
  pointer-events: none;
  user-select: none;
}
.lace-link { stroke: var(--ochre); stroke-linecap: round; }

/* Theme pill fills */
.lace-pill-earth { fill: var(--earth);  fill-opacity:.16; stroke: var(--earth);  stroke-width:1.5; }
.lace-pill-sage  { fill: var(--sage);   fill-opacity:.16; stroke: var(--sage);   stroke-width:1.5; }
.lace-pill-rose  { fill: var(--rose);   fill-opacity:.16; stroke: var(--rose);   stroke-width:1.5; }
.lace-pill-ochre { fill: var(--ochre);  fill-opacity:.16; stroke: var(--ochre);  stroke-width:1.5; }
.lace-pill-text-earth { fill: var(--earth); }
.lace-pill-text-sage  { fill: var(--sage);  }
.lace-pill-text-rose  { fill: var(--rose);  }
.lace-pill-text-ochre { fill: var(--ochre); }

/* Legend popover */
.lace-legend {
  position: absolute;
  top: calc(1rem + 38px + .5rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  box-shadow: 0 4px 18px var(--shadow-md);
  min-width: 260px;
  max-width: 320px;
}
.lace-legend-title {
  font-family: 'Special Elite', cursive;
  font-size: .9rem;
  color: var(--bark);
  margin-bottom: .7rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.lace-legend-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-bottom: .55rem;
  font-size: .82rem;
  color: var(--earth);
  line-height: 1.35;
}

/* ── Activity Log ─────────────────────────────────────── */
.activity-list {
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--border);
  margin-left: .5rem;
  padding-bottom: 1rem;
}
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  padding: .55rem 0 .55rem 1.25rem;
  position: relative;
}
.activity-dot {
  position: absolute;
  left: -5px;
  top: .85rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ochre);
  flex-shrink: 0;
}
.activity-body {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.activity-message {
  font-size: .88rem;
  color: var(--earth);
  text-decoration: none;
  flex: 1;
  min-width: 0;
}
.activity-message:hover { color: var(--terracotta); text-decoration: underline; }
.activity-message-plain {
  color: var(--bark);
}
.activity-time {
  font-size: .75rem;
  color: var(--sand);
  white-space: nowrap;
  flex-shrink: 0;
}
.activity-pagination {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.activity-page-info {
  font-size: .85rem;
  color: var(--sand);
}

/* ── Cooee ────────────────────────────────────────────── */
.cooee-nav-li { display: flex; align-items: center; }
.cooee-nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sand);
  padding: .3rem .4rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  position: relative;
  transition: color .15s;
  line-height: 0;
}
.cooee-nav-btn:hover { color: #fff; }

.cooee-badge {
  position: absolute;
  bottom: -2px;
  right: -4px;
  background: var(--terracotta);
  color: #fff;
  font-size: .6rem;
  font-family: 'Courier Prime', monospace;
  min-width: 15px;
  height: 15px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  pointer-events: none;
}

.cooee-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.22);
  z-index: 900;
}

.cooee-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  max-width: 95vw;
  height: 100dvh;
  background: var(--parchment-light);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 28px var(--shadow-md);
  z-index: 901;
  display: flex;
  flex-direction: column;
  transition: right .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.cooee-panel.is-open { right: 0; }

.cooee-panel-header {
  background: var(--bark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem 1rem;
  flex-shrink: 0;
}
.cooee-panel-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: 'Special Elite', cursive;
  font-size: 1.05rem;
  letter-spacing: .06em;
}
.cooee-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.65);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 .15rem;
  transition: color .12s;
}
.cooee-close:hover { color: #fff; }

.cooee-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.cooee-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: .5rem;
  background: var(--parchment-light);
}
.cooee-view-label {
  font-family: 'Special Elite', cursive;
  font-size: .9rem;
  color: var(--bark);
  letter-spacing: .03em;
}
.cooee-back-btn {
  background: none;
  border: none;
  color: var(--earth);
  cursor: pointer;
  font-family: 'Courier Prime', monospace;
  font-size: .85rem;
  padding: 0;
  transition: color .12s;
}
.cooee-back-btn:hover { color: var(--terracotta); }

.cooee-yarn-title-display {
  font-family: 'Special Elite', cursive;
  font-size: .88rem;
  color: var(--bark);
  flex: 1;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Thread list */
.cooee-thread-list {
  flex: 1;
  overflow-y: auto;
}
.cooee-thread-item {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.cooee-thread-item:hover { background: rgba(0,0,0,.04); }
.cooee-thread-item.has-unread { background: rgba(196,113,79,.06); }
.cooee-thread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--terracotta);
  flex-shrink: 0;
  margin-top: .45rem;
}
.cooee-thread-dot-empty { width: 8px; flex-shrink: 0; }
.cooee-thread-info { flex: 1; min-width: 0; }
.cooee-thread-name {
  font-family: 'Special Elite', cursive;
  font-size: .92rem;
  color: var(--bark);
  margin-bottom: .1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cooee-thread-preview {
  font-size: .8rem;
  color: var(--earth);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .1rem;
}
.cooee-thread-meta {
  font-size: .72rem;
  color: var(--sand);
}

.cooee-empty {
  text-align: center;
  color: var(--sand);
  padding: 3rem 1.5rem;
  font-size: .88rem;
}
.cooee-loading {
  text-align: center;
  color: var(--sand);
  padding: 2rem;
  font-size: .85rem;
  font-style: italic;
}

/* Messages */
.cooee-messages-list {
  flex: 1;
  overflow-y: auto;
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.cooee-message { max-width: 90%; }
.cooee-message.is-mine { align-self: flex-end; }

.cooee-message-bubble {
  background: color-mix(in srgb, var(--ochre) 28%, var(--parchment-light));
  border: 1px solid color-mix(in srgb, var(--ochre) 55%, var(--border));
  border-radius: 10px 10px 10px 3px;
  padding: .5rem .8rem;
  font-size: .86rem;
  line-height: 1.55;
  word-wrap: break-word;
}
.cooee-message.is-mine .cooee-message-bubble {
  background: var(--bark);
  color: var(--parchment-light);
  border-color: var(--bark);
  border-radius: 10px 10px 3px 10px;
}
.cooee-message-meta {
  font-size: .7rem;
  color: var(--sand);
  margin-top: .2rem;
  padding: 0 .2rem;
}
.cooee-message.is-mine .cooee-message-meta { text-align: right; }

.cooee-profile-link {
  color: var(--terracotta);
  font-weight: 700;
  text-decoration: none;
}
.cooee-profile-link:hover { text-decoration: underline; }
.cooee-message.is-mine .cooee-message-bubble .cooee-profile-link {
  color: var(--ochre);
}

/* Reply area */
.cooee-reply-area {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--parchment-light);
}
.cooee-input-wrap { position: relative; }
.cooee-textarea {
  resize: none;
  width: 100%;
  font-size: .85rem;
}

/* #Sheila typeahead dropdown */
.cooee-sheila-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 2px);
  background: var(--parchment-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 -4px 14px var(--shadow);
  z-index: 10;
  max-height: 180px;
  overflow-y: auto;
}
.cooee-sheila-item {
  padding: .45rem .75rem;
  cursor: pointer;
  font-size: .85rem;
  color: var(--bark);
  border-bottom: 1px solid var(--border);
}
.cooee-sheila-item:last-child { border-bottom: none; }
.cooee-sheila-item:hover { background: var(--parchment); }

/* Search bar */
.cooee-search-bar {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--parchment-light);
  flex-shrink: 0;
}
.cooee-search-input {
  flex: 1;
  font-size: .85rem;
  padding: .3rem .55rem;
  height: auto;
}
.cooee-search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.cooee-search-clear {
  background: none;
  border: none;
  color: var(--sand);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 .1rem;
  flex-shrink: 0;
  transition: color .12s;
}
.cooee-search-clear:hover { color: var(--terracotta); }

.cooee-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--earth);
  padding: .25rem .3rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color .12s, background .12s;
  line-height: 0;
}
.cooee-icon-btn:hover { color: var(--bark); background: rgba(0,0,0,.06); }
.cooee-icon-btn.is-active { color: var(--bark); }

/* In-message search highlight */
.cooee-search-mark {
  background: var(--ochre);
  color: var(--bark);
  border-radius: 2px;
  padding: 0 1px;
}
.cooee-message.is-mine .cooee-search-mark {
  background: var(--terracotta);
  color: #fff;
}

/* New yarn form */
.cooee-yarn-form {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}
