:root {
  --bg: #f4f1ec;
  --paper: #fffcf6;
  --ink: #20211f;
  --muted: #6c6a64;
  --line: #ded8ce;
  --green: #2f6f5e;
  --green-dark: #245648;
  --coral: #c85745;
  --yellow: #e6b85c;
  --blue: #40739f;
  --shadow: 0 18px 45px rgba(36, 31, 25, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(47, 111, 94, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(47, 111, 94, 0.07) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
  color: var(--ink);
}

body:not(.is-authenticated) .app-shell {
  display: none;
}

body.is-authenticated .auth-screen {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

.auth-panel {
  display: grid;
  gap: 24px;
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-brand {
  min-height: auto;
}

.auth-copy h2 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3rem);
  line-height: 1;
}

.auth-copy p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-actions {
  display: grid;
  gap: 10px;
}

.oauth-button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 900;
}

.oauth-button span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 0.9rem;
}

.auth-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background: #252927;
  color: #f8f3e8;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
}

.brand p,
.brand h1,
.eyebrow,
.panel h2,
.section-head h3,
.topbar h2,
.month-title h3 {
  margin: 0;
}

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .brand p,
.sidebar .hint {
  color: #beb7a9;
}

.brand h1 {
  font-size: 1.75rem;
  line-height: 1;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 18px);
  grid-template-rows: repeat(2, 18px);
  gap: 5px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
}

.brand-mark span {
  display: block;
  border-radius: 3px;
}

.brand-mark span:nth-child(1) {
  background: var(--yellow);
}

.brand-mark span:nth-child(2) {
  background: var(--coral);
}

.brand-mark span:nth-child(3) {
  grid-column: span 2;
  background: var(--green);
}

.panel,
.task-composer,
.board,
.calendar-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.sidebar .panel {
  background: rgba(255, 252, 246, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

.panel {
  padding: 16px;
}

.panel-head,
.section-head,
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel h2 {
  font-size: 1rem;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.household-select {
  width: 100%;
  min-height: 42px;
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff8eb;
  padding: 0 12px;
}

.household-select option {
  color: var(--ink);
}

.household-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.sidebar .ghost-button {
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff8eb;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
}

.sidebar .icon-button {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff8eb;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  background: var(--green);
  color: white;
}

.primary-button:hover {
  background: var(--green-dark);
}

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

.member-list,
.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.member-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.09);
}

.member-pill strong,
.task-card strong {
  overflow-wrap: anywhere;
}

.member-name {
  display: flex;
  align-items: center;
  gap: 9px;
}

.member-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.mini-danger-button {
  min-height: 28px;
  border: 1px solid rgba(200, 87, 69, 0.48);
  border-radius: 8px;
  background: rgba(200, 87, 69, 0.16);
  color: #fff8eb;
  padding: 0 8px;
  font-size: 0.74rem;
  font-weight: 800;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.user-card div:last-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.user-card strong,
.user-card span,
.user-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card span,
.user-card small {
  color: #beb7a9;
  font-size: 0.78rem;
}

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 999px;
  background: var(--yellow);
  color: #252927;
  font-weight: 900;
}

.dot {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 999px;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 26px;
  min-width: 0;
}

.topbar {
  min-height: 78px;
}

.topbar h2 {
  max-width: 760px;
  font-size: clamp(1.5rem, 2.6vw, 2.5rem);
  line-height: 1.06;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 10px;
  min-width: 310px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 246, 0.74);
  padding: 10px;
}

.stat strong {
  display: block;
  font-size: 1.4rem;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.task-composer {
  display: grid;
  grid-template-columns: minmax(220px, 1.7fr) repeat(5, minmax(116px, 1fr)) auto;
  align-items: end;
  gap: 12px;
  padding: 16px;
}

.task-advanced {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.task-advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.advanced-grid {
  display: grid;
  grid-template-columns: minmax(120px, 0.6fr) repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.advanced-grid .wide {
  min-width: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.field input,
.field select,
.section-head select,
.dialog-form input,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
  color: var(--ink);
  padding: 0 12px;
}

.field textarea {
  padding: 10px 12px;
  resize: vertical;
  font: inherit;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.board,
.calendar-pane {
  padding: 16px;
}

.section-head h3,
.month-title h3 {
  font-size: 1.24rem;
}

.task-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #fffdfa;
  padding: 12px;
  user-select: none;
}

.task-card[draggable="true"] {
  cursor: grab;
}

.task-card.done {
  opacity: 0.58;
}

.task-card.done strong {
  text-decoration: line-through;
}

.task-description {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.task-checklist {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.task-checklist span::before {
  content: "□ ";
  color: var(--green);
  font-weight: 900;
}

.task-card.priority-high {
  background: #fff7f4;
}

.task-card.priority-low {
  background: #f8fbf8;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border-radius: 999px;
  background: #f0ebe1;
  padding: 0 9px;
  font-weight: 700;
}

.priority-tag {
  color: #fff;
}

.priority-high-tag {
  background: var(--coral);
}

.priority-normal-tag {
  background: var(--blue);
}

.priority-low-tag {
  background: var(--green);
}

.task-actions {
  display: flex;
  gap: 8px;
}

.task-actions button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
  font-weight: 800;
  padding: 0 10px;
}

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekdays {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.calendar-grid {
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  margin-top: 8px;
}

.day-cell {
  min-height: 132px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 250, 0.72);
  padding: 8px;
}

.day-cell.other-month {
  background: rgba(242, 236, 226, 0.68);
  color: #918b82;
}

.day-cell.today {
  box-shadow: inset 0 0 0 2px var(--green);
}

.day-cell.drag-over {
  background: #e8f2ec;
}

.day-number {
  display: flex;
  justify-content: space-between;
  min-height: 24px;
  color: var(--muted);
  font-weight: 900;
}

.calendar-task {
  display: block;
  width: 100%;
  min-height: 30px;
  margin-top: 6px;
  border: 0;
  border-radius: 6px;
  color: white;
  padding: 5px 7px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-task.done {
  opacity: 0.58;
  text-decoration: line-through;
  filter: grayscale(0.35);
}

.calendar-task.done::before {
  content: "✓ ";
  font-weight: 900;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 16px;
  text-align: center;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(20, 20, 18, 0.42);
}

.dialog-form {
  display: grid;
  gap: 14px;
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  background: var(--paper);
}

.dialog-form h2 {
  margin: 0;
}

.task-dialog-form {
  width: min(760px, calc(100vw - 32px));
}

.dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dialog-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
  color: var(--ink);
  padding: 10px 12px;
  resize: vertical;
  font: inherit;
}

.color-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.color-choice {
  min-height: 38px;
  border: 3px solid transparent;
  border-radius: 8px;
}

.color-choice.selected {
  border-color: var(--ink);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

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

  .sidebar {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) 1fr 1fr;
    align-items: start;
  }

  .task-composer,
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .sidebar,
  .main {
    padding: 16px;
  }

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    min-width: 0;
  }

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

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

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

  .day-cell {
    min-height: 106px;
    padding: 5px;
  }

  .calendar-task {
    min-height: 26px;
    padding: 4px 5px;
    font-size: 0.7rem;
  }
}
