/* Дом — Mini App.
   Направление: achromatic ledger (taste-skill), адаптированное под семейный
   планировщик: тёплая каменная подложка, белые листы, чернильные данные,
   один синий акцент на сегодняшнем дне и событиях. */

:root {
  --ground: #f4f3f1;
  --surface: #ffffff;
  --raised: #eceae4;
  --active: #e5e4e1;
  --weekend: #f8f6f2;
  --border: #e1ded7;
  --rule: #ece9e2;
  --control: #cfcac1;
  --text: #171614;
  --muted: #5f5c56;
  --faint: #6b675f;
  --accent: #1d5fbf;
  --accent-soft: #e9eff9;
  --accent-ink: #173e78;
  --primary: #1b1a18;
  --primary-ink: #ffffff;
  --positive: #247b50;
  --negative: #b4232a;

  --font: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-title: 24px;
  --fs-section: 16px;
  --fs-body: 14px;
  --fs-small: 12px;

  --rail-width: 56px;
  --pad: 24px;
  --gap: 16px;
  --card-pad: 16px;
  --radius-card: 8px;
  --radius-control: 6px;
  --control-height: 32px;
  --row-height: 44px;

  --t-fast: 120ms;
  --t-ui: 180ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--ground);
  color: var(--text);
  font: var(--fs-body) / 20px var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
figure,
ul,
ol,
dl,
dd {
  margin: 0;
}

ul[class],
ol[class] {
  padding: 0;
  list-style: none;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.num,
.event-time,
.avatar,
.month-date,
.side-row-meta,
.task-row-meta {
  font-variant-numeric: tabular-nums;
}

.app {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  min-height: 100svh;
}

/* ---------- rail ---------- */

.rail {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100svh;
  padding: 14px 0;
  border-right: 1px solid var(--border);
  background: var(--ground);
}

.brand {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--text);
}

.brand-mark {
  width: 24px;
  height: 24px;
}

.mark-accent {
  fill: var(--accent);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 26px;
}

.rail-item {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  transition: background-color var(--t-ui) ease, color var(--t-ui) ease;
}

.rail-item svg {
  width: 19px;
  height: 19px;
}

.rail-item:hover {
  background: var(--raised);
  color: var(--text);
}

.rail-item[aria-current="page"] {
  background: var(--active);
  color: var(--text);
}

.rail-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.rail-foot {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: auto;
  padding: 12px 0 4px;
}

.rail-rule {
  width: 20px;
  height: 1px;
  background: var(--border);
}

/* ---------- canvas and title ---------- */

.canvas {
  width: 100%;
  max-width: 1520px;
  min-width: 0;
  margin: 0 auto;
  padding: var(--pad) var(--pad) 40px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.title-block {
  min-width: 0;
}

.scope {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: var(--fs-small);
}

h1 {
  font-size: var(--fs-title);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subline {
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--fs-body);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-card);
  background: var(--raised);
}

.segmented button {
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  transition: background-color var(--t-fast) ease, color var(--t-fast) ease;
}

.segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
}

.period-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: var(--control-height);
  height: var(--control-height);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  transition: background-color var(--t-fast) ease, color var(--t-fast) ease;
}

.icon-button svg {
  width: 16px;
  height: 16px;
}

.icon-button:hover {
  background: var(--raised);
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-height);
  padding: 0 11px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  transition: background-color var(--t-fast) ease, transform var(--t-fast) var(--ease-out);
}

.btn:hover {
  background: var(--raised);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  border-color: transparent;
  background: var(--primary);
  color: var(--primary-ink);
}

.btn.primary:hover {
  background: #2a2825;
}

