:root {
  --bg: #f4f3ed;
  --surface: #ffffff;
  --surface-soft: #faf9f5;
  --text: #17211c;
  --muted: #66736c;
  --line: #dde3de;
  --brand: #12372a;
  --brand-2: #2f6b4f;
  --brand-soft: #e4efe8;
  --danger: #b42318;
  --shadow: 0 14px 34px rgba(29, 55, 43, .10);
  --radius: 22px;
  --research: #4f46e5;
  --materials: #b66b00;
  --waiting: #c2410c;
  --labour: #16803f;
  --done: #53635b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; padding-bottom: 98px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 18px 12px;
  background: linear-gradient(180deg, rgba(244,243,237,.98) 72%, rgba(244,243,237,.86));
  backdrop-filter: blur(14px);
}
.topbar h1 { margin: 2px 0 0; font-size: clamp(1.65rem, 6vw, 2rem); letter-spacing: -.04em; }
.eyebrow { margin: 0; font-size: .68rem; font-weight: 850; letter-spacing: .14em; color: var(--brand-2); }
.profile-button {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand); color: white;
  font-weight: 800; box-shadow: var(--shadow);
}
.main-content { width: min(760px, 100%); margin: 0 auto; padding: 4px 14px 50px; }

.summary-panel { margin-bottom: 16px; }
.hero-card {
  overflow: hidden; position: relative;
  padding: 22px; border-radius: 28px;
  background: linear-gradient(135deg, #12372a, #2f6b4f);
  color: white; box-shadow: var(--shadow);
}
.hero-card::after {
  content: ""; position: absolute; width: 160px; height: 160px; right: -58px; top: -65px;
  border-radius: 50%; border: 28px solid rgba(255,255,255,.08);
}
.hero-card h2 { margin: 8px 0 6px; max-width: 310px; font-size: 1.55rem; line-height: 1.12; letter-spacing: -.035em; }
.hero-card p { margin: 0; max-width: 430px; color: rgba(255,255,255,.78); line-height: 1.45; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 18px; }
.stat { padding: 12px 10px; border-radius: 16px; background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.10); }
.stat strong { display: block; font-size: 1.45rem; }
.stat span { display: block; font-size: .72rem; color: rgba(255,255,255,.78); margin-top: 2px; }
.view-intro { padding: 8px 3px 3px; }
.view-intro h2 { margin: 0 0 5px; font-size: 1.2rem; letter-spacing: -.02em; }
.view-intro p { margin: 0; color: var(--muted); line-height: 1.45; }

.task-list { display: grid; gap: 12px; }
.section-label { margin: 12px 4px 2px; display: flex; justify-content: space-between; align-items: baseline; }
.section-label h2 { margin: 0; font-size: 1rem; }
.section-label span { color: var(--muted); font-size: .8rem; }

