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

:root {
  /* INDEX CARD theme palette */
  --field:       #d9e6f0;   /* pale blue field background */
  --card:        #fdfbf3;   /* cream/off-white cards */
  --card-edge:   #cfd9e2;   /* card border */
  --hair:        #c9dcea;   /* subtle borders */
  --margin-rule: #dd8b7c;   /* red margin line (for ruled paper) */
  --ink:         #2b3038;   /* main text color */
  --muted:       #6b7480;   /* muted text */
  --accent:      #2f6f9f;   /* blue accent */
  
  /* Typography */
  --font-ui:     "Inter", system-ui, sans-serif;
  --font-card:   "Inter", system-ui, sans-serif;
  --ui:          var(--font-ui);
  --mono:        var(--font-card);

  /* ── Global font size offset ─────────────────────────────────────────────
     Increase this number to make ALL text bigger. 0 = default sizes.
     Try 2, 4, 6 … everything scales together.                              */
  --fs-offset:   4px;
  
  /* Ruled paper line pitch */
  --pitch:       22px;
  
  /* Shadows - subtle for index cards */
  --card-shadow: 0 1px 2px rgba(43,48,56,.10);
  --shadow:      var(--card-shadow);
  
  /* Ruled paper lines gradient */
  --rules:       repeating-linear-gradient(to bottom, transparent 0, transparent 21px, #dce9f3 21px, #dce9f3 22px);
  
  /* Border radius - sharp corners for index cards */
  --r-lg:        3px;       /* minimal radius */
  --r-md:        2px;       /* very subtle */
  --r-sm:        2px;       /* very subtle */
  --r-pill:      999px;     /* still pill-shaped for badges */
  
  /* Legacy compatibility mapping */
  --board-bg:    var(--field);
  --card-bg:     var(--card);
  --text:        var(--ink);
  --text-muted:  var(--muted);
  --border:      var(--hair);
  --overdue:     #d3705c;
  --due-today:   #d19a52;
  --warn:        var(--overdue);
  --accent-soft: #e8f2fa;
  --field-2:     #d0dde9;
  --faint:       #94a0ab;
}

body {
  font-family: var(--font-ui);
  background: #f0f2f4;
  color: var(--ink);
  min-height: 100vh;
  font-size: calc(14px + var(--fs-offset));
  -webkit-font-smoothing: antialiased;
}
body.page-board {
  background: var(--field);
}

/* ── Nav ─────────────────────────────────────────────────────────────────── */
nav {
  background: var(--field-2);
  border-bottom: 1px solid var(--card-edge);
  margin: 0 0 16px;
}
body:not(.page-board) nav {
  background: #e8eaec;
  border-bottom-color: #d6d9dd;
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 24px 18px;
  max-width: 1180px;
  margin: 0 auto;
  font-family: var(--font-ui);
  font-size: calc(12px + var(--fs-offset));
  text-transform: uppercase;
  letter-spacing: .08em;
}
nav .brand {
  font-weight: 700;
  font-size: calc(12px + var(--fs-offset));
  color: var(--ink);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.brand-logo {
  width: 20px !important;
  height: 20px !important;
  max-width: 20px !important;
  max-height: 20px !important;
  border-radius: 6px;
  display: block;
  flex-shrink: 0;
  object-fit: cover;
}
nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 400;
  font-size: calc(12px + var(--fs-offset));
  padding: 0;
  transition: color .15s;
}
nav a:hover { 
  color: var(--ink);
}
nav a.active { 
  color: var(--ink);
  font-weight: 700;
}
.nav-spacer { flex: 1; }
.nav-logout {
  font-family: var(--font-ui);
  font-size: calc(12px + var(--fs-offset));
  font-weight: 400;
  padding: 5px 10px;
  border: 1px solid var(--hair);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .08em;
  transition: background .15s, color .15s;
}
.nav-logout:hover { 
  background: var(--card);
  color: var(--ink);
}

main { 
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 24px 60px;
}

.debug-footer {
  text-align: center;
  padding: 16px;
  font-size: calc(10px + var(--fs-offset));
  letter-spacing: .06em;
  text-transform: uppercase;
}
.debug-footer a {
  color: var(--faint);
  text-decoration: none;
  transition: color .15s;
}
.debug-footer a:hover { color: var(--muted); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: calc(11px + var(--fs-offset));
  font-weight: 600;
  padding: 5px 10px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .08em;
  transition: opacity .15s;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover { opacity: .85; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-outline  { 
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--hair);
}
.btn-sm { padding: 4px 8px; font-size: calc(10px + var(--fs-offset)); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: calc(.8rem + var(--fs-offset));
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .25rem;
  margin-top: .75rem;
}
label:first-child { margin-top: 0; }
.hint { font-weight: 400; color: #94a3b8; font-size: .75rem; }

input[type=text], input[type=password], input[type=date],
textarea, select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  font-size: calc(14px + var(--fs-offset));
  font-family: var(--ui);
  background: var(--field);
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 60px; }

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.form-row > div { flex: 1; min-width: 140px; }
.form-actions { margin-top: 1rem; display: flex; gap: .5rem; align-items: center; }

.form-page {
  max-width: 680px;
  margin: 0 auto;
  background: #fff;
  border-radius: 10px;
  padding: 2rem;
  box-shadow: var(--card-shadow);
}
.form-page h2 { margin-bottom: 1.25rem; font-size: 1.1rem; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; }
.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 4px 24px rgba(0,0,0,.12);
  margin-top: -6vh;
}
.login-box h1 { font-size: 1.4rem; margin-bottom: 1.5rem; text-align: center; }
.login-error { color: var(--overdue); font-size: .85rem; margin-bottom: .75rem; }

/* ── Board ───────────────────────────────────────────────────────────────── */
.board-wrap {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.board-section { margin-bottom: 0.5rem; }

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-family: var(--font-ui);
  font-size: calc(12px + var(--fs-offset));
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.sec-handle {
  color: var(--muted);
  opacity: .4;
  cursor: grab;
  font-size: 13px;
  padding: 0 2px;
  transition: opacity .15s;
}
.sec-handle:active { cursor: grabbing; }
.section-header:hover .sec-handle { opacity: .8; }
.section-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  padding: 0;
}
.section-toggle:hover { color: var(--ink); }
.chevron { font-size: 10px; }
.section-name {
  font-weight: 700;
  font-size: calc(12px + var(--fs-offset));
  color: var(--ink);
  white-space: nowrap;
}
.sec-dots {
  flex: 1;
  border-bottom: 1px dotted #9ab0c2;
  height: 1px;
  min-width: 12px;
}
/* ── Section action menu ────────────────────────────────────────────────── */
.sec-actions {
  position: relative;
  display: flex;
  align-items: center;
}
.sec-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--muted);
  padding: 0 2px;
  line-height: 1;
  letter-spacing: .05em;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.section-header:hover .sec-menu-btn,
