:root {
  color-scheme: light;
  --bg: #477c80;
  --bg-deep: #3d7075;
  --card: #56888a;
  --card-edge: rgba(236, 243, 222, 0.16);
  --ink: #fff4dc;
  --muted: #d3e3d7;
  --muted-2: #b9d0c8;
  --gold: #efc56f;
  --gold-ink: #395c59;
  --danger: #f2a18b;
  --shadow: 0 9px 24px rgba(23, 57, 59, 0.16);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 12% 0%, rgba(125, 177, 158, 0.32), transparent 42%),
    linear-gradient(155deg, #52878a 0%, var(--bg) 48%, var(--bg-deep) 100%);
  background-attachment: fixed;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 28px) 22px calc(env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
}
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon {
  width: 48px; height: 48px; flex: 0 0 48px;
  display: grid; place-items: center;
  color: var(--gold);
  background: rgba(28, 78, 81, 0.30);
  border: 1px solid rgba(243, 226, 184, 0.20);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.brand-icon svg { width: 29px; height: 29px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: 1.35px; }
h1 { margin: 0; font-size: clamp(28px, 7vw, 34px); line-height: 1.05; letter-spacing: -1.1px; font-weight: 760; }
.task-count {
  flex: 0 0 auto;
  padding: 8px 11px;
  color: var(--ink);
  background: rgba(35, 91, 93, 0.38);
  border: 1px solid rgba(238, 244, 222, 0.16);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}
.intro { margin: 19px 0 24px 1px; color: var(--muted); font-size: 14px; letter-spacing: 0.1px; }
.task-section { flex: 1 0 auto; }
.task-list { display: grid; gap: 10px; }
.task-card {
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  background: linear-gradient(135deg, rgba(93, 148, 145, 0.97), rgba(73, 128, 131, 0.98));
  border: 1px solid var(--card-edge);
  border-radius: 19px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.07);
  animation: rise-in 220ms ease both;
}
.task-mark {
  width: 44px; height: 44px; flex: 0 0 44px;
  display: grid; place-items: center;
  border-radius: 15px;
  color: #fff4dc;
  background: rgba(34, 91, 91, 0.35);
  border: 1px solid rgba(242, 239, 207, 0.16);
  font-size: 22px;
}
.task-main {
  min-width: 0; flex: 1;
  padding: 2px 0;
  color: inherit;
  text-align: left;
  background: transparent; border: 0;
  cursor: pointer;
}
.task-title { display: block; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.25; font-weight: 680; letter-spacing: -0.18px; }
.task-time { display: block; margin-top: 5px; color: #d9e8d9; font-size: 12.5px; font-weight: 560; }
.task-date { display: block; margin-top: 2px; color: var(--muted-2); font-size: 10.5px; }
.done-button {
  min-width: 57px; height: 38px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 0 9px;
  color: var(--gold-ink);
  background: var(--gold);
  border: 0; border-radius: 13px;
  font-size: 11.5px; font-weight: 780;
  box-shadow: 0 3px 8px rgba(33, 66, 61, 0.14);
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}
.done-button:active, .add-button:active, .primary-button:active { transform: scale(0.97); filter: brightness(0.97); }
.done-button svg { width: 13px; height: 13px; }
.empty-state {
  min-height: 330px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 26px 22px 36px;
  text-align: center;
}
.empty-illustration {
  width: 88px; height: 88px; margin-bottom: 18px;
  display: grid; place-items: center;
  color: var(--gold);
  background: rgba(35, 91, 93, 0.33);
  border: 1px solid rgba(239, 222, 178, 0.2);
  border-radius: 28px;
}
.empty-illustration svg { width: 59px; height: 59px; }
.empty-state h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: -0.4px; }
.empty-state p { max-width: 270px; margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.add-button {
  width: 100%; min-height: 57px; margin-top: 24px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--gold-ink); background: var(--gold);
  border: 0; border-radius: 18px;
  box-shadow: 0 9px 20px rgba(33, 66, 61, 0.18), inset 0 1px 0 rgba(255,255,255,0.28);
  font-size: 16px; font-weight: 760; letter-spacing: -0.1px;
  cursor: pointer; transition: transform 120ms ease, filter 120ms ease;
}
.add-plus { font-size: 25px; line-height: 0.8; font-weight: 400; }
.privacy-note { margin: 15px 0 0; color: rgba(230, 240, 222, 0.72); text-align: center; font-size: 10.5px; letter-spacing: 0.2px; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 18px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: rgba(22, 48, 50, 0.52);
  -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px);
}
.modal-backdrop[hidden] { display: none; }
.modal-sheet {
  width: min(100%, 520px); max-height: min(88vh, 720px); overflow-y: auto;
  padding: 10px 21px 23px;
  color: var(--ink);
  background: linear-gradient(150deg, #548487, #3e7074);
  border: 1px solid rgba(241, 238, 209, 0.20);
  border-radius: 27px;
  box-shadow: 0 18px 50px rgba(16, 40, 42, 0.34);
  animation: sheet-in 180ms ease both;
}
.sheet-handle { width: 39px; height: 4px; margin: 0 auto 20px; background: rgba(242, 244, 218, 0.42); border-radius: 99px; }
.modal-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 23px; }
.modal-heading h2 { margin: 0; font-size: 24px; line-height: 1.15; letter-spacing: -0.6px; }
.icon-button {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center;
  color: var(--ink); background: rgba(26, 72, 75, 0.34);
  border: 1px solid rgba(238, 244, 222, 0.14); border-radius: 50%;
  font-size: 24px; line-height: 1; cursor: pointer;
}
.field-label { display: block; margin: 0 0 8px 2px; color: var(--muted); font-size: 12px; font-weight: 650; }
#task-name, #rename-name {
  width: 100%; min-height: 52px; padding: 0 15px;
  color: var(--ink); background: rgba(29, 74, 76, 0.42);
  border: 1px solid rgba(233, 239, 213, 0.22); border-radius: 14px;
  outline: none; font-size: 16px;
}
#task-name::placeholder, #rename-name::placeholder { color: rgba(221, 235, 218, 0.56); }
#task-name:focus, #rename-name:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(239, 197, 111, 0.13); }
.field-hint { margin: 9px 2px 20px; color: var(--muted); font-size: 11.5px; }
.primary-button, .secondary-button, .delete-button {
  min-height: 48px; padding: 0 16px; border: 0; border-radius: 14px;
  font-size: 14px; font-weight: 730; cursor: pointer;
}
.primary-button { width: 100%; color: var(--gold-ink); background: var(--gold); }
.last-done-panel {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 14px 18px; margin-bottom: 23px;
  background: rgba(29, 74, 76, 0.34);
  border: 1px solid rgba(233, 239, 213, 0.16); border-radius: 18px;
}
.panel-label { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 1.35px; }
.last-done-panel strong { margin-top: 8px; color: var(--gold); font-size: 29px; letter-spacing: -0.7px; }
.panel-date { margin-top: 5px; color: var(--muted); font-size: 12px; }
.history-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.history-heading h3 { margin: 0; font-size: 14px; }
.history-heading span { color: var(--muted); font-size: 11px; }
.history-list { display: grid; gap: 7px; max-height: 190px; overflow-y: auto; }
.history-item { display: flex; justify-content: space-between; gap: 12px; padding: 11px 12px; color: var(--ink); background: rgba(31, 76, 78, 0.28); border-radius: 11px; font-size: 12px; }
.history-item span:last-child { color: var(--muted); white-space: nowrap; }
.no-history { padding: 12px; color: var(--muted); font-size: 12px; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 19px; }
.secondary-button { color: var(--ink); background: rgba(27, 70, 73, 0.42); border: 1px solid rgba(239, 240, 215, 0.15); }
.delete-button { color: #ffe1d5; background: rgba(148, 72, 61, 0.42); border: 1px solid rgba(255, 194, 171, 0.16); }
.toast {
  position: fixed; z-index: 20; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 22px);
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 40px); padding: 11px 16px;
  color: #fff4dc; background: #285c60; border: 1px solid rgba(255,255,255,0.16); border-radius: 99px;
  box-shadow: 0 8px 22px rgba(20, 45, 46, 0.3); font-size: 12px; font-weight: 650;
  transition: opacity 170ms ease, transform 170ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes rise-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@media (min-width: 600px) {
  .app-shell { padding-top: 42px; padding-bottom: 32px; }
  .modal-backdrop { align-items: center; }
  .modal-sheet { border-radius: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
