* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: 12px;
  overflow-x: hidden;
  overflow-wrap: break-word;
}

/* ─── Auth Screen ─── */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-card {
  background: white;
  border-radius: 18px;
  padding: 36px 28px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.auth-card h1, .auth-card h2 {
  font-size: 1.6rem;
  margin-bottom: 4px;
}
.auth-card h2 { font-size: 1.3rem; }

.auth-sub {
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.auth-close {
  margin-top: 16px;
  font-size: 0.85rem;
}
.auth-close a {
  color: #888;
  text-decoration: none;
  font-weight:500;
}
.auth-close a:hover { color: #4f46e5; }

/* ─── Landing Page ─── */
#landing-screen {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  min-width: 0;
}

.landing-hero {
  text-align: center;
  color: white;
  padding: 48px 16px 40px;
  max-width: 100%;
  min-width: 0;
}

.landing-content h1 {
  font-size: 2.4rem;
  margin-bottom: 8px;
}

.landing-tagline {
  font-size: 1.1rem;
  opacity: 0.95;
  margin-bottom: 6px;
}

.landing-desc {
  font-size: 0.9rem;
  opacity: 0.75;
  margin-bottom: 28px;
}

.landing-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.landing-btn {
  padding: 14px 32px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.2s;
}
.landing-btn:active { opacity: 0.8; }
.landing-btn.primary {
  background: white;
  color: #4f46e5;
}
.landing-btn.secondary {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 2px solid rgba(255,255,255,0.3);
}

/* Features grid */
.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  padding: 0 16px 32px;
  max-width: 100%;
  min-width: 0;
}

.feature-card {
  background: white;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  text-align: center;
}

.feature-icon {
  display: block;
  font-size: 2rem;
  margin-bottom: 8px;
}

.feature-card h3 {
  font-size: 1rem;
  color: #333;
  margin-bottom: 6px;
}

.feature-card p {
  font-size: 0.85rem;
  color: #888;
  line-height: 1.5;
}

/* Auth section on landing */
.auth-section {
  display: flex;
  justify-content: center;
  padding: 0 16px 40px;
}

.landing-footer {
  text-align: center;
  color: rgba(255,255,255,0.5);
  font-size: 0.8rem;
  padding: 16px 0 32px;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#auth-form input {
  padding: 14px 16px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 1rem;
}

#auth-form input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}

.auth-error {
  color: #ef4444;
  font-size: 0.85rem;
  min-height: 1.2em;
  text-align: left;
}

#auth-submit {
  padding: 14px;
  background: #4f46e5;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

#auth-submit:active { opacity: 0.8; }

.auth-links {
  font-size: 0.85rem;
  color: #888;
  margin-top: 4px;
}

.auth-links a {
  color: #4f46e5;
  text-decoration: none;
  font-weight: 600;
}

.auth-sep { color: #ddd; margin: 0 4px; }

.auth-divider {
  display: flex; align-items: center; gap: 12px; margin: 20px 0 12px; color: #ccc; font-size: 0.85rem;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: #eee; }

.demo-btn {
  width: 100%; padding: 14px; background: white; color: #4f46e5; border: 2px solid #4f46e5;
  border-radius: 10px; font-size: 1rem; font-weight: 600; cursor: pointer; touch-action: manipulation;
}
.demo-btn:active { background: #f5f3ff; }

#password-field-group { position: relative; }
#forgot-link { font-size: 0.8rem; }

/* ─── Header ─── */
.container { width: 100%; max-width: 100%; display: flex; flex-direction: column; gap: 14px; }

header { color: white; }

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

header h1 { font-size: 1.4rem; }

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}

.plan-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  letter-spacing: 0.5px;
}

.plan-badge.free { background: #6b7280; color: white; }
.plan-badge.premium { background: #f59e0b; color: white; }

.user-email {
  font-size: 0.8rem;
  opacity: 0;
  overflow: hidden;
  max-width: 0;
  transition: all 0.3s;
}

@media (min-width: 400px) {
  .user-email {
    opacity: 0.85;
    max-width: 200px;
  }
}

.login-btn {
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.3);
  color: white;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  touch-action: manipulation;
  transition: background 0.2s;
}

.login-btn:active { background: rgba(255,255,255,0.3); }

.logout-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  touch-action: manipulation;
}

.logout-btn:active { background: rgba(255,255,255,0.3); }

header p {
  opacity: 0.85;
  font-size: 0.85rem;
  margin-top: 2px;
}

/* ─── Cards ─── */
.card {
  background: white;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  min-width: 0;
  overflow-wrap: break-word;
}

.card h2 { font-size: 1.05rem; color: #333; margin-bottom: 14px; }

/* ─── Premium lock ─── */
.lock-overlay {
  position: relative;
}

.lock-overlay::after {
  content: '🔒 Premium';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: #888;
  border-radius: 10px;
  cursor: pointer;
  backdrop-filter: blur(2px);
}

/* ─── Onboarding ─── */
.onboarding-card {
  position: relative;
  background: #fef3c7;
  border: 1px solid #fde68a;
  text-align: center;
}

.onboarding-dismiss {
  position: absolute; top: 8px; right: 12px; background: none; border: none;
  font-size: 1.1rem; cursor: pointer; color: #b45309; padding: 4px;
}

.onboarding-text {
  font-size: 0.85rem; color: #92400e; margin-top: 4px; line-height: 1.5;
}

/* ─── Timer Custom Durations ─── */
.timer-duration-editor {
  display: flex; gap: 6px; align-items: center; justify-content: center;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid #f0f0f0;
  flex-wrap: wrap;
}

.timer-duration-editor input {
  width: 48px; padding: 6px 4px; border: 1px solid #ddd; border-radius: 6px;
  text-align: center; font-size: 0.8rem;
}

.timer-duration-editor label {
  font-size: 0.72rem; color: #888; margin-right: 4px;
}

.timer-duration-editor button {
  padding: 6px 14px; background: #4f46e5; color: white; border: none;
  border-radius: 6px; cursor: pointer; font-size: 0.8rem; font-weight: 600;
}

.mode-duration { font-weight: 700; }

/* ─── Timer ─── */
.timer-display {
  font-size: 3.2rem;
  font-weight: 700;
  text-align: center;
  color: #4f46e5;
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
  letter-spacing: 2px;
}

.timer-controls { display: flex; gap: 10px; justify-content: center; margin-bottom: 14px; }

.timer-controls button {
  flex: 1; max-width: 110px; padding: 12px 0; border: none; border-radius: 10px;
  font-size: 0.95rem; cursor: pointer; font-weight: 600; transition: opacity 0.2s; touch-action: manipulation;
}

.timer-controls button:active { opacity: 0.7; }
.timer-controls button:focus-visible { outline: 2px solid #4f46e5; outline-offset: 2px; }

#timer-start { background: #4f46e5; color: white; }
#timer-pause { background: #f59e0b; color: white; }
#timer-reset { background: #6b7280; color: white; }

.timer-mode { display: flex; gap: 6px; }

.mode-btn {
  flex: 1; padding: 10px 4px; border: 1px solid #ddd; border-radius: 8px;
  background: white; cursor: pointer; font-size: 0.78rem; font-weight: 500;
  transition: all 0.2s; touch-action: manipulation; text-align: center;
}

.mode-btn.active { background: #4f46e5; color: white; border-color: #4f46e5; }
.mode-btn:focus-visible { outline: 2px solid #4f46e5; outline-offset: 2px; }

.status-text { text-align: center; color: #888; font-size: 0.85rem; margin-top: 10px; min-height: 1.3em; }

/* ─── Tasks ─── */
#todo-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

#todo-input {
  flex: 1 1 100%; padding: 12px 14px; border: 1px solid #ddd; border-radius: 10px; font-size: 1rem;
  max-width: 100%;
  min-width: 0;
}

#todo-input:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.15); }

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

.form-row select {
  flex: 1; padding: 10px 8px; border: 1px solid #ddd; border-radius: 10px;
  font-size: 0.9rem; background: white; min-height: 44px; touch-action: manipulation;
  max-width: 100%;
  min-width: 0;
}

#todo-form button {
  padding: 10px 20px; background: #4f46e5; color: white; border: none; border-radius: 10px;
  cursor: pointer; font-weight: 600; font-size: 0.95rem; min-height: 44px; touch-action: manipulation;
}
#todo-form button:active { opacity: 0.8; }

.subject-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; min-width: 0; max-width: 100%; }

.manage-btn {
  flex-shrink: 0; width: 36px; height: 36px; border: 1px solid #ddd; border-radius: 50%;
  background: white; cursor: pointer; font-size: 1rem; display: flex; align-items: center;
  justify-content: center; transition: all 0.2s; touch-action: manipulation;
}
.manage-btn:active { background: #f0f0f0; }

.filter-bar { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; max-width: 100%; }
.filter-bar::-webkit-scrollbar { display: none; }

.filter-btn {
  flex-shrink: 0; padding: 8px 16px; border: 1px solid #ddd; border-radius: 20px;
  background: white; cursor: pointer; font-size: 0.82rem; font-weight: 500;
  transition: all 0.2s; touch-action: manipulation;
}
.filter-btn.active { background: #4f46e5; color: white; border-color: #4f46e5; }

/* ─── Sounds ─── */
.sounds-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; min-width: 0; }

.sound-btn {
  flex: 1; min-width: 70px; padding: 10px 8px; border: 1px solid #ddd; border-radius: 10px;
  background: white; cursor: pointer; font-size: 0.82rem; font-weight: 500;
  transition: all 0.2s; touch-action: manipulation; text-align: center; line-height: 1.3;
}
.sound-btn:active { transform: scale(0.96); }
.sound-btn.active { background: #4f46e5; color: white; border-color: #4f46e5; }
.sound-btn.locked { opacity: 0.5; cursor: default; }
.sound-btn .sound-icon { display: block; font-size: 1.3rem; margin-bottom: 2px; }

.sound-upload { border-top: 1px solid #f0f0f0; padding-top: 12px; }
.upload-label { font-size: 0.85rem; color: #888; display: block; margin-bottom: 8px; }
.file-input { display: block; margin-top: 4px; font-size: 0.85rem; width: 100%; max-width: 100%; }
#music-player { width: 100%; margin-top: 8px; border-radius: 8px; height: 44px; }

/* ─── Subjects ─── */
#subject-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

.subject-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; background: #f9f9f9; border-radius: 8px;
}
.subject-row .name { font-size: 0.9rem; font-weight: 500; }

.subject-row .remove-subject {
  background: none; border: none; color: #ccc; font-size: 1rem;
  cursor: pointer; padding: 4px 10px; border-radius: 6px; touch-action: manipulation;
}
.subject-row .remove-subject:active { background: #fee2e2; color: #ef4444; }

.add-subject-row { display: flex; gap: 8px; }
.add-subject-row input {
  flex: 1; padding: 10px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.9rem;
}
.add-subject-row input:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.15); }
.add-subject-row button {
  padding: 10px 18px; background: #4f46e5; color: white; border: none;
  border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.9rem; touch-action: manipulation;
}
.add-subject-row button:active { opacity: 0.8; }

/* ─── Upgrade ─── */
.upgrade-card { text-align: center; }
.upgrade-card h2 { color: #f59e0b; }
.upgrade-desc { color: #888; font-size: 0.9rem; margin-bottom: 16px; }

.perks { list-style: none; text-align: left; margin-bottom: 20px; display: inline-block; }
.perks li { padding: 6px 0; font-size: 0.9rem; border: none; min-height: 0; }

.upgrade-btn {
  width: 100%; padding: 14px; background: #f59e0b; color: white; border: none;
  border-radius: 10px; font-size: 1rem; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.upgrade-btn:active { opacity: 0.8; }

.dismiss-btn {
  margin-top: 10px; background: none; border: none; color: #aaa;
  font-size: 0.85rem; cursor: pointer; padding: 8px; touch-action: manipulation;
}

/* ─── List ─── */
ul { list-style: none; max-width: 100%; }

li {
  display: flex; align-items: center; gap: 8px; padding: 12px 0;
  border-bottom: 1px solid #f0f0f0; min-height: 48px; max-width: 100%;
}
li:last-child { border-bottom: none; }

.priority-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.priority-dot.high { background: #ef4444; }
.priority-dot.medium { background: #eab308; }
.priority-dot.low { background: #22c55e; }

.subject-badge { font-size: 0.7rem; padding: 3px 10px; border-radius: 10px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }

.subject-badge.Math { background: #dbeafe; color: #1d4ed8; }
.subject-badge.Science { background: #dcfce7; color: #15803d; }
.subject-badge.English { background: #fce7f3; color: #be185d; }
.subject-badge.History { background: #fef3c7; color: #b45309; }
.subject-badge.Other { background: #f3e8ff; color: #7c3aed; }

.task-text { flex: 1; cursor: pointer; font-size: 0.92rem; line-height: 1.4; padding: 4px 0; word-break: break-word; }
.task-text.done { text-decoration: line-through; color: #aaa; }

.delete-btn {
  background: none; border: none; color: #ccc; cursor: pointer; font-size: 1.1rem;
  padding: 8px 10px; touch-action: manipulation; border-radius: 8px; transition: all 0.2s;
}
.delete-btn:active { background: #fee2e2; color: #ef4444; }

.empty-msg { color: #aaa; text-align: center; padding: 24px 0; font-size: 0.9rem; }

/* ─── Stats ─── */
.stats-grid { display: flex; justify-content: space-around; text-align: center; gap: 8px; }
.stat { flex: 1; padding: 4px; }
.stat-value { display: block; font-size: 1.6rem; font-weight: 700; color: #4f46e5; }
.stat-label { display: block; font-size: 0.78rem; color: #888; margin-top: 2px; }

.export-btn {
  margin-top: 14px; width: 100%; padding: 10px; background: #f3f4f6;
  border: 1px solid #e5e7eb; border-radius: 8px; cursor: pointer; font-size: 0.85rem;
  font-weight: 500; color: #555; transition: all 0.2s; touch-action: manipulation;
}
.export-btn:active { background: #e5e7eb; }

/* ─── Ads ─── */
.ad-container {
  width: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  max-width: 100%;
}

/* ─── Quote ─── */
.quote-card { text-align: center; background: rgba(255,255,255,0.95); }
#quote-text { font-style: italic; font-size: 0.92rem; color: #555; line-height: 1.5; }
#quote-author { font-size: 0.8rem; color: #999; margin-top: 6px; }

/* ─── Footer ─── */
footer {
  text-align: center;
  color: rgba(255,255,255,0.6);
  font-size: 0.8rem;
  padding: 8px 0 4px;
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
  body { padding: 10px; }
  .container { gap: 12px; }
  .card { padding: 16px; border-radius: 12px; }
  .card h2 { font-size: 1rem; margin-bottom: 12px; }
  .timer-display { font-size: 2.6rem; }
  .timer-controls button { padding: 14px 0; font-size: 0.9rem; max-width: 100px; }
  .mode-btn { font-size: 0.72rem; padding: 10px 2px; }
  header h1 { font-size: 1.3rem; }
  .stat-value { font-size: 1.4rem; }
  .task-text { font-size: 0.88rem; }
  #todo-input { padding: 14px; }
  .form-row select { font-size: 0.85rem; padding: 10px 6px; }
}

@media (max-width: 360px) {
  body { padding: 6px; }
  .card { padding: 12px; border-radius: 10px; }
  .timer-display { font-size: 2.2rem; }
  .timer-controls { gap: 6px; }
  .timer-controls button { font-size: 0.85rem; padding: 12px 0; }
  .mode-btn { font-size: 0.65rem; padding: 8px 2px; }
  .filter-btn { padding: 6px 12px; font-size: 0.75rem; }
  .stats-grid { flex-direction: column; gap: 4px; }
  .stat { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
  .stat-value { font-size: 1.2rem; }
  .stat-label { font-size: 0.85rem; margin-top: 0; }
  .auth-card { padding: 28px 20px; }
}

@media (min-width: 600px) {
  body { padding: 16px 24px; }
  .container { max-width: 720px; }
}

@media (min-width: 768px) {
  body { padding: 24px 32px; }
  .container {
    max-width: 960px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
  .container header,
  .container .ad-container,
  .container .onboarding-card,
  .container .quote-card,
  .container .subjects-card,
  .container .upgrade-card,
  .container footer {
    grid-column: 1 / -1;
  }
  .card { padding: 24px; }
  .timer-card { grid-column: 1; }
  .todo-card { grid-column: 1; }
  .container .sounds-card { grid-column: 2; }
  .container .stats-card { grid-column: 2; }
  .timer-display { font-size: 3.6rem; }
  .timer-controls button:hover { opacity: 0.85; }
  .delete-btn:hover { color: #ef4444; }
  #timer-start:hover { background: #4338ca; }
  #timer-pause:hover { background: #d97706; }
  #timer-reset:hover { background: #4b5563; }
  #todo-form button:hover { background: #4338ca; }
  .filter-btn:hover { background: #f5f5f5; }
  .filter-btn.active:hover { background: #4338ca; }
  .logout-btn:hover { background: rgba(255,255,255,0.25); }
  .login-btn:hover { background: rgba(255,255,255,0.25); }
  #landing-screen { max-width: 960px; }
  .landing-hero { padding: 64px 16px 48px; }
  .landing-content h1 { font-size: 3rem; }
  .landing-features { grid-template-columns: repeat(3, 1fr); padding: 0 16px 40px; }
}