.members {
  display: flex;
  align-items: center;
  padding-left: 6px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-left: -6px;
  border: 2px solid var(--ground);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.avatar:nth-child(3n + 1) {
  background: #dfe8f6;
  color: #193b66;
}

.avatar:nth-child(3n + 2) {
  background: #e5ece0;
  color: #2f4a2a;
}

.avatar:nth-child(3n + 3) {
  background: #efe5da;
  color: #573d27;
}

.summary-bar {
  min-height: 18px;
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: var(--fs-small);
}

/* ---------- loading and errors ---------- */

.loading {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 0;
}

.skeleton {
  display: block;
  border-radius: 4px;
  background: var(--raised);
}

.skeleton-line {
  width: 230px;
  max-width: 60%;
  height: 13px;
}

.skeleton-line.short {
  width: 150px;
}

.skeleton-block {
  width: 100%;
  height: 430px;
  margin-top: 8px;
}

.error-panel {
  max-width: 560px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.error-panel h2 {
  margin-bottom: 6px;
  font-size: 18px;
  font-weight: 600;
}

.error-panel p {
  margin-bottom: 16px;
  color: var(--muted);
}

/* ---------- workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
}

.primary-column {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

.board {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

/* ---------- week ---------- */

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

.day {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 300px;
  border-left: 1px solid var(--rule);
}

.day:first-child {
  border-left: 0;
}

.day.is-weekend {
  background: var(--weekend);
}

.day.is-today::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
}

.day-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-height: 54px;
  padding: 11px 12px 10px;
  border-bottom: 1px solid var(--rule);
}

.day-name {
  color: var(--muted);
  font-size: var(--fs-small);
  text-transform: lowercase;
}

.day-date {
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
}

.day.is-today .day-date {
  color: var(--accent);
}

.day-count {
  margin-left: auto;
  color: var(--faint);
  font-size: var(--fs-small);
}

.day-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  max-height: 520px;
  overflow-y: auto;
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--control) transparent;
}

.week-inbox {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 11px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ---------- period summary ---------- */

.period-summary {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 16px 20px;
}

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

.summary-head h2 {
  font-size: var(--fs-section);
  font-weight: 600;
}

.summary-head span {
  color: var(--faint);
  font-size: var(--fs-small);
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.summary-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
}

.summary-stat + .summary-stat {
  padding-left: 16px;
  border-left: 1px solid var(--rule);
}

.summary-label {
  color: var(--muted);
  font-size: var(--fs-small);
}

.summary-value {
  font-size: 24px;
  font-weight: 500;
  line-height: 1.15;
}

.summary-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
}

.summary-subhead {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: var(--fs-small);
}

.summary-list {
  display: flex;
  flex-direction: column;
}

.summary-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-width: 0;
  padding: 4px 0;
}

.summary-item .check {
  width: 15px;
  height: 15px;
  margin-top: 2px;
}

.summary-item .task-title-button,
.summary-item-text {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-item-text {
  color: var(--muted);
}

.summary-empty {
  padding: 2px 0;
  color: var(--faint);
  font-size: var(--fs-small);
}

.load-bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-top: auto;
}

.load-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.load-bar-track {
  display: flex;
  align-items: flex-end;
  height: 34px;
  border-radius: 2px;
  background: var(--raised);
}

