:root {
  --bg: #fff;
  --ink: #050505;
  --muted: #686868;
  --line: #dedede;
  --soft: #f7f7f5;
  --accent: #9ee6d0;
  --accent-strong: #4ab998;
  --yellow: #f7d774;
  --red: #f29b9b;
  --green: #8fd9a8;
  --gray: #cfcfcf;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
  --radius: 18px;
  color-scheme: light;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(158, 230, 208, 0.32), transparent 32rem),
    linear-gradient(180deg, #fff 0%, #fafaf8 100%);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  padding: 0 16px;
  cursor: pointer;
}

button.secondary,
button.ghost {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
}

button.danger {
  background: #991b1b;
  border-color: #991b1b;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
  padding: 12px 13px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

svg {
  width: 20px;
  height: 20px;
}

.app-shell,
.dashboard {
  min-height: 100vh;
}

.auth-screen,
.loading-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(430px, 100%);
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.auth-card h1,
.auth-card p {
  margin: 0;
}

.mark {
  width: 50px;
  height: 50px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.topbar-inner {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 1.08rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-grid {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 16px 16px 100px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 14px;
  animation: rise 0.22s ease-out;
}

.wide {
  width: 100%;
}

.eyebrow {
  display: inline-block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.84rem;
}

.mind-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  position: relative;
}

.mind-map::before {
  content: "";
  position: absolute;
  inset: 80px 30px auto;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--line), var(--line) 8px, transparent 8px, transparent 16px);
  pointer-events: none;
}

.node,
.visual-panel,
.chat-app {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.node {
  min-height: 126px;
  padding: 16px;
  display: grid;
  gap: 10px;
  align-content: start;
  position: relative;
  overflow: hidden;
}

.node::after {
  content: "";
  position: absolute;
  right: -26px;
  bottom: -26px;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: rgba(158, 230, 208, 0.3);
}

.node-hero,
.wide-node {
  grid-column: 1 / -1;
}

.node-hero {
  min-height: 170px;
  background: linear-gradient(135deg, #fff 0%, #effcf8 100%);
}

.node h2,
.visual-panel h2,
.chat-title h2 {
  margin: 0;
  font-size: 1.5rem;
}

.node p,
.visual-panel p,
.bubble p,
.empty p {
  margin: 0;
  color: var(--muted);
}

.announcement {
  border-left: 4px solid var(--accent);
  padding: 10px 12px;
  border-radius: 12px;
  background: #f4fffb;
}

.node-icon {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--ink);
}

.clock-node .actions {
  align-items: center;
}

.ring {
  --p: 0;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ink) calc(var(--p) * 1%), var(--soft) 0);
}

.ring span {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg);
  font-size: 0.72rem;
  font-weight: 800;
}

