:root {
  color-scheme: light;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", "STSong", "Noto Serif SC",
    "Source Han Serif SC", "SimSun", serif;
  --paper: #f4efe4;
  --surface: #fffdf8;
  --surface-2: #faf5eb;
  --surface-3: #f0e8d9;
  --ink: #211d17;
  --ink-2: #4a4135;
  --muted: #877a67;
  --line: #e1d7c5;
  --line-strong: #cbbda5;
  --accent: #b1441f;
  --accent-2: #8f3417;
  --accent-soft: #f3e0d3;
  --ok: #2f7950;
  --ok-soft: #e4f2e9;
  --danger: #aa2e25;
  --danger-soft: #f9e4e1;
  --danger-row: #fff0ee;
  --warning: #a96f19;
  --shadow: 0 20px 55px rgba(65, 46, 25, 0.1), 0 3px 10px rgba(65, 46, 25, 0.05);
  --radius: 16px;
  --sidebar: 238px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171411;
  --surface: #211d18;
  --surface-2: #1b1814;
  --surface-3: #2b251e;
  --ink: #f2eadc;
  --ink-2: #d7ccbb;
  --muted: #9f927f;
  --line: #362f26;
  --line-strong: #4c4134;
  --accent: #df7b4c;
  --accent-2: #f2986d;
  --accent-soft: #3b261b;
  --ok: #82c49a;
  --ok-soft: #183326;
  --danger: #e36b61;
  --danger-soft: #3a1f1c;
  --danger-row: #2e1b19;
  --warning: #e4aa59;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.42), 0 3px 12px rgba(0, 0, 0, 0.25);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --paper: #171411;
    --surface: #211d18;
    --surface-2: #1b1814;
    --surface-3: #2b251e;
    --ink: #f2eadc;
    --ink-2: #d7ccbb;
    --muted: #9f927f;
    --line: #362f26;
    --line-strong: #4c4134;
    --accent: #df7b4c;
    --accent-2: #f2986d;
    --accent-soft: #3b261b;
    --ok: #82c49a;
    --ok-soft: #183326;
    --danger: #e36b61;
    --danger-soft: #3a1f1c;
    --danger-row: #2e1b19;
    --warning: #e4aa59;
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.42), 0 3px 12px rgba(0, 0, 0, 0.25);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(800px 500px at 5% -10%, color-mix(in srgb, #b8873b 12%, transparent), transparent 68%),
    radial-gradient(760px 480px at 100% 0%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 64%),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.muted {
  color: var(--muted);
}

.noscript {
  padding: 40px;
  text-align: center;
}

/* auth */
.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(440px, 1fr);
}

.auth__panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 58px clamp(28px, 6vw, 82px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--accent);
  color: #fff9f2;
  font-family: var(--font-serif);
  font-size: 20px;
}

.brand__edition {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.2em;
}

.auth__inner {
  margin: auto 0;
  max-width: 390px;
}

.auth h1 {
  margin: 0 0 18px;
  font-family: var(--font-serif);
  font-size: clamp(36px, 5vw, 58px);
  font-weight: 500;
  line-height: 1.17;
  letter-spacing: -0.035em;
}

.auth__lead {
  margin: 0 0 26px;
  color: var(--muted);
}

.auth__hello {
  margin: 18px 0;
  font-size: 13px;
}

.auth__aside {
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: center;
  padding: 10vw;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--paper) 74%, var(--accent-soft)), var(--paper));
}

.auth__aside::before {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  left: 10%;
  top: 12%;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow:
    0 0 0 55px color-mix(in srgb, var(--accent) 3%, transparent),
    0 0 0 115px color-mix(in srgb, var(--accent) 2%, transparent);
}

.auth__quote {
  position: relative;
  max-width: 520px;
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(36px, 5vw, 68px);
  line-height: 1.32;
  letter-spacing: -0.04em;
}

.auth__note {
  position: relative;
  margin-top: 32px;
  color: var(--muted);
  font-size: 13px;
}

.auth__copy {
  margin: 40px 0 0;
  color: var(--muted);
  font-size: 11px;
}

/* forms and buttons */
.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.field__label {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 650;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

.form-error {
  margin: 10px 0;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fffaf4;
}

.btn--primary:hover {
  border-color: var(--accent-2);
  background: var(--accent-2);
}

.btn--danger {
  border-color: color-mix(in srgb, var(--danger) 58%, var(--line));
  color: var(--danger);
  background: var(--surface);
}

.btn--ok {
  border-color: var(--ok);
  background: var(--ok);
  color: white;
}

.btn--full {
  width: 100%;
}

.btn--sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.icon-btn:hover {
  background: var(--surface-2);
}

.icon {
  flex: none;
  display: block;
}

/* shell */
.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  background: color-mix(in srgb, var(--surface) 76%, var(--paper));
  border-right: 1px solid var(--line);
  z-index: 20;
}

.sidebar__brand {
  padding: 2px 8px 24px;
}

.sidebar__nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.is-active {
  border-color: color-mix(in srgb, var(--accent) 22%, var(--line));
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 700;
}

