:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --text: #17201c;
  --muted: #6f7b75;
  --line: #dfe5e1;
  --green: #176b4d;
  --green-soft: #e7f3ed;
  --red: #b43d35;
  --red-soft: #fbecea;
  --amber: #9a6219;
  --amber-soft: #fff2db;
  --blue: #32658d;
  --blue-soft: #eaf2f8;
  --shadow: 0 8px 22px rgba(25, 45, 36, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(40, 139, 96, 0.1), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

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

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px
    calc(32px + env(safe-area-inset-bottom));
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 15px;
  background: var(--green);
  box-shadow: 0 7px 18px rgba(23, 107, 77, 0.22);
}

.brand-mark svg {
  width: 29px;
  fill: none;
  stroke: white;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

#syncText {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--green);
}

.icon-button:active {
  transform: scale(0.96);
}

.icon-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.loading svg {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 15px;
}

.summary-card {
  display: flex;
  min-height: 88px;
  flex-direction: column;
  justify-content: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.summary-card.urgent {
  background: var(--amber-soft);
  border-color: #f1d8ad;
}

.summary-card.done {
  background: var(--green-soft);
  border-color: #cce4d8;
}

.summary-value {
  font-size: 27px;
  font-weight: 750;
  letter-spacing: -0.04em;
}

.summary-label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.9);
}

.search-box svg {
  width: 19px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-box input::placeholder {
  color: #9aa49f;
}

.filter-tabs {
  display: flex;
  gap: 6px;
  margin: 14px 0 13px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  flex: 0 0 auto;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.filter-tab.active {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.task-group-heading + .task-card {
  margin-top: -2px;
}

.task-card {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 11px;
  overflow: hidden;
  padding: 15px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.task-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #81918a;
  content: "";
}

.task-card.p0::before {
  background: var(--red);
}

.task-card.p1::before {
  background: var(--amber);
}

.task-card.p2::before {
  background: var(--blue);
}

.task-card.completed {
  opacity: 0.68;
}

.task-card.completed h2 {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.task-check {
  display: grid;
  width: 27px;
  height: 27px;
  margin-top: 2px;
  place-items: center;
  border: 2px solid #9bab9f;
  border-radius: 50%;
  background: transparent;
  color: white;
}

.task-check svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.task-card.completed .task-check {
  border-color: var(--green);
  background: var(--green);
}

.task-card.completed .task-check svg {
  opacity: 1;
}

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

.task-meta-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}

.priority,
.due-pill,
.category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.priority {
  background: #eef1ef;
  color: #52605a;
}

.p0 .priority,
.due-pill.today,
.due-pill.overdue {
  background: var(--red-soft);
  color: var(--red);
}

.p1 .priority {
  background: var(--amber-soft);
  color: var(--amber);
}

.p2 .priority {
  background: var(--blue-soft);
  color: var(--blue);
}

.category-pill {
  background: var(--green-soft);
  color: var(--green);
}

.task-card h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.task-source {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.task-source span {
  overflow-wrap: anywhere;
}

.task-details {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.task-details summary {
  width: max-content;
  cursor: pointer;
  color: var(--green);
  font-weight: 600;
}

.task-details p {
  margin: 7px 0 0;
  line-height: 1.5;
}

.loading-card,
.empty-card {
  padding: 38px 18px;
  border: 1px dashed #cdd8d2;
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.auth-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 20% 10%, rgba(40, 139, 96, 0.18), transparent 22rem),
    rgba(244, 246, 243, 0.96);
  backdrop-filter: blur(18px);
}

.auth-panel[hidden] {
  display: none;
}

.auth-card {
  width: min(100%, 360px);
  padding: 26px 22px 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(25, 45, 36, 0.16);
}

.auth-mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 16px;
  background: var(--green-soft);
  color: var(--green);
}

.auth-mark svg {
  width: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-card h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.auth-card > p {
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.auth-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.auth-card input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: #f8faf8;
  color: var(--text);
  font-size: 16px;
}

.auth-card input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 107, 77, 0.12);
}

.auth-card .auth-error {
  min-height: 18px;
  margin: 8px 0 5px;
  color: var(--red);
}

.auth-submit {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  background: var(--green);
  color: white;
  font-weight: 700;
}

.auth-submit:active {
  transform: scale(0.985);
}

body.auth-open {
  overflow: hidden;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 16px;
  z-index: 10;
  max-width: 560px;
  margin: auto;
  padding: 12px 15px;
  border-radius: 14px;
  background: #18231e;
  color: white;
  font-size: 13px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 620px) {
  .app-shell {
    padding-inline: 24px;
  }

  .summary-card {
    min-height: 104px;
  }
}
