/* Apple-style calendar + todos */
:root {
  --bg: #f5f5f7;
  --surface: rgba(255,255,255,.78);
  --surface-solid: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --hairline: rgba(0,0,0,.08);
  --accent: #0071e3;
  --accent-soft: rgba(0,113,227,.1);
  --today-ring: #ff3b30;
  --shadow: 0 8px 30px rgba(0,0,0,.06);
  --c-blue: #0a84ff; --c-red: #ff453a; --c-green: #30d158;
  --c-orange: #ff9f0a; --c-purple: #bf5af2; --c-teal: #64d2ff;
  --c-gray: #98989d;
}
html[data-theme="dark"] {
  --bg: #000000;
  --surface: rgba(28,28,30,.78);
  --surface-solid: #1c1c1e;
  --text: #f5f5f7;
  --text-2: #98989d;
  --hairline: rgba(255,255,255,.12);
  --accent: #0a84ff;
  --accent-soft: rgba(10,132,255,.18);
  --shadow: 0 8px 30px rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background .35s ease, color .35s ease;
  display: flex; flex-direction: column;
  letter-spacing: -0.01em;
}

/* Top bar — frosted glass */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 22px; }
.topbar h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.btn {
  font: inherit; font-size: 14px; font-weight: 500;
  border: none; border-radius: 980px;
  padding: 7px 16px; cursor: pointer;
  background: transparent; color: var(--text);
  transition: background .2s, transform .1s, color .2s;
}
.btn:active { transform: scale(.96); }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.ghost:hover { background: var(--accent); color: #fff; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: rgba(255,69,58,.12); color: var(--c-red); }
.btn.danger:hover { background: var(--c-red); color: #fff; }
.btn.small { padding: 3px 12px; font-size: 16px; line-height: 1.2; }
.theme-toggle { font-size: 16px; }

/* Layout */
.layout { flex: 1; display: flex; min-height: 0; gap: 18px; padding: 18px 22px; }

/* Sidebar */
.sidebar {
  width: 320px; flex-shrink: 0; overflow-y: auto;
  background: var(--surface-solid);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sidebar-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.todo-group { margin-bottom: 18px; animation: rise .4s ease both; }
.todo-group h3 {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-2); margin-bottom: 8px;
}
.todo {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 6px; border-radius: 10px; cursor: pointer;
  transition: background .15s;
}
.todo:hover { background: var(--accent-soft); }
.todo-check {
  flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px;
  border: 1.5px solid var(--text-2); border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; color: transparent; background: transparent;
  cursor: pointer; transition: all .2s;
}
.todo.done .todo-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.todo-body { min-width: 0; }
.todo-title { font-size: 14px; line-height: 1.35; }
.todo.done .todo-title { color: var(--text-2); text-decoration: line-through; }
.todo-due { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.todo-due.overdue { color: var(--c-red); }

/* Calendar */
.calendar-wrap {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  background: var(--surface-solid);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  padding: 10px 0 8px; border-bottom: 1px solid var(--hairline);
}
.weekdays div {
  text-align: center; font-size: 12px; font-weight: 600;
  color: var(--text-2); text-transform: uppercase; letter-spacing: .05em;
}
.grid {
  flex: 1; display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(110px, 1fr);
}
.day {
  border-right: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  padding: 6px; overflow: hidden;
  display: flex; flex-direction: column; gap: 3px;
  cursor: pointer; transition: background .15s;
  animation: rise .4s ease both;
}
.day:nth-child(7n) { border-right: none; }
.day:hover { background: var(--accent-soft); }
.day.other { opacity: .35; }
.day-num {
  align-self: flex-end;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 500;
}
.day.today .day-num { background: var(--today-ring); color: #fff; font-weight: 700; }
.pill {
  font-size: 11.5px; font-weight: 500; line-height: 1.3;
  padding: 2px 7px; border-radius: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #fff; cursor: pointer; transition: filter .15s, transform .1s;
}
.pill:hover { filter: brightness(1.12); }
.pill:active { transform: scale(.97); }
.pill.timed { background: transparent !important; color: var(--text); padding-left: 4px; }
.pill.timed::before { content: "●"; font-size: 8px; vertical-align: 1px; margin-right: 4px; color: var(--pc); }
.pill.todo-pill {
  background: transparent !important; color: var(--text-2);
  border: 1px dashed var(--hairline); border-radius: 6px;
}
.pill .t { opacity: .85; font-weight: 400; margin-right: 3px; }
.more { font-size: 11px; color: var(--text-2); padding-left: 4px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  animation: fade .2s ease;
}
.modal {
  width: 420px; max-width: calc(100vw - 32px);
  background: var(--surface-solid);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0,0,0,.3);
  padding: 22px;
  animation: pop .25s cubic-bezier(.2,1.4,.4,1);
}
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; letter-spacing: -0.02em; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-size: 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--hairline); border-radius: 10px;
  padding: 9px 12px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.color-row { display: flex; gap: 8px; }
.color-dot {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform .15s, border-color .15s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.sel { border-color: var(--text); transform: scale(1.12); }
.switch-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.switch-row label { font-size: 14px; }
.switch { position: relative; width: 46px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 980px;
  background: var(--hairline); transition: background .25s; cursor: pointer;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25);
  transition: transform .25s cubic-bezier(.2,1.2,.4,1);
}
.switch input:checked + .track { background: #30d158; }
.switch input:checked + .track::after { transform: translateX(18px); }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.modal-actions .spacer { flex: 1; }
.hidden { display: none !important; }

@keyframes pop { from { transform: scale(.92); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; max-height: 40vh; }
}
