:root {
  --bg: #0A1628;
  --surface: #131f35;
  --surface2: #1a2a42;
  --accent: #4FC3F7;
  --accent-dark: #0a6fa8;
  --text: #f0f4f8;
  --text-muted: #7a93ad;
  --success: #4ade80;
  --border: rgba(255, 255, 255, 0.07);
  --today-bg: rgba(79, 195, 247, 0.08);
  --today-border: rgba(79, 195, 247, 0.5);
  --topbar-bg: rgba(10, 22, 40, 0.82);
  --radius: 14px;
  --radius-sm: 8px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 24px);
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

.topbar, .day-card, .task-item, .team-select-btn,
.more-menu-items, .club-select-menu, .stats-panel {
  transition: background 0.4s ease, border-color 0.4s ease, color 0.4s ease;
}

/* ── Floating topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--topbar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  padding: 10px 16px 0;
}

/* iOS PWA — navigator.standalone → .pwa-ios on <html> */
html.pwa-ios .topbar {
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}

@media (min-width: 640px) {
  html.pwa-ios .topbar {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
}

/* Android / Chrome PWA fallback */
@media (display-mode: standalone) {
  .topbar { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
}

@media (display-mode: standalone) and (min-width: 640px) {
  .topbar { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
}

.topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: contain;
  background: #fff;
  padding: 2px;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
  display: none;
}

@media (min-width: 480px) {
  .brand-name { display: inline; }
}

/* Team dropdown + more-menu row */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Team dropdown */
.team-select {
  position: relative;
}

.team-select-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 7px 14px;
  border-radius: 24px;
  border: 1.5px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 36px;
}

.team-select-btn:active,
.team-select-btn[aria-expanded="true"] {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: var(--accent);
}

.chevron {
  flex-shrink: 0;
  transition: transform 0.2s;
}

.team-select-btn[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.team-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: var(--surface2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: menu-in 0.15s ease;
}

.team-select-menu[hidden] {
  display: none;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}

.team-option {
  display: block;
  width: 100%;
  padding: 11px 16px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.team-option:hover,
.team-option:focus {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
}

.team-option.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* More menu */
.more-menu {
  position: relative;
}

.more-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.more-btn:active,
.more-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.more-menu-items {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 164px;
  background: var(--surface2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: menu-in 0.15s ease;
}

.more-menu-items[hidden] {
  display: none;
}

.more-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 16px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.more-option:hover,
.more-option:focus {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
}

.more-option + .more-option {
  border-top: 1px solid var(--border);
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  white-space: nowrap;
}

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

/* Week nav — inside topbar */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding: 8px 0 10px;
}

.week-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

#week-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

#week-dates {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.week-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.week-btn:active {
  background: var(--accent-dark);
  border-color: var(--accent);
}

.today-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.today-btn:active {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border-color: var(--accent);
}

.today-btn[hidden] {
  display: none;
}

/* ── Main content ── */
main {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
}

/* ── Day cards ── */
.day-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
  transition: border-color 0.2s;
}

.day-card.today {
  background: var(--today-bg);
  border-color: var(--today-border);
}

.day-card.all-done {
  border-color: rgba(74, 222, 128, 0.4);
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  gap: 8px;
}

.day-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.day-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.today-badge {
  display: none;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--accent);
  color: #0A1628;
  padding: 2px 7px;
  border-radius: 10px;
}

.day-card.today .today-badge {
  display: inline-block;
}

.progress-text {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.day-card.all-done .progress-text {
  color: var(--success);
}

.progress-bar {
  height: 2px;
  background: var(--surface2);
  margin: 0 16px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 0.35s ease;
}

.day-card.all-done .progress-bar-fill {
  background: var(--success);
}

/* ── Tasks ── */
.tasks {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  border: 1px solid transparent;
}

.task-item:active {
  opacity: 0.75;
}

.task-item.done {
  opacity: 0.45;
}

.task-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
  margin-top: 1px;
  border-radius: 4px;
}

.task-text {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.45;
}

.task-item.done .task-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* ── Repeat notice ── */
.repeat-notice {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 4px;
}

/* ── Loading / empty states ── */
.loading,
.no-data {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.no-data strong {
  display: block;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 6px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Notification banner ── */
.notif-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
  animation: slide-up 0.3s ease;
}

.notif-banner.hidden {
  display: none;
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.notif-banner p {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.4;
}

.notif-banner p span {
  font-size: 1.1em;
}

.notif-actions {
  display: flex;
  gap: 8px;
}

.notif-btn-yes {
  flex: 1;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #0A1628;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.notif-btn-no {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ── Responsive ── */
@media (min-width: 640px) {
  .topbar {
    padding: 12px 28px 0;
  }

  main {
    padding: 20px 28px;
    gap: 14px;
  }
}

/* ── Club selector (brand area, left side) ── */
.club-select {
  position: relative;
}

.club-select-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 2px 0;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.club-select-btn:active,
.club-select-btn[aria-expanded="true"] {
  opacity: 0.75;
}

.club-select-btn[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.club-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--surface2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: menu-in 0.15s ease;
  z-index: 30;
}

.club-select-menu[hidden] {
  display: none;
}

.club-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.club-option:hover,
.club-option:focus {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
}

.club-option.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.club-option-logo {
  border-radius: 3px;
  object-fit: contain;
  background: #fff;
  padding: 1px;
  flex-shrink: 0;
}

/* ── Task extra content ── */
.task-content {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.task-info {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  transition: opacity 0.2s;
}

.task-video {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}

.task-video:hover {
  text-decoration: underline;
}

.task-item.done .task-info,
.task-item.done .task-video {
  opacity: 0.45;
}

/* ── Statistics modal ── */
.stats-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 150;
  display: flex;
  align-items: flex-end;
  padding: 0;
}

.stats-modal[hidden] {
  display: none;
}

.stats-panel {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--border);
  width: 100%;
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.stats-header h2 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.stats-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.stats-close:active {
  background: rgba(255,255,255,.08);
}

.stats-summary {
  padding: 12px 20px 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.stats-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 4px 12px 12px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.stat-item:last-child {
  border-bottom: none;
}

.stat-week {
  font-weight: 700;
  color: var(--text);
  min-width: 72px;
}

.stat-team {
  color: var(--text-muted);
  font-size: 0.78rem;
  flex: 1;
}

.stat-done {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .stats-modal {
    align-items: center;
    padding: 20px;
  }
  .stats-panel {
    border-radius: var(--radius);
    max-width: 560px;
    margin: 0 auto;
    max-height: 75dvh;
  }
}