.task-card, .group-card {
  border: 1px solid rgba(29,55,43,.08); border-radius: var(--radius);
  background: var(--surface); box-shadow: 0 7px 22px rgba(29,55,43,.055);
}
.task-card { position: relative; overflow: hidden; padding: 16px; }
.task-card.parent-linked { border-left: 6px solid var(--parent-color, var(--brand-2)); }
.task-card.blocked { background: #fffaf8; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.badge-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 9px; }
.stage-badge, .parent-badge, .blocked-badge {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 25px; padding: 4px 9px; border-radius: 999px;
  font-size: .7rem; line-height: 1; font-weight: 800;
}
.stage-badge.research { color: var(--research); background: #eeedff; }
.stage-badge.materials { color: #8a5100; background: #fff2d5; }
.stage-badge.waiting { color: #9a3412; background: #ffeadf; }
.stage-badge.labour { color: #116530; background: #e5f5e9; }
.stage-badge.done { color: #3c4a43; background: #e8ece9; }
.parent-badge { color: var(--parent-color, var(--brand)); background: color-mix(in srgb, var(--parent-color, var(--brand)) 11%, white); }
.blocked-badge { color: var(--danger); background: #feeceb; }
.task-card h3, .group-card h3 { margin: 0; font-size: 1.14rem; line-height: 1.3; letter-spacing: -.02em; }
.task-description { margin: 9px 0 0; font-size: .95rem; color: var(--muted); line-height: 1.45; white-space: pre-line; }
.blocked-copy { margin: 10px 0 0; padding: 10px 11px; border-radius: 12px; background: #feeceb; color: #7a271a; font-size: .83rem; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; color: var(--muted); font-size: .72rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.card-actions .button { flex: 1 1 auto; min-height: 40px; padding: 9px 12px; font-size: .82rem; }
.more-button { flex: 0 0 auto; border: 0; background: transparent; color: var(--muted); border-radius: 10px; width: 36px; height: 36px; font-size: 1.25rem; }
.more-button:hover { background: var(--surface-soft); }
.purchase-link { display: inline-flex; margin-top: 10px; color: var(--brand-2); font-weight: 750; font-size: .8rem; text-decoration: none; }

.group-card { overflow: hidden; border-top: 7px solid var(--group-color); }
.group-header { padding: 17px 17px 13px; }
.group-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.group-kicker { margin: 0 0 5px; color: var(--group-color); font-size: .7rem; font-weight: 850; letter-spacing: .1em; }
.group-description { margin: 7px 0 0; color: var(--muted); line-height: 1.4; }
.progress-line { height: 7px; margin-top: 14px; overflow: hidden; border-radius: 999px; background: #e8ece9; }
.progress-line span { display: block; height: 100%; border-radius: inherit; background: var(--group-color); }
.group-progress-copy { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; color: var(--muted); font-size: .72rem; }
.group-children { padding: 0 11px 12px; display: grid; gap: 9px; }
.group-children .task-card { background: var(--surface-soft); box-shadow: none; border-left: 5px solid var(--group-color); }
.add-subtask { margin: 0 12px 14px; width: calc(100% - 24px); }
.no-subtasks { margin: 0 12px 12px; padding: 14px; border: 1px dashed var(--line); border-radius: 15px; color: var(--muted); text-align: center; font-size: .85rem; }

.button {
  border: 0; border-radius: 14px; min-height: 45px; padding: 11px 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-weight: 800; text-decoration: none;
}
.button.primary { background: var(--brand); color: white; }
.button.secondary { background: var(--brand-soft); color: var(--brand); }
.button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.button.danger { color: var(--danger); }
.button.full { width: 100%; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.fab {
  position: fixed; right: 17px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 30;
  border: 0; border-radius: 999px; min-height: 53px; padding: 0 18px 0 13px;
  display: flex; align-items: center; gap: 6px;
  background: var(--brand); color: white; font-weight: 850; box-shadow: 0 12px 30px rgba(18,55,42,.30);
}
.fab span:first-child { font-size: 1.55rem; font-weight: 300; }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 5px max(8px, env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(16px);
}
.nav-item { border: 0; background: transparent; color: var(--muted); min-height: 53px; border-radius: 14px; display: grid; place-items: center; align-content: center; gap: 2px; font-size: .62rem; font-weight: 780; }
.nav-icon { font-size: 1.25rem; line-height: 1; }
.nav-item.active { color: var(--brand); background: var(--brand-soft); }

.sheet-dialog {
  width: min(100%, 680px); max-height: min(92vh, 900px); margin: auto 0 0;
  border: 0; border-radius: 28px 28px 0 0; padding: 0;
  background: var(--surface); color: var(--text); box-shadow: 0 -20px 80px rgba(0,0,0,.18);
}
.sheet-dialog::backdrop { background: rgba(13,28,21,.48); backdrop-filter: blur(2px); }
.sheet-form { max-height: 92vh; overflow-y: auto; padding: 10px 18px max(22px, env(safe-area-inset-bottom)); }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 12px; border-radius: 99px; background: #ccd4cf; }
.sheet-header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.sheet-header h2 { margin: 3px 0 0; font-size: 1.45rem; letter-spacing: -.035em; }
.icon-button { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--surface-soft); color: var(--muted); font-size: 1.45rem; }
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field > span, .type-fieldset legend { font-size: .83rem; font-weight: 800; color: #34443b; }
.field small { color: var(--muted); font-weight: 500; }
.field strong { color: var(--danger); }
input, textarea, select {
  width: 100%; border: 1px solid #ccd5cf; border-radius: 14px; padding: 12px 13px;
  color: var(--text); background: white; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(47,107,79,.12); }
textarea { resize: vertical; }
.type-fieldset { margin: 4px 0 14px; padding: 0; border: 0; }
.type-grid { display: grid; gap: 9px; margin-top: 9px; }
.type-option input { position: absolute; opacity: 0; pointer-events: none; }
.type-card { display: grid; gap: 2px; padding: 13px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
.type-card b { justify-self: start; padding: 4px 7px; border-radius: 999px; background: #e8ece9; font-size: .67rem; color: var(--muted); }
.type-card strong { margin-top: 3px; font-size: .92rem; }
.type-card small { color: var(--muted); line-height: 1.35; }
.type-option input:checked + .type-card { border: 2px solid var(--brand-2); padding: 12px; background: var(--brand-soft); }
.type-option input:checked + .type-card b { background: var(--brand); color: white; }
.project-card { border-style: dashed; }
.advanced-fields { margin: 6px 0 18px; }
.advanced-fields summary { padding: 11px 0; color: var(--brand-2); font-weight: 800; cursor: pointer; }
.advanced-fields[open] summary { margin-bottom: 4px; }
.sheet-actions { position: sticky; bottom: -1px; display: flex; gap: 9px; padding-top: 12px; background: linear-gradient(180deg, rgba(255,255,255,0), white 18%); }
.sheet-actions .button:last-child { flex: 1; }
.compact-dialog { max-width: 480px; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 18px; background: radial-gradient(circle at top right, #dbeadf, transparent 42%), var(--bg); }
.login-card { width: min(100%, 420px); padding: 28px; border-radius: 30px; background: white; box-shadow: var(--shadow); }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 19px; background: var(--brand-soft); font-size: 1.8rem; }
.login-card h1 { margin: 5px 0 8px; font-size: 2.15rem; letter-spacing: -.05em; }
.login-copy { margin: 0 0 22px; color: var(--muted); line-height: 1.5; }
.stack { display: grid; gap: 14px; }
.stack label { display: grid; gap: 7px; font-size: .82rem; font-weight: 800; }
.microcopy { margin: 15px 0 0; color: var(--muted); font-size: .74rem; line-height: 1.4; text-align: center; }

.empty-state { padding: 42px 24px; border: 1px dashed #cfd8d2; border-radius: 24px; text-align: center; background: rgba(255,255,255,.55); }
.empty-icon { font-size: 2.5rem; }
.empty-state h2 { margin: 10px 0 4px; }
.empty-state p { margin: 0 auto 16px; max-width: 320px; color: var(--muted); line-height: 1.45; }
.timeline { display: grid; gap: 16px; }
.timeline-group { display: grid; grid-template-columns: 20px 1fr; gap: 10px; }
.timeline-marker { position: relative; }
.timeline-marker::before { content: ""; position: absolute; left: 8px; top: 16px; bottom: -24px; width: 2px; background: #d7ded9; }
.timeline-group:last-child .timeline-marker::before { display: none; }
.timeline-dot { position: relative; z-index: 1; width: 18px; height: 18px; margin-top: 3px; border-radius: 50%; background: var(--brand-2); border: 4px solid var(--brand-soft); }
.timeline-content { display: grid; gap: 8px; }
.timeline-date { margin: 0 0 2px; font-size: .87rem; color: var(--muted); text-transform: capitalize; }

.connection-banner { position: sticky; top: 77px; z-index: 19; margin: 0 12px 8px; padding: 9px 12px; border-radius: 12px; background: #fff1e7; color: #8a3d0b; font-size: .8rem; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 104px; z-index: 100; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; max-width: calc(100% - 32px); padding: 11px 15px; border-radius: 13px; background: #17211c; color: white; font-size: .82rem; box-shadow: var(--shadow); transition: .22s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }


.hero-eyebrow { color: rgba(255,255,255,.72); }
.card-heading { min-width: 0; flex: 1; }
.parent-copy { margin: 5px 0 0; color: var(--muted); font-size: .78rem; }
.field-help { margin-top: -2px; color: var(--muted); font-size: .74rem; line-height: 1.35; }

.assignment-chip {
  min-height: 30px; max-width: 100%; padding: 5px 10px; border-radius: 999px;
  border: 1px solid #bfd3c6; background: #eef7f1; color: #174e35;
  font-size: .74rem; line-height: 1.15; font-weight: 850; text-align: left;
}
.assignment-chip.unassigned { border-style: dashed; background: white; color: var(--muted); }
.assignment-chip.compact { min-height: 27px; padding: 4px 9px; font-size: .7rem; }
.project-assignment { margin-top: 11px; }
.assignment-quick-list { margin-bottom: 14px; }
.assignment-note { margin: 0 0 10px; padding: 10px 12px; border-radius: 13px; background: var(--brand-soft); color: var(--brand); font-size: .82rem; }
.quick-people { display: flex; flex-wrap: wrap; gap: 8px; }
.person-button { min-height: 40px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); color: var(--text); font-weight: 800; }
.person-button.selected { border-color: var(--brand-2); background: var(--brand-soft); color: var(--brand); }
.assignment-actions { display: grid; grid-template-columns: 1fr; gap: 9px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 15px; padding: 5px; border-radius: 17px; background: #e7ebe8; }
.segment { min-height: 46px; border: 0; border-radius: 13px; background: transparent; color: var(--muted); font-weight: 850; }
.segment strong { display: inline-grid; place-items: center; min-width: 23px; min-height: 23px; margin-left: 4px; border-radius: 999px; background: rgba(0,0,0,.06); }
.segment.active { background: white; color: var(--brand); box-shadow: 0 4px 14px rgba(29,55,43,.08); }

@media (max-width: 390px) {
  .bottom-nav { padding-left: 2px; padding-right: 2px; }
  .nav-item { font-size: .57rem; }
  .nav-icon { font-size: 1.12rem; }
  .fab { right: 12px; padding-right: 14px; }
}

@media (min-width: 720px) {
  .app-shell { padding-left: 90px; padding-bottom: 40px; }
  .bottom-nav { top: 0; right: auto; width: 82px; grid-template-columns: 1fr; align-content: center; border-top: 0; border-right: 1px solid var(--line); padding: 12px 8px; }
  .nav-item { min-height: 72px; }
  .topbar { padding-left: 28px; }
  .main-content { padding-left: 24px; padding-right: 24px; }
  .fab { bottom: 24px; right: 28px; }
  .sheet-dialog { margin: auto; border-radius: 28px; }
  .sheet-form { padding-bottom: 24px; }
  .type-grid { grid-template-columns: 1fr 1fr; }
  .connection-banner { top: 85px; margin-left: auto; margin-right: auto; max-width: 680px; }
}
