.app-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  position: relative;
  overflow-x: hidden;
}

.activity-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.activity-panel {
  position: absolute;
  top: 12vh;
  bottom: 12vh;
  display: grid;
  grid-template-columns: repeat(27, 7px);
  grid-template-rows: repeat(7, 7px);
  grid-auto-flow: column;
  gap: 4px;
  opacity: 0.82;
  align-content: center;
  filter: blur(0.1px);
}

.activity-panel-left {
  right: calc(50% + (var(--shell-width) / 2) + 52px);
}

.activity-panel-right {
  left: calc(50% + (var(--shell-width) / 2) + 52px);
}

.activity-cell {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--heat-0);
}
.activity-cell[data-level="1"] { background: var(--heat-1); }
.activity-cell[data-level="2"] { background: var(--heat-2); }
.activity-cell[data-level="3"] { background: var(--heat-3); }
.activity-cell[data-level="4"] { background: var(--heat-4); }

body[data-activity-background="false"] .activity-bg {
  display: none;
}

.main-wrap {
  width: min(var(--shell-width), calc(100vw - 32px));
  margin: 0 auto;
  padding: clamp(48px, 9vh, 108px) 0 32px;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
}

.app-shell {
  width: 100%;
  min-height: 540px;
  padding: clamp(20px, 3vw, 34px);
  background: var(--shell);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-radius: var(--radius-soft);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.06);
}

.app-header {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.brand-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.wordmark {
  font-size: var(--size-md);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  margin-right: 0.15rem;
}

.status-line {
  font-size: var(--size-sm);
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-wrap {
  display: flex;
  align-items: center;
  position: relative;
}

.search-input {
  width: 0;
  opacity: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line-color);
  background: transparent;
  color: var(--text);
  transition: width 150ms ease, opacity 150ms ease, padding 150ms ease;
}

.search-wrap[data-active="true"] .search-input {
  width: min(260px, 32vw);
  opacity: 1;
  padding: 0.15rem 0.35rem;
  margin-left: 0.25rem;
}

.day-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr) auto;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-5);
}

.day-tab,
.sort-button,
.icon-button,
.text-button,
.danger-button,
.task-complete,
.task-delete,
.task-nest-button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  cursor: pointer;
}

.day-tab {
  font-size: var(--size-xs);
  color: var(--muted);
  letter-spacing: 0.15em;
  text-align: center;
  text-transform: uppercase;
  padding-bottom: 0.4rem;
  position: relative;
}

.day-tab::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 16px;
  height: 1px;
  background: transparent;
  transform: translateX(-50%);
}

.day-tab[aria-selected="true"] {
  color: var(--text);
}

.day-tab[aria-selected="true"]::after {
  background: var(--text);
}

.sort-button {
  min-width: 42px;
  font-size: var(--size-xs);
  color: var(--muted);
  letter-spacing: 0.08em;
  text-align: right;
  padding-bottom: 0.4rem;
}

.icon-button {
  width: 25px;
  height: 25px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  border-radius: 999px;
}

.icon-button:hover,
.icon-button[aria-expanded="true"],
.task-delete:hover,
.task-nest-button:hover {
  color: var(--text);
}

.icon {
  width: 16px;
  height: 16px;
  display: block;
}

.task-list {
  min-height: 220px;
  margin-bottom: var(--space-5);
}

.empty-state {
  color: var(--muted);
  font-size: var(--size-sm);
  padding: var(--space-5) 0;
  text-align: center;
}

.task-row {
  --indent: 0px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  padding: 0.18rem 0 0.18rem var(--indent);
  border-bottom: 1px solid var(--fainter);
  position: relative;
}

.task-row[data-depth="1"] { --indent: 24px; }
.task-row[data-depth="2"] { --indent: 48px; }
.task-row[data-depth="3"] { --indent: 72px; }

.task-row.is-subtask::before {
  content: '';
  position: absolute;
  left: calc(var(--indent) - 13px);
  top: -1px;
  width: 12px;
  height: calc(50% + 1px);
  border-left: 1px solid var(--faint);
  border-bottom: 1px solid var(--faint);
  border-bottom-left-radius: 7px;
}

.task-complete {
  width: 15px;
  height: 15px;
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: transparent;
  background: transparent;
}

.task-row.is-completed .task-complete {
  color: var(--complete);
  border-color: var(--complete);
}

