:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #141414;
  --muted: #9c9c9c;
  --line: #ededed;
  --soft: #f5f5f4;
  --accent: #111111;
  --orange: #ffae24;
  --blue: #2bb7ff;
  --danger: #c93f3f;
  --shadow: 0 14px 50px rgba(0, 0, 0, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 440px);
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
  padding: calc(env(safe-area-inset-top) + 9px) 12px calc(env(safe-area-inset-bottom) + 76px);
  background: var(--bg);
}

.topbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
  font-weight: 800;
}

.topbar p {
  min-height: 18px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.topbar .sync-line {
  min-height: 0;
  margin-top: 1px;
  font-size: 10px;
}

.auth-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top) + 24px) 20px calc(env(safe-area-inset-bottom) + 24px);
  background: var(--bg);
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  width: min(100%, 360px);
  gap: 15px;
  padding: 28px 22px 22px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 22px;
}

.auth-card h1,
.auth-card p {
  margin: 0;
}

.auth-card h1 {
  font-size: 28px;
}

.auth-card > p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.auth-card label {
  padding: 0;
}

.auth-submit {
  min-height: 48px;
  border: 0;
  border-radius: 7px;
  background: #111;
  color: #fff;
  font-weight: 700;
}

.auth-submit:disabled {
  opacity: 0.5;
}

.auth-card .auth-message {
  min-height: 20px;
  color: var(--danger);
}

.auth-card small {
  color: var(--muted);
  text-align: center;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 0;
  position: relative;
}

.icon-button:not(.tray)::before,
.icon-button:not(.tray)::after {
  content: "";
  width: 28px;
  height: 3px;
  background: var(--text);
  border-radius: 3px;
  display: block;
  position: absolute;
}

.icon-button:not(.tray)::before {
  transform: translateY(-6px);
}

.icon-button:not(.tray)::after {
  transform: translateY(6px);
}

.tray::before {
  content: "";
  width: 26px;
  height: 18px;
  border: 4px solid var(--text);
  border-top-width: 0;
  border-radius: 4px 4px 7px 7px;
  display: block;
  position: relative;
}

.tray::after {
  content: "";
  width: 15px;
  height: 9px;
  border: 4px solid var(--text);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  position: absolute;
  transform: translateY(-7px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.week-nav {
  min-height: 48px;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  margin: -2px 0 9px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  touch-action: pan-y;
}

.week-nav > button {
  width: 48px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 27px;
  line-height: 1;
}

.week-picker {
  min-width: 0;
  min-height: 46px;
  display: grid;
  place-content: center;
  text-align: center;
  position: relative;
  cursor: pointer;
}

.week-picker strong {
  font-size: 16px;
  line-height: 1.2;
}

.week-picker span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.week-picker input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.date-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin: 0 0 16px;
  touch-action: pan-y;
}

.date-pill {
  border: 0;
  background: transparent;
  color: #aaa;
  border-radius: 16px;
  min-height: 52px;
  padding: 4px 2px;
  display: grid;
  place-items: center;
  gap: 4px;
}

.date-pill span:first-child {
  font-size: 13px;
}

.date-pill span:last-child {
  font-size: 18px;
  font-weight: 650;
}

.date-pill.active {
  color: var(--text);
  border: 1px solid #dedede;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
  background: rgba(255, 255, 255, 0.65);
}

.day-section {
  margin-bottom: 18px;
}

.section-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1;
  font-weight: 800;
}

.section-heading h2::before {
  content: "";
  width: 14px;
  height: 14px;
  margin-right: 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--blue);
  vertical-align: -1px;
}

.day-section[data-slot="morning"] .section-heading h2::before {
  background: #ffca3a;
  clip-path: polygon(50% 0, 62% 33%, 98% 35%, 69% 56%, 79% 91%, 50% 70%, 21% 91%, 31% 56%, 2% 35%, 38% 33%);
}

.day-section[data-slot="afternoon"] .section-heading h2::before {
  background: #ff8c32;
}

.day-section[data-slot="evening"] .section-heading h2::before {
  background: #7da7ff;
}

.day-section[data-slot="unscheduled"] .section-heading h2::before {
  border-radius: 3px;
  background: #787878;
}

.section-heading small {
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  margin-left: 4px;
}

