:root {
  --bg: #FAF7F2;
  --panel: #FFFFFF;
  --panel-2: #F3EEE4;
  --panel-border: #E4DDCF;
  --text: #2B2A28;
  --text-dim: #7A756B;
  --accent: #7B6DCC;
  --accent-ink: #FFFFFF;
  --good: #4F7A62;
  --warn: #E6A65D;
  --bad: #C1584A;
  --col-not-started: #A69C8B;
  --col-in-progress: #7B6DCC;
  --col-completed: #4F7A62;
  --col-abandoned: #C1584A;
  --radius: 10px;
  --font-sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- header */

header.site-header {
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-right { display: flex; align-items: center; gap: 10px; }

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.01em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.whoami-chip {
  font-size: 13px;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
}
.whoami-chip:hover { text-decoration: none; border-color: var(--accent); color: var(--text); }
.chip-caret { font-size: 10px; }
.member-menu { position: relative; }
.member-menu summary { list-style: none; cursor: pointer; }
.member-menu summary::-webkit-details-marker { display: none; }
.member-menu-panel { position: absolute; z-index: 20; right: 0; top: calc(100% + 8px); width: min(280px, calc(100vw - 32px)); padding: 12px; border: 1px solid var(--panel-border); border-radius: 8px; background: var(--panel); box-shadow: 0 8px 20px rgba(43, 42, 40, 0.14); }
.member-menu-panel form { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin: 0; }
.member-menu-panel form + form { padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--panel-border); }
.member-menu-panel label { grid-column: 1 / -1; }
.member-menu-panel input, .member-menu-panel select { min-width: 0; }

header.site-header nav {
  display: flex;
  gap: 18px;
  margin-top: 10px;
}
header.site-header nav a {
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
}
header.site-header nav a:hover { color: var(--text); text-decoration: none; }

.nav-toggle-checkbox { position: absolute; opacity: 0; pointer-events: none; }
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  cursor: pointer;
}
.hamburger-btn span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

@media (max-width: 640px) {
  .hamburger-btn { display: flex; }
  header.site-header nav {
    display: none;
    flex-direction: column;
    gap: 2px;
    margin-top: 12px;
  }
  header.site-header nav a { padding: 8px 4px; border-top: 1px solid var(--panel-border); }
  .nav-toggle-checkbox:checked ~ nav { display: flex; }
}

/* ------------------------------------------------------------------ main */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

h1 { font-size: 21px; margin: 4px 0 12px; color: var(--text); }
h2 { font-size: 15px; margin: 20px 0 10px; color: var(--text); }

.hint { color: var(--text-dim); font-size: 13px; }
.empty-state { color: var(--text-dim); padding: 24px 0; }

.toast-stack {
  position: fixed;
  z-index: 100;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  margin: 0;
  list-style: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 20px rgba(43, 42, 40, 0.14);
  animation: toast-enter 180ms ease-out;
}
.toast-leaving { animation: toast-leave 180ms ease-in forwards; }
.toast-success { border-color: var(--good); }
.toast-error { border-color: var(--bad); }
.toast-warning { border-color: var(--warn); }
.toast-dismiss {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.toast-dismiss:hover { color: var(--text); }
@keyframes toast-enter {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-leave {
  to { opacity: 0; transform: translateY(-8px); }
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}
.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 20px;
}
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.breadcrumb { font-size: 13px; color: var(--text-dim); margin-bottom: 4px; }

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

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.error-panel { border-color: var(--bad); color: var(--bad); }
.error-panel ul { margin: 6px 0 0; padding-left: 18px; }

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

form p { margin: 0 0 14px; }
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 4px; }
input, textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 10px;
  font-size: 15px;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-block;
  border: 1px solid var(--panel-border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { background: transparent; border-color: var(--bad); color: var(--bad); }

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--panel-2);
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 999px;
  padding: 2px 9px;
}
.pill-color { border-width: 1px; border-style: solid; }

.swatch { width: 20px; height: 20px; border-radius: 50%; display: inline-block; }
.swatch-inline { width: 9px; height: 9px; }

