:root {
  color-scheme: light;
  --paper: #d3d3d5;
  --paper-deep: #e7dfd0;
  --surface: #faf8f2;
  --surface-raised: #fffdf8;
  --ink: #000000;
  --muted: #716f63;
  --line: #d4cbbb;
  --olive: #344a37;
  --olive-soft: #e3e9e0;
  --brass: #826443;
  --brass-soft: #eee6d8;
  --wine: #725458;
  --red: #9c5047;
  --red-soft: #f3e7e3;
  --green: #40583f;
  --green-soft: #e4eae0;
  --shadow: 0 12px 32px rgba(53, 48, 36, 0.07);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% -22%, rgba(255, 255, 255, 0.86), transparent 12%),
    var(--paper);
  color: var(--ink);
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

.app {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  padding: 30px 20px 48px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
}

.header h1 {
  margin: 0;
  color: var(--ink);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 35px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.015em;
}

.header-actions { display: flex; align-items: center; gap: 9px; }

.icon-button {
  display: flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--olive);
  font: 500 23px/1 "Manrope", sans-serif;
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}

.icon-button:hover { border-color: var(--olive); background: var(--olive-soft); }
.icon-button:active { transform: scale(.96); }
.icon-button--ghost { color: var(--brass); font-size: 19px; }
.icon-button--ghost:hover { border-color: var(--brass); background: var(--brass-soft); }

.form-title {
  margin: 0;
  color: var(--ink);
  font: 600 23px/1.1 "Cormorant Garamond", Georgia, serif;
}

.add-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.add-form.hidden, .empty.hidden, .error.hidden, .hidden { display: none; }

.add-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.add-form input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-raised);
  color: var(--ink);
  font: 500 15px "Manrope", sans-serif;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.add-form select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-raised);
  color: var(--ink);
  font: 500 15px "Manrope", sans-serif;
}
.add-form textarea {
  width: 100%; min-height: 76px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px;
  background: var(--surface-raised); color: var(--ink); font: 500 14px/1.45 "Manrope", sans-serif; resize: vertical;
}
.add-form textarea:focus-visible { outline: none; border-color: var(--olive); box-shadow: 0 0 0 3px rgba(89, 100, 75, .14); }
.add-form textarea::placeholder { color: #aaa69a; font-weight: 400; }
.add-form select:focus-visible { outline: none; border-color: var(--olive); box-shadow: 0 0 0 3px rgba(89, 100, 75, .14); }

.date-picker-control {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-raised);
  color: var(--ink);
  font: 500 15px "Manrope", sans-serif;
  text-transform: none;
}
.date-picker-display { color: var(--muted); }
.date-picker-icon { color: var(--muted); font-size: 18px; line-height: 1; }
.date-picker-control input#field-deadline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.date-picker-control input#field-deadline:focus-visible { outline: none; border: 0; box-shadow: none; }
.date-picker-control:focus-within { outline: 2px solid var(--olive); outline-offset: 2px; }

