:root {
  --color-primary: #4A90D9;
  --color-primary-dark: #357ABD;
  --color-primary-light: #6BA3E0;
  --color-danger: #e74c3c;
  --color-success: #27ae60;
  --color-warning: #f39c12;
  --color-text: #2c3e50;
  --color-text-light: #7f8c8d;
  --color-bg: #f0f4f8;
  --color-white: #ffffff;
  --color-border: #dce1e8;
  --color-nav: #2c3e50;
  --color-nav-hover: #34495e;
  --color-nav-active: #4A90D9;

  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-size-sm: 0.8125rem;
  --font-size-base: 0.9375rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-xxl: 1.75rem;

  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(44, 62, 80, 0.08);
  --shadow-lg: 0 4px 20px rgba(44, 62, 80, 0.12);
}

.dark {
  --color-primary: #5aa0e9;
  --color-primary-dark: #4a90d9;
  --color-primary-light: #7ab8f0;
  --color-danger: #ef4444;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-text: #e2e8f0;
  --color-text-light: #94a3b8;
  --color-bg: #0f172a;
  --color-white: #1e293b;
  --color-border: #334155;
  --color-nav: #0f172a;
  --color-nav-hover: #1e293b;
  --color-nav-active: #4A90D9;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  padding-bottom: 80px;
  transition: background 0.3s ease, color 0.3s ease;
}

#main-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--color-nav);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
}

.nav-btn {
  flex: 1;
  padding: var(--spacing-md) var(--spacing-sm);
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-btn:hover {
  background: var(--color-nav-hover);
  color: rgba(255, 255, 255, 0.9);
}

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

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--spacing-lg);
}

.section {
  display: none;
}

.section.active {
  display: block;
  animation: slideIn 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

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

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

h1 {
  font-size: var(--font-size-xxl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--spacing-xs);
}

.section-desc {
  color: var(--color-text-light);
  margin-bottom: var(--spacing-lg);
  font-size: var(--font-size-base);
}

.card {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.card-header {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 2px solid var(--color-bg);
  transition: border-color 0.3s ease;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
  color: var(--color-text);
  font-size: var(--font-size-sm);
}

input[type="text"],
input[type="date"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-white);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.3s ease, color 0.3s ease;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

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

.form-group {
  margin-bottom: var(--spacing-md);
}

.form-row {
  display: flex;
  gap: var(--spacing-md);
}

.form-row .form-group {
  flex: 1;
}

#packing-result {
  margin-top: var(--spacing-lg);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

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

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

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

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

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

.btn-outline {
  background: transparent;
  color: var(--color-text-light);
  border: 1.5px solid var(--color-border);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: var(--font-size-sm);
}

.btn-group {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
  flex-wrap: wrap;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-weight: 400;
  cursor: pointer;
  padding: var(--spacing-sm);
  border-radius: var(--radius-sm);
  transition: background 0.2s, opacity 0.25s ease;
}

.checkbox-label:hover {
  background: var(--color-bg);
}

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

.list {
  list-style: none;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.list-item:last-child {
  border-bottom: none;
}

.list-item-content {
  flex: 1;
}

.list-item-title {
  font-weight: 600;
  font-size: var(--font-size-base);
}

.list-item-sub {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
}

.empty-state {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--color-text-light);
}

.settings-form {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

.list-item-actions {
  display: flex;
  gap: var(--spacing-xs);
  flex-shrink: 0;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--color-bg);
  border-radius: 12px;
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
  line-height: 1.5;
}

.tag-sm {
  padding: 1px 6px;
  font-size: 0.75rem;
}

.packing-progress-live {
  margin-bottom: var(--spacing-md);
}

.packing-category-list {
  display: flex;
  flex-direction: column;
}

.packing-item {
  order: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.packing-item.packed {
  order: 1;
  opacity: 0.55;
}

.packing-item.packed span {
  text-decoration: line-through;
}

#toast-container {
  position: fixed;
  bottom: 88px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--color-text);
  color: var(--color-white);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: auto;
  max-width: 280px;
}

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

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

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-border);
  transition: 0.3s;
  border-radius: 26px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: var(--color-primary);
}