.sec-actions.open .sec-menu-btn { opacity: 1; }
.sec-menu-btn:hover { color: var(--ink); }

.sec-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  box-shadow: 0 4px 12px rgba(43,48,56,.12);
  z-index: 100;
  min-width: 110px;
  overflow: hidden;
}
.sec-actions.open .sec-dropdown { display: block; }

.sec-dropdown-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: calc(11px + var(--fs-offset));
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 7px 12px;
  text-align: left;
  white-space: nowrap;
}
.sec-dropdown-item:hover { background: var(--accent-soft); color: var(--ink); }
.sec-delete-btn:hover { background: #fde8e4; color: var(--overdue); }
.sec-delete-form { margin: 0; }

.sec-rename-form {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.sec-rename-input {
  width: auto;
  flex: 0 0 180px;
  padding: 4px 8px;
  font-size: 11px;
  font-family: var(--font-ui);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--ink);
}

.board-section.collapsed .cards-row { display: none; }

.cards-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 18px;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  width: 270px;
  min-height: 142px;
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: box-shadow .16s, transform .16s;
  cursor: pointer;
  position: relative;
}
.card:hover {
  box-shadow: var(--shadow-hi);
  transform: translateY(-2px);
  z-index: 20;
}


.card-body { 
  flex: 1;
  padding: 16px 17px 10px;
  font-family: var(--font-card);
  font-size: calc(16px + var(--fs-offset));
  font-weight: 400;
  line-height: 1.6;
  color: var(--ink);
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}
.card-body p { margin: 0 0 .5em; }
.card-body strong { 
  display: block;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: calc(18px + var(--fs-offset));
  margin-bottom: 6px;
  letter-spacing: -.03em;
  color: var(--ink);
}
.card-body strong + br { display: none; }
.card-body a { color: var(--accent); }
.card-body code { 
  font-family: var(--mono);
  font-size: .9em;
  background: var(--field);
  padding: 2px 6px;
  border-radius: 4px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 7px 15px;
  border-top: 1px solid var(--hair);
  font-family: var(--font-ui);
  font-size: calc(12px + var(--fs-offset));
  letter-spacing: .04em;
  color: var(--muted);
}

