:root {
  --primary: #4A90D9;
  --primary-light: #6BA5E0;
  --primary-dark: #3570B0;
  --success: #7ED321;
  --warning: #F5A623;
  --danger: #D0021B;
  --purple: #BD10E0;
  --teal: #50E3C2;
  --bg: #F5F7FA;
  --card-bg: #FFFFFF;
  --text: #2C3E50;
  --text-light: #7F8C8D;
  --text-lighter: #BDC3C7;
  --border: #E8ECF1;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --tentative-bg: repeating-linear-gradient(135deg, transparent, transparent 4px, rgba(245,166,35,0.15) 4px, rgba(245,166,35,0.15) 8px);
  --tentative-border: 2px dashed #F5A623;
  --nav-height: 48px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

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;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(74,144,217,0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.app-title { font-size: 20px; font-weight: 700; white-space: nowrap; }
.app-subtitle { font-size: 12px; opacity: 0.85; white-space: nowrap; }
.header-date { font-size: 14px; opacity: 0.9; white-space: nowrap; }

.app-nav {
  background: var(--card-bg);
  display: flex;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  position: sticky;
  top: 48px;
  z-index: 99;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.app-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  padding: 12px 20px;
  border: none;
  background: none;
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn:hover { color: var(--primary); }
.nav-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  min-height: calc(100vh - 100px);
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 16px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon { font-size: 18px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.success { border-left-color: var(--success); }

.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.view-toggle-btn {
  padding: 6px 16px;
  border: none;
  background: var(--card-bg);
  color: var(--text-light);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.view-toggle-btn.active { background: var(--primary); color: white; }

.list-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  transition: background 0.15s;
}

.list-item:hover { background: #F8FAFC; }
.list-item:last-child { border-bottom: none; }

.list-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.list-item-dot.warning { background: var(--warning); }
.list-item-dot.danger { background: var(--danger); }
.list-item-dot.success { background: var(--success); }

.list-item-content { flex: 1; min-width: 0; }
.list-item-title { font-size: 14px; font-weight: 500; word-break: break-word; }
.list-item-sub { font-size: 12px; color: var(--text-light); margin-top: 2px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-tentative {
  background: rgba(245,166,35,0.15);
  color: #C17D10;
  border: 1px solid rgba(245,166,35,0.3);
}

.badge-confirmed {
  background: rgba(126,211,33,0.15);
  color: #5A9A18;
  border: 1px solid rgba(126,211,33,0.3);
}

.badge-pending {
  background: rgba(74,144,217,0.15);
  color: var(--primary-dark);
}

.badge-overdue {
  background: rgba(208,2,27,0.15);
  color: var(--danger);
}

.badge-completed {
  background: rgba(126,211,33,0.15);
  color: #5A9A18;
}

.badge-high { background: rgba(208,2,27,0.15); color: var(--danger); }
.badge-medium { background: rgba(245,166,35,0.15); color: #C17D10; }
.badge-low { background: rgba(74,144,217,0.15); color: var(--primary-dark); }

.priority-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.priority-dot.high { background: var(--danger); }
.priority-dot.medium { background: var(--warning); }
.priority-dot.low { background: var(--primary); }

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  touch-action: manipulation;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; min-width: 32px; justify-content: center; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-right { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

select, input[type="text"], input[type="date"], input[type="time"], input[type="url"], textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: var(--card-bg);
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  max-width: 100%;
}

select:focus, input:focus, textarea:focus { border-color: var(--primary); }

textarea { resize: vertical; min-height: 60px; }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--text); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; min-width: 0; }

.color-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.color-option {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.color-option:hover { transform: scale(1.15); }
.color-option.selected { border-color: var(--text); box-shadow: 0 0 0 2px white, 0 0 0 4px var(--text); }

/* ====== Week Grid (Desktop) ====== */
.week-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card-bg);
}

.week-header {
  padding: 10px 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  background: #F0F4F8;
  border-bottom: 1px solid var(--border);
  color: var(--text-light);
}

.week-header-date {
  font-size: 10px;
  font-weight: 400;
  margin-top: 2px;
  opacity: 0.7;
}

.week-header.today .week-header-date { opacity: 0.9; }

.week-header.today { background: var(--primary); color: white; }

.week-time {
  padding: 4px 6px;
  font-size: 11px;
  color: var(--text-lighter);
  text-align: right;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 48px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}

.week-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 48px;
  padding: 2px;
  position: relative;
}

.week-cell:last-child { border-right: none; }

.course-block {
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: white;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
  line-height: 1.3;
  margin: 1px;
}

.course-block:hover { filter: brightness(1.1); transform: scale(1.02); z-index: 1; }

.course-block.confirmed {
  border: 2px solid rgba(0,0,0,0.1);
}

.course-block.tentative {
  background-image: var(--tentative-bg);
  border: var(--tentative-border);
  color: var(--text);
}

.course-block .tentative-tag {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--warning);
  color: white;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 0 2px 0 4px;
  font-weight: 700;
}

.course-block .course-name {
  font-weight: 600;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 28px;
}

.course-block .course-time {
  font-size: 10px;
  opacity: 0.85;
}

.course-block .course-extra {
  display: block;
  font-size: 10px;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-block.tentative .course-time { opacity: 0.7; }
.course-block.tentative .course-extra { opacity: 0.6; }

/* ====== Day List (Mobile fallback for courses) ====== */
.day-list {
  display: none;
}

.day-list-group {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}

.day-list-header {
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  background: #F0F4F8;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.day-list-date {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-light);
}

.day-list-header.today {
  background: var(--primary);
  color: white;
}

.day-list-header.today .badge-confirmed {
  background: rgba(255,255,255,0.25);
  color: white;
  border-color: rgba(255,255,255,0.4);
}

.day-list-header.today .day-list-date {
  color: rgba(255,255,255,0.8);
}

.day-list-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.day-list-item:last-child { border-bottom: none; }
.day-list-item:active { background: #F0F4F8; }

.day-list-color {
  width: 4px;
  height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
}

.day-list-color.tentative {
  border: 1px dashed var(--warning);
  background: repeating-linear-gradient(180deg, var(--warning), var(--warning) 3px, transparent 3px, transparent 6px);
}

.day-list-info { flex: 1; min-width: 0; }
.day-list-name { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.day-list-meta { font-size: 12px; color: var(--text-light); margin-top: 2px; }

.conflict-banner {
  background: linear-gradient(135deg, rgba(208,2,27,0.1), rgba(208,2,27,0.05));
  border: 1px solid rgba(208,2,27,0.3);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: conflictPulse 2s ease-in-out infinite;
}

.conflict-banner-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.conflict-banner-content {
  flex: 1;
  min-width: 0;
}

.conflict-banner-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--danger);
}

.conflict-banner-desc {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

@keyframes conflictPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(208,2,27,0); }
  50% { box-shadow: 0 0 12px 2px rgba(208,2,27,0.15); }
}

.badge-conflict {
  background: rgba(208,2,27,0.15);
  color: var(--danger);
  border: 1px solid rgba(208,2,27,0.3);
}

.course-block.conflict {
  border: 2px solid var(--danger) !important;
  box-shadow: 0 0 6px 1px rgba(208,2,27,0.4);
}

.course-block .conflict-tag {
  position: absolute;
  bottom: 0;
  right: 0;
  background: var(--danger);
  color: white;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 2px 0 0 0;
  font-weight: 700;
  z-index: 1;
}

.day-list-item.conflict {
  background: rgba(208,2,27,0.04);
  border-left: 3px solid var(--danger);
}

.day-list-color.conflict {
  box-shadow: 0 0 6px 1px rgba(208,2,27,0.5);
}

.conflict-warning {
  background: rgba(208,2,27,0.08);
  border: 1px solid rgba(208,2,27,0.2);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 8px;
}

.conflict-warning-list {
  background: rgba(208,2,27,0.06);
  border: 1px solid rgba(208,2,27,0.2);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 4px;
}

.conflict-warning-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  margin-bottom: 8px;
}

.conflict-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(208,2,27,0.1);
}

