:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-light: #eff6ff;
  --ink: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --danger: #dc2626;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --success-border: #a7f3d0;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

input,
select,
textarea,
button {
  font-family: inherit;
  font-size: 16px; /* prevents iOS zoom-on-focus */
}

a {
  text-decoration: none;
  color: inherit;
}

.muted {
  color: var(--muted);
}

form label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin: 14px 0 6px;
}

form label:first-of-type {
  margin-top: 0;
}

form input,
form select,
form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

form input:focus,
form select:focus,
form textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-light);
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin: 10px 0 0;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-outline {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--muted);
}

.btn-outline:hover {
  background: #f1f5f9;
}

.btn-link-danger {
  background: none;
  border: none;
  color: var(--danger);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  padding: 8px 0 0;
}

.btn-icon,
.btn-text {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  padding: 6px 10px;
}

.btn-icon {
  font-size: 18px;
  line-height: 1;
}

.btn-icon:hover,
.btn-text:hover {
  background: #f1f5f9;
}

/* App shell */
.app-shell {
  min-height: 100vh;
  padding-bottom: 64px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: none;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar .brand {
  font-weight: 700;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.nav-link.active {
  background: var(--brand-light);
  color: var(--brand-dark);
}

.nav-link:hover {
  background: #f1f5f9;
}

.bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(6px);
}

.bottomnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
}

.bottomnav-item.active {
  color: var(--brand);
}

.bottomnav-icon {
  font-size: 18px;
  line-height: 1;
}

@media (min-width: 640px) {
  .topbar {
    display: block;
  }
  .bottomnav {
    display: none;
  }
  .app-shell {
    padding-bottom: 0;
  }
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  padding-top: 20px;
  padding-bottom: 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.page-header h1 {
  margin: 0;
  font-size: 20px;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hint {
  font-size: 12px;
  color: var(--faint);
  margin: -8px 0 16px;
}

/* Lists */
.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
}

.list-card:hover {
  border-color: #93c5fd;
}

.min-w-0 {
  min-width: 0;
}

.list-card-title {
  margin: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.repeat-icon {
  font-size: 12px;
  opacity: 0.6;
}

.list-card-sub {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.list-card-faint {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--faint);
}

.chevron {
  color: var(--faint);
  font-size: 18px;
}

.empty-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.empty-day {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--faint);
  margin: 0;
}

.day-section {
  margin-bottom: 18px;
}

.day-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 8px;
}

.day-heading.is-today {
  color: var(--brand);
}

.status-badge {
  flex-shrink: 0;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-scheduled {
  background: var(--brand-light);
  color: var(--brand-dark);
  border-color: #bfdbfe;
}

.status-completed {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.status-canceled {
  background: #f1f5f9;
  color: var(--faint);
  border-color: var(--border);
  text-decoration: line-through;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 24px;
}

.modal-sheet h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.modal-actions .btn {
  flex: 1;
}

.modal-actions .btn-outline {
  flex: 0 0 auto;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.weekday-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 4px;
}

.weekday-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.weekday-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  margin: 0;
}

.weekday-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.weekday-time {
  flex: 0 0 auto;
}

/* 24-hour time picker (hour : minute selects) */
.time-picker {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 0 4px;
}

.time-picker:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-light);
}

.time-picker select {
  width: auto;
  border: 0;
  background: transparent;
  padding: 9px 2px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.time-picker select:focus {
  outline: none;
  box-shadow: none;
}

.time-picker .tp-sep {
  color: var(--muted);
  font-weight: 700;
}

.time-picker select:disabled {
  opacity: 0.4;
  cursor: default;
}

.grid-2 .time-picker {
  display: flex;
  width: 100%;
  justify-content: center;
}

.preview-box {
  background: var(--brand-light);
  color: var(--brand-dark);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  margin: 12px 0 0;
  min-height: 16px;
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
  }
  .modal-sheet {
    border-radius: 20px;
  }
}
