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

:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #8e8e93;
  --border: #e5e5ea;
  --accent: #007aff;
  --danger: #ff3b30;
  --success: #34c759;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px 32px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 16px 0 12px;
}

.header-top {
  margin-bottom: 12px;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

#global-form {
  display: flex;
  gap: 8px;
  position: relative;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 48px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 20;
  overflow: hidden;
}

.autocomplete-list li {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.95rem;
}

.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: var(--accent);
  color: white;
}

.input-container {
  flex: 1;
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

#global-input {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  position: relative;
  z-index: 1;
}

#global-input:focus {
  outline: none;
}
.input-container:focus-within {
  box-shadow: 0 0 0 2px var(--accent);
}

.input-mirror {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
  display: flex;
  align-items: center;
  color: var(--text);
}
.input-mirror svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
  margin-right: 4px;
}
.input-mirror .dim {
  color: var(--text-secondary);
}
.input-mirror .task-icon {
  margin-left: 6px;
  display: inline-flex;
}
.input-mirror .active svg {
  color: var(--text);
}
.input-mirror .placeholder {
  color: var(--text-secondary);
  font-style: italic;
}

.input-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 4px 14px 0;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 4px;
}
.input-hint svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.input-hint .task-icon {
  margin-left: 4px;
  display: inline-flex;
}

/* Buttons */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-primary:hover { background: #0066d6; }

/* Buckets */
.bucket {
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
}

.bucket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 0;
}

.bucket-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}

.bucket-name-input {
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-bottom: 2px solid var(--accent);
  background: transparent;
  color: var(--text);
  padding: 0 0 2px;
  outline: none;
  width: 100%;
  font-family: inherit;
}

.item-text-input {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.4;
  border: none;
  border-bottom: 2px solid var(--accent);
  background: transparent;
  color: var(--text);
  padding: 0 0 2px;
  outline: none;
  font-family: inherit;
}

.bucket-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.bucket-toggle {
  background: none;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}

.bucket-toggle:hover { background: rgba(0,122,255,0.08); }

.archive-count {
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: -2px;
}

/* Icon buttons */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.15s, background 0.15s;
}

.icon-btn:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text);
}

.icon-btn.danger:hover {
  background: rgba(255,59,48,0.1);
  color: var(--danger);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* Bucket form */
.bucket-form {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
}

.bucket-form input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}

.bucket-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.bucket-form input::placeholder { color: var(--text-secondary); font-style: italic; }

.bucket-form button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.bucket-form button:hover { background: #0066d6; }

.bucket-form button svg {
  width: 16px;
  height: 16px;
}

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

.item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.item .text {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.4;
  cursor: text;
}

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

.item .item-actions {
  display: flex;
  gap: 2px;
  opacity: 0.4;
  transition: opacity 0.15s;
}

.item:hover .item-actions { opacity: 1; }

@media (hover: none) {
  .item .item-actions { opacity: 0.7; }
}

.item.archived {
  opacity: 0.5;
}

/* Empty state */
.empty-bucket {
  padding: 12px 16px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state h2 {
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Nav bar */
.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 12px;
  transition: padding 0.3s ease;
}

.nav-bar.nav-scrolled {
  padding: 4px 0 6px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.8rem;
  transition: font-size 0.3s ease, gap 0.3s ease;
}

.nav-scrolled .nav-logo {
  font-size: 1.1rem;
  gap: 6px;
}

.nav-logo img {
  transition: transform 0.3s ease;
  transform-origin: left center;
}

.nav-scrolled .nav-logo img {
  transform: scale(0.571);
  margin-right: -24px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.nav-icon:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text);
}

.nav-icon svg {
  width: 20px;
  height: 20px;
}

.nav-version {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.05);
}
.nav-version:hover {
  background: rgba(0,0,0,0.1);
}

