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

[hidden] { display: none !important; }

:root {
  --bg: #1a1f14;
  --surface: #252b1e;
  --border: #3a4530;
  --text: #d8e8c8;
  --text-dim: #7a9060;
  --accent: #6abf54;
  --accent2: #f5c842;
  --danger: #e05555;
  --tab-h: 56px;
  --tray-h: 90px;
}

html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; }

.tab-bar {
  display: flex;
  height: var(--tab-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.15s;
}
.tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); }

main {
  position: fixed;
  top: var(--tab-h);
  bottom: 0; left: 0; right: 0;
  overflow: hidden;
}

.view { position: absolute; inset: 0; overflow: hidden; }

/* Scanner */
#scanner-container { width: 100%; height: 100%; background: #000; position: relative; }
#scanner-container video { width: 100%; height: 100%; object-fit: cover; }
#scanner-container.flash::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(255,255,255,0.4); animation: flash 0.3s ease-out;
}
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
#scan-result {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--surface); padding: 16px;
  border-top: 1px solid var(--border);
}
.scan-result-svg { width: 80px; height: 80px; display: inline-block; }
.scan-result-svg svg { width: 100%; height: 100%; }
.scan-result-name { font-size: 1.1rem; font-weight: 600; margin-top: 8px; }
.scan-result-type { font-size: 0.8rem; color: var(--text-dim); text-transform: capitalize; }
.scan-result-status.new { color: var(--accent); }
.scan-result-status.duplicate { color: var(--text-dim); }
.btn-dismiss {
  margin-top: 12px; padding: 8px 20px;
  background: var(--accent); color: #000; border: none;
  border-radius: 20px; cursor: pointer; font-weight: 600;
}
.error-state { padding: 32px; text-align: center; color: var(--text-dim); }
.error-state button { margin-top: 12px; padding: 8px 20px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 20px; cursor: pointer; }

/* Inventory */
.inventory-controls { display: flex; gap: 8px; padding: 10px; background: var(--surface); border-bottom: 1px solid var(--border); }
#inventory-search { flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 6px 10px; border-radius: 6px; font-size: 0.9rem; }
#inventory-filter { background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 6px 8px; border-radius: 6px; font-size: 0.9rem; }
#inventory-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px; overflow-y: auto; height: calc(100% - 50px); }
.inventory-cell { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px; text-align: center; cursor: pointer; }
.inventory-cell svg { width: 100%; aspect-ratio: 1; }
.inventory-cell-name { font-size: 0.65rem; color: var(--text-dim); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#item-detail { position: absolute; inset: 0; background: var(--bg); padding: 20px; overflow-y: auto; }
.detail-svg { width: 140px; height: 140px; margin: 0 auto 16px; display: block; }
.detail-svg svg { width: 100%; height: 100%; }
.detail-name { font-size: 1.3rem; font-weight: 700; text-align: center; }
.detail-type { text-align: center; color: var(--text-dim); text-transform: capitalize; margin-bottom: 16px; }
.detail-actions { display: flex; gap: 8px; justify-content: center; }
.btn-place { padding: 10px 24px; background: var(--accent); color: #000; border: none; border-radius: 20px; font-weight: 600; cursor: pointer; }
.btn-close { padding: 10px 24px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 20px; cursor: pointer; }

/* Garden */
#garden-viewport { position: absolute; top: 0; bottom: var(--tray-h); left: 0; right: 0; overflow: hidden; background: #2a3d1e; cursor: grab; }
#garden-viewport.placing { cursor: crosshair; }
#garden-surface { position: absolute; width: 2000px; height: 2000px; transform-origin: 0 0; }
#garden-plot { position: absolute; pointer-events: none; z-index: 0; }
#garden-plot svg { width: 100%; height: 100%; display: block; }
#garden-items { position: absolute; inset: 0; z-index: 1; }
.garden-item { position: absolute; width: 80px; height: 80px; transform-origin: center; cursor: pointer; }
.garden-item svg { width: 100%; height: 100%; }
.garden-item.selected { outline: 2px solid var(--accent2); border-radius: 4px; }
#item-controls { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 6px 12px; z-index: 10; }
#item-controls button { background: none; border: none; color: var(--text); padding: 4px 8px; cursor: pointer; font-size: 0.85rem; }
#item-controls [data-action="delete"] { color: var(--danger); }
#garden-tray { position: absolute; bottom: 0; left: 0; right: 0; height: var(--tray-h); background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; padding: 8px; overflow-x: auto; }
.tray-item { flex-shrink: 0; width: 64px; height: 64px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 4px; cursor: pointer; }
.tray-item svg { width: 100%; height: 100%; }
.tray-item.pending { border-color: var(--accent2); box-shadow: 0 0 6px var(--accent2); }
.tray-empty { color: var(--text-dim); font-size: 0.85rem; padding: 8px; }
#save-indicator { position: absolute; top: 8px; right: 8px; background: var(--surface); color: var(--text-dim); font-size: 0.75rem; padding: 4px 8px; border-radius: 10px; z-index: 10; }