.card-meta {
  font-family: var(--font-ui);
  font-size: calc(11px + var(--fs-offset));
  color: var(--muted);
}

.card-actions {
  position: relative;
  cursor: pointer;
}
.card-actions-trigger {
  font-size: 14px;
  line-height: 1;
  letter-spacing: 1px;
  padding: 2px 5px;
  border-radius: var(--r-sm);
  color: var(--faint);
  user-select: none;
}
.card:hover .card-actions-trigger,
.card-actions:focus .card-actions-trigger {
  color: var(--muted);
}
.card-actions-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  box-shadow: 0 3px 10px rgba(43,48,56,.12);
  z-index: 50;
  min-width: 90px;
  flex-direction: column;
  overflow: hidden;
}
.card-actions:focus .card-actions-menu,
.card-actions:focus-within .card-actions-menu,
.card-actions:hover .card-actions-menu {
  display: flex;
}
.card-action {
  background: none;
  border: none;
  padding: 7px 12px;
  font-family: var(--font-ui);
  font-size: calc(12px + var(--fs-offset));
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  display: block;
  white-space: nowrap;
}
.card-action:hover { background: var(--field); }
.card-action-delete { color: var(--overdue); }
.card-action-delete:hover { background: #fde8e4; }

/* ── Card status inline (footer) ──────────────────────────────────────── */
.card-status-inline {
  font-family: var(--font-ui);
  font-size: calc(11px + var(--fs-offset));
  color: var(--muted);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 6px;
}

/* ── Card detail modal ───────────────────────────────────────────────────── */
.card-detail-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(43,48,56,.4);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.card-detail-overlay.open { display: flex; }

.card-detail-modal {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  box-shadow: 0 12px 48px rgba(43,48,56,.22);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}



.card-detail-body-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.card-detail-section-label,
.card-detail-front,
.card-detail-divider,
.card-detail-back {
  width: 100%;
  max-width: 440px;
}
.card-detail-front,
.card-detail-back {
  font-family: var(--mono);
  font-size: calc(15px + var(--fs-offset));
  line-height: 1.75;
  color: var(--ink);
}
.card-detail-front p,
.card-detail-back p { margin: 0 0 .5em; }
.card-detail-front strong,
.card-detail-front h2 {
  display: block;
  font-family: var(--ui);
  font-weight: 700;
  font-size: calc(18px + var(--fs-offset));
  margin-bottom: 8px;
  letter-spacing: -.01em;
  color: var(--ink);
}
.card-detail-front strong + br,
.card-detail-front h2 + br { display: none; }
.card-detail-front a,
.card-detail-back a { color: var(--accent); }
.card-detail-front ul, .card-detail-front ol,
.card-detail-back ul, .card-detail-back ol {
  padding-left: 1.4em;
  margin: .4em 0;
}

.card-detail-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-ui);
  font-size: calc(9px + var(--fs-offset));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--faint);
  margin-bottom: 12px;
}
.card-detail-section-label::before,
.card-detail-section-label::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--hair);
}

.card-detail-divider {
  margin: 20px 0 0;
}

.card-detail-loading { color: var(--faint); font-style: italic; }

