:root {
  color-scheme: light;
  font-family: "DM Sans", sans-serif;
  color: #20231f;
  background: #f6f7f4;
  font-synthesis: none;
  --ink: #20231f;
  --muted: #6b7169;
  --line: #d9ddd5;
  --surface: #ffffff;
  --green: #28644c;
  --green-soft: #e2eee7;
  --coral: #c9563f;
  --coral-soft: #fae7e2;
  --gold: #a77718;
  --gold-soft: #f7edcf;
  --blue: #426b8a;
  --blue-soft: #e1ebf2;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; min-height: 100vh; background: #f6f7f4; }
button, input { font: inherit; }
button { cursor: pointer; }
body[data-theme="competitive"] {
  --ink: #171717;
  --muted: #504a5f;
  --line: #171717;
  --surface: #fff8d8;
  --green: #ff2f8f;
  --green-soft: #f8ff38;
  --coral: #ff4a1f;
  --coral-soft: #ffe2d7;
  --gold: #ffb000;
  --gold-soft: #fff061;
  --blue: #00a8ff;
  --blue-soft: #9ee8ff;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23,23,23,.08) 1px, transparent 1px),
    linear-gradient(rgba(23,23,23,.08) 1px, transparent 1px),
    #45f0d8;
  background-size: 24px 24px;
}

.app-header {
  height: 76px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.brand-lockup, .header-actions, .date-controls, .button-group, .view-tabs,
.view-tab, .profile-button, .member-chip, .task-meta, .task-summary,
.dialog-header, .dialog-actions, .toolbar-actions { display: flex; align-items: center; }

.brand-lockup { gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: transparent; border-radius: 0;
}
.brand-mark img { width: 36px; height: 36px; display: block; object-fit: contain; }
.brand-lockup h1 { margin: 0; font-family: "DM Serif Display", serif; font-size: 25px; font-weight: 400; }
.brand-lockup p { margin: 1px 0 0; color: var(--muted); font-size: 12px; }
.header-actions { gap: 10px; }
.theme-switch { margin-left: 18px; }
.theme-switch button { min-width: 142px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.theme-switch button.active { background: var(--green); color: white; }
.theme-icon { width: 22px; height: 18px; flex: 0 0 auto; }
.cooperation-icon { overflow: visible; }
.cooperation-icon path { stroke: #171717; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }
.cooperation-icon .heart-blue { fill: #36a8ff; }
.cooperation-icon .heart-pink { fill: #ff66b3; }
.cooperation-icon .shake-pink { fill: #ff93c8; }
.cooperation-icon .shake-blue { fill: #67c4ff; }
.cooperation-icon .finger { fill: none; }
.competition-icon path { stroke: #171717; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.competition-icon .glove-blue { fill: #2478ff; }
.competition-icon .glove-red { fill: #ff3f9b; }
.competition-icon .glove-cuff { fill: #fff8d8; }
.competition-icon .glove-spark { fill: #fff061; }
.member-legend { display: flex; gap: 6px; margin-right: 6px; }
.member-chip { gap: 6px; color: var(--muted); font-size: 12px; }
.member-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--member-color); }

.icon-button, .text-button, .profile-button, .view-tab, .primary-button,
.segmented-control button { border: 0; background: transparent; color: var(--ink); }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; }
.icon-button:hover, .text-button:hover { background: #eceeea; }
.icon-button svg { width: 18px; height: 18px; }
.profile-button { height: 40px; gap: 8px; padding: 0 10px 0 5px; border-left: 1px solid var(--line); margin-left: 4px; }
.profile-button svg { width: 15px; }
.profile-initial { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); font-weight: 700; }

main { max-width: 1440px; margin: 0 auto; padding: 0 32px 48px; }
.view-tabs { height: 58px; gap: 24px; border-bottom: 1px solid var(--line); }
.view-tab { height: 100%; gap: 8px; color: var(--muted); padding: 0 4px; position: relative; font-weight: 600; }
.view-tab svg { width: 18px; }
.view-tab.active { color: var(--ink); }
.view-tab.active::after { content: ""; position: absolute; height: 3px; background: var(--green); left: 0; right: 0; bottom: -1px; }

.view { display: none; }
.view.active { display: block; }
.view-toolbar { min-height: 96px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.view-toolbar h2, dialog h2, .empty-state h2 { margin: 2px 0 0; font-family: "DM Serif Display", serif; font-weight: 400; font-size: 29px; }
.section-kicker { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.date-controls { gap: 8px; }
.button-group { border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface); }
.button-group .icon-button { border-radius: 0; }
.button-group .icon-button + .icon-button { border-left: 1px solid var(--line); }
.text-button { min-height: 36px; padding: 0 12px; border-radius: 6px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; }
.text-button svg { width: 16px; height: 16px; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); min-height: 520px; }
.calendar-day { min-width: 0; border-right: 1px solid var(--line); }
.calendar-day:last-child { border-right: 0; }
.day-header { height: 64px; padding: 12px; border-bottom: 1px solid var(--line); background: #fbfcfa; }
.day-header strong { display: block; font-size: 11px; text-transform: uppercase; color: var(--muted); }
.day-header span { display: grid; width: 28px; height: 28px; place-items: center; margin-top: 3px; font-size: 14px; font-weight: 600; }
.calendar-day.today .day-header span { background: var(--ink); color: white; border-radius: 50%; }
.day-items { padding: 9px; display: flex; flex-direction: column; gap: 7px; }
.calendar-item { width: 100%; text-align: left; padding: 9px 9px 10px; border: 1px solid transparent; border-left: 3px solid var(--member-color); border-radius: 5px; background: var(--blue-soft); color: var(--ink); }
.calendar-item.completed { background: var(--green-soft); }
.calendar-item.personal { background: var(--gold-soft); }
.calendar-item.cancelled { opacity: .55; text-decoration: line-through; }
.calendar-item:hover { border-color: color-mix(in srgb, var(--member-color) 35%, transparent); }
.calendar-item time { display: block; color: var(--muted); font-size: 10px; font-weight: 700; margin-bottom: 4px; }
.calendar-item strong { display: block; font-size: 12px; line-height: 1.3; overflow-wrap: anywhere; }
.calendar-item small { display: block; color: var(--muted); margin-top: 4px; font-size: 10px; }
.day-empty { padding: 14px 4px; color: #a3a89f; text-align: center; font-size: 11px; }

.segmented-control { display: flex; border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 3px; }
.segmented-control button { height: 30px; min-width: 82px; padding: 0 10px; border-radius: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.segmented-control button.active { background: var(--ink); color: white; }
.toolbar-actions { gap: 10px; }
.task-summary { gap: 24px; min-height: 48px; padding: 0 2px 14px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); }
.summary-value { color: var(--ink); font-size: 18px; font-weight: 700; margin-right: 5px; }
.task-list { background: var(--surface); border-bottom: 1px solid var(--line); }
.task-row { width: 100%; min-height: 68px; display: grid; grid-template-columns: 26px minmax(180px, 1fr) 130px 150px 80px 28px; align-items: center; gap: 14px; padding: 10px 14px; border: 0; border-bottom: 1px solid #e8eae6; background: transparent; text-align: left; color: var(--ink); }
.task-row:hover { background: #fafbf9; }
.task-status { width: 18px; height: 18px; border: 2px solid var(--line); border-radius: 50%; display: grid; place-items: center; }
.task-status.completed { background: var(--green); border-color: var(--green); color: white; }
.task-status svg { width: 12px; }
.task-title { min-width: 0; }
.task-title strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.task-title small { color: var(--muted); }
.badge { justify-self: start; padding: 4px 7px; border-radius: 4px; background: #eef0ec; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.badge.personal { background: var(--gold-soft); color: #76520d; }
.task-meta { gap: 5px; color: var(--muted); font-size: 11px; }
.task-meta svg { width: 14px; }
.task-duration { color: var(--muted); font-size: 11px; text-align: right; }
.task-row > svg { width: 16px; color: #9ba097; }
.list-empty { padding: 64px 20px; text-align: center; color: var(--muted); }

.empty-state { text-align: center; padding: 120px 20px; }
.empty-state > svg { width: 34px; color: var(--green); }
.empty-state p { color: var(--muted); }
.hidden { display: none !important; }
.primary-button { min-height: 40px; padding: 0 16px; border-radius: 6px; background: var(--green); color: white; font-weight: 700; }
.primary-button:disabled { cursor: wait; opacity: .65; }
.primary-button svg, .text-button svg { width: 16px; height: 16px; vertical-align: middle; margin-right: 6px; }

.household-meta { display: flex; gap: 28px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.household-meta > span { display: grid; grid-template-columns: 20px auto; column-gap: 7px; align-items: center; font-size: 12px; }
.household-meta svg { width: 16px; color: var(--muted); grid-row: span 2; }
.household-meta strong { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.member-list { background: var(--surface); border-bottom: 1px solid var(--line); }
.member-row { min-height: 64px; display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid #e8eae6; }
.member-row:last-child { border-bottom: 0; }
.member-avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--member-color); font-weight: 700; }
.member-row strong, .member-row small { display: block; }
.member-row small { color: var(--muted); font-size: 11px; }
.current-member { padding: 4px 7px; border-radius: 4px; background: var(--green-soft); color: var(--green); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.invite-panel { margin-top: 20px; padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.invite-panel strong { display: block; margin-top: 5px; overflow-wrap: anywhere; }

dialog { width: min(480px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 8px; padding: 22px; box-shadow: 0 24px 70px rgba(28,33,27,.2); }
.wide-dialog { width: min(620px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(24,28,23,.38); backdrop-filter: blur(2px); }
.dialog-header { justify-content: space-between; margin-bottom: 24px; }
.dialog-title-stack { flex: 1; min-width: 0; }
.dialog-title-input {
  width: 100%;
  height: auto;
  margin: 2px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: "DM Serif Display", serif;
  font-size: 29px;
  font-weight: 400;
  line-height: 1.2;
}
.dialog-title-input:focus { outline: 0; border-color: transparent; }
.dialog-title-input::placeholder { color: var(--muted); opacity: .9; }
.time-mode { display: flex; width: max-content; margin-top: 14px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.time-mode label { margin: 0; padding: 8px 12px; border-radius: 4px; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.time-mode label:has(input:checked) { background: var(--ink); color: white; }
.time-mode input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; margin: 0; }
dialog label { display: block; margin-top: 14px; color: var(--muted); font-size: 12px; font-weight: 700; }
dialog input, dialog textarea, dialog select { width: 100%; margin-top: 7px; padding: 0 11px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: white; }
dialog input, dialog select { height: 42px; }
dialog textarea { min-height: 76px; padding-top: 10px; resize: vertical; }
dialog input:focus, dialog textarea:focus, dialog select:focus { outline: 2px solid var(--green-soft); border-color: var(--green); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog fieldset { margin: 18px 0 0; padding: 0; border: 0; }
dialog legend { color: var(--muted); font-size: 12px; font-weight: 700; }
.participant-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.participant-option { display: flex; align-items: center; gap: 7px; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); font-weight: 500; }
.participant-option input { width: 15px; height: 15px; margin: 0; }
.optional-label { font-weight: 400; text-transform: none; }
.dialog-options { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.dialog-options summary { width: max-content; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.dialog-options[open] summary { margin-bottom: 2px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; }
.checkbox-row input { width: 16px; height: 16px; margin: 0; }
.field-help { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; font-weight: 400; }
.dialog-note { color: var(--muted); font-size: 11px; line-height: 1.5; }
.form-error { margin: 12px 0 0; padding: 10px 11px; border-left: 3px solid var(--coral); background: var(--coral-soft); color: #793225; font-size: 12px; line-height: 1.45; }
.dialog-actions { justify-content: flex-end; gap: 8px; margin-top: 22px; }
.auth-mode { margin-bottom: 18px; }
.auth-mode button { flex: 1; }
.setup-options form { padding: 2px 0 18px; }
.setup-options h3 { margin: 0 0 8px; font-size: 15px; }
.setup-options .primary-button { margin-top: 16px; }
.setup-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.setup-divider::before, .setup-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.invite-result { margin-top: 16px; padding: 12px; background: var(--green-soft); border-radius: 6px; }
.invite-result span { display: block; color: var(--muted); font-size: 11px; }
.invite-result strong { display: block; margin-top: 5px; overflow-wrap: anywhere; }
.item-details { display: grid; grid-template-columns: 120px 1fr; gap: 13px; margin: 0; }
.item-details dt { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.item-details dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.task-description { margin: -8px 0 22px; color: var(--muted); line-height: 1.55; }
.detail-section { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.detail-section-header { display: flex; align-items: center; justify-content: space-between; }
.detail-section-header h3 { margin: 0; }
.detail-section-header .text-button { font-size: 11px; }
.detail-empty { color: var(--muted); font-size: 12px; }
.detail-row { padding: 9px 0; border-bottom: 1px solid #e8eae6; font-size: 12px; }
.detail-row:last-child { border-bottom: 0; }
.danger-button { color: var(--coral); }
#delete-task-button { margin-right: auto; }
.item-dialog-actions { border-top: 1px solid var(--line); padding-top: 16px; }
#remove-calendar-item { margin-right: auto; }
.task-lifecycle-actions { border-top: 1px solid var(--line); padding-top: 16px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 12px 16px; background: var(--ink); color: white; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: 12px; z-index: 30; }

body[data-theme="competitive"] .app-header {
  border-bottom: 4px solid var(--ink);
  background: #fff061;
  backdrop-filter: none;
  box-shadow: 0 8px 0 var(--ink);
}
body[data-theme="competitive"] .primary-button,
body[data-theme="competitive"] .segmented-control button.active,
body[data-theme="competitive"] .time-mode label:has(input:checked),
body[data-theme="competitive"] .calendar-day.today .day-header span {
  background: var(--green);
  color: white;
}
body[data-theme="competitive"] .primary-button,
body[data-theme="competitive"] .text-button,
body[data-theme="competitive"] .button-group,
body[data-theme="competitive"] .segmented-control,
body[data-theme="competitive"] .time-mode,
body[data-theme="competitive"] .calendar-grid,
body[data-theme="competitive"] .task-list,
body[data-theme="competitive"] .member-list,
body[data-theme="competitive"] .invite-panel,
body[data-theme="competitive"] dialog,
body[data-theme="competitive"] dialog input,
body[data-theme="competitive"] dialog textarea,
body[data-theme="competitive"] dialog select,
body[data-theme="competitive"] .participant-option {
  border: 3px solid var(--ink);
}
body[data-theme="competitive"] .primary-button,
body[data-theme="competitive"] .calendar-grid,
body[data-theme="competitive"] .task-list,
body[data-theme="competitive"] .member-list,
body[data-theme="competitive"] .invite-panel,
body[data-theme="competitive"] dialog {
  box-shadow: 8px 8px 0 var(--ink);
}
body[data-theme="competitive"] .brand-lockup h1,
body[data-theme="competitive"] .view-toolbar h2,
body[data-theme="competitive"] dialog h2,
body[data-theme="competitive"] .empty-state h2,
body[data-theme="competitive"] .dialog-title-input {
  font-family: "DM Sans", sans-serif;
  font-weight: 900;
  text-transform: uppercase;
}
body[data-theme="competitive"] .section-kicker,
body[data-theme="competitive"] .view-tab,
body[data-theme="competitive"] dialog label,
body[data-theme="competitive"] dialog legend,
body[data-theme="competitive"] .task-title strong {
  letter-spacing: 0;
}
body[data-theme="competitive"] .view-tabs { border-bottom: 4px solid var(--ink); }
body[data-theme="competitive"] .view-tab.active::after { height: 6px; background: var(--coral); }
body[data-theme="competitive"] .day-header { background: #f8ff38; border-bottom: 3px solid var(--ink); }
body[data-theme="competitive"] .calendar-day { border-right: 3px solid var(--ink); }
body[data-theme="competitive"] .calendar-item {
  border: 3px solid var(--ink);
  border-left: 9px solid var(--member-color);
  background: #fff8d8;
  box-shadow: 4px 4px 0 var(--ink);
}
body[data-theme="competitive"] .calendar-item.completed { background: #b6ff6b; }
body[data-theme="competitive"] .calendar-item.personal { background: #ffd166; }
body[data-theme="competitive"] .task-row,
body[data-theme="competitive"] .member-row,
body[data-theme="competitive"] .detail-row {
  border-bottom: 3px solid var(--ink);
}
body[data-theme="competitive"] .task-row:hover,
body[data-theme="competitive"] .icon-button:hover,
body[data-theme="competitive"] .text-button:hover {
  background: var(--blue-soft);
}
body[data-theme="competitive"] .badge { background: var(--gold-soft); color: var(--ink); border: 2px solid var(--ink); }
body[data-theme="competitive"] dialog::backdrop { background: rgba(0,0,0,.48); backdrop-filter: none; }
body[data-theme="competitive"] dialog input:focus,
body[data-theme="competitive"] dialog textarea:focus,
body[data-theme="competitive"] dialog select:focus {
  outline: 4px solid var(--blue);
}
body[data-theme="competitive"] .toast {
  border: 3px solid var(--ink);
  background: var(--green);
  box-shadow: 6px 6px 0 var(--ink);
}

@media (max-width: 900px) {
  .app-header { padding: 0 18px; }
  main { padding: 0 18px 36px; }
  .app-header { height: auto; min-height: 76px; gap: 14px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .brand-lockup { flex-wrap: wrap; }
  .theme-switch { margin-left: 0; }
  .member-legend { display: none; }
  .calendar-grid { grid-template-columns: 1fr; min-height: 0; }
  .calendar-day { border-right: 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 82px 1fr; }
  .calendar-day:last-child { border-bottom: 0; }
  .day-header { height: auto; border-bottom: 0; border-right: 1px solid var(--line); }
  .day-items { min-height: 64px; }
  .task-row { grid-template-columns: 24px minmax(120px, 1fr) 100px 28px; }
  .task-row .task-meta, .task-duration { display: none; }
}

@media (max-width: 560px) {
  .app-header { height: auto; min-height: 64px; }
  .brand-lockup p, #profile-name, #refresh-button { display: none; }
  .theme-switch button { min-width: 0; }
  .profile-button { border-left: 0; padding-right: 0; }
  main { padding: 0 12px 28px; }
  .view-toolbar { align-items: flex-start; padding: 18px 0; min-height: 0; }
  .view-toolbar h2 { font-size: 24px; }
  .view-toolbar { flex-direction: column; }
  .date-controls, .segmented-control { align-self: stretch; justify-content: space-between; }
  .toolbar-actions { width: 100%; align-items: stretch; flex-direction: column; }
  .segmented-control button { min-width: 0; flex: 1; }
  .task-row { grid-template-columns: 22px minmax(100px, 1fr) 76px 18px; padding: 10px 8px; gap: 8px; }
  .task-summary { gap: 12px; }
}
