/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Light mode — Teal + Orange */
  --bg:          #F0FDFA;
  --surface:     #FFFFFF;
  --surface-2:   #F8FAFB;
  --text:        #134E4A;
  --text-muted:  #64748B;
  --primary:     #0D9488;
  --primary-hover: #0F766E;
  --primary-light: #CCFBF1;
  --accent:      #EA580C;
  --accent-hover: #C2410C;
  --accent-light: #FFF7ED;
  --border:      #E2E8F0;
  --border-light: #F1F5F9;
  --destructive: #DC2626;
  --destructive-light: #FEE2E2;
  --success:     #22C55E;
  --warning:     #F59E0B;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   16px;
  --shadow:      0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 6px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-lg:   0 10px 20px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --spring:      cubic-bezier(0.34, 1.56, 0.64, 1);
  --spring-soft: cubic-bezier(0.32, 1.2, 0.56, 1);
  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --transition:  200ms cubic-bezier(0.22, 1, 0.36, 1);
  --nav-h:       56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --bg:          #0F1B1A;
  --surface:     #1A2828;
  --surface-2:   #233333;
  --text:        #E2E8F0;
  --text-muted:  #94A3A3;
  --primary:     #2DD4BF;
  --primary-hover: #14B8A6;
  --primary-light: #134E4A;
  --accent:      #FB923C;
  --accent-hover: #F97316;
  --accent-light: #431407;
  --border:      #2A3F3E;
  --border-light: #1F3030;
  --destructive: #EF4444;
  --destructive-light: #450A0A;
  --success:     #4ADE80;
  --warning:     #FBBF24;
  --shadow:      0 1px 2px rgba(0,0,0,0.2);
  --shadow-md:   0 4px 6px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.15);
  --shadow-lg:   0 10px 20px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.2);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 350ms var(--ease-out), color 350ms var(--ease-out);
}

/* ===== Layout ===== */
#app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

.view {
  display: none;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 24px);
}

.view.active {
  display: block;
  animation: fadeIn 300ms var(--ease-out);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 16px 12px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

/* ===== View Body ===== */
.view-body {
  padding: 0 16px;
}

.hidden { display: none !important; }

/* ===== Loading / Empty ===== */
.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 0;
  font-size: 15px;
}

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.25;
}

.empty-state p {
  font-size: 15px;
  line-height: 1.6;
}

/* ===== Reminder Card ===== */
.reminders-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.reminder-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  overflow: hidden;
  position: relative;
  transition: transform 250ms var(--spring-soft), opacity 300ms var(--ease-out), box-shadow var(--transition);
  will-change: transform;
  animation: cardIn 300ms var(--ease-out) backwards;
}

.reminder-card:active {
  transform: scale(0.99);
}

.reminder-card.overdue {
  border-left-color: var(--destructive);
}

.reminder-card.completed {
  border-left-color: var(--border);
  opacity: 0.5;
}

.reminder-card.completing {
  opacity: 0.5;
  transform: scale(0.97);
  transition: opacity 400ms var(--ease-out), transform 400ms var(--spring-soft);
}

/* Card content (tap to edit) */
.reminder-card-content {
  flex: 1;
  padding: 14px 12px 14px 14px;
  min-width: 0;
}

.reminder-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reminder-card.completed .reminder-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.reminder-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reminder-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.reminder-meta.overdue {
  color: var(--destructive);
  font-weight: 600;
}

.reminder-badges {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.reminder-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

/* ===== Complete Toggle Button ===== */
.complete-toggle {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-right: 14px;
  transition: all 250ms var(--spring-soft);
  color: transparent;
  position: relative;
  z-index: 2;
}

.complete-toggle:active {
  transform: scale(0.85);
}

.complete-toggle.completing {
  background: var(--success);
  border-color: var(--success);
  color: #FFFFFF;
  animation: checkPop 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

.complete-toggle.done {
  background: var(--success);
  border-color: var(--success);
  color: #FFFFFF;
}

@keyframes checkPop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.3); }
  55%  { transform: scale(0.92); }
  80%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.check-icon {
  opacity: 0;
  transition: opacity 200ms var(--ease-out);
}