.card-detail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px 16px;
  border-top: 1px solid var(--hair);
  flex-shrink: 0;
  gap: 12px;
}
.card-detail-status {
  font-family: var(--font-ui);
  font-size: calc(12px + var(--fs-offset));
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── New card status input ───────────────────────────────────────────────── */
.new-card-status {
  width: 100%;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  background: var(--field);
  font-family: var(--font-ui);
  font-size: calc(12px + var(--fs-offset));
  color: var(--ink);
  padding: 6px 10px;
  margin-bottom: 10px;
  outline: none;
}
.new-card-status:focus { border-color: var(--accent); }
.new-card-status::placeholder { color: var(--faint); }

/* add-card widget (ghost card) */
/* ── New card modal ──────────────────────────────────────────────────────── */
.new-card-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(43,48,56,.35);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
}
.new-card-modal-overlay.open { display: flex; }
.new-card-modal {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 32px rgba(43,48,56,.18);
  width: 460px;
  padding: 20px;
}
.new-card-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-ui);
  font-size: calc(11px + var(--fs-offset));
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
}
.new-card-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  padding: 0;
  line-height: 1;
}
.new-card-close:hover { color: var(--ink); }
.new-card-body {
  width: 100%;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  background: var(--field);
  font-family: var(--mono);
  font-size: calc(14px + var(--fs-offset));
  resize: none;
  outline: none;
  line-height: 1.65;
  color: var(--ink);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.new-card-body:focus { border-color: var(--accent); }
.new-card-body::placeholder { color: var(--faint); }
.new-card-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.new-card-section {
  flex: 1;
  padding: 5px 8px;
  font-family: var(--font-ui);
  font-size: calc(11px + var(--fs-offset));
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  background: var(--field);
  color: var(--ink);
}
.new-card-meta input[type=date] {
  padding: 5px 8px;
  font-size: calc(11px + var(--fs-offset));
  font-family: var(--font-ui);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  background: var(--field);
  color: var(--ink);
}
.new-card-label {
  display: block;
  font-family: var(--font-ui);
  font-size: calc(11px + var(--fs-offset));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 5px;
}
.new-card-label .hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--faint);
}
.new-card-back { margin-top: 0; }
.new-card-actions { display: flex; gap: 8px; margin-top: 4px; }