.status-pill { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 9px; }
.status-not_started { background: var(--panel-2); color: var(--text-dim); }
.status-in_progress { background: rgba(123,109,204,0.15); color: var(--col-in-progress); }
.status-completed { background: rgba(79,122,98,0.15); color: var(--good); }
.status-abandoned { background: rgba(193,88,74,0.15); color: var(--bad); }

/* -------------------------------------------------------------- boards */

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

.board-card, .goal-profile-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text);
}
.board-card:hover, .goal-profile-card:hover { border-color: var(--accent); text-decoration: none; }
.board-card h2, .goal-profile-card h2 { margin: 0 0 6px; font-size: 16px; }
.board-card-desc { color: var(--text-dim); font-size: 13px; margin: 0 0 10px; }
.board-card-stats { display: flex; gap: 14px; font-size: 12px; color: var(--text-dim); }

.goal-profile-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.category-grid { display: flex; flex-wrap: wrap; gap: 8px; }

/* -------------------------------------------------------------- filters */

.filter-bar {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
}
.filter-bar summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  padding: 4px 0;
}
.filter-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}
.filter-field { min-width: 0; }
.filter-field label { margin-bottom: 4px; }
.filter-field input, .filter-field select { width: 100%; }
@media (min-width: 700px) {
  .filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.filter-actions { display: flex; gap: 8px; grid-column: 1 / -1; }
.event-past-toggle { align-self: end; padding-bottom: 10px; }
.event-past-toggle input { width: auto; padding: 0; }
.event-list { display: grid; gap: 8px; }
.event-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; padding: 14px; border: 1px solid var(--panel-border); border-radius: 8px; background: var(--panel); color: var(--text); }
.event-row:hover { border-color: var(--accent); text-decoration: none; }
.event-row time { color: var(--accent); font-size: 13px; font-weight: 600; }
.event-row h2 { margin: 0 0 3px; font-size: 16px; }
.event-row p, .event-row small { margin: 0; color: var(--text-dim); font-size: 13px; }
.event-past { opacity: 0.65; }
@media (max-width: 600px) { .event-row { grid-template-columns: 1fr; gap: 4px; } }

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

