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

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --text: #1d1d1f;
  --text-secondary: #86868b;
  --border: #e5e5ea;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --urgent: #ef4444;
  --important: #f59e0b;
  --low: #22c55e;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

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

.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.screen.hidden {
  display: none;
}

/* ===== Auth Screen ===== */
.auth-container {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

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

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

.auth-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.form-group {
  margin-bottom: 16px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  padding: 13px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

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

.btn-primary:active {
  transform: scale(0.98);
}

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

/* ===== Todo Screen ===== */
.todo-container {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 0 16px;
}

.todo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  margin-bottom: 8px;
}

.header-left h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.title-with-icon {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.count-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  padding: 3px 10px;
  border-radius: 20px;
  margin-top: 4px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.greeting {
  font-size: 14px;
  color: var(--text-secondary);
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}

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

/* ===== Add Form ===== */
.add-form {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.add-form input {
  flex: 1;
  border: none;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  background: transparent;
  border-radius: 8px;
}

.add-form input:focus {
  background: var(--bg);
}

.btn-add {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

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

.btn-add:active {
  transform: scale(0.95);
}

/* Priority Select */
.priority-select {
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

.priority-select:focus {
  border-color: var(--primary);
}

/* ===== Todo List ===== */
.todo-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: all 0.2s;
  animation: slideIn 0.25s ease-out;
  border-left: 4px solid transparent;
}

/* Priority Colors */
.todo-item.priority-urgent {
  border-left-color: var(--urgent);
}

.todo-item.priority-important {
  border-left-color: var(--important);
}

.todo-item.priority-low {
  border-left-color: var(--low);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.todo-item:hover {
  box-shadow: var(--shadow-lg);
}

.todo-item.completed .todo-text {
  text-decoration: line-through;
  color: var(--text-secondary);
}

/* Custom Checkbox */
.todo-checkbox {
  position: relative;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.todo-checkbox input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 1;
}

.todo-checkbox .checkmark {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.todo-checkbox input:checked + .checkmark {
  background: var(--success);
  border-color: var(--success);
}

.todo-checkbox .checkmark svg {
  width: 14px;
  height: 14px;
  stroke: white;
  stroke-width: 3;
  fill: none;
  opacity: 0;
  transform: scale(0);
  transition: all 0.2s;
}

.todo-checkbox input:checked + .checkmark svg {
  opacity: 1;
  transform: scale(1);
}

.todo-text {
  flex: 1;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  word-break: break-word;
}

.todo-delete {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  opacity: 0;
  transition: all 0.2s;
  flex-shrink: 0;
}

.todo-item:hover .todo-delete {
  opacity: 1;
}

.todo-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* Mobile: always show delete button */
@media (hover: none) {
  .todo-delete {
    opacity: 1;
  }
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state.hidden {
  display: none;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

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

.empty-hint {
  font-size: 14px;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
}

.toast.show {
  opacity: 1;
}

.toast.hidden {
  display: none;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .screen {
    padding: 12px;
    align-items: flex-start;
  }

  .auth-container {
    padding: 32px 24px;
  }

  .todo-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 0;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .header-left h1 {
    font-size: 24px;
  }

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

/* ===== History Screen ===== */
.history-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.date-input {
  flex: 1;
  min-width: 140px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.date-input:focus {
  border-color: var(--primary);
}

.btn-secondary {
  padding: 10px 18px;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-secondary:active {
  transform: scale(0.97);
}

.btn-secondary.hidden {
  display: none;
}

.history-stats {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.history-stats.hidden {
  display: none;
}

.stat-item {
  font-size: 14px;
  color: var(--text-secondary);
}

.stat-item strong {
  color: var(--text);
  margin-left: 4px;
}

/* Priority Badge in History */
.priority-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  margin-left: 8px;
  flex-shrink: 0;
}

.priority-badge.urgent {
  background: rgba(239, 68, 68, 0.15);
  color: var(--urgent);
}

.priority-badge.important {
  background: rgba(245, 158, 11, 0.15);
  color: var(--important);
}

.priority-badge.low {
  background: rgba(34, 197, 94, 0.15);
  color: var(--low);
}

/* Priority Change Select in Todo Item */
.priority-change-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--surface);
  color: var(--text-secondary);
  outline: none;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s;
  flex-shrink: 0;
}

.todo-item:hover .priority-change-select {
  opacity: 1;
}

.priority-change-select:focus {
  border-color: var(--primary);
  color: var(--text);
}

@media (hover: none) {
  .priority-change-select {
    opacity: 1;
  }
}

/* Add to today button in history */
.btn-copy {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  opacity: 0;
  transition: all 0.2s;
  flex-shrink: 0;
}

.todo-item:hover .btn-copy {
  opacity: 1;
}

.btn-copy:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
}

@media (hover: none) {
  .btn-copy {
    opacity: 1;
  }
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.modal.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.btn-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.btn-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.url-box {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.url-box input {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-family: monospace;
}

.url-box input:focus {
  border-color: var(--primary);
}

.btn-copy-url {
  padding: 12px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.btn-copy-url:hover {
  background: var(--primary-hover);
}

.btn-copy-url:active {
  transform: scale(0.95);
}

.calendar-tips {
  background: var(--bg);
  border-radius: 8px;
  padding: 16px;
}

.calendar-tips h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--text);
}

.calendar-tips ol {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.calendar-tips li {
  margin-bottom: 4px;
}

.calendar-tips strong {
  color: var(--text);
}
