:root {
  color-scheme: light;
  --canvas: #f8f1ed;
  --paper: #fffdf8;
  --paper-strong: #fff9f4;
  --ink: #493139;
  --muted: #826b73;
  --soft: #a78f96;
  --line: #dbc7c4;
  --dash: #eaded7;
  --rose: #f3d7dd;
  --rose-strong: #bf7688;
  --plum: #6f4a5c;
  --sage: #dfe8d8;
  --sage-strong: #79916f;
  --sky: #deebf2;
  --sky-strong: #6f8da3;
  --honey: #f3e5c8;
  --danger: #f0d0d0;
  --shadow: 0 18px 40px rgba(106, 70, 77, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    repeating-linear-gradient(0deg, rgba(191, 118, 136, 0.05) 0 1px, transparent 1px 32px),
    repeating-linear-gradient(90deg, rgba(121, 145, 111, 0.05) 0 1px, transparent 1px 32px),
    var(--canvas);
  color: var(--ink);
  font-family: Tahoma, Arial, sans-serif;
  line-height: 1.65;
}

button,
input,
select {
  font: inherit;
}

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

.app-shell {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px 28px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 156px;
  height: 44px;
  background: linear-gradient(135deg, rgba(243, 215, 221, 0.88), rgba(243, 229, 200, 0.72));
  clip-path: polygon(0 0, 100% 0, 72% 100%, 0 72%);
  pointer-events: none;
}

.brand-block {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  background: var(--plum);
  color: #fffdf8;
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

#subtitle {
  max-width: 48ch;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-button,
.button,
.tab,
.task-action,
.habit-button,
.theme-choice {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
}

.icon-button {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--plum);
  font-size: 24px;
  font-weight: 800;
}

.icon-button:disabled,
.button:disabled,
.task-action:disabled {
  cursor: wait;
  opacity: 0.68;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  padding: 8px 0;
  margin-bottom: 10px;
  background: rgba(248, 241, 237, 0.94);
  backdrop-filter: blur(10px);
}

.tab {
  min-height: 42px;
  padding: 8px 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.tab.active {
  background: var(--rose);
  border-color: #dcaeb8;
  color: var(--plum);
}

.stack {
  display: grid;
  gap: 12px;
}

.hidden {
  display: none !important;
}

.notice {
  margin-bottom: 10px;
  padding: 11px 12px;
  background: var(--sky);
  border: 1px solid #c8dce8;
  border-radius: 8px;
  color: #4f6f82;
  font-size: 14px;
  font-weight: 700;
}

.notice.success {
  background: var(--sage);
  border-color: #c7d9c0;
  color: #59734f;
}

.notice.warn {
  background: var(--honey);
  border-color: #e0cca3;
  color: #7b6742;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 12px;
}

.panel {
  position: relative;
  overflow: hidden;
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(106, 70, 77, 0.07);
}

.panel.pad {
  padding: 14px;
}

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

.panel-head h2,
.panel-head h3 {
  font-size: 17px;
  line-height: 1.4;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
}

.chip,
.metric,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.focus-panel {
  display: grid;
  gap: 13px;
  min-height: 214px;
}

.focus-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.focus-title strong {
  display: block;
  margin-top: 4px;
  font-size: 27px;
  line-height: 1.35;
}

.progress-wrap {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.progress-ring {
  --p: 0;
  display: grid;
  place-items: center;
  width: 112px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--paper) 0 58%, transparent 59%),
    conic-gradient(var(--rose-strong) calc(var(--p) * 1%), var(--dash) 0);
  border: 1px solid var(--line);
  color: var(--plum);
  font-size: 24px;
  font-weight: 800;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  display: grid;
  min-height: 72px;
  padding: 8px;
  text-align: center;
}

.metric b {
  color: var(--ink);
  font-size: 19px;
  line-height: 1.2;
}

.priority-list {
  display: grid;
  gap: 9px;
  counter-reset: priority;
}

.priority-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px dashed var(--dash);
}

.priority-row:last-child {
  border-bottom: 0;
}

.priority-row::before {
  counter-increment: priority;
  content: counter(priority);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: var(--rose);
  border-radius: 50%;
  color: var(--plum);
  font-weight: 800;
}

.timeline {
  display: grid;
  gap: 0;
}

