:root {
  --bg: #F4F3FB;
  --card: #FFFFFF;
  --ink: #1B1830;
  --ink-soft: #6B6880;
  --line: #ECEAF3;
  --indigo: #6366F1;
  --violet: #7C3AED;
  --indigo-soft: #EEF0FE;

  --free: #0EA371;
  --free-bg: #E7F8F0;
  --harry: #D97706;
  --harry-bg: #FEF4E2;
  --harry-line: #F4C775;

  --liv: #D6263A;
  --liv-bg: #FCE9EB;
  --f1: #1F2937;
  --f1-bg: #E9EAEE;
  --golf: #15803D;
  --golf-bg: #E6F4EA;

  --shadow: 0 1px 2px rgba(27, 24, 48, .06), 0 6px 18px rgba(27, 24, 48, .06);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(var(--safe-top) + 14px) 16px 10px;
  background: linear-gradient(135deg, #6D6BF2 0%, #7C3AED 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(76, 29, 149, .22);
}
.header-row { display: flex; align-items: center; justify-content: space-between; }
.app-header h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.summary { margin: 6px 0 12px; font-size: 13.5px; color: rgba(255,255,255,.92); min-height: 17px; }
.summary b { font-weight: 700; }

.icon-btn {
  width: 38px; height: 38px;
  border: none; border-radius: 12px;
  background: rgba(255,255,255,.16);
  color: #fff; font-size: 22px; line-height: 1;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,.28); }

/* ---------- Filter chips ---------- */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: none;
  background: rgba(255,255,255,.18);
  color: #fff;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, transform .1s;
}
.chip.is-active { background: #fff; color: var(--violet); }
.chip:active { transform: scale(.96); }

/* ---------- List ---------- */
.list { padding: 12px 14px calc(40px + var(--safe-bottom)); max-width: 680px; margin: 0 auto; }

.month-head {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 18px 2px 8px;
  font-size: 13px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-soft);
}
.month-head:first-child { margin-top: 4px; }

/* ---------- Weekend card ---------- */
.wk {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 12px 13px;
  margin-bottom: 12px;
  border: 1.5px solid transparent;
  scroll-margin-top: 150px;
}
.wk.is-free { background: linear-gradient(180deg, var(--free-bg) 0%, #fff 60%); }
.wk.is-harry { border-color: var(--harry-line); }
.wk.is-now { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(99,102,241,.14), var(--shadow); }

.wk-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.wk-date { display: flex; flex-direction: column; line-height: 1.15; }
.wk-range { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.wk-sub { font-size: 12px; color: var(--ink-soft); font-weight: 600; margin-top: 1px; }
.wk-now-tag { color: var(--indigo); }

.wk-badges { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.free-badge {
  font-size: 12px; font-weight: 700;
  color: var(--free); background: var(--free-bg);
  padding: 4px 9px; border-radius: 999px;
}
.harry-badge {
  font-size: 12px; font-weight: 700;
  color: var(--harry); background: var(--harry-bg);
  border: 1.5px solid var(--harry-line);
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}

/* event chips */
.wk-events { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0 2px; }
.wk-events:empty { display: none; }
.ev {
  font-size: 11.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 4px;
}
.ev-liverpool { color: var(--liv); background: var(--liv-bg); }
.ev-f1 { color: var(--f1); background: var(--f1-bg); }
.ev-golf { color: var(--golf); background: var(--golf-bg); }

/* days */
.wk-days { margin-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.day { display: grid; grid-template-columns: 46px 1fr 1fr; gap: 6px; align-items: stretch; }
.day-label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.day-name { font-size: 12px; font-weight: 800; color: var(--ink-soft); }
.day.has-harry .day-name { color: var(--harry); }
.harry-day {
  width: 28px; height: 28px; padding: 0;
  border: 1.5px dashed var(--line); background: #fff;
  border-radius: 50%; cursor: pointer;
  font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: .4; filter: grayscale(1);
  transition: opacity .12s, filter .12s, border-color .12s, background .12s, transform .1s;
}
.harry-day:active { transform: scale(.88); }
.harry-day.on { opacity: 1; filter: none; border-style: solid; border-color: var(--harry-line); background: var(--harry-bg); }
.slot {
  position: relative;
  text-align: left;
  border: 1.5px dashed var(--line);
  background: #FAFAFD;
  border-radius: 12px;
  padding: 8px 9px 8px;
  min-height: 46px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  display: flex; flex-direction: column; gap: 2px;
  transition: border-color .12s, background .12s;
}
.slot:active { background: #F1F1F8; }
.slot.filled { border-style: solid; border-color: var(--indigo-soft); background: var(--indigo-soft); }
.slot-tag { font-size: 9.5px; font-weight: 800; letter-spacing: .08em; color: var(--ink-soft); text-transform: uppercase; }
.slot.filled .slot-tag { color: var(--violet); }
.slot-text { font-size: 13px; line-height: 1.25; white-space: pre-wrap; word-break: break-word; }
.slot-empty { font-size: 18px; color: #C9C7D6; font-weight: 400; margin-top: -1px; }

/* ---------- Bottom sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20,18,35,.4); animation: fade .18s ease; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(20px + var(--safe-bottom));
  max-width: 680px; margin: 0 auto;
  box-shadow: 0 -8px 40px rgba(0,0,0,.2);
  animation: slideup .24s cubic-bezier(.2,.8,.2,1);
}
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: #DDD9E8; margin: 6px auto 12px; }
.sheet-title { margin: 0 0 12px; font-size: 17px; font-weight: 800; }
.sheet-input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 12px; font: inherit; font-size: 16px; resize: none;
  background: #FAFAFD; color: var(--ink);
}
.sheet-input:focus { outline: none; border-color: var(--indigo); background: #fff; }
.sheet-actions { display: flex; gap: 10px; margin-top: 14px; }

.btn {
  border: none; border-radius: 14px; padding: 13px 16px;
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-primary { flex: 1; background: var(--indigo); color: #fff; }
.btn-primary:active { background: #5457e0; }
.btn-ghost { background: #F1F1F8; color: var(--ink-soft); }
.btn-ghost:active { background: #E7E6F0; }
.btn-block { display: block; width: 100%; text-align: left; background: #F6F6FB; color: var(--ink); margin-bottom: 9px; }
.btn-block:active { background: #ECEBF4; }

.menu-note { font-size: 12.5px; color: var(--ink-soft); margin: 2px 0 14px; line-height: 1.4; }
.menu-foot { margin-top: 8px; margin-bottom: 0; }

@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 480px) {
  .slot-text { font-size: 13.5px; }
  .wk-range { font-size: 17px; }
}
