/* ===========================================================
   Design tokens
   Theme: a shared roster/ledger — the kind of board where a
   group signs off on shared chores. Cool paper background,
   ink-green accent, monospace used for anything that reads
   like a record (names, dates, the completion "stamp").
   =========================================================== */

:root {
  --bg: #eef1ec;
  --surface: #ffffff;
  --surface-2: #f6f8f4;
  --ink: #1b2420;
  --ink-soft: #5c6a61;
  --ink-faint: #8b9a90;
  --line: #dbe2d8;
  --accent: #2f6f5e;
  --accent-strong: #234f43;
  --accent-soft: #dfece5;
  --warn: #a8412f;
  --warn-soft: #f4e2dd;

  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(27, 36, 32, 0.06), 0 6px 18px rgba(27, 36, 32, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  margin: 0;
  letter-spacing: -0.01em;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--ink-soft);
  font-weight: 400;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
}

input {
  font-family: var(--font-body);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Brand ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--accent);
  transform: rotate(45deg);
  flex-shrink: 0;
}

.brand h1 {
  font-size: 1.4rem;
}

.brand--small h1 {
  font-size: 1.15rem;
}

/* ---------- Auth view ---------- */

.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.auth-tagline {
  color: var(--ink-soft);
  margin: 0.6rem 0 1.4rem;
  font-size: 0.92rem;
}

.tab-row {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.4rem;
}

.tab {
  flex: 1;
  background: none;
  border: none;
  padding: 0.6rem 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active {
  color: var(--accent-strong);
  border-bottom-color: var(--accent);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.field-hint {
  margin: -0.4rem 0 0;
  font-size: 0.76rem;
  color: var(--ink-faint);
}

input {
  font-size: 0.92rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
}

input:focus {
  background: var(--surface);
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}

button.primary:hover {
  background: var(--accent-strong);
}

button.small {
  padding: 0.45rem 0.8rem;
  font-size: 0.82rem;
}

.form-error {
  color: var(--warn);
  font-size: 0.82rem;
  margin: 0;
  min-height: 1em;
}

/* ---------- App shell ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.rail {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 1.4rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  overflow-y: auto;
}

.rail-top {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.me {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.rail-section h2 {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-family: var(--font-body);
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.group-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.group-list button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.6rem;
  font-size: 0.88rem;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.group-list button:hover {
  background: var(--surface-2);
}

.group-list button.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.group-list .count {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-faint);
}

.new-group summary {
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent-strong);
  list-style: none;
}

.new-group summary::-webkit-details-marker {
  display: none;
}

.new-group form {
  margin-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 0.82rem;
  padding: 0;
  text-align: left;
  margin-top: auto;
}

.link-btn:hover {
  color: var(--ink);
  text-decoration: underline;
}

.danger-link {
  background: none;
  border: none;
  color: var(--warn);
  font-size: 0.82rem;
  padding: 0.3rem 0;
}

.danger-link:hover {
  text-decoration: underline;
}

/* ---------- Board ---------- */

.board {
  padding: 2rem 2.4rem;
  overflow-y: auto;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60vh;
  color: var(--ink-faint);
  font-size: 0.95rem;
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.group-header h2 {
  font-size: 1.7rem;
}

#group-description {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
}

.member-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: #fff;
  border: 2px solid var(--surface);
  flex-shrink: 0;
}

.owner-tools {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.9rem 0 0;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}

.owner-tools form {
  display: flex;
  gap: 0.4rem;
}

.owner-tools input {
  width: 200px;
}

#leave-group-btn {
  margin: 0.9rem 0 1.1rem;
}

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 1.4rem;
}

.column h3 {
  font-size: 0.95rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.column h3 .muted {
  font-size: 0.74rem;
  font-family: var(--font-mono);
  text-transform: lowercase;
}

.new-todo-form {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.new-todo-form input[name="title"] {
  flex: 1;
}

.new-todo-form input[name="dueDate"] {
  width: 130px;
  color: var(--ink-soft);
}

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.todo-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.todo-item.completed {
  background: var(--surface-2);
}

.todo-item input[type="checkbox"] {
  margin-top: 0.2rem;
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.todo-main {
  flex: 1;
  min-width: 0;
}

.todo-title {
  font-size: 0.9rem;
  word-break: break-word;
}

.todo-item.completed .todo-title {
  text-decoration: line-through;
  color: var(--ink-faint);
}

.todo-meta {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  flex-wrap: wrap;
  align-items: center;
}

.todo-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 0.78rem;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-btn.warn:hover {
  color: var(--warn);
}

.edit-form {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.edit-form input[name="title"] {
  flex: 1;
  min-width: 140px;
}

.edit-form input[name="dueDate"] {
  width: 130px;
}

/* The signature element: a rubber-stamp style mark applied when a
   task is completed, naming who signed off on it and when. */
.stamp {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--accent-strong);
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  padding: 0.12rem 0.4rem;
  transform: rotate(-2deg);
  background: var(--accent-soft);
  letter-spacing: 0.02em;
}

/* ---------- Team board (read-only) ---------- */

.member-block {
  margin-bottom: 1.3rem;
}

.member-block-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.member-block-header .avatar {
  width: 24px;
  height: 24px;
  font-size: 0.62rem;
  border: none;
}

.member-block-header h4 {
  margin: 0;
  font-size: 0.85rem;
  font-family: var(--font-body);
  font-weight: 600;
}

.member-block-header .count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
}

.readonly-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.86rem;
}

.readonly-item:last-child {
  border-bottom: none;
}

.readonly-check {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-faint);
  margin-top: 0.25rem;
  flex-shrink: 0;
}

.readonly-check.done {
  background: var(--accent);
  border-color: var(--accent);
}

.readonly-title.done {
  text-decoration: line-through;
  color: var(--ink-faint);
}

.no-tasks {
  color: var(--ink-faint);
  font-size: 0.82rem;
  font-style: italic;
}

/* ---------- Toasts ---------- */

.toast-root {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 50;
}

.toast {
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  box-shadow: var(--shadow);
  max-width: 320px;
}

.toast.error {
  background: var(--warn);
}

.user-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.user-list .user-name {
  font-weight: 500;
  color: var(--ink);
}

.user-list .user-handle {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .board {
    padding: 1.4rem;
  }

  .columns {
    grid-template-columns: 1fr;
  }

  .owner-tools {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .owner-tools form {
    flex-wrap: wrap;
    flex: 1 1 100%;
  }

  .owner-tools input {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
  }

  .new-todo-form {
    flex-wrap: wrap;
  }

  .new-todo-form input[name="title"] {
    flex: 1 1 100%;
  }

  .new-todo-form input[name="dueDate"] {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