.nav-item__count {
  margin-left: auto;
  min-width: 24px;
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 66%, transparent);
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.sidebar__note {
  margin-top: 28px;
  padding: 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
  color: var(--muted);
  font-size: 12px;
}

.sidebar__foot {
  margin-top: auto;
  padding: 14px 8px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.content {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 14;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 70px;
  padding: 12px clamp(18px, 4vw, 42px);
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
  backdrop-filter: blur(16px);
}

.topbar__titles {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 550;
}

.topbar__sub {
  color: var(--muted);
  font-size: 11px;
}

.topbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
}

.sync-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

.sync-pill.is-error::before {
  background: var(--danger);
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 26px clamp(18px, 4vw, 42px) 60px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(26px, 3.2vw, 42px);
  font-weight: 520;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* month */
.month-layout {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.month-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.month-toolbar__title {
  margin: 0 auto;
  font-family: var(--font-serif);
  font-size: 20px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar__head {
  padding: 11px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  text-align: center;
  letter-spacing: 0.12em;
}

.calendar__day {
  position: relative;
  min-height: 112px;
  padding: 10px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.calendar__day:nth-child(7n + 7) {
  border-right: 0;
}

.calendar__day.is-outside {
  background: color-mix(in srgb, var(--surface-2) 62%, var(--surface));
  color: var(--muted);
  opacity: 0.58;
}

.calendar__day.is-disabled {
  pointer-events: none;
  background:
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 7px,
      color-mix(in srgb, var(--line) 22%, transparent) 7px,
      color-mix(in srgb, var(--line) 22%, transparent) 8px
    ),
    var(--surface-2);
  color: var(--muted);
  opacity: 0.56;
}

.calendar__day:hover:not(.is-disabled):not(.is-outside) {
  background: color-mix(in srgb, var(--accent-soft) 42%, var(--surface));
}

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

.calendar__num {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
}

.calendar__count {
  min-width: 21px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  text-align: center;
}

.calendar__preview {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.calendar__preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar__preview b {
  color: var(--accent);
  font-weight: 650;
}

/* task table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.task-table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
  table-layout: fixed;
}

.task-table th {
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: left;
}

.task-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  transition: background 0.16s ease;
}

.task-table tbody tr:last-child td {
  border-bottom: 0;
}

.task-table tbody tr.is-pending td {
  background: var(--danger-row);
}

.task-table tbody tr.is-done td {
  background: var(--surface);
}

.task-table tbody tr:hover td {
  background: color-mix(in srgb, var(--accent-soft) 28%, var(--surface));
}

.col-time {
  width: 105px;
}

.col-title {
  width: 34%;
}

.col-urgency {
  width: 95px;
}

.col-status {
  width: 190px;
}

.col-actions {
  width: 82px;
}

.time-text {
  color: var(--accent-2);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
}

.unscheduled {
  color: var(--muted);
  font-size: 11px;
}

.task-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.task-detail {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: pre-wrap;
}

.task-kind {
  display: inline-flex;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  white-space: nowrap;
}

.urgency {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  color: var(--warning);
  font-size: 11px;
  font-weight: 700;
}

.urgency--high {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-btn {
  min-height: 29px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.status-btn.is-pending {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}

.status-btn.is-done {
  border-color: var(--ok);
  background: var(--ok);
  color: white;
}

.row-actions {
  display: flex;
  gap: 4px;
}

.row-actions .icon-btn {
  width: 29px;
  height: 29px;
}

.empty {
  padding: 54px 20px;
  color: var(--muted);
  text-align: center;
}

.empty strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-2);
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 500;
}

/* modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(25, 20, 14, 0.44);
  backdrop-filter: blur(5px);
}

.modal {
  width: min(640px, 100%);
  max-height: min(88dvh, 860px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 36px 90px rgba(35, 25, 15, 0.28);
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal__head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 550;
}

.modal__body {
  padding: 20px;
}

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.modal-grid .field--wide {
  grid-column: 1 / -1;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.segmented button {
  flex: 1;
  min-height: 31px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(40, 30, 20, 0.1);
}

/* toast */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  font-size: 12px;
  pointer-events: auto;
}

.toast.is-error {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
  color: var(--danger);
}

@media (max-width: 900px) {
  .auth {
    grid-template-columns: 1fr;
  }

  .auth__aside {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 290px);
    transform: translateX(-102%);
    transition: transform 0.2s ease;
  }

  .app-shell.is-nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 20px 0 60px rgba(20, 15, 10, 0.28);
  }

  .mobile-menu {
    display: inline-grid;
  }

  .content {
    min-height: 100dvh;
  }

  .topbar {
    padding: 10px 14px;
  }

  .sync-pill span {
    display: none;
  }

  .calendar {
    min-width: 720px;
  }

  .month-layout {
    overflow-x: auto;
  }

  .page {
    padding: 18px 14px 40px;
  }
}

@media (min-width: 901px) {
  .mobile-menu {
    display: none;
  }
}

@media (max-width: 620px) {
  .auth__panel {
    padding: 28px 22px;
  }

  .auth h1 {
    font-size: 38px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-head h2 {
    font-size: 30px;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }
}
