/* Movelmp — clean, minimal styles. Day/night via [data-theme]. */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f1f1f3;
  --fg: #18181b;
  --fg-muted: #6b7280;
  --border: #e4e4e7;
  --accent: #ed7d31;
  --accent-fg: #ffffff;
  --accent-soft: #fff1e4;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --radius: 10px;
}

[data-theme="dark"] {
  --bg: #0f0f10;
  --surface: #1c1c20;
  --surface-2: #2a2a2f;
  --fg: #f4f4f5;
  --fg-muted: #a1a1aa;
  --border: #3a3a40;
  --accent: #ff8a3d;
  --accent-fg: #18181b;
  --accent-soft: #2a1a0d;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --btn-bg: #2e2e34;
  --btn-hover: #3a3a40;
}

:root { --btn-bg: var(--surface); --btn-hover: var(--surface-2); }
.btn { background: var(--btn-bg); }
.btn:hover { background: var(--btn-hover); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header .logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--border), 0 1px 3px rgba(0,0,0,0.08);
}
.app-header h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header .spacer { flex: 1; }
@media (max-width: 480px) {
  .app-header { gap: 6px; padding: 10px 12px; }
  .app-header h1 { font-size: 15px; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  min-height: 44px;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
  user-select: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--fg-muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn:disabled:hover { background: var(--surface); border-color: var(--border); }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.06); background: var(--accent); border-color: var(--accent); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger); color: white; border-color: var(--danger); }
.btn-icon {
  width: 40px; height: 40px; min-height: 40px; padding: 0;
  font-size: 18px;
  border-radius: var(--radius);
}
.btn-block { width: 100%; }
.btn-lg { padding: 14px 20px; font-size: 17px; min-height: 56px; }

/* Inputs */
input[type="text"], input[type="search"], input[type="number"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  min-height: 44px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--fg-muted); margin-bottom: 6px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 15px; font-weight: 600; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

/* Misc */
.muted { color: var(--fg-muted); font-size: 14px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  border-radius: 999px;
  color: var(--fg-muted);
  white-space: nowrap;
}
.tag-accent { background: var(--accent-soft); color: var(--accent); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.chip:active { transform: scale(0.97); }
.chip { transition: transform 0.05s, background 0.1s, color 0.1s; }

/* Mobile PWA specific — typography scales via --font-scale (1.0 = default).
   Saved in localStorage and adjusted with the A− / A+ buttons in the header. */
.mobile-shell { max-width: 480px; margin: 0 auto; padding: 16px; padding-bottom: 100px;
  font-size: calc(17px * var(--font-scale, 1));
}
.mobile-shell label { font-size: calc(14px * var(--font-scale, 1)); }
/* Exclude file inputs — they're visually-hidden and iOS needs them
   at their natural size or .click() won't trigger the camera. */
.mobile-shell input:not([type="file"]), .mobile-shell select, .mobile-shell textarea {
  font-size: calc(17px * var(--font-scale, 1));
  min-height: 48px;
}
.mobile-shell .btn { font-size: calc(16px * var(--font-scale, 1)); }
.mobile-shell .btn-lg { font-size: calc(18px * var(--font-scale, 1)); }
.mobile-shell .chip { font-size: calc(14px * var(--font-scale, 1)); padding: 8px 12px; }
.mobile-shell .muted { font-size: calc(14px * var(--font-scale, 1)); }
.mobile-shell .photo-area .placeholder span:not(.icon) { font-size: calc(16px * var(--font-scale, 1)); }
.mobile-shell .autocomplete-list .item { padding: 12px 14px; }
.mobile-shell .autocomplete-list .item .name { font-size: calc(15px * var(--font-scale, 1)); }
.photo-area {
  width: 100%;
  aspect-ratio: 4/3;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.05s;
}
.photo-area:hover { border-color: var(--accent); }
.photo-area:active { transform: scale(0.995); }
.photo-area img { width: 100%; height: 100%; object-fit: cover; }
.photo-area .placeholder { text-align: center; color: var(--fg-muted); padding: 16px; }
.photo-area .placeholder .icon {
  font-size: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px; height: 80px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
  margin-bottom: 12px;
}
.photo-area .placeholder span:not(.icon) {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: var(--fg);
}
.photo-area .retake {
  position: absolute; top: 10px; right: 10px;
  background: rgba(0,0,0,0.65); color: white;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 500;
  backdrop-filter: blur(4px);
}

/* Autocomplete */
.autocomplete { position: relative; }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 6px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.06);
  animation: dropdown 0.12s ease-out;
}
@keyframes dropdown { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.autocomplete-list .item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.05s;
}
.autocomplete-list .item:last-child { border-bottom: none; }
.autocomplete-list .item:hover, .autocomplete-list .item.active { background: var(--accent-soft); }
.autocomplete-list .item .code {
  font-family: monospace; font-size: 12px; font-weight: 600;
  color: var(--accent);
  padding: 2px 6px; background: var(--accent-soft); border-radius: 4px;
  margin-right: 6px;
}
.autocomplete-list .item:hover .code { background: var(--surface); }
.autocomplete-list .item .name { display: block; font-size: 14px; margin-top: 4px; }

/* Box selector / chip list */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
}
.chip.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* Toast / undo */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg);
  padding: 12px 18px; border-radius: 999px;
  display: flex; align-items: center; gap: 12px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25), 0 2px 6px rgba(0,0,0,0.15);
  z-index: 100;
  animation: slideUp 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: calc(100vw - 32px);
}
.toast button { background: transparent; border: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 4px 8px; font-size: 14px; }
.toast button:hover { filter: brightness(1.2); }
@keyframes slideUp { from { transform: translate(-50%, 100%); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* Items grid */
.items-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  position: relative;
  box-shadow: var(--shadow);
}
.item-card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04); border-color: var(--fg-muted); }
.item-card.selected { outline: 2px solid var(--accent); outline-offset: -1px; }
.item-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--surface-2); }
.item-card .meta { padding: 8px 10px; font-size: 13px; }
.item-card .meta .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-card .meta .sub { color: var(--fg-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-card .checkbox { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; cursor: pointer; }

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.tabs button {
  padding: 10px 18px; background: transparent; border: none;
  color: var(--fg-muted); font-size: 15px; font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
  transition: color 0.1s;
}
.tabs button:hover { color: var(--fg); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 16px;
  backdrop-filter: blur(2px);
  animation: modalFade 0.15s ease-out;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 500px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.1);
}
.modal h2 { margin: 0 0 16px; font-size: 18px; }

/* Stats */
.stat {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat .label { font-size: 12px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; }
.stat .value { font-size: 32px; font-weight: 700; margin-top: 6px; line-height: 1.1; }

/* Hidden file inputs */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); }

/* Utility */
.hidden { display: none !important; }
.center { text-align: center; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; }
.flex-grow { flex: 1; }
