:root {
  --green: #4CAF50;
  --yellow: #FFC107;
  --red: #F44336;
  --grey: #9E9E9E;
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --text: #e0e0e0;
  --text-muted: #888;
  --border: #2a2a4a;
  --radius: 12px;
  --header-height: 88px;
}

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

/* Ensure [hidden] always wins over display rules set on specific elements */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 600px;
  margin: 0 auto;
  padding-bottom: 80px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

#header {
  padding: 12px 16px 10px;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.sitter-name {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.today-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.away-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

.weather-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
}

/* ── Week strip ─────────────────────────────────────────────────────────── */

.week-strip {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.week-strip::-webkit-scrollbar {
  display: none;
}

.day-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 48px;
  padding: 8px 4px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s, opacity 0.2s;
}

.day-chip:active {
  opacity: 0.7;
}

.day-label {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1;
}

.day-label.depart { color: var(--yellow); }
.day-label.return { color: var(--green); }

.day-chip.is-today .day-num {
  background: var(--text);
  color: var(--bg);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.day-time {
  font-size: 0.6rem;
  color: var(--text-muted);
  line-height: 1;
}

.day-dow {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.day-num {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.day-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
}

.day-remaining {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
}

.day-chip.grey  .day-dot { background: var(--grey); opacity: 0.4; }
.day-chip.yellow .day-dot { background: var(--yellow); }
.day-chip.green  .day-dot { background: var(--green); }
.day-chip.red    .day-dot { background: var(--red); }

.day-chip.active {
  border-color: var(--text);
}

.day-chip.green.active  { border-color: var(--green); }
.day-chip.yellow.active { border-color: var(--yellow); }
.day-chip.red.active    { border-color: var(--red); }

/* ── Missed banner ──────────────────────────────────────────────────────── */

.missed-banner {
  background: var(--red);
  color: white;
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  position: sticky;
  top: var(--header-height);
  z-index: 90;
  letter-spacing: 0.02em;
}

/* ── Day view ───────────────────────────────────────────────────────────── */

.day-view {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.day-title {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 400;
  padding: 2px 4px;
}

.day-note {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  margin: 0 4px;
}

.depart-note {
  color: var(--yellow);
  background: rgba(255, 193, 7, 0.1);
}

.return-note {
  color: var(--green);
  background: rgba(76, 175, 80, 0.1);
}

/* ── Group card ─────────────────────────────────────────────────────────── */

.group-card {
  border-top: 1px solid var(--border);
}

.group-card.group-done {
  opacity: 0.75;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
}

.group-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.group-label {
  font-weight: 600;
  font-size: 0.9rem;
  flex: 1;
}

.group-timerange {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.group-fraction {
  font-size: 0.75rem;
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.group-done-msg {
  padding: 14px;
  text-align: center;
  color: var(--green);
  font-size: 0.88rem;
  font-weight: 500;
}

.forgot-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  margin-left: 10px;
}

.forgot-link:active {
  opacity: 0.6;
}

/* ── Task row ───────────────────────────────────────────────────────────── */

.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  user-select: none;
}

.task-row:last-child {
  border-bottom: none;
}

.task-row:active {
  background: var(--surface2);
}

.task-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--grey);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
  color: white;
  font-weight: 700;
}

.task-row.complete .task-checkbox {
  background: var(--green);
  border-color: var(--green);
}

.task-row.skipped .task-checkbox {
  background: var(--grey);
  border-color: var(--grey);
}

.task-row.missed .task-checkbox {
  border-color: var(--red);
}

.task-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.task-icon svg {
  width: 100%;
  height: 100%;
}

.task-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.task-title {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.task-row.complete .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-row.skipped .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-row.missed .task-title {
  color: #ff6b6b;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.time-badge {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.4;
}

.missed-badge {
  background: rgba(244, 67, 54, 0.18);
  color: #ff6b6b;
}

.skipped-badge {
  background: rgba(158, 158, 158, 0.2);
  color: var(--grey);
}

.skip-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
  line-height: 1;
  border-radius: 50%;
  transition: background 0.15s;
}

.detail-btn:active {
  background: var(--surface2);
}

/* ── Detail panel (bottom sheet) ────────────────────────────────────────── */

.detail-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.detail-panel.open {
  opacity: 1;
  pointer-events: all;
}

.detail-panel-inner {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  padding: 20px 16px 36px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-panel.open .detail-panel-inner {
  transform: translateY(0);
}

.detail-close {
  float: right;
  background: var(--surface2);
  border: none;
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.detail-content h3 {
  font-size: 1.05rem;
  margin-bottom: 10px;
  margin-top: 4px;
  line-height: 1.3;
}

.detail-content p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 8px;
}

.detail-time {
  color: var(--yellow) !important;
  font-size: 0.8rem !important;
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn-complete,
.btn-skip {
  flex: 1;
  padding: 13px 8px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-complete:active,
.btn-skip:active {
  opacity: 0.8;
}

.btn-complete {
  background: var(--green);
  color: white;
}

.btn-skip {
  background: var(--surface2);
  color: var(--text);
}

.skip-area {
  margin-top: 14px;
}

.skip-area textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.875rem;
  resize: none;
  height: 80px;
  font-family: inherit;
  line-height: 1.4;
}

.skip-area textarea:focus {
  outline: 1px solid var(--grey);
}

.btn-confirm-skip {
  width: 100%;
  margin-top: 10px;
  padding: 13px;
  background: var(--grey);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

/* ── Error screen ───────────────────────────────────────────────────────── */

.error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px;
  text-align: center;
  gap: 10px;
}

.error-screen p:first-child {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.error-screen p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ── Auth gate ─────────────────────────────────────────── */
.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.auth-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.auth-cat {
  font-size: 3rem;
}

.auth-box h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.auth-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
  font-style: italic;
}

.auth-form {
  display: flex;
  gap: 8px;
  width: 100%;
}

.auth-form input {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.auth-form input:focus {
  border-color: var(--accent);
}

.auth-form button {
  padding: 12px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.auth-error {
  color: #e53e3e;
  font-size: 0.85rem;
  margin: 0;
}