.add-inline {
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  font-size: 32px;
  line-height: 1;
  color: var(--text);
}

.task-list {
  display: grid;
  gap: 9px;
}

.empty {
  color: #c6c6c6;
  font-size: 14px;
  padding: 6px 0 12px 36px;
}

.task-card {
  min-height: 56px;
  border: 0;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 5px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 7px;
  text-align: left;
  box-shadow: 0 7px 28px rgba(0, 0, 0, 0.025);
}

.check-ring {
  width: 26px;
  height: 26px;
  border: 3px solid #d8d8d8;
  border-radius: 50%;
  display: block;
  background: transparent;
  padding: 0;
}

.task-card.completed {
  opacity: 0.45;
  background: #eeeeed;
}

.task-card.completed .check-ring {
  border-color: var(--orange);
}

.task-main {
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
}

.task-title {
  display: block;
  font-size: 17px;
  line-height: 1.25;
  color: var(--text);
  word-break: break-word;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
  color: #f0a21d;
  font-size: 12px;
}

.timer-dot {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #303030;
  display: grid;
  place-items: center;
}

.timer-dot::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  display: block;
}

.focus-card {
  background: rgba(255, 255, 255, 0.68);
  border-radius: 4px;
  padding: 11px 12px;
  margin-bottom: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.03);
}

.focus-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
}

.focus-mark {
  width: 15px;
  height: 15px;
  border-top: 3px solid var(--text);
  border-left: 3px solid var(--text);
  transform: rotate(45deg);
}

#editFocusButton {
  width: 27px;
  height: 27px;
  border: 0;
  background: transparent;
  position: relative;
}

#editFocusButton::before {
  content: "";
  width: 18px;
  height: 6px;
  border: 2px solid #b9b9b9;
  position: absolute;
  transform: rotate(-45deg);
  left: 5px;
  top: 10px;
}

.focus-card p {
  margin: 7px 0 0;
  color: #c2c2c2;
  font-size: 12px;
  line-height: 1.35;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  grid-auto-rows: minmax(112px, auto);
}

.week-day {
  min-height: 112px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px 6px 7px;
}

.week-day.todos-cell {
  background: rgba(255, 255, 255, 0.3);
}

.week-day.today {
  background: rgba(255, 255, 255, 0.42);
}

.week-day.drop-target {
  background: #fff4d9;
  box-shadow: inset 0 0 0 2px var(--orange);
}

.week-heading {
  display: grid;
  grid-template-columns: 1fr 30px;
  align-items: center;
  margin-bottom: 4px;
}

.week-heading strong {
  font-size: 17px;
}

.week-heading button {
  border: 0;
  background: transparent;
  color: #b7b7b7;
  font-size: 24px;
  min-width: 30px;
  min-height: 34px;
}

