:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, light-dark(#fff, #17212b));
  --ink: var(--tg-theme-text-color, light-dark(#17212b, #edf3f8));
  --muted: var(--tg-theme-hint-color, light-dark(#657789, #a4b5c7));
  --blue: var(--tg-theme-button-color, light-dark(#2485cf, #68b5f0));
  --on-blue: var(--tg-theme-button-text-color, light-dark(#fff, #102536));
  --soft: var(--tg-theme-secondary-bg-color, light-dark(#f1f6fb, #233241));
  --line: light-dark(#e3eaf1, #354655);
  font:
    15px/1.45 system-ui,
    sans-serif;
  background: var(--bg);
  color: var(--ink);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
[hidden] {
  display: none !important;
}
#planner {
  max-width: 540px;
  margin: auto;
  padding: max(
      18px,
      env(safe-area-inset-top),
      var(--tg-content-safe-area-inset-top, 0px)
    )
    max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-size: 28px;
  line-height: 1.2;
}
h2 {
  font-size: 17px;
  font-weight: 600;
}
button,
input,
textarea {
  font: inherit;
}
button {
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  background: var(--soft);
  cursor: pointer;
}
button:disabled {
  opacity: 0.55;
  cursor: default;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}
.heading,
.period,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.eyebrow,
.muted,
.privacy {
  color: var(--muted);
  font-size: 13px;
}
.eyebrow {
  margin-bottom: 4px;
}
.text-button {
  color: var(--blue);
  background: transparent;
}
.period {
  margin: 18px 0 12px;
}
#planning-consent {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}
#planning-consent > * + * {
  margin-top: 10px;
}
[data-planning-terms] {
  white-space: pre-line;
}
.period button {
  width: 44px;
  font-size: 26px;
  padding: 0;
}
.segments {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--soft);
  padding: 3px;
  border-radius: 12px;
  margin-bottom: 12px;
}
.segments button[aria-pressed="true"] {
  background: var(--blue);
  color: var(--on-blue);
}
.dates {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.weekday {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 0;
  background: var(--soft);
}
.date {
  position: relative;
  min-width: 0;
  min-height: 44px;
  padding: 6px 0 10px;
  border-radius: 0;
  background: transparent;
  border-top: 1px solid var(--line);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.date[aria-pressed="true"] {
  background: var(--blue);
  color: var(--on-blue);
  border-radius: 10px;
}
.date.today {
  font-weight: 750;
}
.date.has-tasks::after {
  content: "·";
  position: absolute;
  font-size: 24px;
  line-height: 10px;
  bottom: 3px;
  left: 0;
  right: 0;
  color: var(--blue);
}
.date[aria-pressed="true"]::after {
  color: var(--on-blue);
}
.date.outside {
  color: var(--muted);
}
.goal-strip {
  width: 100%;
  text-align: left;
  margin-bottom: 16px;
  color: var(--blue);
  overflow-wrap: anywhere;
}
.agenda-title {
  align-items: baseline;
  flex-wrap: wrap;
  margin: 12px 0 3px;
}
.task-list {
  padding: 0;
  list-style: none;
  margin: 0 0 16px;
}
.task {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.task .check {
  flex-shrink: 0;
  width: 44px;
  padding: 8px;
  color: var(--blue);
  font-size: 21px;
  background: transparent;
}
.task-copy {
  flex: 1;
  min-width: 0;
}
.task-title {
  overflow-wrap: anywhere;
  margin: 7px 0 2px;
  font-weight: 550;
}
.task.completed .task-title {
  color: var(--muted);
  text-decoration: line-through;
}
.task.cancelled .task-title {
  color: var(--muted);
}
.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.task-actions button {
  padding: 6px 8px;
  background: transparent;
  color: var(--blue);
  font-size: 13px;
}
.primary {
  background: var(--blue);
  color: var(--on-blue);
}
#add-task,
#goal-edit {
  width: 100%;
}
#undated-section {
  margin-top: 20px;
}
#notice {
  padding: 10px 0;
  font-size: 14px;
  color: var(--muted);
}
#notice:empty {
  display: none;
}
nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding: 8px 0
    max(
      10px,
      env(safe-area-inset-bottom),
      var(--tg-content-safe-area-inset-bottom, 0px)
    );
  background: var(--bg);
}
nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  font-size: 23px;
  background: transparent;
  color: var(--muted);
}
nav span {
  font-size: 11px;
}
nav button[aria-current] {
  color: var(--blue);
}
.privacy {
  margin-top: 20px;
}
.privacy p {
  margin-top: 8px;
}
.privacy summary {
  cursor: pointer;
  min-height: 36px;
}
#goal-view p {
  margin: 12px 0 18px;
  overflow-wrap: anywhere;
}
#goal-actions {
  margin-top: 12px;
  flex-wrap: wrap;
}
.total {
  margin: 16px 0;
  font-size: 28px;
}
#progress-view {
  margin-top: 20px;
}
dialog {
  width: min(440px, calc(100% - 24px));
  max-height: 90dvh;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: var(--bg);
}
dialog::backdrop {
  background: #0007;
}
label {
  display: block;
  margin: 14px 0;
}
input:not([type="checkbox"]),
textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  margin-top: 5px;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
}
#link-field {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
}
input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--blue);
}
#form-error {
  color: light-dark(#ae3030, #ff9999);
  margin: 10px 0;
}
form > .muted {
  margin: 14px 0;
}
.actions {
  justify-content: flex-start;
}
@media (max-width: 350px) {
  #planner {
    padding-left: 10px;
    padding-right: 10px;
  }
  .task {
    gap: 3px;
  }
}
#habits-section {
  margin: 14px 0 18px;
}
#habits-title {
  font-size: 14px;
}
#add-habit {
  padding: 6px;
  font-size: 13px;
  white-space: nowrap;
}
.habit-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}
.habit-table th,
.habit-table td {
  padding: 0;
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.habit-table th:first-child {
  width: 30%;
  text-align: left;
  overflow-wrap: anywhere;
}
.habit-table thead th {
  font-weight: 500;
  background: var(--soft);
  color: var(--muted);
}
.habit-table th span {
  display: block;
}
.habit-table button {
  width: 100%;
  padding: 0;
  min-height: 44px;
  background: transparent;
}
.habit-table .habit-name {
  text-align: left;
  font-size: 12px;
  padding-right: 4px;
  overflow-wrap: anywhere;
}
.habit-check {
  color: var(--blue);
  font-size: 22px;
}
.habit-check[aria-pressed="true"] {
  background: var(--soft);
}
#success-section {
  margin-top: 20px;
}
#add-success {
  padding: 6px;
  font-size: 13px;
}