.load-bar-fill {
  width: 100%;
  min-height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.load-bar-label {
  overflow: hidden;
  color: var(--faint);
  font-size: 11px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-inbox-label {
  flex: none;
  width: 78px;
  padding-top: 2px;
  color: var(--muted);
  font-size: var(--fs-small);
}

.week-inbox-list {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 5px 18px;
  min-width: 0;
}

.inbox-task {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
}

.inbox-task .check {
  width: 15px;
  height: 15px;
  margin-top: 2px;
}

.inbox-task .task-title-button {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-empty {
  padding: 3px 2px;
  color: var(--faint);
  font-size: var(--fs-small);
}

.event {
  display: block;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-left: 2px solid var(--accent);
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--text);
  text-align: left;
  transition: background-color var(--t-fast) ease;
}

.event:hover {
  background: #dfe8f7;
}

.event-time {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-ink);
  font-size: 11px;
  line-height: 1.2;
}

.event-title {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.event-repeat {
  width: 11px;
  height: 11px;
  flex: none;
}

.task {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 2px;
  border-radius: 4px;
}

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

.check {
  display: grid;
  place-items: center;
  flex: none;
  width: 17px;
  height: 17px;
  margin-top: 1px;
  padding: 0;
  border: 1px solid var(--control);
  border-radius: 4px;
  background: var(--surface);
  color: var(--surface);
  transition: background-color var(--t-fast) ease, border-color var(--t-fast) ease;
}

.check svg {
  width: 11px;
  height: 11px;
  opacity: 0;
}

.check:hover {
  border-color: var(--muted);
}

.task.is-done .check {
  border-color: var(--text);
  background: var(--text);
}

.task.is-done .check svg {
  opacity: 1;
}

.task-title {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.task-title-button {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
}

.task-title-button:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.task.is-done .task-title {
  color: var(--muted);
  text-decoration: line-through;
}

.task-meta {
  display: block;
  margin-top: 1px;
  color: var(--faint);
  font-size: 11px;
}

/* ---------- month ---------- */

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--rule);
}

.month-weekday {
  padding: 9px 12px;
  color: var(--muted);
  font-size: var(--fs-small);
  text-transform: lowercase;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: 118px;
}

.month-day {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 8px;
  border: 0;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  transition: background-color var(--t-fast) ease;
}

.month-day:nth-child(7n + 1) {
  border-left: 0;
}

.month-day.is-weekend {
  background: var(--weekend);
}

.month-day.is-outside {
  background: #fbfaf8;
  color: var(--faint);
}

.month-day:hover {
  background: var(--raised);
}

.month-day.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.month-date {
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
}

.month-day.is-today .month-date {
  color: var(--accent);
}

.month-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.month-item {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-item.is-event {
  color: var(--accent-ink);
}

.month-more {
  color: var(--faint);
  font-size: 13px;
}

.month-dots {
  display: none;
  gap: 3px;
  align-items: center;
  margin-top: auto;
  padding-top: 4px;
}

.month-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
}

.month-dot.is-event {
  background: var(--accent);
}

/* ---------- side ---------- */

.side {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.side-panel {
  min-width: 0;
  padding: var(--card-pad) 20px;
}

.side-panel + .side-panel {
  border-left: 1px solid var(--rule);
}

.side-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.side-head h2 {
  font-size: var(--fs-section);
  font-weight: 600;
}

.side-head span {
  color: var(--faint);
  font-size: var(--fs-small);
}

.side-list {
  display: flex;
  flex-direction: column;
}

.side-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
}

.side-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.side-row-button {
  width: 100%;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.side-row-button:hover .side-row-title {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.side-row-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.side-row-meta {
  color: var(--muted);
  font-size: var(--fs-small);
}

.side-empty {
  padding: 4px 0 2px;
  color: var(--faint);
  font-size: var(--fs-small);
}

.side-task {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.side-task > div {
  min-width: 0;
}

.side-task .task-title {
  font-size: 13px;
}

.category-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--rule);
}

.category-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.category-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-count {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

/* ---------- tasks view ---------- */

.tasks-view {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  font-size: var(--fs-section);
  font-weight: 600;
}

.panel-note {
  color: var(--faint);
  font-size: var(--fs-small);
}

.tasks-group {
  padding: 0;
}

.tasks-group h3 {
  padding: 18px 0 4px;
  color: var(--muted);
  font-size: var(--fs-small);
  font-weight: 500;
}

.tasks-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 32px;
  padding: 0 20px 20px;
}

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: var(--row-height);
  padding: 11px 0;
  border-top: 1px solid var(--rule);
}

.task-row:first-of-type {
  border-top: 0;
}

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

.task-row-title {
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.task-row-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--fs-small);
}

/* ---------- dialog ---------- */

