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

:root {
  --bg: #FFF8F0;
  --bg-card: #FFFFFF;
  --primary: #E8734A;
  --primary-hover: #D4613A;
  --text: #3D3229;
  --text-light: #8A7B6B;
  --border: #E8DDD0;
  --success: #5CB85C;
  --pending: #F0AD4E;
  --danger: #D9534F;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(61, 50, 41, 0.08);
}

body {
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Header */
header {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(232, 115, 74, 0.3);
  max-width: 100%;
}

@media (min-width: 640px) {
  header {
    padding: 16px calc((100% - 600px) / 2 + 20px);
  }
}

header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

header .back-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  line-height: 1;
}

header .back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

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

.header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* Main content */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}

/* Unlock screen */
.unlock-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 20px;
  text-align: center;
}

.unlock-screen h2 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

.unlock-screen p {
  color: var(--text-light);
  max-width: 300px;
}

.unlock-screen input {
  width: 100%;
  max-width: 300px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

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

.unlock-error {
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

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

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

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

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

.btn-danger:hover {
  background: #C9302C;
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  padding: 8px 16px;
}

.btn-ghost:hover {
  background: rgba(232, 115, 74, 0.1);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Fab button */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(232, 115, 74, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(232, 115, 74, 0.5);
}

/* Filter bar */
.filter-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-light);
  user-select: none;
}

.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-switch.active {
  background: var(--primary);
}

.toggle-switch.active::after {
  transform: translateX(16px);
}

/* List cards */
.list-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid var(--border);
}

.list-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(61, 50, 41, 0.12);
}

.list-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.list-card .meta {
  font-size: 0.8rem;
  color: var(--text-light);
  display: flex;
  gap: 12px;
  align-items: center;
}

.print-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.print-badge.printed {
  background: rgba(92, 184, 92, 0.15);
  color: var(--success);
}

.print-badge.pending {
  background: rgba(240, 173, 78, 0.15);
  color: var(--pending);
}

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

.empty-state .emoji {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 1.1rem;
}

/* Type badge (home view) */
.type-badge.note {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: rgba(100, 149, 237, 0.15);
  color: #4A7BD4;
  margin-right: 6px;
  vertical-align: middle;
}

/* Type toggle bar */
.type-toggle-bar {
  display: flex;
  margin-bottom: 16px;
}

/* Note textarea */
.note-textarea {
  width: 100%;
  min-height: 300px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  outline: none;
  resize: vertical;
  transition: border-color 0.2s;
  margin-bottom: 24px;
  line-height: 1.6;
}

.note-textarea:focus {
  border-color: var(--primary);
}

/* List detail */
.list-title-input {
  width: 100%;
  font-size: 1.5rem;
  font-weight: 800;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 8px 0;
  margin-bottom: 16px;
  border-bottom: 2px solid transparent;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.list-title-input:focus {
  border-bottom-color: var(--primary);
}

/* Items */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  transition: background 0.15s;
}

.item-row.checked {
  opacity: 0.55;
}

.item-row.checked .item-text {
  text-decoration: line-through;
}

.item-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  font-size: 0.8rem;
  color: white;
}

.item-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
}

.item-text {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  padding: 2px 0;
}

.item-delete {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

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

.item-delete:hover {
  color: var(--danger);
}

/* Add item input */
.add-item-row {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.add-item-row input {
  flex: 1;
  padding: 12px 16px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  background: transparent;
  transition: border-color 0.2s;
}

.add-item-row input:focus {
  border-color: var(--primary);
  border-style: solid;
}

/* List actions */
.list-actions {
  display: flex;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* Print queue */
.queue-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.queue-item h4 {
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.queue-remove-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.queue-remove-btn:hover {
  color: var(--danger);
  background: rgba(217, 83, 79, 0.1);
}

.queue-item .items-preview {
  color: var(--text-light);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.queue-item .queue-meta {
  font-size: 0.8rem;
  color: var(--text-light);
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot.pending {
  background: var(--pending);
}

.status-dot.printed {
  background: var(--success);
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
  color: var(--text-light);
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 200;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

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

/* Modal / confirm dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  animation: fadeIn 0.15s ease;
}

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

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.modal h3 {
  margin-bottom: 12px;
  font-size: 1.2rem;
}

.modal p {
  color: var(--text-light);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

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

/* Responsive */
@media (max-width: 480px) {
  main {
    padding: 14px;
  }

  header {
    padding: 14px 16px;
  }

  .item-delete {
    opacity: 1;
  }
}