.add-form input::placeholder { color: #aaa69a; font-weight: 400; }
.add-form input:focus, .button:focus-visible, .icon-button:focus-visible,
.icon-action:focus-visible, .language-option:focus-visible, .theme-option:focus-visible {
  outline: none;
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(89, 100, 75, .14);
}

.form-actions { display: flex; gap: 10px; margin-top: 3px; }

.button {
  flex: 1;
  min-height: 43px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 3px;
  font: 700 13px "Manrope", sans-serif;
  letter-spacing: .025em;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}


.button:active { transform: translateY(1px); }
.button.primary { border-color: #263a2d; background: #263a2d; color: #fffdf8; }
.button.primary:hover { border-color: #1d3024; background: #1d3024; }
.link-code-dialog { width: min(420px, calc(100vw - 32px)); padding: 0; border: 0; background: transparent; color: var(--ink); }
.link-code-dialog::backdrop { background: rgba(16, 20, 16, .48); }
.link-code-dialog .add-form { margin: 0; }
.link-code-dialog p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.link-code-value { display: block; padding: 15px; border: 1px dashed var(--brass); background: var(--brass-soft); color: var(--olive); font: 700 22px/1.2 "Manrope", sans-serif; letter-spacing: .16em; text-align: center; user-select: all; }
.link-code-dialog .button { width: 100%; }
.analytics-day-dialog { width: min(460px, calc(100vw - 28px)); max-height: min(78vh, 680px); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.analytics-day-dialog::backdrop { background: rgba(16, 20, 16, .48); backdrop-filter: blur(3px); }
.analytics-day-card { padding: 18px; }
.analytics-day-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.analytics-day-header h2 { margin: 0; color: var(--ink); font: 600 22px/1.1 "Cormorant Garamond", Georgia, serif; }
.analytics-day-dialog .list { margin: 0; }
.analytics-day-dialog .empty { margin: 12px 0 2px; }
.confirm-dialog { width: min(420px, calc(100vw - 32px)); padding: 0; border: 0; background: transparent; color: var(--ink); }
.confirm-dialog::backdrop { background: rgba(16, 20, 16, .48); }
.confirm-dialog-content { margin: 0; }
.confirm-dialog-message { margin: 0; color: var(--ink); font-size: 14px; line-height: 1.6; }
.confirm-dialog .form-actions { margin-top: 18px; }
.button.secondary { border-color: var(--line); background: transparent; color: var(--muted); }
.button.secondary:hover { border-color: var(--muted); color: var(--ink); }

.reminder-setting { min-width: 0; margin: 0; padding: 0; border: 0; }
.setting-help { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.task-reminder-setting { margin-top: 2px; }
.task-reminder-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; }
.add-form input[type="range"] {
  --reminder-progress: 31.6%;
  --reminder-color: #263a2d;
  width: 100%;
  min-height: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.add-form input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--reminder-color) 0 var(--reminder-progress), var(--line) var(--reminder-progress) 100%); }
.add-form input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--line); }
.add-form input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--reminder-color); }
.add-form input[type="range"]::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -7px; border: 2px solid var(--surface); border-radius: 50%; background: var(--reminder-color); box-shadow: 0 0 0 1px var(--reminder-color); appearance: none; -webkit-appearance: none; }
.add-form input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 2px solid var(--surface); border-radius: 50%; background: var(--reminder-color); box-shadow: 0 0 0 1px var(--reminder-color); }
.add-form input[type="range"]:focus-visible { outline: 2px solid var(--reminder-color); outline-offset: 4px; box-shadow: none; }
.task-reminder-control output { min-width: 58px; color: var(--olive); font-size: 14px; font-weight: 800; text-align: right; white-space: nowrap; }
.reminder-setting legend { margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; }
.reminder-day-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.add-form .reminder-day-option {
  display: flex;
  min-height: 42px;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-raised);
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
}
.add-form .reminder-day-option input { width: 17px; min-height: 17px; margin: 0; accent-color: var(--olive); }
.reminder-times { display: flex; flex-direction: column; gap: 8px; }
.reminder-time-row { display: flex; align-items: center; gap: 8px; }
.add-form .reminder-time-row input { flex: 1; min-width: 0; }
.remove-reminder-time { min-height: 42px; }
.remove-reminder-time:disabled { opacity: .45; cursor: default; }
.add-reminder-time { flex: 0; align-self: flex-start; margin-top: 8px; }

.error { margin: 0; color: var(--red); font-size: 13px; font-weight: 600; }
.status { min-height: 18px; margin: 0 0 8px; color: var(--muted); font-size: 13px; }

.sections {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 20px;
}

.section-button {
  min-width: 0;
  min-height: 42px;
  padding: 7px 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(251, 250, 246, .74);
  color: var(--muted);
  font: 700 clamp(10px, 2.8vw, 12px)/1.15 "Manrope", sans-serif;
  letter-spacing: .005em;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}