/* add-section row */
.add-section-row { 
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.add-section-btn {
  color: var(--faint);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  display: inline-block;
  transition: all .15s;
}
.add-section-btn:hover {
  background: var(--card);
  color: var(--accent);
  box-shadow: var(--shadow);
}
.add-section-form { 
  display: flex;
  gap: 8px;
  align-items: center;
}
.add-section-sep {
  width: 1px;
  height: 20px;
  background: var(--hair);
  margin: 0 4px;
  flex-shrink: 0;
}
.add-section-form input { 
  margin: 0;
  padding: 6px 12px;
  border-radius: var(--r-sm);
}

/* ── Calendar ────────────────────────────────────────────────────────────── */
.cal-wrap { max-width: 900px; margin: 0 auto; }

.cal-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.cal-title { 
  font-weight: 700;
  font-size: calc(17px + var(--fs-offset));
  color: var(--ink);
  flex: 1;
}
.cal-arrow {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: color .15s;
}
.cal-arrow:hover { color: var(--accent); }

.cal-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.stat-pill {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  padding: 10px 14px;
  box-shadow: var(--card-shadow);
  min-width: 72px;
}
.stat-pill .n {
  font-family: var(--font-ui);
  font-size: calc(20px + var(--fs-offset));
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
}
.stat-pill .l {
  font-family: var(--font-ui);
  font-size: calc(11px + var(--fs-offset));
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 3px;
}

.cal-grid {
  background: var(--card-edge);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  padding: 3px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  overflow: visible;
}
.cal-dow {
  text-align: center;
  font-size: calc(9.5px + var(--fs-offset));
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--faint);
  padding: 4px 0 7px;
  text-transform: uppercase;
}
.cal-cell {
  min-height: 66px;
  border-radius: 1px;
  padding: 5px 6px 6px;
  display: flex;
  flex-direction: column;
  background: var(--card);
  cursor: pointer;
  transition: background .15s;
  overflow: visible;
  position: relative;
  z-index: 1;
}
.cal-cell:hover { z-index: 10; }
.cal-cell:hover { background: #f0ebe0; }
.cal-cell.cal-empty { 
  background: var(--field);
  cursor: default;
}
.cal-cell.cal-today { 
  background: var(--accent-soft);
}

.cal-day-num {
  font-family: var(--mono);
  font-size: calc(10.5px + var(--fs-offset));
  color: var(--faint);
  line-height: 1;
}
.cal-today .cal-day-num { 
  color: var(--accent);
  font-weight: 600;
}

.cal-pill {
  margin-top: 4px;
  font-size: calc(9px + var(--fs-offset));
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 2px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.cal-pill-tooltip {
  display: none;
  position: fixed;
  z-index: 999;
  background: var(--ink);
  color: #fff;
  border-radius: var(--r-md);
  padding: 9px 11px;
  min-width: 180px;
  max-width: 260px;
  box-shadow: 0 4px 16px rgba(43,48,56,.28);
  pointer-events: none;
  white-space: normal;
}
.cal-pill:hover .cal-pill-tooltip { display: block; }

.cal-tip-type {
  font-family: var(--font-ui);
  font-size: calc(9px + var(--fs-offset));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 4px;
}
.cal-tip-title {
  font-family: var(--font-ui);
  font-size: calc(13px + var(--fs-offset));
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
  margin-bottom: 4px;
}
.cal-tip-tags {
  font-family: var(--font-ui);
  font-size: calc(9.5px + var(--fs-offset));
  color: rgba(255,255,255,.55);
  margin-bottom: 4px;
  letter-spacing: .04em;
}
.cal-tip-details {
  font-size: calc(12px + var(--fs-offset));
  color: rgba(255,255,255,.75);
  line-height: 1.5;
  border-top: 1px solid rgba(255,255,255,.15);
  padding-top: 5px;
  margin-top: 2px;
  white-space: pre-wrap;
}

.cal-dots {
  margin-top: auto;
  display: flex;
  gap: 3.5px;
  padding-top: 5px;
}
.cal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 14px;
  margin-bottom: 20px;
}
.legend-item { 
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: calc(12px + var(--fs-offset));
  color: var(--muted);
  background: var(--card);
  border-radius: var(--r-pill);
  padding: 4px 10px 4px 8px;
  box-shadow: 0 1px 2px rgba(35,43,54,.04);
}
.legend-dot { 
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Log accomplishment modal ──────────────────────────────────────────── */
.cal-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(43,48,56,.45);
  z-index: 400;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
}
.cal-modal-overlay.open { display: flex; }

.cal-modal {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  box-shadow: 0 12px 40px rgba(43,48,56,.22);
  width: 100%;
  max-width: 460px;
  padding: 22px 24px 20px;
}

.cal-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-ui);
  font-size: calc(10px + var(--fs-offset));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--faint);
  margin-bottom: 18px;
}
.cal-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--faint);
  padding: 0;
  line-height: 1;
  transition: color .15s;
}
.cal-modal-close:hover { color: var(--ink); }
.cal-modal-form label:first-of-type { margin-top: 0; }

.cal-log {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  padding: 20px 22px 18px;
  box-shadow: var(--card-shadow);
}
.cal-log h3 {
  font-family: var(--font-ui);
  font-size: calc(10px + var(--fs-offset));
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 14px;
}

.log-day { margin-bottom: 14px; }
.log-date {
  font-family: var(--font-ui);
  font-size: calc(9.5px + var(--fs-offset));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--faint);
  margin-bottom: 6px;
}
.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 6px;
  border-radius: var(--r-sm);
  margin-bottom: 3px;
}
.log-entry:hover { background: var(--field); }
.log-type-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.log-body { flex: 1; font-size: calc(14px + var(--fs-offset)); line-height: 1.5; }
.log-body strong { font-weight: 600; font-size: calc(14px + var(--fs-offset)); }
.log-body p { margin: 0; }
.log-tags {
  font-family: var(--font-ui);
  font-size: calc(9.5px + var(--fs-offset));
  color: var(--faint);
  margin-left: 4px;
  letter-spacing: .04em;
}
.log-details { font-size: calc(13px + var(--fs-offset)); color: var(--muted); margin-top: 2px; }
.log-details p { margin: 0; }
.log-details a { color: var(--accent); }
.log-card-link {
  font-size: calc(10px + var(--fs-offset));
  color: var(--accent);
  text-decoration: none;
  margin-left: 6px;
  opacity: 0.7;
}
.log-card-link:hover { opacity: 1; text-decoration: underline; }