.switch input:checked + .slider:before {
  transform: translateX(22px);
}

.auto-save-status {
  transition: opacity 0.3s ease;
}

.auto-save-status.visible {
  display: block !important;
}

@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }

  #main-nav {
    position: static;
    justify-content: center;
    background: var(--color-white);
    box-shadow: 0 2px 12px rgba(44, 62, 80, 0.08);
    border-bottom: 1px solid var(--color-border);
    transition: background 0.3s ease;
  }

  .nav-btn {
    flex: 0 1 auto;
    padding: var(--spacing-md) var(--spacing-xl);
    color: var(--color-text-light);
    text-transform: none;
    letter-spacing: normal;
    font-size: var(--font-size-base);
    border-bottom: 3px solid transparent;
  }

  .nav-btn:hover {
    background: transparent;
    color: var(--color-text);
    border-bottom-color: var(--color-border);
  }

  .nav-btn.active {
    background: transparent;
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
  }

  #app {
    padding: var(--spacing-xl);
  }

  #toast-container {
    bottom: 24px;
  }
}

.history-card {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.3s ease;
  position: relative;
}

.history-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-xs);
}

.history-card-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
}

.history-card-arrow {
  font-size: var(--font-size-xl);
  color: var(--color-primary);
  font-weight: 700;
  line-height: 1;
}

.history-card-meta {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
  margin-bottom: var(--spacing-sm);
}

.history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--spacing-sm);
}

.history-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.4;
}

.history-tag--type {
  background: #e8f0fe;
  color: #1a56db;
}

.history-tag--transport {
  background: #f3e8ff;
  color: #7c3aed;
}

.history-tag--package {
  background: #ecfdf5;
  color: #059669;
}

.history-tag--weather {
  background: #fff7ed;
  color: #ea580c;
}

.dark .history-tag--type { background: #1e3a5f; color: #93c5fd; }
.dark .history-tag--transport { background: #2e1065; color: #c4b5fd; }
.dark .history-tag--package { background: #064e3b; color: #6ee7b7; }
.dark .history-tag--weather { background: #431407; color: #fdba74; }

.history-progress {
  margin-bottom: var(--spacing-sm);
}

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

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

.history-progress-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
  margin-top: 2px;
}

.history-card-actions {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
  padding-top: var(--spacing-sm);
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}

@media print {
  @page {
    margin: 6mm;
    size: auto;
  }

  #main-nav,
  .btn-group,
  .btn,
  #toast-container,
  #add-item-card,
  .packing-progress-live,
  .auto-save-status {
    display: none !important;
  }

  body {
    padding: 0;
    background: white;
    font-size: 10pt;
    line-height: 1.25;
    color: #000;
  }

  #app {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .section {
    display: none !important;
  }

  .section.active {
    display: block !important;
  }

  h1 {
    font-size: 14pt;
    margin-bottom: 4px;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    padding: 4px 6px;
    margin-bottom: 4px;
    break-inside: avoid;
    border-radius: 4px;
  }

  .card-header {
    font-size: 11pt;
    margin-bottom: 2px;
    padding-bottom: 2px;
    border-bottom: 1px solid #ddd;
  }

  .packing-item {
    padding: 1px 0;
    font-size: 9.5pt;
    gap: 4px;
  }

  .packing-item span {
    font-size: 9.5pt;
  }

  input[type="checkbox"] {
    width: 12px;
    height: 12px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #packing-list-items {
    columns: 2;
    column-gap: 10px;
  }

  #packing-list-items .card {
    break-inside: avoid;
    margin-bottom: 4px;
  }

  .list-item {
    padding: 2px 0;
  }

  .list-item-title {
    font-size: 10pt;
  }

  .list-item-sub {
    font-size: 8.5pt;
  }
}