.task-complete .icon {
  width: 12px;
  height: 12px;
}

.task-text {
  min-width: 0;
  color: var(--text);
  font-size: var(--size-sm);
  overflow-wrap: anywhere;
}

.task-row.is-completed .task-text {
  color: var(--complete);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: currentColor;
}

.task-row.is-scheduled:not(.is-completed) .task-text::before {
  content: '·';
  color: var(--scheduled);
  margin-right: 0.35rem;
}

.task-row.is-overdue:not(.is-completed) .task-meta {
  color: var(--overdue);
}

.task-meta {
  color: var(--muted);
  font-size: var(--size-xs);
  white-space: nowrap;
}

.task-row.is-scheduled:not(.is-completed) .task-meta {
  color: var(--scheduled);
}

.task-row.is-completed .task-meta {
  color: var(--complete);
}

.task-nest-controls {
  display: inline-flex;
  gap: 0.16rem;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.task-row:hover .task-nest-controls,
.task-row:focus-within .task-nest-controls {
  opacity: 1;
  transform: translateX(0);
}

.task-nest-button,
.task-delete {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
}

.task-nest-button .icon,
.task-delete .icon {
  width: 14px;
  height: 14px;
}

.task-delete:hover {
  color: var(--danger);
}

.token-tag { color: var(--tag); }
.token-mention { color: var(--mention); }

.composer {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.task-input {
  width: 100%;
  min-height: 42px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line-color);
  background: var(--shell-strong);
  color: var(--text);
  resize: none;
  outline: none;
}

.task-input::placeholder {
  color: var(--muted);
}

.task-input:focus {
  border-color: var(--line-strong);
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.text-button,
.danger-button {
  min-height: 28px;
  padding: 0.35rem 0.7rem;
  font-size: var(--size-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.text-button {
  background: var(--button-bg);
  color: var(--button-text);
}

.secondary-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-color);
}

.danger-button {
  color: var(--danger);
  border: 1px solid currentColor;
}

.date-button {
  width: 32px;
  height: 28px;
  border: 1px solid var(--line-color);
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
}

.date-button:hover,
.date-button.has-date {
  color: var(--text);
  border-color: var(--line-strong);
}

.counter-line {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--size-xs);
}

.settings-panel {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.14);
  z-index: 10;
}

.settings-panel[hidden] {
  display: none;
}

.settings-card {
  width: min(560px, 100%);
  max-height: min(760px, 88vh);
  overflow: auto;
  background: var(--shell-strong);
  color: var(--text);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  padding: var(--space-5);
  border-radius: var(--radius-soft);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.16);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.settings-title {
  font-size: var(--size-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-grid {
  display: grid;
  gap: var(--space-4);
}

.setting-row {
  display: grid;
  gap: 0.35rem;
}

.setting-row label,
.setting-label {
  color: var(--muted);
  font-size: var(--size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.setting-row select,
.setting-row input[type="date"] {
  width: 100%;
  padding: 0.5rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-color);
}

.setting-actions,
.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.local-note,
.history-output {
  color: var(--muted);
  font-size: var(--size-xs);
}

.history-output {
  white-space: pre-wrap;
  border-top: 1px solid var(--fainter);
  padding-top: var(--space-3);
}

.site-footer {
  position: relative;
  z-index: 1;
  width: min(var(--shell-width), calc(100vw - 32px));
  margin: 0 auto;
  padding: 0 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  color: var(--muted);
  font-size: var(--size-xs);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.7rem;
}

.footer-links a {
  color: inherit;
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text);
}

@media (max-width: 1080px) {
  .activity-panel { opacity: 0.24; }
  .activity-panel-left { right: calc(100% - 52px); }
  .activity-panel-right { left: calc(100% - 52px); }
}

@media (max-width: 760px) {
  .activity-bg { display: none; }
  .header-top { align-items: flex-start; }
  .status-line { text-align: left; white-space: normal; }
  .day-row { gap: 0.35rem; }
  .day-tab { letter-spacing: 0.08em; }
  .task-row { grid-template-columns: 22px minmax(0, 1fr) auto auto; }
  .task-nest-controls { display: none; }
  .site-footer { align-items: flex-start; flex-direction: column; }
  .footer-links { justify-content: flex-start; }
  .search-wrap[data-active="true"] .search-input { width: min(220px, 45vw); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
