:root {
  --paper: #ffffff;
  --ink: #151310;
  --muted: #77736e;
  --rule: #dedbd7;
  --rule-dark: #aaa6a0;
  --accent: #b7352b;
  --accent-dark: #922820;
  --danger: #9e2f27;
  --font-display: "STSong", "SimSun", "Noto Serif CJK SC", serif;
  --font-ui: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: #ecebea;
  color: var(--ink);
  font-family: var(--font-ui);
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
  border-inline: 1px solid var(--rule);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 48px 30px;
}

.login-inner {
  width: 100%;
}

.wordmark {
  font: 500 clamp(46px, 14vw, 64px)/1.08 var(--font-display);
  letter-spacing: .04em;
  text-align: center;
}

.login-lead,
.privacy-note {
  margin: 22px 0 0;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.login-form {
  margin-top: 50px;
}

.login-form label,
.task-dialog form > label {
  display: block;
  margin-top: 23px;
  font-weight: 500;
}

.login-form label span,
.task-dialog label > span,
.task-dialog legend {
  display: block;
  margin-bottom: 10px;
  font-size: 16px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--rule-dark);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 15px 16px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgb(183 53 43 / 12%);
}

.button {
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 12px 20px;
  cursor: pointer;
  font-size: 17px;
  font-weight: 500;
}

.button:focus-visible,
.icon-button:focus-visible,
.bottom-nav button:focus-visible,
.task-row:focus-visible {
  outline: 3px solid rgb(183 53 43 / 25%);
  outline-offset: 2px;
}

.button-primary {
  background: var(--accent);
  color: #fff;
}

.button-primary:hover {
  background: var(--accent-dark);
}

.button-outline {
  border-color: var(--accent);
  background: var(--paper);
  color: var(--accent);
}

.button-secondary {
  border-color: var(--ink);
  background: var(--paper);
}

.button-danger {
  border-color: var(--danger);
  background: var(--paper);
  color: var(--danger);
}

.button-block {
  width: 100%;
}

.login-form .button {
  margin-top: 26px;
}

.privacy-note {
  margin-top: 34px;
}

.form-error {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 14px;
}

.app-screen {
  min-height: 100vh;
  padding: max(24px, env(safe-area-inset-top)) 28px calc(92px + env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header h1 {
  margin: 0;
  font: 500 38px/1.2 var(--font-display);
  letter-spacing: .03em;
}

.sync-state {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 15px;
}

.sync-state svg,
.bottom-nav svg,
.icon-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.date-block {
  margin: 57px 0 34px;
}

.date-block h2 {
  margin: 0;
  font: 500 clamp(36px, 11vw, 52px)/1.2 var(--font-display);
  letter-spacing: .02em;
}

.add-button {
  height: 60px;
  font-size: 19px;
}

.add-button span {
  margin-right: 8px;
  font-size: 28px;
  font-weight: 300;
  vertical-align: -2px;
}

.task-groups {
  padding-bottom: 25px;
}

.task-group {
  margin-top: 50px;
}

.task-group h3 {
  margin: 0 0 13px;
  font: 500 28px/1.2 var(--font-display);
}

.task-list {
  border-top: 1px solid var(--rule);
}

.task-row {
  width: 100%;
  min-height: 78px;
  display: grid;
  grid-template-columns: 36px 1fr 22px;
  align-items: center;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  padding: 12px 0;
  text-align: left;
  cursor: pointer;
}

.task-check {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border: 1.8px solid var(--ink);
  border-radius: 3px;
  background: var(--paper);
}

.task-row.is-done .task-check {
  background: var(--ink);
  color: var(--paper);
}

.task-check svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

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

.task-title {
  display: block;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-row.is-done .task-title {
  color: var(--muted);
  text-decoration: line-through;
}

.task-time {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 14px;
}

.task-chevron {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.7;
}

.empty-state {
  margin: 48px 0;
  color: var(--muted);
  line-height: 1.8;
  text-align: center;
}

.bottom-nav {
  position: fixed;
  z-index: 2;
  bottom: 0;
  left: 50%;
  width: min(100%, 518px);
  min-height: calc(76px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: center;
  transform: translateX(-50%);
  border-top: 1px solid var(--rule);
  background: rgb(255 255 255 / 96%);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav button {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 17px;
}

.nav-divider {
  width: 1px;
  height: 38px;
  background: var(--rule);
}

.sub-header {
  height: 64px;
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  border-bottom: 1px solid var(--rule);
  margin: -8px -28px 0;
  padding: 0 20px;
}

.sub-header h1 {
  margin: 0;
  font: 500 26px/1.2 var(--font-display);
  text-align: center;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.device-content {
  padding-top: 35px;
}

.pair-code-panel {
  padding: 33px 0 28px;
  text-align: center;
}

.pair-code-panel output {
  display: block;
  font: 500 50px/1.2 var(--font-display);
  letter-spacing: .16em;
}

.pair-code-panel p,
.device-help {
  margin: 13px 0 0;
  color: var(--muted);
}

.device-list {
  margin-top: 26px;
  border-top: 1px solid var(--rule);
}

.device-item {
  min-height: 83px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--rule);
}

.device-item strong,
.device-item small {
  display: block;
}

.device-item strong {
  font-size: 18px;
}

.device-item small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.device-item button {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  padding: 12px 0 12px 12px;
}

.device-help {
  margin-top: 25px;
  line-height: 1.7;
}

.task-dialog {
  width: min(calc(100% - 24px), 500px);
  max-height: calc(100vh - 24px);
  border: 0;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  padding: 0;
}

.task-dialog::backdrop {
  background: rgb(21 19 16 / 38%);
}

.task-dialog form {
  padding: 25px 24px 24px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-header h2 {
  margin: 0;
  font: 500 29px/1.2 var(--font-display);
}

.task-dialog textarea {
  min-height: 112px;
  resize: vertical;
}

.task-dialog fieldset {
  margin: 23px 0 0;
  border: 1px solid var(--rule-dark);
  border-radius: var(--radius);
  padding: 0;
}

.task-dialog legend {
  width: 100%;
  margin: 0 0 8px;
  border: 0;
  font-weight: 500;
  transform: translateY(-31px);
}

.radio-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--rule);
  padding: 0 15px;
}

.radio-row:first-of-type {
  border-top: 0;
}

.radio-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.radio-row span {
  margin: 0;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
}

.action-spacer {
  flex: 1;
}

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 96px;
  max-width: calc(100% - 40px);
  transform: translate(-50%, 18px);
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  padding: 11px 17px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (min-width: 700px) {
  .shell {
    min-height: calc(100vh - 40px);
    margin-block: 20px;
    box-shadow: 0 8px 32px rgb(21 19 16 / 8%);
  }

  .login-screen,
  .app-screen {
    min-height: calc(100vh - 40px);
  }
}

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