.visual-panel {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.mini-progress {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

.task-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.task-card {
  min-height: 112px;
  padding: 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: start;
  gap: 10px;
  text-align: left;
  border-color: var(--line);
  border-radius: 18px;
  background: var(--bg);
  color: var(--ink);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.task-card:hover,
.task-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.task-card strong,
.task-card span,
.task-card small {
  display: block;
}

.task-card small {
  grid-column: 2;
  color: var(--muted);
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 4px;
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(242, 155, 155, 0.18);
}

.task-card.progress .status-dot,
.task-card.submitted .status-dot,
.status-line.progress .status-dot,
.status-line.submitted .status-dot {
  background: var(--yellow);
  box-shadow: 0 0 0 5px rgba(247, 215, 116, 0.22);
}

.task-card.complete .status-dot,
.status-line.complete .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(143, 217, 168, 0.22);
}

.task-card.archived .status-dot,
.status-line.archived .status-dot {
  background: var(--gray);
  box-shadow: 0 0 0 5px rgba(207, 207, 207, 0.22);
}

.task-card.complete {
  background: linear-gradient(135deg, #fff 0%, #f1fff6 100%);
  border-color: rgba(143, 217, 168, 0.7);
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.chat-app {
  min-height: calc(100vh - 170px);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.thread-rail {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.thread-chip {
  min-width: 74px;
  min-height: 74px;
  padding: 8px;
  display: grid;
  justify-items: center;
  gap: 5px;
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
  font-size: 0.76rem;
}

.thread-chip.active {
  background: var(--accent);
  border-color: var(--ink);
}

.thread-name {
  max-width: 66px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  object-fit: cover;
}

.letter-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  letter-spacing: 0;
  padding-top: 1px;
}

.small-avatar {
  width: 28px;
  height: 28px;
  align-self: end;
}

.profile-avatar {
  width: 62px;
  height: 62px;
  border-radius: 22px;
  display: inline-grid;
  place-items: center;
  background: var(--ink);
  color: var(--bg);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  object-fit: cover;
}

.profile-node {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.profile-node .avatar-form {
  grid-column: 1 / -1;
}

.chat-window {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.chat-title {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.pinned-note {
  margin-top: 8px;
  padding: 9px 11px;
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: #f0fff9;
  color: var(--ink);
}

.bubble-list {
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: bubbleIn 0.2s ease-out;
}

.bubble-row.mine {
  justify-content: flex-end;
}

.bubble {
  max-width: min(76%, 440px);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 6px;
  background: var(--bg);
}

.bubble-stack {
  max-width: min(76%, 440px);
  display: grid;
  gap: 4px;
}

.bubble-stack .bubble {
  max-width: none;
}

.bubble-row.mine .bubble {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  border-radius: 18px 18px 6px 18px;
}

.bubble-row.mine .bubble p,
.bubble-row.mine .bubble .bubble-name {
  color: var(--bg);
}

.bubble-name {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.bubble-meta {
  display: flex;
  gap: 7px;
  color: var(--muted);
  font-size: 0.72rem;
}

.bubble-row.mine .bubble-meta,
.bubble-row.mine .reaction-row {
  justify-content: flex-end;
}

.reaction-row,
.reaction-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.reaction-button {
  min-height: 26px;
  padding: 0 8px;
  border-color: var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.82rem;
}

.reaction-summary {
  margin-top: 8px;
}

.reaction-summary span {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(158, 230, 208, 0.28);
  color: var(--ink);
  font-size: 0.75rem;
}

.chat-photo,
.proof {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.chat-video {
  background: var(--ink);
  object-fit: contain;
}

.poll-card {
  min-width: min(280px, 70vw);
  display: grid;
  gap: 8px;
}

.poll-option {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
}

.poll-option i {
  position: absolute;
  inset: auto auto 0 0;
  height: 4px;
  background: var(--accent-strong);
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 30;
  width: min(520px, calc(100% - 24px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(var(--tabs, 4), minmax(0, 1fr));
  gap: 8px;
  padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.bottom-nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.bottom-nav button.active {
  background: var(--ink);
  color: var(--bg);
}

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(90px + env(safe-area-inset-bottom));
  z-index: 28;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(10px);
}

.modal {
  width: min(520px, 100%);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--bg);
  box-shadow: var(--shadow);
  animation: sheetUp 0.22s ease-out;
}

.accent-sheet {
  background: linear-gradient(135deg, #fff 0%, #eafff8 100%);
  border-color: var(--accent-strong);
}

.form-grid,
.task-detail,
.action-sheet,
.pay-list,
.modal-stack {
  display: grid;
  gap: 12px;
}

.form-grid.tight {
  gap: 10px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.inline-form.wrap {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.role-grid,
.member-grid,
.admin-action-grid,
.stat-grid,
.pay-member-grid,
.ledger-list {
  display: grid;
  gap: 10px;
}

.admin-action-grid {
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
}

.admin-action {
  min-height: 132px;
  padding: 14px;
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 8px;
  text-align: left;
  border-color: var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, #fff 0%, #f0fff9 100%);
  color: var(--ink);
}

.admin-action strong,
.admin-action small {
  display: block;
}

.admin-action small {
  color: var(--muted);
}

.settings-profile,
.pay-hero {
  background: linear-gradient(135deg, #fff 0%, #f2fffb 100%);
}

.profile-large {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
}

.settings-avatar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.readonly-field {
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 12px 13px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--soft);
  color: var(--muted);
}

.form-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: #f1fff9;
  color: var(--ink);
}

.stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.stat-card {
  min-height: 120px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg);
}

.stat-card strong {
  font-size: 1.45rem;
}

.stat-card small,
.pay-member-card span,
.ledger-row small,
.ledger-row em {
  color: var(--muted);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent);
  font-weight: 900;
}

.live-pill.quiet {
  background: var(--soft);
  color: var(--muted);
}

.pay-member-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.pay-member-card,
.ledger-row {
  display: grid;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
}

.pay-member-card {
  grid-template-columns: auto 1fr auto;
}

.pay-member-card.inactive {
  opacity: 0.68;
  background: var(--soft);
}

.mini-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pay-member-card strong,
.pay-member-card span,
.ledger-row strong,
.ledger-row small {
  display: block;
}

.ledger-row {
  grid-template-columns: auto 1fr auto auto;
}

.ledger-row b {
  font-size: 1.05rem;
}

.paid-dot {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(143, 217, 168, 0.22);
}

.role-editor,
.member-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--soft);
}

.icon-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.role-editor {
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
}

.member-settings,
.avatar-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  align-items: center;
  gap: 8px;
}

.member-identity {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.member-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.compact-avatar {
  grid-template-columns: 1fr auto;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--chip, var(--accent));
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
}

.role-chip.inline {
  margin-left: 5px;
}

.pay-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
}

.detail-grid span {
  color: var(--muted);
}

.actions,
.compact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-action {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  text-align: center;
}

.toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  z-index: 80;
  max-width: min(92vw, 620px);
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
}

.toast.success {
  background: #0f7b55;
  color: #fff;
}

.toast.error {
  background: #b42323;
  color: #fff;
}

.toast.info {
  background: var(--ink);
  color: var(--bg);
}

.delete-link {
  min-height: auto;
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-decoration: underline;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bubbleIn {
  from { opacity: 0; transform: scale(0.98) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes sheetUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 840px) {
  .main-grid {
    padding-bottom: 112px;
  }

  .mind-map {
    grid-template-columns: 1.2fr 0.9fr 0.9fr;
  }

  .node-hero {
    grid-column: span 2;
  }

  .wide-node {
    grid-column: span 2;
  }

  .chat-app {
    grid-template-columns: 190px 1fr;
    grid-template-rows: 1fr;
  }

  .thread-rail {
    flex-direction: column;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .thread-chip {
    grid-template-columns: auto 1fr;
    justify-items: start;
    min-width: 0;
    min-height: 58px;
  }

  .thread-name {
    max-width: 110px;
  }
}

@media (max-width: 680px) {
  .main-grid {
    padding-left: 12px;
    padding-right: 12px;
  }

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

  .node-hero,
  .wide-node {
    grid-column: auto;
  }

  .node h2,
  .visual-panel h2,
  .chat-title h2 {
    font-size: 1.28rem;
  }

  .thread-chip {
    min-width: 54px;
    min-height: 54px;
    padding: 7px;
  }

  .thread-name {
    display: none;
  }

  .bubble,
  .bubble-stack {
    max-width: 84%;
  }

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

  .modal-backdrop {
    padding: 10px;
  }
}