/* ── Notes ───────────────────────────────────────────────────────────────── */
.notes-wrap { max-width: 680px; margin: 0 auto; }

.note-capture-wrap {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  padding: 16px 18px 14px;
  box-shadow: var(--card-shadow);
  margin-bottom: 20px;
}
.note-capture-form { display: flex; flex-direction: column; gap: 10px; }
.note-capture-form textarea {
  margin: 0;
  background: var(--field);
  border-color: var(--hair);
  border-radius: var(--r-sm);
  font-size: calc(14px + var(--fs-offset));
  min-height: 68px;
}
.note-capture-actions {
  display: flex;
  justify-content: flex-end;
}

.notes-group { margin-bottom: 20px; }
.notes-group-label {
  font-family: var(--font-ui);
  font-size: calc(9.5px + var(--fs-offset));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--faint);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.notes-group-label::after {
  content: '';
  flex: 1;
  border-top: 1px dotted var(--hair);
}
.notes-empty {
  font-size: calc(12px + var(--fs-offset));
  color: var(--faint);
  font-style: italic;
}

.note-card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  padding: 14px 16px 10px;
  margin-bottom: 8px;
  box-shadow: var(--card-shadow);
}
.note-card.is-pinned {
  border-left: 2px solid var(--accent);
}
.note-body { font-size: calc(15px + var(--fs-offset)); line-height: 1.65; color: var(--ink); }
.note-body p { margin: 0 0 .4em; }
.note-body p:last-child { margin-bottom: 0; }
.note-body a { color: var(--accent); }
.note-body strong { font-weight: 700; }
.note-body code { font-family: var(--mono); font-size: .88em; background: var(--field); padding: 1px 5px; border-radius: var(--r-sm); }
.note-body pre  { background: var(--field); padding: 10px 12px; border-radius: var(--r-sm); overflow-x: auto; font-size: calc(13px + var(--fs-offset)); }

.note-edit-form textarea { margin: 0; font-size: calc(15px + var(--fs-offset)); }

.note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.note-ts {
  font-family: var(--font-ui);
  font-size: calc(9.5px + var(--fs-offset));
  color: var(--faint);
  letter-spacing: .04em;
}
.note-actions { display: flex; gap: 2px; }
.note-action {
  background: none;
  border: none;
  cursor: pointer;
  font-size: calc(11px + var(--fs-offset));
  padding: 3px 5px;
  border-radius: var(--r-sm);
  color: var(--faint);
  line-height: 1;
  transition: background .1s, color .1s;
  font-family: var(--font-ui);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.note-action:hover { background: var(--field); color: var(--ink); }

/* ── Type colors for calendar and logs ─────────────────────────────────── */
.c-code  { background: #5a8fc4; }
.c-ship  { background: #5aa87c; }
.c-gave  { background: #9179c2; }
.c-got   { background: #d19a52; }
.c-design{ background: #d1739b; }
.c-meet  { background: #8b95a2; }
.c-other { background: #a3915f; }

@media (max-width: 720px) {
  nav { margin: 12px; padding: 7px; flex-wrap: wrap; border-radius: 16px; }
  nav .brand { margin-right: auto; }
  nav form { margin-left: 0 !important; }
  nav a { padding: 7px 10px; }
  main { padding: 0 14px 40px; }
  .cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .card { width: auto; }
  .card-actions { opacity: 1; pointer-events: auto; }
  .cal-cell { min-height: 64px; padding: .3rem; }
  .cal-pill { display: none; }
  .cal-grid { padding: 5px; }
}
