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

:root {
  --bg: #ffffff;
  --surface: #f5f7f6;
  --surface-2: #e6edeb;
  --border: #c8d5d2;
  --text: #1a2421;
  --text-muted: #4a6361;
  --primary: #0d6559;
  --primary-dark: #0a5248;
  --primary-text: #ffffff;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning-bg: #fef9c3;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.10);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
  --min-touch: 52px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 19px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */

.view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}


/* ── Header (shared by all views) ── */

.app-header {
  background: var(--primary);
  color: var(--primary-text);
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.app-header h1,
.header-date {
  font-size: 20px;
  font-weight: 600;
}

.app-header h1 {
  flex: 1;
}

.header-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: inherit;
  border-radius: var(--radius-sm);
  padding: 0 18px;
  height: var(--min-touch);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.header-btn:active {
  background: rgba(255,255,255,0.35);
}

.back-btn {
  border-radius: 50%;
  width: var(--min-touch);
  height: var(--min-touch);
  font-size: 22px;
  justify-content: center;
}

/* ── Main content ── */

.main-content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(52px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.settings-content {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(52px + env(safe-area-inset-bottom));
}

/* ── Module card ── */

.module-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.module-title {
  padding: 14px 16px 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  background: var(--surface);
}

/* ── Card rows (shared by tasks and events) ── */

.card-list {
  list-style: none;
}

.card-row {
  display: flex;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
  min-height: var(--min-touch);
}

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

.card-label {
  flex: 1;
  font-size: 19px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
}

.event-location {
  font-size: 15px;
  color: var(--text-muted);
}

.card-empty {
  padding: 24px 16px;
  color: var(--text-muted);
  text-align: center;
  font-size: 19px;
}

/* ── Task list ── */

.task-item {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}

.task-item:active {
  background: var(--surface);
}

.task-item.completed {
  background: var(--success-bg);
}

.task-checkbox {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg);
  font-size: 18px;
  transition: all 0.15s;
}

.task-item.completed .task-checkbox {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

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


/* ── Calendar module ── */

.event-time {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  padding-top: 2px;
  min-width: 70px;
}

.event-allday {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 2px;
}

.event-past {
  opacity: 0.4;
}

.calendar-connect {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.calendar-connect p {
  font-size: 19px;
  color: var(--text-muted);
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--min-touch);
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-ghost:active {
  background: var(--surface-2);
}

/* ── Settings sections ── */

.settings-section {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.settings-section-title {
  padding: 14px 16px 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  background: var(--surface);
}

.settings-row {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--min-touch);
}

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

.settings-row-label {
  flex: 1;
  font-size: 19px;
}

.settings-row-label small {
  display: block;
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Period tab selector (settings) ── */

.period-selector {
  display: flex;
  border-bottom: 1.5px solid var(--border);
}

.period-selector-btn {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: var(--surface);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  border-right: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
}

.period-selector-btn:last-child {
  border-right: none;
}

.period-selector-btn.active {
  background: var(--bg);
  color: var(--primary);
  border-bottom: 2.5px solid var(--primary);
  margin-bottom: -1.5px;
}

.form-input {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 18px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  min-height: var(--min-touch);
  transition: border-color 0.15s;
  /* Never disable paste — COGA requirement */
}

.form-input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 101, 89, 0.22);
}

.form-input.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

/* ── Task editor ── */

.task-editor-list {
  list-style: none;
}

.task-editor-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--min-touch);
}

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

.task-editor-name {
  flex: 1;
  font-size: 19px;
  border-color: transparent;
  background: transparent;
  padding: 8px 10px;
  min-height: unset;
}

.task-editor-name:focus {
  border-color: var(--primary);
  background: var(--bg);
}

.move-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.move-btn:active {
  background: var(--surface-2);
}

.move-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.delete-btn {
  background: var(--danger-bg);
  border: none;
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  font-size: 18px;
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.delete-btn:active {
  background: #fca5a5;
}

.add-task-row {
  display: flex;
  padding: 14px 16px;
  border-top: 1.5px solid var(--border);
  background: var(--surface);
  align-items: flex-end;
}

/* add-task-input uses .form-input with flex:1 */
.add-task-input {
  flex: 1;
  min-width: 0;
}

.schedule-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 30px 0 10px;
  font-size: 15px;
  color: var(--text);
  height: 52px;
  cursor: pointer;
  flex-shrink: 0;
}

.add-btn {
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  width: 52px;
  height: 52px;
  font-size: 26px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.add-btn:active {
  background: var(--primary-dark);
}

/* ── Screen-reader only (visually hidden but announced) ── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Scrollbar (subtle) ── */

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ── Account settings ── */

.account-signin {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 16px;
}

.account-signin p {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Google sign-in button ── */

.btn-google {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  color: #3c4043;
  border: 1.5px solid #dadce0;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-height: var(--min-touch);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  transition: box-shadow 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-google:active {
  background: #f8f8f8;
  box-shadow: none;
}

.btn-google svg {
  flex-shrink: 0;
}


/* ── Loading spinner ── */

.spinner {
  display: flex;
  justify-content: center;
  padding: 24px;
}

.spinner::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .spinner::after { animation: none; }
}

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

/* ── Flexbox gap fallback (Safari < 14.1 does not support gap on flex) ── */

.app-header > * + *       { margin-left: 12px; }
.main-content > * + *     { margin-top: 16px; }
.settings-content > * + * { margin-top: 20px; }
.card-row > * + *          { margin-left: 14px; }
.card-label > * + *        { margin-top: 2px; }
.calendar-connect > * + *  { margin-top: 12px; }
.btn > * + *               { margin-left: 8px; }
.settings-row > * + *      { margin-left: 12px; }
.account-signin > * + *    { margin-top: 12px; }
.btn-google > * + *        { margin-left: 12px; }
.add-task-row > * + *      { margin-left: 10px; }
.task-editor-item > * + *  { margin-left: 10px; }
.app-footer > * + *        { margin-left: 6px; }

/* ── Footer ── */

.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  font-size: 13px;
  color: var(--text-muted);
  pointer-events: none;
}