.section-button:hover { border-color: #aaa38f; color: var(--ink); }
.section-button.active { border-color: var(--olive); background: var(--olive); color: #fbfaf6; }
.section-button[data-section="completed"] { border-color: #cdd5c5; color: var(--green); }
.section-button[data-section="completed"].active { border-color: var(--green); background: var(--green); color: #fbfaf6; }
.section-button[data-section="overdue"] { border-color: #e0c9c3; color: var(--red); }
.section-button[data-section="overdue"].active { border-color: var(--red); background: var(--red-soft); color: #85443d; }

.list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.list.hidden, .analytics.hidden, .calendar-panel.hidden { display: none; }
.task-filters { display: flex; gap: 8px; margin: 0 0 12px; }
.task-filters.hidden { display: none; }
.task-filters select, .task-filters input { min-width: 0; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); color: var(--ink); font: 500 12px "Manrope", sans-serif; }
.task-filters select { flex: 0 0 auto; }
.task-filters input { flex: 1; }

.language-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.language-label { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; }
.language-picker { display: flex; gap: 6px; }
.language-select { width: auto; min-width: 150px; min-height: 38px !important; padding: 7px 30px 7px 10px !important; border: 1px solid var(--line) !important; border-radius: 3px !important; background-color: var(--surface-raised) !important; color: var(--ink) !important; font: 600 12px "Manrope", sans-serif !important; }
.language-option, .theme-option {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-raised);
  color: var(--muted);
  font: 600 12px "Manrope", sans-serif;
  cursor: pointer;
}
.language-option.active, .theme-option.active { border-color: var(--olive); background: var(--olive-soft); color: var(--olive); }
.language-option:hover, .theme-option:hover { border-color: var(--olive); }
.theme-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.analytics { margin: 0 0 22px; }
.month-filter { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 13px; }
.month-filter input {
  min-width: 165px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  font: 600 14px "Manrope", sans-serif;
  text-align: center;
}
.month-picker-control {
  position: relative;
  display: grid;
  min-width: 165px;
  min-height: 42px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  font: 600 14px "Manrope", sans-serif;
}
.month-picker-label { padding: 8px 12px; text-align: center; text-transform: capitalize; }
.month-picker-control input#month-picker { position: absolute; inset: 0; width: 100%; min-width: 0; height: 100%; min-height: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.month-picker-control:focus-within { outline: 2px solid var(--olive); outline-offset: 2px; }
.month-filter input:focus-visible, .month-arrow:focus-visible { outline: 2px solid var(--olive); outline-offset: 2px; }
.month-arrow {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--olive);
  font: 400 24px/1 "Manrope", sans-serif;
  cursor: pointer;
}
.month-arrow:hover { border-color: var(--olive); background: var(--olive-soft); }
.month-arrow:disabled { opacity: .38; cursor: default; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.week-range { margin: 0 0 10px; color: var(--muted); font-size: 12px; font-weight: 600; }

.analytics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.stat-card {
  display: flex;
  min-height: 92px;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 13px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
}
.stat-card span { color: var(--muted); font-size: 11px; font-weight: 600; line-height: 1.3; }
.stat-card strong { color: var(--olive); font: 600 30px/.9 "Cormorant Garamond", Georgia, serif; }
.stat-card--month strong { color: var(--wine); }
.stat-card--overdue strong { color: var(--red); }

.chart-panel {
  margin-top: 12px;
  padding: 15px 13px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(53, 48, 36, .035);
}
.chart-panel h2 { margin: 0 0 12px; color: var(--ink); font: 600 21px/1.1 "Cormorant Garamond", Georgia, serif; }
.recommendation-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.recommendation-heading h2 { margin: 0; }
.recommendations-note { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.recommendations-result { margin: 12px 0 0; color: var(--ink); font-size: 14px; line-height: 1.65; white-space: pre-line; }
.recommendations-error { margin: 10px 0 0; color: var(--red); font-size: 13px; }
.chart-scroll { overflow-x: auto; scrollbar-color: #b5ad9a var(--paper-deep); scrollbar-width: thin; }
.line-chart { width: 100%; height: 210px; }
.line-chart--month { width: max-content; min-width: 100%; }
.line-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.line-chart--month svg { height: 210px; max-width: none; }
.chart-grid-line { stroke: rgba(119, 118, 108, .2); stroke-width: 1; stroke-dasharray: 2 5; }
.chart-axis-label, .chart-date-label { fill: var(--muted); font: 600 11px "Manrope", sans-serif; }
.chart-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-point { stroke-width: 2; }
.chart-point { cursor: pointer; }
.chart-point:hover, .chart-point:focus { r: 6; outline: none; }
.line-chart--week .chart-line { stroke: #8a6844; }
.line-chart--week .chart-point { fill: #9b7954; stroke: var(--surface); }
.line-chart--month .chart-line { stroke: #344a37; }
.line-chart--month .chart-point { fill: #4d674e; stroke: var(--surface); }

.item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 15px 15px 17px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(53, 48, 36, .035);
}
.item::before { position: absolute; top: 12px; bottom: 12px; left: 0; width: 3px; border-radius: 2px; background: #b7b1a3; content: ""; }
.item:has(.item-deadline.overdue)::before { background: var(--red); }
.item:has(.item-deadline.today)::before, .item:has(.item-deadline.soon)::before { background: var(--brass); }
.item:has(.item-deadline.later)::before { background: var(--green); }
.item-body { flex: 1; min-width: 0; padding-left: 4px; }
.item-subject { margin: 0 0 3px; color: #826443; font-size: 11px; font-weight: 700; letter-spacing: .055em; text-transform: uppercase; }
.item-title { margin: 0 0 5px; color: var(--ink); font-size: 15px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.item-deadline { margin: 0; font-size: 12px; font-weight: 600; }
.item-completed { margin: 5px 0 0; color: var(--green); font-size: 11px; font-weight: 700; }
.item-deadline.overdue { color: var(--red); }
.item-deadline.today, .item-deadline.soon { color: #816a3d; }
.item-deadline.later { color: var(--green); }
.item-priority, .item-note { margin: 6px 0 0; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.item-priority { font-weight: 800; }
.item-priority.priority-low { color: var(--muted); }
.item-priority.priority-high { color: var(--red); }
.item-note { color: var(--muted); white-space: pre-wrap; }
.item-actions { display: flex; flex-shrink: 0; flex-direction: column; gap: 7px; }
.icon-action {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-raised);
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.edit-button { color: var(--olive); }
.complete-button { color: var(--green); }
.complete-button:hover, .complete-button.is-completed { border-color: var(--green); background: var(--green-soft); }
.edit-button:hover { border-color: var(--olive); background: var(--olive-soft); }
.delete-button { color: var(--red); }
.delete-button:hover { border-color: var(--red); background: var(--red-soft); }
.empty { margin-top: 48px; color: var(--muted); font: 500 19px "Cormorant Garamond", Georgia, serif; text-align: center; }

.calendar-panel { margin: 0 0 22px; padding: 16px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); box-shadow: var(--shadow); }
.calendar-month { min-width: 170px; color: var(--ink); font: 600 22px/1.1 "Cormorant Garamond", Georgia, serif; text-align: center; text-transform: capitalize; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.calendar-weekday { padding: 5px 0; color: var(--muted); font-size: 10px; font-weight: 800; text-align: center; text-transform: uppercase; }
.calendar-date, .calendar-blank { display: flex; min-width: 0; min-height: 42px; align-items: center; justify-content: center; position: relative; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink); font: 600 13px "Manrope", sans-serif; }
.calendar-date { cursor: pointer; }
.calendar-date:hover { border-color: var(--line); background: var(--surface-raised); }
.calendar-date.selected { border-color: var(--olive); background: var(--olive); color: white; }
.calendar-dot { position: absolute; bottom: 4px; left: 50%; width: 5px; height: 5px; transform: translateX(-50%); border-radius: 50%; background: var(--brass); }
.calendar-date.selected .calendar-dot { background: #fff; }
.calendar-day-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 19px 0 11px; padding-top: 14px; border-top: 1px solid var(--line); }
.calendar-day-heading h2 { margin: 3px 0 0; font: 600 21px/1.1 "Cormorant Garamond", Georgia, serif; text-transform: capitalize; }
.calendar-kicker { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.calendar-event.is-done .item-title { color: var(--muted); text-decoration: line-through; }
.calendar-event .item-deadline { color: var(--brass); }
.calendar-day-heading .button { min-height: 38px; padding: 7px 11px; font-size: 11px; }

@media (max-width: 440px) {
  .app { padding: 24px 15px 38px; }
  .header { margin-bottom: 20px; }
  .header h1 { font-size: 32px; }
  .sections { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .section-button { min-height: 43px; padding: 8px 6px; font-size: 12px; letter-spacing: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
