/* ===== Reset & Base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Helvetica Neue", sans-serif;
  font-size: 16px;
  overflow-x: hidden;
}
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }

/* ===== Layout ===== */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.view { display: none; flex: 1; flex-direction: column; }
.view.active { display: flex; }

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  gap: 8px;
}
.header-title { font-size: 20px; font-weight: 700; flex: 1; text-align: center; }
.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
}
.primary-btn {
  background: #80004D;
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.primary-btn:active { opacity: 0.7; }

/* ===== Search & Filter ===== */
.search-row {
  display: flex;
  gap: 12px;
  padding: 0 16px 12px;
}
.search-box {
  flex: 1;
  background: #333;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 16px;
  outline: none;
}
.search-box input::placeholder { color: #888; }
.filter-btn {
  width: 44px; height: 44px;
  background: #333;
  border-radius: 8px;
  font-size: 20px;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}

/* ===== Grid ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}
.grid-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cell-image-wrap {
  width: 100%;
  height: 180px;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cell-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: linear-gradient(135deg, #3a3a3a 0%, #1a1a1a 100%);
}
.cell-meta { padding: 0 4px; }
.cell-season { font-weight: 600; font-size: 16px; }
.cell-category { font-size: 14px; color: #888; }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: #666;
  font-size: 15px;
}

/* ===== Detail / Form ===== */
.scroll-content {
  overflow-y: auto;
  flex: 1;
  padding: 16px;
}
.detail-image {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: 12px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #222;
  font-size: 15px;
  gap: 12px;
}
.detail-row .label { color: #888; flex-shrink: 0; }
.detail-row .value { font-weight: 500; text-align: right; word-break: break-word; }

.form-section { margin-bottom: 24px; }
.form-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #1a1a1a;
  border-radius: 8px;
  margin-bottom: 8px;
  gap: 12px;
}
.form-row label {
  color: #ccc;
  font-size: 15px;
  flex-shrink: 0;
}
.form-row input, .form-row select, .form-row textarea {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 16px;
  text-align: right;
  outline: none;
  flex: 1;
  min-width: 0;
}
.form-row select { text-align: right; -webkit-appearance: none; appearance: none; }
.form-row textarea {
  text-align: left;
  resize: vertical;
  min-height: 60px;
}
.form-row.column {
  flex-direction: column;
  align-items: stretch;
}
.form-row.column input, .form-row.column textarea { text-align: left; }
.form-row.column label { margin-bottom: 6px; }

.photo-area {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
}
.photo-area img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
}
.photo-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.photo-button {
  flex: 1;
  min-width: 120px;
  padding: 16px;
  background: #1c2937;
  color: #4ea0ff;
  border-radius: 10px;
  font-size: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.photo-button.green { background: #1c372a; color: #4ed085; }
.photo-button .ico { font-size: 28px; }

.processing {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; color: #aaa; font-size: 14px;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid #444;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.action-btn {
  width: 100%;
  padding: 14px;
  background: #80004D;
  color: #fff;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 8px;
}
.action-btn:disabled { opacity: 0.4; }
.action-btn.danger { background: rgba(255, 50, 50, 0.15); color: #ff5050; }
.action-btn.secondary { background: #2a2a2a; color: #fff; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #1a1a1a;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #2a2a2a;
}
.modal-title { font-size: 17px; font-weight: 600; }
.modal-content {
  overflow-y: auto;
  padding: 16px;
}
.modal-link {
  color: #4ea0ff;
  font-size: 15px;
  background: none;
  padding: 4px 8px;
}
.modal-link.bold { font-weight: 600; }

/* ===== Filter list ===== */
.filter-section { margin-bottom: 16px; }
.filter-section h4 {
  font-size: 13px;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  padding-left: 4px;
}
.chip-row {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.chip {
  padding: 8px 14px;
  background: #2a2a2a;
  border-radius: 16px;
  font-size: 14px;
  color: #ccc;
}
.chip.active {
  background: #80004D;
  color: #fff;
}

/* ===== Category list ===== */
.category-list { list-style: none; }
.category-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #2a2a2a;
  font-size: 16px;
}
.category-list li button {
  color: #888;
  font-size: 14px;
  padding: 4px 8px;
}
.category-list li button.delete { color: #ff5050; }

/* ===== Settings ===== */
.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #1a1a1a;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 15px;
  width: 100%;
  text-align: left;
}
.settings-row .ico { font-size: 18px; width: 24px; text-align: center; }
.settings-note {
  font-size: 13px;
  color: #777;
  padding: 12px 4px;
  line-height: 1.5;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 40, 40, 0.95);
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 1000;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-10px);
}
.toast.error { background: rgba(180, 30, 30, 0.95); }

/* ===== Loading screen ===== */
.loading-screen {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 2000;
  color: #fff;
  text-align: center;
  padding: 20px;
}
.loading-screen .big-spinner {
  width: 40px; height: 40px;
  border: 3px solid #444;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-screen .progress-text {
  font-size: 14px;
  color: #aaa;
}

.hidden { display: none !important; }