.detail-dialog {
  width: min(430px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 40px rgb(23 22 20 / 18%);
}

.detail-dialog::backdrop {
  background: rgb(23 22 20 / 32%);
}

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

.dialog-kicker {
  color: var(--muted);
  font-size: var(--fs-small);
}

#dialog-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

#dialog-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: var(--fs-body);
  line-height: 1.5;
}

.dialog-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
}

.dialog-row span:first-child {
  color: var(--faint);
}

.dialog-row span:last-child {
  color: var(--text);
  text-align: right;
}

/* ---------- gate ---------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--ground);
}

.gate-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.gate-mark {
  width: 30px;
  height: 30px;
  margin-bottom: 18px;
}

.gate-card h2 {
  margin-bottom: 8px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.gate-card p {
  margin-bottom: 20px;
  color: var(--muted);
}

.empty {
  padding: 14px 0;
  color: var(--faint);
  font-size: var(--fs-small);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 70;
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 10px 24px rgb(23 22 20 / 12%);
}

.noscript {
  padding: 24px;
  color: var(--muted);
}

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .side {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app {
    display: block;
  }

  .rail {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    top: auto;
    z-index: 20;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    width: auto;
    height: 64px;
    padding: 4px 10px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    border-right: 0;
    background: var(--surface);
  }

  .brand,
  .rail-foot {
    display: none;
  }

  .rail-nav {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
    margin: 0;
  }

  .rail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 72px;
    height: 52px;
    padding: 3px 0;
  }

  .rail-item svg {
    width: 18px;
    height: 18px;
  }

  .rail-label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    color: currentColor;
    font-size: 11px;
    line-height: 1.2;
  }

  .canvas {
    padding: 18px 16px calc(84px + env(safe-area-inset-bottom));
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 14px;
  }

  .top-actions {
    justify-content: flex-start;
    gap: 8px;
  }

  .members {
    margin-left: auto;
  }

  .summary-bar {
    margin-top: 0;
  }

  .week-grid {
    display: flex;
    flex-direction: column;
  }

  .day {
    min-height: 0;
    border-top: 1px solid var(--rule);
    border-left: 0;
  }

  .day:first-child {
    border-top: 0;
  }

  .day-head {
    min-height: 48px;
    padding: 9px 12px;
  }

  .day-body {
    max-height: none;
    padding: 8px 12px 12px;
  }

  .week-inbox {
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
  }

  .week-inbox-label {
    width: auto;
    padding-top: 0;
  }

  .week-inbox-list {
    gap: 5px 14px;
  }

  .side {
    display: flex;
    flex-direction: column;
  }

  .side-panel + .side-panel {
    border-top: 1px solid var(--rule);
    border-left: 0;
  }

  .month-grid {
    grid-auto-rows: 76px;
  }  .month-day {
    gap: 2px;
    padding: 5px;
  }

  .month-weekday {
    padding: 7px 6px;
    font-size: 12px;
  }

  .month-item {
    font-size: 13px;
  }

  .month-date {
    font-size: 12px;
  }

  .month-items .month-item:nth-child(n + 2) {
    display: none;
  }

  .month-more {
    font-size: 11px;
  }

  .panel-head,
  .tasks-group {
    padding-right: 16px;
    padding-left: 16px;
  }

  .tasks-columns {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 0 16px 16px;
  }

  .tasks-columns .tasks-group {
    padding-right: 0;
    padding-left: 0;
  }
}

@media (max-width: 520px) {
  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }

  .top-actions {
    align-items: center;
  }

  .period-nav {
    order: 3;
  }

  .members {
    order: 2;
    margin-left: auto;
  }

  .title-block h1 {
    font-size: 22px;
  }

  .day-body {
    gap: 5px;
  }

  .event {
    padding: 6px 7px;
  }

  .month-grid {
    grid-auto-rows: 66px;
  }

  .month-day {
    padding: 4px;
  }

  .month-item {
    display: none;
  }

  .month-dots {
    display: flex;
  }

  .month-more {
    margin-top: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
}
