:root {
  --bg: #f8f7f2;
  --panel: #ffffff;
  --muted: #6b7280;
  --text: #1f2937;
  --today: #f9a8d4;
  --tomorrow: #bae6fd;
  --done: #fef08a;
  --line: #e4e9f2;
  --margin: rgba(15, 23, 42, 0.08);
  --border: #e1e5ef;
  --radius: 5px;
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    linear-gradient(90deg, var(--margin) 72px, transparent 72px),
    repeating-linear-gradient(0deg, var(--line), var(--line) 1px, transparent 1px, transparent 28px),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 940px;
  margin: 0 auto;
  padding: 16px clamp(12px, 4vw, 32px) 120px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 5;
  position: relative;
}

.logo { display: flex; align-items: center; gap: 14px; }
.logo-mark {
  width: 46px; height: 46px; border-radius: var(--radius);
  background: var(--panel);
  border: 2px solid #0f172a;
  display: grid; place-items: center;
  font-weight: 800;
  cursor: pointer;
  overflow: hidden;
}
.logo-text { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.logo-title { font-weight: 800; letter-spacing: 0.6px; }

.logo-mark.has-photo {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: transparent;
}

.ghost-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: border 0.2s, transform 0.15s;
}

.logout-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: #3b82f6;
  border: none;
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}
.ghost-btn:hover { border-color: #94a3b8; }
.ghost-btn:active { transform: scale(0.98); }

.notebook {
  position: relative;
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.rings {
  position: absolute;
  left: -36px;
  top: 0; bottom: 0;
  width: 24px;
  background:
    radial-gradient(circle at 12px 22px, #cbd5e1 0, #cbd5e1 6px, transparent 6px),
    radial-gradient(circle at 12px 72px, #cbd5e1 0, #cbd5e1 6px, transparent 6px),
    radial-gradient(circle at 12px 122px, #cbd5e1 0, #cbd5e1 6px, transparent 6px),
    radial-gradient(circle at 12px 172px, #cbd5e1 0, #cbd5e1 6px, transparent 6px),
    radial-gradient(circle at 12px 222px, #cbd5e1 0, #cbd5e1 6px, transparent 6px),
    radial-gradient(circle at 12px 272px, #cbd5e1 0, #cbd5e1 6px, transparent 6px),
    radial-gradient(circle at 12px 322px, #cbd5e1 0, #cbd5e1 6px, transparent 6px),
    radial-gradient(circle at 12px 372px, #cbd5e1 0, #cbd5e1 6px, transparent 6px);
  background-repeat: repeat-y;
}

.page {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 18px;
  min-height: 50vh;
  height: auto;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.06);
}
.page.today { border-color: var(--today); }
.page.tomorrow { border-color: var(--tomorrow); }
.page.done { border-color: var(--done); }
.page::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, var(--margin) 56px, transparent 56px),
    repeating-linear-gradient(0deg, #e9edf4, #e9edf4 1px, transparent 1px, transparent 28px);
  opacity: 0.65;
  pointer-events: none;
}
.page.today::after { background: linear-gradient(90deg, rgba(249, 168, 212, 0.5) 56px, transparent 56px), repeating-linear-gradient(0deg, #e9edf4, #e9edf4 1px, transparent 1px, transparent 28px); }
.page.tomorrow::after { background: linear-gradient(90deg, rgba(186, 230, 253, 0.5) 56px, transparent 56px), repeating-linear-gradient(0deg, #e9edf4, #e9edf4 1px, transparent 1px, transparent 28px); }
.page.done::after { background: linear-gradient(90deg, rgba(254, 240, 138, 0.5) 56px, transparent 56px), repeating-linear-gradient(0deg, #e9edf4, #e9edf4 1px, transparent 1px, transparent 28px); }

.page-head { position: relative; z-index: 1; margin-bottom: 12px; }
.page-head h2 {
  margin: 0 0 0 12px;
  font-size: 22px;
  letter-spacing: 1px;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
  display: inline-block;
}
.page.today .page-head h2 { background: var(--today); color: #0f172a; }
.page.tomorrow .page-head h2 { background: var(--tomorrow); color: #0f172a; }
.page.done .page-head h2 { background: var(--done); color: #0f172a; }

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 1;
  overflow-y: auto;
  flex: 1;
  padding: 12px 10px 24px;
  background: transparent;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    black 24px,
    black calc(100% - 24px),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    black 24px,
    black calc(100% - 24px),
    transparent 100%
  );
  scrollbar-width: none;
}
.list::-webkit-scrollbar { display: none; }

.list::before,
.list::after {
  content: '';
  position: sticky;
  left: 0;
  right: 0;
  height: 40px;
  pointer-events: none;
  z-index: 2;
  display: block;
}

.list::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0));
  opacity: 0;
  transition: opacity 0.15s;
}

.list::after {
  bottom: -1px;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0));
  opacity: 0;
  transition: opacity 0.15s;
}

.list.fade-top::before { opacity: 1; }
.list.fade-bottom::after { opacity: 1; }

.item-card {
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #cbd5e1;
  border-radius: var(--radius);
  padding: 12px 14px;
  position: relative;
  touch-action: pan-y;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}
.item-card.deleting { opacity: 0.4; }

.item-main { display: flex; gap: 12px; align-items: flex-start; font-size: 17px; }
.item-main > *:last-child { align-self: center; }
.item-text { margin: 0; font-weight: 600; line-height: 1.4; }
.item-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.item-time {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid #cbd5e1;
  background: #e8f0ff;
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
}
.item-note { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.item-meta { display: flex; gap: 8px; align-items: center; margin-top: 8px; color: var(--muted); font-size: 12px; }
.item-card.archived { opacity: 0.55; }
.check {
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  margin-top: 2px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.check-icon { font-size: 22px; color: #9ad4a5; }
.item-card.done { opacity: 0.7; }
.item-card.done .check-icon { color: #0f172a; }
.item-card.done .item-text { text-decoration: line-through; }


.delete-btn {
  margin-left: auto;
  padding: 0;
  border: none;
  background: transparent;
  color: #d94c4c;
}
.delete-btn .fa-solid { margin: 0; }
.delete-btn .fa-regular {
  font-size: 20px;
  color: inherit;
}

.cta {
  border: none; cursor: pointer;
  background: #0f172a; color: #ffffff;
  padding: 14px 18px; font-weight: 700; border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s, box-shadow 0.2s;
}
.cta .fa-solid { margin-right: 8px; }
.fa-solid {
  font-size: 14px;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(0, 0, 0, 0.12); }
.cta:active { transform: translateY(1px); }
.cta.full { width: 100%; }

#add-item {
  position: fixed;
  bottom: 16px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: calc(100% - 32px);
  max-width: 900px;
  z-index: 22;
  padding-inline: 22px;
  box-shadow: none;
  border: 2px solid #9ad4a5;
  background: #c8f2d0;
  color: #0f172a;
  border-radius: var(--radius);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
  z-index: 25;
}
.sheet {
  position: fixed; inset: auto 0 0;
  background: var(--panel);
  border-top-left-radius: var(--radius); border-top-right-radius: var(--radius);
  border: 1px solid var(--border);
  transform: translateY(100%);
  transition: transform 0.25s;
  box-shadow: 0 -20px 40px rgba(0, 0, 0, 0.18);
  z-index: 30;
}
.sheet.open { transform: translateY(0); }
.sheet-backdrop.open { opacity: 1; pointer-events: all; }
.sheet-content { padding: 20px; display: grid; gap: 14px; }
body.sheet-open #add-item { display: none; }

.delete-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 45;
}
.delete-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 46;
}
.delete-content {
  background: #ffe4e6;
  border: 1px solid #e6b9c0;
  border-radius: var(--radius);
  padding: 16px;
  min-width: 280px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.2);
  transform: translateY(-10px);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.delete-content p {
  margin: 15px;
  font-weight: 700;
  text-align: center;
  color: #0f172a;
}
.delete-note {
  margin-top: 14px;
  display: block;
  text-align: center;
  font-size: 12px;
  color: #b77676;
}
.delete-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.delete-actions .ghost-btn,
.delete-actions .cta {
  width: 100%;
  justify-content: center;
  border-radius: var(--radius);
}
.delete-actions .ghost-btn {
  background: #c8f2d0;
  border: 2px solid #9ad4a5;
  color: #0f172a;
}
.delete-actions .cta {
  background: #d94c4c;
  border: 2px solid #b13a3a;
  color: #ffffff;
  box-shadow: none;
}
.delete-actions .cta .fa-solid,
.delete-actions .ghost-btn .fa-solid {
  margin-right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}
.delete-actions .ghost-btn .fa-solid { background: #9ad4a5; }
.delete-actions .cta .fa-solid { background: #b13a3a; }
.delete-open .delete-backdrop {
  opacity: 1;
  pointer-events: all;
}
.delete-open .delete-modal {
  pointer-events: all;
}
.delete-open .delete-content {
  opacity: 1;
  transform: translateY(0);
}
.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 35;
}

.settings {
  position: fixed;
  inset: 0 0 auto 0;
  top: 0;
  transform: translateY(-100%);
  background: var(--panel);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
  transition: transform 0.25s;
  z-index: 40;
}
.settings.open { transform: translateY(0); }
.settings-backdrop.open { opacity: 1; pointer-events: all; }
.settings-content { padding: 20px; display: grid; gap: 14px; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.settings-status {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.settings-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.field { display: grid; gap: 8px; }
.field span { color: var(--muted); font-size: 14px; }
input, textarea, select {
  width: 100%; background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border); padding: 12px;
  color: var(--text); border-radius: var(--radius); font-family: inherit;
}
textarea { resize: vertical; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.segmented {
  display: grid; grid-template-columns: 1fr 1fr;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.segmented label { position: relative; overflow: hidden; border-radius: var(--radius); }
.segmented input { display: none; }
.segmented span { display: block; padding: 10px 12px; text-align: center; cursor: pointer; user-select: none; }
.segmented input:checked + span { background: rgba(37, 99, 255, 0.12); color: var(--text); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.toggle input {
  display: none;
}
.toggle-ui {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #e2e8f0;
  position: relative;
  transition: background 0.2s;
  border: 1px solid var(--border);
}
.toggle-ui::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-ui {
  background: #38bdf8;
}
.toggle input:checked + .toggle-ui::after {
  transform: translateX(20px);
}

.login {
  position: fixed; inset: 0;
  background: rgba(248, 247, 242, 0.92);
  display: grid; place-items: center;
  z-index: 40;
  transition: opacity 0.2s, visibility 0.2s;
}
.login.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
}
.google-btn {
  margin-top: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.google-btn .fa-brands { color: #ea4335; }
.login-card h2 { margin: 0 0 8px; }
.login-card p { margin: 0 0 16px; color: var(--muted); }
.login-hint { font-size: 12px; margin-top: 12px; }

.toast {
  position: fixed; bottom: 16px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 12px 16px; border-radius: var(--radius);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.14);
  opacity: 0; transition: opacity 0.2s, transform 0.2s;
  color: var(--text);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.tabs {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  width: min(900px, calc(100% - 32px));
  display: flex;
  gap: 8px;
  padding: 0 2px;
  z-index: 21;
}
.tab {
  flex: 1;
  border: 2px solid #cbd5e1;
  cursor: pointer;
  color: #0f172a;
  padding: 10px 10px;
  border-radius: var(--radius);
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tab[data-tab="today"] { background: var(--today); border-color: #e58abb; }
.tab[data-tab="today"] .tab-count { background: #ffffff; border: 1px solid #e58abb; color: #e58abb; }
.tab[data-tab="tomorrow"] { background: var(--tomorrow); border-color: #8fb7d8; }
.tab[data-tab="tomorrow"] .tab-count { background: #ffffff; border: 1px solid #8fb7d8; color: #8fb7d8; }
.tab[data-tab="done"] { background: var(--done); border-color: #e0c75c; }
.tab[data-tab="done"] .tab-count { background: #ffffff; border: 1px solid #e0c75c; color: #e0c75c; }
.tab-count {
  display: inline-block;
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  min-width: 32px;
  color: #0f172a;
  border: 1px solid transparent;
}
.tab-label {
  font-size: 14px;
}

@media (max-width: 640px) {
  .hero { flex-direction: column; align-items: flex-start; gap: 12px; }
  #add-item { left: 16px; right: 16px; width: auto; }
  .notebook { grid-template-columns: 1fr; }
  .tabs { flex-direction: row; justify-content: flex-start; }
  .tab {
    writing-mode: horizontal-tb;
    transform: none;
    min-height: unset;
    border-radius: var(--radius);
    padding: 10px 14px;
  }
  .tab.active { transform: none; }
}
