:root {
  --bg: #050505;
  --fg: #ffffff;
  --muted: #a9a9b0;
  --card: #242426;
  --line: #38383b;
  --field: #171719;
  --accent: #d72df2;
  --danger: #ff453a;
}

body.light {
  --bg: #f7f3ed;
  --fg: #1f2328;
  --muted: #69707a;
  --card: #fffaf3;
  --line: #ddd3c6;
  --field: #ffffff;
  --accent: #8b3ffc;
  --danger: #b42318;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  justify-content: center;
}

.app { width: min(820px, 100%); padding: 16px 14px 34px; }
.top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.brand { display: flex; gap: 10px; align-items: center; }
.ico { width: 38px; height: 38px; border-radius: 11px; background: #050505; border: 1px solid var(--line); display: grid; place-items: center; }
.ico::before { content: "◷"; font-size: 25px; color: #fff; }
.kicker { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .14em; font-weight: 800; }
h1 { font-size: 38px; line-height: .92; letter-spacing: -.055em; margin: 2px 0; }
.controls, .actions { display: flex; gap: 7px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 800; padding: 9px 12px; font-size: 14px; cursor: pointer; }
.btn.alt { background: var(--field); color: var(--fg); border: 1px solid var(--line); }
.btn.bad { background: var(--danger); }
.group { color: var(--muted); font-weight: 850; margin: 14px 0 6px; font-size: 13px; }
.grid { display: grid; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.name { font-size: 18px; font-weight: 850; }
.meta { color: var(--muted); font-size: 13px; margin-top: 1px; }
.chev { color: var(--muted); font-size: 22px; }

.swipe-shell {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: var(--field);
  touch-action: pan-y;
}
.swipe-action {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 118px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  pointer-events: none;
}
.swipe-action.add { left: 0; background: var(--accent); }
.swipe-action.custom { right: 0; background: var(--accent); }
.row {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 420ms cubic-bezier(.22, 1, .36, 1);
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
}
.row.dragging {
  transition: none;
  cursor: grabbing;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 850;
  opacity: 0;
  transition: .2s;
  pointer-events: auto;
  max-width: calc(100vw - 24px);
  white-space: nowrap;
}
.toast.show { opacity: 1; }
.toast button { margin-left: 10px; border: 0; border-radius: 999px; padding: 6px 9px; font-weight: 900; background: var(--accent); color: #fff; }

.form, .edit, .import { display: none; margin: 8px 0; }
.open { display: grid; gap: 7px; }
.input, select, textarea { width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 12px; color: var(--fg); padding: 10px; font-size: 14px; }
textarea { min-height: 110px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pillrow { display: flex; gap: 6px; }
.pill { flex: 1; background: var(--field); border: 1px solid var(--line); color: var(--fg); border-radius: 10px; padding: 8px; font-weight: 800; }
.pill.on { background: var(--accent); color: #fff; }
.stat { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding: 8px 0; font-size: 15px; }
.big { font-size: 32px; font-weight: 900; }
.hist { border-top: 1px solid var(--line); padding: 7px 0; color: var(--muted); font-size: 13px; }
.footer { margin-top: 18px; font-size: 13px; }
.footer a { color: var(--muted); font-weight: 800; text-decoration: none; }
.note { color: var(--muted); font-size: 12px; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(0, 0, 0, .62);
}
.occurrence-sheet {
  width: min(520px, 100%);
  display: grid;
  gap: 10px;
  background: color-mix(in srgb, var(--card) 88%, #000);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 16px;
  box-shadow: 0 24px 90px rgba(0, 0, 0, .48);
}
.sheet-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.sheet-title { text-align: center; font-weight: 900; font-size: 18px; }
.center { text-align: center; }
.sheet-now { width: 100%; padding: 13px; }
.sheet-label { font-weight: 850; margin-top: 2px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip, .note-toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--fg);
  padding: 9px 11px;
  font-weight: 850;
}
.note-toggle { border-radius: 13px; width: 100%; }
.note-area { min-height: 86px; resize: vertical; }

@media (max-width: 540px) {
  .top { display: block; }
  .controls { margin-top: 8px; }
  h1 { font-size: 36px; }
  .card { padding: 11px; }
  .name { font-size: 17px; }
  .modal-backdrop { padding: 10px; }
  .occurrence-sheet { border-radius: 24px 24px 0 0; }
}

/* Swipe placement: dragging left reveals the right action; dragging right reveals the left action. */
.swipe-action.add { left: auto; right: 0; background: var(--accent); }
.swipe-action.custom { right: auto; left: 0; background: var(--accent); }
.swipe-settings-card select { margin: 4px 0 10px; }
.hist .input { margin-top: 6px; }
.hist b { color: var(--fg); }
.row:not(.dragging) { transform: translateX(0); }
.detail-custom-add-card .input { margin-top: 6px; }