.complete-toggle.completing .check-icon,
.complete-toggle.done .check-icon {
  opacity: 1;
}

/* ===== Swipe Action (Delete) ===== */
.swipe-action {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: var(--destructive);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  cursor: pointer;
  z-index: 0;
}

.reminder-card:not(.swiped) .swipe-action {
  opacity: 0;
  pointer-events: none;
}

.reminder-card.swiped .swipe-action {
  opacity: 1;
  pointer-events: auto;
}

/* Hide complete toggle when swiped — only show delete */
.reminder-card.swiped .complete-toggle {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* ===== Chip Groups ===== */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.chip:active { transform: scale(0.95); }

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

/* ===== Form Hints ===== */
.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* ===== Buttons ===== */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-accent {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-accent:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border-light); }

.btn-danger {
  color: var(--destructive);
  border-color: var(--destructive-light);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== Icon Button (Header) ===== */
.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}

.icon-btn:active { transform: scale(0.92); }
.icon-btn:hover  { background: var(--surface-2); }

/* Theme toggle: show sun in light, moon in dark */
.icon-sun  { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ===== FAB ===== */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all 250ms var(--spring-soft);
  z-index: 90;
}

.fab:active {
  transform: scale(0.9);
  background: var(--accent-hover);
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  max-width: 600px;
  margin: 0 auto;
  padding-bottom: var(--safe-bottom);
}

.nav-item {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
  font-family: inherit;
  padding: 4px 0;
  min-height: 44px;
}

.nav-item span {
  font-size: 11px;
  font-weight: 500;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item:active { transform: scale(0.95); }

/* ===== Cards (Settings) ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group:last-child { margin-bottom: 0; }

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.req { color: var(--destructive); }

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  min-height: 44px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

/* ===== Radio Group ===== */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.radio-item:hover { background: var(--surface-2); }
.radio-item:active { transform: scale(0.99); }

.radio-item input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
}

.radio-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-label strong {
  font-size: 14px;
  color: var(--text);
}

.radio-label small {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Checkbox Group ===== */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.checkbox-item:hover { background: var(--surface-2); }
.checkbox-item:active { transform: scale(0.99); }

.checkbox-item input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
}

.checkbox-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.checkbox-label strong {
  font-size: 14px;
  color: var(--text);
}

.checkbox-label small {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Push Status ===== */
.push-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background var(--transition);
}

.status-dot.active { background: var(--success); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: overlayIn var(--transition);
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes overlayOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 350ms var(--spring-soft);
}

.modal.closing {
  animation: modalOut 250ms var(--ease-out) forwards;
}

.modal-overlay.closing {
  animation: overlayOut 250ms var(--ease-out) forwards;
}

@keyframes modalIn {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes modalOut {
  from { transform: translateY(0); }
  to   { transform: translateY(100%); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.btn-close:hover { background: var(--surface-2); }
.btn-close:active { transform: scale(0.9); }

.modal-body { padding: 20px; }

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  justify-content: flex-end;
  padding-bottom: calc(20px + var(--safe-bottom));
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  box-shadow: var(--shadow-lg);
  animation: toastIn var(--transition);
  max-width: 90%;
  text-align: center;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  to   { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.95); }
}

.toast.closing {
  animation: toastOut 200ms var(--ease-out) forwards;
}

.toast.success { background: var(--success); color: #FFFFFF; }
.toast.error   { background: var(--destructive); color: #FFFFFF; }

/* ===== Msg ===== */
.msg {
  margin-top: 12px;
  font-size: 14px;
  min-height: 20px;
}

.msg.success { color: var(--success); }
.msg.error   { color: var(--destructive); }

/* ===== Responsive ===== */
@media (min-width: 480px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius-lg); }
}

@media (max-width: 380px) {
  .page-header { padding: 16px 12px 8px; }
  .page-header h1 { font-size: 24px; }
  .view-body { padding: 0 12px; }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