.conflict-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.conflict-item-color {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.conflict-item-info {
  flex: 1;
  min-width: 0;
}

.conflict-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--danger);
}

.conflict-item-meta {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

.plan-timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.plan-period {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.plan-period-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.plan-period-header.morning { background: linear-gradient(135deg, #FFF3E0, #FFE0B2); color: #E65100; }
.plan-period-header.afternoon { background: linear-gradient(135deg, #E3F2FD, #BBDEFB); color: #1565C0; }
.plan-period-header.evening { background: linear-gradient(135deg, #F3E5F5, #E1BEE7); color: #6A1B9A; }

.plan-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  gap: 10px;
}

.plan-item.completed { opacity: 0.5; }
.plan-item.completed .plan-item-title { text-decoration: line-through; }

.plan-checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  touch-action: manipulation;
}

.plan-checkbox:hover { border-color: var(--primary); }
.plan-checkbox.checked { background: var(--success); border-color: var(--success); }
.plan-checkbox.checked::after { content: '\2713'; color: white; font-size: 12px; font-weight: 700; }

.plan-item-title { font-size: 14px; font-weight: 500; flex: 1; min-width: 0; word-break: break-word; }
.plan-item-desc { font-size: 12px; color: var(--text-light); }

.plan-item .badge-tentative { margin-left: 4px; }

.material-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  transition: all 0.2s;
}

.material-card:hover { box-shadow: var(--shadow-lg); }
.material-card.favorite { border-left-color: var(--warning); }

.material-card-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; word-break: break-word; }
.material-card-meta { font-size: 12px; color: var(--text-light); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.material-card-actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.url-warning {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.todo-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  touch-action: manipulation;
}

.todo-checkbox:hover { border-color: var(--primary); }
.todo-checkbox.checked { background: var(--success); border-color: var(--success); }
.todo-checkbox.checked::after { content: '\2713'; color: white; font-size: 11px; font-weight: 700; }

.list-item.completed .list-item-title { text-decoration: line-through; color: var(--text-light); }

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 1;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header.tentative {
  border-bottom: 2px dashed var(--warning);
  background: rgba(245,166,35,0.05);
}

.modal-title { font-size: 16px; font-weight: 600; }

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  font-size: 22px;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: manipulation;
}

.modal-close:hover { background: #F0F0F0; }

.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
}

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 40px);
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: white;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 320px;
  word-break: break-word;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.status-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.status-toggle-btn {
  padding: 6px 14px;
  border: none;
  background: var(--card-bg);
  color: var(--text-light);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  touch-action: manipulation;
}

.status-toggle-btn.active-confirmed { background: var(--success); color: white; }
.status-toggle-btn.active-tentative { background: var(--warning); color: white; }

/* ====== Responsive: Tablet (max-width: 1024px) ====== */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .materials-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

/* ====== Responsive: Mobile (max-width: 768px) ====== */
@media (max-width: 768px) {
  html { font-size: 17px; }

  .app-header {
    padding: 10px 16px;
    position: relative;
  }

  .app-title { font-size: 18px; }
  .app-subtitle { display: none; }
  .header-date { font-size: 14px; }

  .app-nav {
    top: 0;
    padding: 0 8px;
  }

  .nav-btn {
    padding: 10px 14px;
    font-size: 15px;
  }

  .app-main {
    padding: 12px;
  }

  .card {
    padding: 16px;
    border-radius: var(--radius);
  }

  .card-title { font-size: 17px; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 14px 10px;
  }

  .stat-value { font-size: 24px; }
  .stat-label { font-size: 13px; }

  /* Week grid -> day list on mobile */
  .week-grid { display: none !important; }
  .day-list { display: block !important; }

  .day-list-name { font-size: 16px; }
  .day-list-meta { font-size: 14px; }

  .toolbar {
    gap: 6px;
    margin-bottom: 12px;
  }

  .toolbar select,
  .toolbar input {
    font-size: 16px;
    min-height: 40px;
  }

  .toolbar-right {
    width: 100%;
    justify-content: flex-end;
    margin-left: 0;
  }

  .materials-grid {
    grid-template-columns: 1fr;
  }

  .material-card-title { font-size: 16px; }
  .material-card-meta { font-size: 14px; }
  .material-card-actions {
    flex-wrap: wrap;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-label { font-size: 15px; }

  select, input[type="text"], input[type="date"], input[type="time"], input[type="url"], textarea {
    font-size: 16px;
    padding: 10px 14px;
  }

  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: slideUp 0.25s ease;
  }

  .modal-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .modal-title { font-size: 18px; }
  .modal-body { padding: 16px; }

  .modal-footer {
    padding: 12px 16px;
  }

  .list-item {
    padding: 12px 14px;
    gap: 10px;
  }

  .list-item-title { font-size: 16px; }
  .list-item-sub { font-size: 14px; }

  .plan-item {
    padding: 12px 14px;
  }

  .plan-item-title { font-size: 16px; }
  .plan-item-desc { font-size: 14px; }

  .btn {
    min-height: 40px;
    font-size: 15px;
  }

  .btn-sm { font-size: 14px; }

  .todo-checkbox {
    width: 24px;
    height: 24px;
  }

  .plan-checkbox {
    width: 26px;
    height: 26px;
  }

  .badge { font-size: 12px; padding: 3px 10px; }

  .toast-container {
    top: auto;
    bottom: 20px;
    right: 12px;
    left: 12px;
    align-items: center;
  }

  .toast {
    max-width: 100%;
    width: 100%;
    text-align: center;
    font-size: 15px;
  }

  .empty-state p { font-size: 16px; }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

/* ====== Responsive: Small Mobile (max-width: 480px) ====== */
@media (max-width: 480px) {
  html { font-size: 18px; }

  .app-header { padding: 8px 12px; }
  .app-title { font-size: 16px; }
  .header-date { font-size: 13px; }

  .nav-btn {
    padding: 9px 10px;
    font-size: 14px;
  }

  .app-main { padding: 8px; }

  .card {
    padding: 12px;
    margin-bottom: 10px;
  }

  .card-title {
    font-size: 16px;
    margin-bottom: 12px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .stat-card { padding: 10px 6px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 12px; }

  .toolbar {
    gap: 4px;
  }

  .toolbar select,
  .toolbar input {
    font-size: 16px;
    flex: 1;
    min-width: 0;
  }

  .toolbar-right {
    gap: 6px;
  }

  .day-list-item {
    padding: 10px 12px;
  }

  .list-item-title { font-size: 15px; }
  .list-item-sub { font-size: 13px; }
  .plan-item-title { font-size: 15px; }
  .plan-item-desc { font-size: 13px; }
}

/* ====== Responsive: Large Desktop (min-width: 1400px) ====== */
@media (min-width: 1400px) {
  .app-main {
    max-width: 1320px;
    padding: 24px;
  }

  .stats-grid {
    gap: 16px;
  }

  .stat-value { font-size: 32px; }

  .materials-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

/* ====== Auth overlay ====== */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.auth-logo {
  font-size: 48px;
  margin-bottom: 16px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.auth-desc {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 24px;
}

.auth-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 8px;
  justify-content: center;
}

.auth-reset-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-light);
  font-size: 13px;
  margin-top: 4px;
}

.auth-reset-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.auth-card .form-group {
  text-align: left;
}

.auth-card .form-group input {
  width: 100%;
  font-size: 15px;
  padding: 10px 14px;
}

#authError {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

@media (max-width: 480px) {
  .auth-card {
    padding: 32px 20px;
  }
  .auth-title { font-size: 18px; }
}

/* ====== Print styles ====== */
@media print {
  .app-header,
  .app-nav,
  .toolbar,
  .modal-overlay,
  .toast-container,
  .btn,
  .todo-checkbox,
  .plan-checkbox { display: none !important; }

  .app-main { padding: 0; max-width: 100%; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}