.task-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 11px;
  padding: 12px 0;
  border-top: 1px dashed var(--dash);
}

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

.time-chip {
  display: grid;
  place-items: center;
  align-self: start;
  min-height: 42px;
  padding: 5px;
  background: var(--sky);
  border: 1px solid #c8dce8;
  border-radius: 8px;
  color: #4f6f82;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

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

.task-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.task-title strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 16px;
}

.task-topic {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.task-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.task-action {
  min-height: 38px;
  padding: 7px 6px;
  font-size: 12px;
  font-weight: 800;
}

.task-action.done {
  background: var(--sage);
  border-color: #c7d9c0;
  color: #59734f;
}

.task-action.partial {
  background: var(--honey);
  border-color: #e0cca3;
  color: #735f3b;
}

.task-action.missed {
  background: var(--danger);
  border-color: #dcafaf;
  color: #884f55;
}

.checkin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 12px;
  text-decoration: none;
  font-weight: 800;
}

.button.primary {
  background: var(--rose-strong);
  border-color: var(--rose-strong);
  color: #fffdf8;
}

.button.secondary {
  background: var(--sky);
  border-color: #c8dce8;
  color: #4f6f82;
}

.empty {
  padding: 14px;
  background: linear-gradient(90deg, rgba(222, 235, 242, 0.8), rgba(223, 232, 216, 0.78));
  border: 1px solid rgba(202, 220, 220, 0.88);
  border-radius: 8px;
  color: #566f71;
  font-size: 14px;
  font-weight: 700;
}

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

.habit-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 9px 10px;
  font-weight: 800;
}

.habit-button .mark {
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--dash);
  color: var(--muted);
}

.habit-button.active {
  background: var(--sage);
  border-color: #c7d9c0;
  color: #59734f;
}

.habit-button.active .mark {
  background: var(--sage-strong);
  color: #fffdf8;
}

.habit-history {
  display: grid;
  gap: 7px;
}

.habit-day {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  border-bottom: 1px dashed var(--dash);
  font-size: 13px;
}

.habit-day:last-child {
  border-bottom: 0;
}

.habit-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.habit-dot {
  width: 10px;
  height: 10px;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.habit-dot.active {
  background: var(--rose-strong);
  border-color: var(--rose-strong);
}

.planner-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(260px, 1.08fr);
  gap: 12px;
  align-items: stretch;
}

.planner-card-preview {
  min-height: 302px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.planner-mini-paper {
  height: 100%;
  min-height: 270px;
  padding: 18px;
  background:
    repeating-linear-gradient(0deg, transparent 0 29px, rgba(191, 118, 136, 0.16) 30px),
    var(--paper-strong);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.planner-mini-title {
  display: grid;
  place-items: center;
  min-height: 40px;
  margin-bottom: 14px;
  background: var(--rose);
  border-radius: 8px;
  color: var(--plum);
  font-weight: 900;
}

.planner-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.planner-mini-box {
  min-height: 70px;
  border: 1px solid var(--dash);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
}

.planner-result {
  display: grid;
  gap: 10px;
}

.planner-img {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.theme-choice {
  display: grid;
  gap: 5px;
  min-height: 62px;
  padding: 8px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.theme-choice .swatch {
  display: block;
  width: 100%;
  height: 18px;
  border: 1px solid rgba(73, 49, 57, 0.14);
  border-radius: 6px;
  background: var(--swatch);
}

.theme-choice.active {
  border-color: var(--rose-strong);
  background: var(--rose);
  color: var(--plum);
}

@media (max-width: 720px) {
  .app-shell {
    padding-inline: 10px;
  }

  .topbar {
    padding: 10px;
  }

  h1 {
    font-size: 21px;
  }

  #subtitle {
    max-width: 29ch;
  }

  .tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .tab {
    min-height: 39px;
    padding-inline: 5px;
    font-size: 12px;
  }

  .dashboard-grid,
  .planner-hero,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .progress-wrap {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .progress-ring {
    width: 94px;
    font-size: 21px;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .metric {
    min-height: 66px;
    padding-inline: 4px;
  }

  .task-row {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 8px;
  }

  .time-chip {
    font-size: 11px;
  }

  .task-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .checkin-grid,
  .habit-grid {
    grid-template-columns: 1fr;
  }

  .theme-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
