:root {
  --ink: #0f1c24;
  --ink-soft: #243741;
  --mist: #e8f0ec;
  --paper: rgba(255, 252, 247, 0.88);
  --sage: #1f6b5a;
  --sage-soft: #c5ddd4;
  --amber: #d4a017;
  --coral: #c45c3e;
  --line: rgba(15, 28, 36, 0.12);
  --shadow: 0 18px 50px rgba(15, 28, 36, 0.12);
  --radius: 18px;
  --font-display: "Fraunces", "Songti TC", serif;
  --font-body: "Figtree", "PingFang TC", "Noto Sans TC", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--mist);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
}

.bg-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 10% -10%, #f7efe0 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #cfe3da 0%, transparent 50%),
    linear-gradient(165deg, #eef5f1 0%, #e2ebe6 45%, #d7e4df 100%);
}

.bg-atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

[hidden] {
  display: none !important;
}

.brand,
.brand-mini {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--sage);
}

.brand {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.brand-mini {
  font-size: 0.72rem;
  margin-bottom: 0.2rem;
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.lede,
.hint {
  color: var(--ink-soft);
  line-height: 1.55;
}

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  animation: rise 0.55s ease both;
}

.gate-panel {
  width: min(420px, 100%);
  padding: 2rem 1.5rem 1.75rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.gate h1 {
  font-size: clamp(1.8rem, 6vw, 2.35rem);
  line-height: 1.15;
  margin-bottom: 0.65rem;
}

.pin-form {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.55rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

input,
textarea,
select {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  background: #fffefb;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(31, 107, 90, 0.35);
  border-color: var(--sage);
}

.btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.25rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--ink);
  color: #f6faf8;
}

.btn.primary:hover {
  background: var(--ink-soft);
}

.btn.google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  margin-top: 1.35rem;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(15, 28, 36, 0.06);
}

.btn.google::before {
  content: "";
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23EA4335' d='M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z'/%3E%3Cpath fill='%234285F4' d='M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z'/%3E%3Cpath fill='%23FBBC05' d='M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z'/%3E%3Cpath fill='%2334A853' d='M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.btn.google:hover {
  background: #f7faf8;
}

.btn.block {
  width: 100%;
}

.pin-details {
  margin-top: 1.1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
}

.pin-details summary {
  cursor: pointer;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
}

.btn.ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  font-weight: 600;
  font-size: 0.85rem;
}

.btn.done {
  background: var(--sage);
  color: #fff;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font-weight: 700;
  font-size: 0.85rem;
  border: 0;
  cursor: pointer;
}

.error {
  color: var(--coral);
  margin: 0;
  font-size: 0.9rem;
}

.app {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: calc(16px + var(--safe-t)) 16px calc(96px + var(--safe-b));
  animation: rise 0.45s ease both;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.top h1 {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
}

.top-actions {
  display: flex;
  gap: 0.4rem;
}

.icon-btn,
.text-btn {
  font: inherit;
  border: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 42px;
  height: 42px;
  cursor: pointer;
}

.text-btn {
  width: auto;
  padding: 0 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.pulse {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.cal-banner,
.cal-ok {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.85rem;
  animation: fade-in 0.35s ease both;
}

.cal-banner {
  background: rgba(212, 160, 23, 0.14);
  border: 1px solid rgba(212, 160, 23, 0.35);
}

.cal-banner p {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.cal-banner .btn {
  flex-shrink: 0;
  text-decoration: none;
  white-space: nowrap;
}

.cal-ok {
  background: rgba(31, 107, 90, 0.1);
  border: 1px solid rgba(31, 107, 90, 0.22);
  color: var(--sage);
  font-weight: 600;
  font-size: 0.9rem;
}

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.75);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 600;
  animation: fade-in 0.4s ease both;
}

.chip strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.chip.overdue {
  background: rgba(196, 92, 62, 0.12);
  color: #8a3420;
  border-color: rgba(196, 92, 62, 0.25);
}

.chip.today {
  background: rgba(212, 160, 23, 0.16);
  color: #7a5a08;
  border-color: rgba(212, 160, 23, 0.3);
}

.chip.soon {
  background: rgba(31, 107, 90, 0.1);
  color: var(--sage);
  border-color: rgba(31, 107, 90, 0.22);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  padding: 0.3rem;
  background: rgba(15, 28, 36, 0.06);
  border-radius: 16px;
  margin-bottom: 1rem;
  position: sticky;
  top: calc(8px + var(--safe-t));
  z-index: 5;
  backdrop-filter: blur(8px);
}

.tab {
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 12px;
  padding: 0.7rem 0.4rem;
  cursor: pointer;
}

.tab.active {
  background: #fffefb;
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(15, 28, 36, 0.08);
}

.panel {
  display: grid;
  gap: 0.75rem;
}

.section-label {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.item {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1rem 0.85rem;
  box-shadow: 0 10px 28px rgba(15, 28, 36, 0.05);
  animation: fade-in 0.35s ease both;
}

.item.overdue {
  border-color: rgba(196, 92, 62, 0.35);
  box-shadow: 0 0 0 1px rgba(196, 92, 62, 0.08);
}

.item.today {
  border-color: rgba(212, 160, 23, 0.4);
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.item h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: 1.25;
}

.meta {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.body-text {
  margin: 0.55rem 0 0;
  white-space: pre-wrap;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.5;
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--sage-soft);
  color: var(--sage);
}

.badge.overdue {
  background: rgba(196, 92, 62, 0.15);
  color: #8a3420;
}

.badge.today {
  background: rgba(212, 160, 23, 0.2);
  color: #7a5a08;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 252, 247, 0.45);
}

.empty h3 {
  font-family: var(--font-display);
  margin: 0 0 0.4rem;
  color: var(--ink);
}

.fab {
  position: fixed;
  right: max(16px, calc(50% - 340px));
  bottom: calc(20px + var(--safe-b));
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: #f6faf8;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(15, 28, 36, 0.28);
  transition: transform 0.18s ease;
  z-index: 20;
}

.fab:active {
  transform: scale(0.94);
}

.sheet {
  width: min(480px, calc(100% - 24px));
  border: 0;
  border-radius: 24px 24px 18px 18px;
  padding: 0;
  background: #fffefb;
  box-shadow: var(--shadow);
  margin: auto auto 12px;
}

.sheet::backdrop {
  background: rgba(15, 28, 36, 0.45);
  backdrop-filter: blur(3px);
}

.sheet-body {
  display: grid;
  gap: 0.85rem;
  padding: 1.1rem 1.1rem calc(1.1rem + var(--safe-b));
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  padding: 0.25rem;
  background: rgba(15, 28, 36, 0.06);
  border-radius: 12px;
}

.seg-btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 0.65rem;
  cursor: pointer;
  color: var(--ink-soft);
}

.seg-btn.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(15, 28, 36, 0.08);
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.loop-fields .hint {
  margin: 0;
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-b));
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #f6faf8;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 40;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (min-width: 720px) {
  .fab {
    right: calc(50% - 360px + 16px);
  }
}