/* Demo mode banner */
.demo-banner {
  text-align: center;
  padding: 8px 14px;
  background: rgba(0,122,255,0.1);
  color: var(--accent);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.demo-banner a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

/* Deadline banner */
.deadline-banner[hidden] { display: none; }
.deadline-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff3cd;
  color: #856404;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.deadline-banner svg { flex-shrink: 0; color: #856404; }

.deadline-banner.active {
  background: #ffe69c;
}

.deadline-banner:hover {
  background: #ffecb3;
}

.deadline-banner.active:hover {
  background: #ffd54f;
}

/* Deadline badges */
.deadline {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.deadline.overdue {
  background: rgba(255,59,48,0.12);
  color: var(--danger);
  font-weight: 600;
}

.deadline.today {
  background: rgba(255,149,0,0.12);
  color: #ff9500;
  font-weight: 600;
}

.deadline.tomorrow {
  background: rgba(255,204,0,0.12);
  color: #cc8800;
  font-weight: 500;
}

.deadline.soon {
  background: rgba(0,122,255,0.08);
  color: var(--accent);
}

/* Deadline picker - inline overlay on calendar button */
.deadline-btn {
  position: relative;
  cursor: pointer;
}

.deadline-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  -webkit-appearance: none;
}

/* Auth pages (login) */
body.auth-page {
  max-width: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  text-align: center;
}

.auth-card .logo {
  margin-bottom: 16px;
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.auth-card .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

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

.auth-card input[type="email"] {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  text-align: center;
}

.auth-card input[type="email"]:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary-full {
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn-primary-full:hover { background: #0066d6; }

.message {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  background: rgba(52,199,89,0.1);
  color: var(--success);
}

.error-msg {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  background: rgba(255,59,48,0.1);
  color: var(--danger);
}

/* Admin page */
.admin-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.admin-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--card);
  color: var(--text);
}

.admin-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.admin-user {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.admin-user .text-secondary {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(0,122,255,0.1);
  color: var(--accent);
  margin-left: 8px;
}

/* Settings page */
.settings-form {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.settings-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  margin-top: 16px;
}

.settings-form label:first-child { margin-top: 0; }

.settings-form input[type="text"],
.settings-form input[type="email"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}

.settings-form input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.settings-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem !important;
  color: var(--text) !important;
  cursor: pointer;
}
.checkbox-label.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  flex-wrap: wrap;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.coming-soon {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
  width: 100%;
  padding-left: 26px;
}

.settings-form button {
  margin-top: 20px;
  width: 100%;
}

/* Page title for admin/settings */
main h1 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 16px;
}

/* Filter chip */
.filter-chip[hidden] { display: none; }
.filter-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(0,122,255,0.1);
  color: var(--accent);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 500;
}

.filter-chip-close {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
}

.filter-chip-close:hover {
  background: rgba(0,122,255,0.15);
}

/* Drag handle */
.bucket-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drag-handle {
  cursor: grab;
  color: var(--text-secondary);
  opacity: 0.4;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.bucket.sortable-ghost {
  opacity: 0.4;
}

.bucket.sortable-chosen {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* Context icon button */
.context-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.15s, background 0.15s;
}

.context-icon-btn:hover {
  background: rgba(0,0,0,0.05);
  color: var(--accent);
}

.context-icon-btn svg {
  width: 16px;
  height: 16px;
}

/* Context picker popup */
.context-picker {
  position: absolute;
  top: 100%;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 30;
  width: 200px;
  margin-top: 4px;
}

.context-picker-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.context-picker-item svg {
  width: 18px;
  height: 18px;
}

.context-picker-item:hover {
  background: rgba(0,122,255,0.08);
  color: var(--accent);
}

.context-picker-item.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0,122,255,0.08);
}

/* Context filter bar */
.context-filter-bar[hidden] { display: none; }
.context-filter-bar {
  display: flex;
  gap: 6px;
  padding: 8px 0;
  margin-bottom: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.context-filter-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.15s;
}

.context-filter-item svg {
  width: 16px;
  height: 16px;
}

.context-filter-item:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.context-filter-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.context-filter-item.active svg {
  stroke: white;
}

/* Releases page */
.releases-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}
.releases-page h1 {
  margin-bottom: 24px;
}
.release {
  margin-bottom: 32px;
}
.release h2 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}
.release-date {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.release ul {
  padding-left: 20px;
}
.release li {
  margin-bottom: 4px;
  line-height: 1.5;
}

/* Toast notifications */
#toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 360px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  color: white;
  text-align: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
}

.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

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

/* Confirm modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: background 0.2s ease;
}

.modal-overlay.modal-visible {
  background: rgba(0,0,0,0.4);
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 320px;
  text-align: center;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.modal-overlay.modal-visible .modal {
  transform: scale(1);
  opacity: 1;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-message {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.modal-cancel {
  background: var(--bg);
  color: var(--text);
}

.modal-cancel:hover { background: var(--border); }

.modal-confirm {
  background: var(--danger);
  color: white;
}

.modal-confirm:hover { background: #e0332b; }

/* Loading spinner */
.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 48px 0;
}

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

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

/* Item animations */
.item-exit {
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .toast,
  .modal-overlay,
  .modal,
  .item-exit,
  .loading-spinner::after,
  .nav-bar,
  .nav-logo,
  .nav-logo img {
    transition: none !important;
    animation: none !important;
  }

  .toast-visible {
    opacity: 1;
    transform: none;
  }

  .modal-overlay.modal-visible {
    background: rgba(0,0,0,0.4);
  }

  .modal-overlay.modal-visible .modal {
    transform: none;
    opacity: 1;
  }
}