.week-task {
  width: 100%;
  background: rgba(245, 245, 244, 0.9);
  border-radius: 5px;
  margin: 3px 0;
  min-height: 24px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  padding: 2px 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.week-check {
  width: 11px;
  height: 11px;
  border: 2px solid var(--orange);
  border-radius: 50%;
  background: transparent;
  padding: 0;
  margin: 4px 0 0;
}

.week-task-title {
  border: 0;
  background: transparent;
  padding: 1px 0 2px;
  text-align: left;
  color: #383838;
  font-size: 14px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.week-task.dragging {
  position: relative;
  z-index: 20;
  opacity: 0.88;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

.week-task.drag-ready {
  box-shadow: inset 0 0 0 1px var(--orange);
}

.week-empty {
  padding: 14px 4px 4px;
  text-align: center;
  font-size: 12px;
}

.week-task.completed {
  color: #a9a9a9;
}

.week-task.completed .week-check {
  opacity: 0.6;
  background: var(--orange);
}

.week-task.completed .week-task-title {
  color: #a9a9a9;
  text-decoration: line-through;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.metrics article,
.panel {
  background: rgba(255, 255, 255, 0.72);
  border-radius: 7px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.035);
}

.metrics article {
  padding: 17px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.metrics strong {
  display: block;
  font-size: 32px;
  margin-top: 8px;
}

.panel {
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-heading {
  padding: 16px 17px 10px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 21px;
}

.recent-list {
  padding: 0 17px 14px;
}

.recent-item {
  border-top: 1px solid var(--line);
  padding: 11px 0;
}

.recent-item strong {
  display: block;
  font-size: 17px;
}

.recent-item span {
  color: var(--muted);
  font-size: 13px;
}

.action-panel {
  display: grid;
}

.action-row {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  padding: 0 18px;
  font-size: 18px;
  color: var(--text);
  display: flex;
  align-items: center;
}

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

.file-action {
  cursor: pointer;
}

#restoreInput {
  display: none;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 440px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 9px 22px calc(env(safe-area-inset-bottom) + 9px);
  background: rgba(251, 251, 250, 0.92);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  z-index: 10;
}

.tab {
  border: 0;
  background: transparent;
  color: #aaa;
  display: grid;
  place-items: center;
  gap: 4px;
  font-size: 13px;
}

.tab.active {
  color: var(--text);
}

.tab-icon {
  width: 31px;
  height: 31px;
  display: block;
  position: relative;
}

.tab-icon.home::before {
  content: "";
  width: 22px;
  height: 20px;
  border: 4px solid currentColor;
  border-top: 0;
  position: absolute;
  bottom: 1px;
  left: 4px;
}

.tab-icon.home::after {
  content: "";
  width: 20px;
  height: 20px;
  border-left: 4px solid currentColor;
  border-top: 4px solid currentColor;
  transform: rotate(45deg);
  position: absolute;
  left: 5px;
  top: 1px;
}

.tab-icon.calendar::before {
  content: "";
  width: 25px;
  height: 25px;
  border: 4px solid currentColor;
  border-radius: 3px;
  position: absolute;
  left: 1px;
  top: 2px;
}

.tab-icon.calendar::after {
  content: "";
  width: 25px;
  height: 5px;
  background: currentColor;
  position: absolute;
  left: 5px;
  top: 9px;
}

.tab-icon.insight::before {
  content: "";
  width: 22px;
  height: 27px;
  border: 4px solid currentColor;
  border-radius: 10px 10px 5px 5px;
  position: absolute;
  left: 3px;
  top: 0;
}

.tab-icon.insight::after {
  content: "";
  width: 4px;
  height: 16px;
  background: currentColor;
  box-shadow: 8px -5px 0 currentColor, 16px -10px 0 currentColor;
  position: absolute;
  left: 7px;
  bottom: 5px;
}

.fab {
  position: fixed;
  right: max(14px, calc((100vw - 440px) / 2 + 14px));
  bottom: calc(env(safe-area-inset-bottom) + 88px);
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: #000;
  color: #fff;
  font-size: 36px;
  line-height: 1;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
  z-index: 12;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
  z-index: 19;
}

.sheet {
  width: min(calc(100% - 28px), 450px);
  border: 0;
  border-radius: 22px;
  padding: 0;
  margin: auto auto 14px;
  box-shadow: var(--shadow);
  background: var(--surface);
  color: var(--text);
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.18);
}

.sheet header {
  display: grid;
  grid-template-columns: 1fr 42px;
  align-items: center;
  padding: 18px 18px 8px;
}

.sheet h2 {
  margin: 0;
  font-size: 22px;
}

.close-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #f1f1f1;
  color: #999;
  font-size: 28px;
}

form,
.task-actions,
.export-box {
  display: grid;
  gap: 14px;
}

form label {
  display: grid;
  gap: 7px;
  padding: 0 18px;
}

form label span {
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fafafa;
  border-radius: 8px;
  padding: 13px 12px;
  color: var(--text);
  outline: 0;
}

textarea {
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.form-grid label {
  min-width: 0;
}

.hint {
  margin: -5px 18px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.sheet footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 6px 18px 18px;
}

.sheet footer button,
.task-actions button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: #f2f2f2;
  color: var(--text);
}

.sheet footer .primary,
.task-actions .primary {
  background: #111;
  color: #fff;
}

.sheet footer .danger {
  margin-right: auto;
  color: var(--danger);
}

.task-actions button {
  margin: 0 18px;
  text-align: left;
  font-size: 18px;
}

.task-actions button:last-child {
  margin-bottom: 18px;
}

.export-box textarea,
#importTextInput,
#focusInput {
  width: calc(100% - 36px);
  margin: 0 18px;
}

@media (min-width: 760px) {
  body {
    background: #ececea;
  }

  .app-shell {
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
  }
}