.task-list { margin-top: 24px; }
.task-list ul { display: grid; gap: 6px; padding: 0; margin: 0; list-style: none; }
.task-create-form { display: grid; grid-template-columns: 180px minmax(180px, 1fr) auto; gap: 8px; margin-bottom: 12px; align-items: end; }
.task-title-field { grid-column: 1 / -1; }
.task-create-form input { min-width: 0; }
.task-create-form label { margin-bottom: 2px; }
.task-create-form .btn { flex: 0 0 auto; }
.task-assignee-picker { min-width: 0; border: 1px solid var(--panel-border); border-radius: 6px; background: var(--bg); }
.task-assignee-picker summary { padding: 9px 10px; color: var(--text-dim); cursor: pointer; font-size: 13px; }
.task-assignee-options { display: grid; gap: 4px; max-height: 156px; overflow-y: auto; padding: 0 10px 10px; }
.task-assignee-options > div { display: flex; align-items: center; gap: 6px; }
.task-assignee-options input { width: auto; padding: 0; }
.task-assignee-options label { margin: 0; color: var(--text); }
.task-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--panel-border); border-radius: 6px; background: var(--panel); }
.task-item span { flex: 1; }
.task-completed span { color: var(--text-dim); text-decoration: line-through; }
.task-deadline { flex: 0 0 auto; color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.task-assignees { color: var(--text-dim); font-size: 12px; }
.task-overdue { color: var(--bad); font-weight: 600; }
.task-comments { flex: 0 0 auto; color: var(--text-dim); font-size: 12px; }
.task-comments summary { cursor: pointer; }
.task-comments p { margin: 6px 0; }
.task-comments form { display: flex; gap: 6px; margin-top: 6px; }
.task-comments input { min-width: 140px; padding: 5px 7px; font-size: 12px; }
.task-comments .btn { padding: 5px 8px; font-size: 12px; }
.task-toggle, .task-delete { width: 24px; height: 24px; padding: 0; border: 1px solid var(--panel-border); border-radius: 4px; background: var(--panel); color: var(--good); cursor: pointer; }
.task-delete { border-color: transparent; color: var(--text-dim); font-size: 20px; line-height: 1; }
.task-delete:hover { color: var(--bad); }
@media (max-width: 600px) { .task-create-form { grid-template-columns: 1fr; } }

.goal-comments, .activity-history { margin-top: 28px; }
.comment-list, .activity-history ul { display: grid; gap: 8px; padding: 0; margin: 0; list-style: none; }
.comment-list li, .activity-history li { padding: 10px; border-left: 3px solid var(--panel-border); background: var(--panel); }
.comment-list p { margin: 4px 0 0; }
.comment-list time, .activity-history time { display: block; margin-top: 2px; color: var(--text-dim); font-size: 12px; }
.goal-comment-form { display: grid; gap: 8px; margin-top: 10px; }
.goal-comment-form .btn { justify-self: start; }

/* --------------------------------------------------------------- kanban */

.kanban {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
@media (min-width: 760px) {
  .kanban {
    flex-direction: row;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: 8px;
  }
  .kanban-column { flex: 1 1 240px; min-width: 240px; }
}

.kanban-column {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-top: 3px solid var(--col-not-started);
  border-radius: var(--radius);
  padding: 10px;
}
.kanban-column[data-status="in_progress"] { border-top-color: var(--col-in-progress); }
.kanban-column[data-status="completed"] { border-top-color: var(--col-completed); }
.kanban-column[data-status="abandoned"] { border-top-color: var(--col-abandoned); }

.kanban-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  list-style: none;
  cursor: pointer;
}
.kanban-column-header::-webkit-details-marker { display: none; }
.kanban-count {
  background: var(--panel-2);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
}
.kanban-list {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.goal-card {
  display: flex;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 10px 10px 6px;
}
.goal-card-ghost { opacity: 0.4; }
.drag-handle {
  cursor: grab;
  color: var(--text-dim);
  padding: 2px 2px 0;
  touch-action: none;
  line-height: 1;
  font-size: 14px;
}
.goal-card-body { flex: 1; min-width: 0; }
.goal-card-title {
  display: block;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}
.goal-card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.goal-owner { font-size: 12px; color: var(--text-dim); }

.progress-bar {
  background: var(--panel-border);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }

.goal-card-footer { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); }
.due-date.overdue, .overdue { color: var(--bad); }
@media (min-width: 760px) { .kanban-column-header { cursor: default; } }

.goal-detail-header {
  display: flex;
  flex-wrap: wrap-reverse;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
}

/* ------------------------------------------------------------- palette */

.color-palette { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.swatch-option { position: relative; cursor: pointer; }
.swatch-option input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
.swatch-option .swatch { border: 2px solid transparent; transition: border-color 0.1s; }
.swatch-option input:checked + .swatch { border-color: var(--text); box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }

/* ---------------------------------------------------------------- gauge */

.gauge { display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0; }
.gauge svg { width: 120px; height: 80px; display: block; }
.gauge--sm svg { width: 92px; height: 61px; }
.gauge--lg svg { width: 168px; height: 112px; }
.gauge-track { stroke: var(--panel-border); stroke-width: 12; stroke-linecap: round; }
.gauge-value { stroke-width: 12; stroke-linecap: round; }
.gauge-marker { stroke: var(--text-dim); stroke-width: 2.5; stroke-linecap: round; }
.gauge-number { fill: var(--text); font-size: 18px; font-weight: 700; font-family: var(--font-sans); }
.gauge--sm .gauge-number { font-size: 13px; }
.gauge--lg .gauge-number { font-size: 24px; }
.gauge-caption { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
.gauge-empty { color: var(--text-dim); align-items: center; justify-content: center; }
.status-dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }

/* ----------------------------------------------------------- leaderboard */

.leaderboard { list-style: none; margin: 0; padding: 0; }
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--panel-border);
}
.leaderboard-rank {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dim);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.leaderboard-info { flex: 1; min-width: 0; }
.leaderboard-name { font-weight: 700; font-size: 15px; }

/* ------------------------------------------------------------------ misc */

.member-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.member-pick { display: inline-block; }
.member-chip {
  background: var(--panel-2);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.member-chip:hover { border-color: var(--accent); }
.member-chip-active { border-color: var(--accent); color: var(--accent); }
