/* ============================================================
   FIELD LOG — Industrial inventory PWA stylesheet
   Warm-black + safety amber, IBM Plex + Archivo Black,
   sharp 2px corners, mobile-first.
   ============================================================ */

:root {
  --bg:          #0E0D0B;
  --bg-grain:    #14130F;
  --surface:     #1A1815;
  --surface-2:   #221F1B;
  --surface-3:   #2A2622;
  --border:      #2D2925;
  --border-bright:#3D3833;
  --text:        #ECE7DC;
  --text-dim:    #B5AE9F;
  --muted:       #7A736A;
  --accent:      #FF8B2E;
  --accent-dim:  #C46A1F;
  --accent-glow: rgba(255, 139, 46, 0.15);
  --danger:      #E5503A;
  --danger-dim:  #8a3325;
  --success:     #6FAF5C;

  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-display: 'Archivo Black', 'IBM Plex Sans', sans-serif;

  --radius: 2px;
  --radius-lg: 3px;
  --shadow-soft: 0 6px 22px rgba(0, 0, 0, 0.45);

  --topbar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --safe-l:   env(safe-area-inset-left, 0px);
  --safe-r:   env(safe-area-inset-right, 0px);
}

/* ---------- Reset / base ---------- */

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  /* subtle grain */
  background-image:
    radial-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
    radial-gradient(rgba(255,255,255,0.008) 1px, transparent 1px);
  background-size: 3px 3px, 7px 7px;
  background-position: 0 0, 1px 2px;
}

img { display: block; max-width: 100%; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent); color: #1a1208; }

/* ---------- App root / layout ---------- */

#app { min-height: 100vh; }

.app-root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main {
  flex: 1;
  padding-top: calc(var(--topbar-h) + var(--safe-top));
  padding-bottom: calc(96px + var(--safe-bot));
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}

.screen {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

.screen-head {
  margin-bottom: 18px;
  padding-top: 6px;
}

.screen-title {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 4px 0 6px;
  color: var(--text);
  text-transform: uppercase;
}

.screen-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
}

.mini-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 12px;
}
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- Top bar ---------- */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: rgba(14, 13, 11, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  height: var(--topbar-h);
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.topbar-title {
  flex: 1;
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-mark-sm {
  display: inline-block;
  width: 22px;
  height: 22px;
  background: var(--accent);
  position: relative;
  flex-shrink: 0;
}
.logo-mark-sm::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 2px solid var(--bg);
}

.iconbtn, .iconbtn-sm {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  padding: 0;
  flex-shrink: 0;
}
.iconbtn:hover, .iconbtn-sm:hover {
  background: var(--surface-2);
  border-color: var(--border);
}
.iconbtn:active, .iconbtn-sm:active { background: var(--surface-3); }
.iconbtn-sm { width: 32px; height: 32px; }

/* ---------- Boot screen ---------- */

.boot {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
  z-index: 100;
}

.boot-mark {
  width: 56px;
  height: 56px;
  background: var(--accent);
  position: relative;
  animation: pulse 1.4s ease-in-out infinite;
}
.boot-mark::after {
  content: '';
  position: absolute;
  inset: 10px;
  border: 3px solid var(--bg);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.93); }
}

.boot-text {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ---------- Drawer / nav ---------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 80;
  animation: fade-in 0.18s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 90;
  width: min(82vw, 320px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bot);
  animation: slide-in 0.22s ease;
  box-shadow: var(--shadow-soft);
}

@keyframes slide-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }

.drawer-head {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-title {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.drawer-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.drawer-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 6px;
  gap: 2px;
  overflow-y: auto;
}

.drawer-nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.drawer-nav button:hover {
  background: var(--surface-2);
  border-color: var(--border);
}
.drawer-nav button svg { color: var(--accent); flex-shrink: 0; }

/* ---------- Pallet grid ---------- */

.search-bar {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 14px;
  transition: border-color 0.12s;
}
.search-bar:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
}
.search-bar::placeholder { color: var(--muted); }

.pallet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.pallet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.06s;
  display: flex;
  flex-direction: column;
  position: relative;
}
.pallet-card:hover { border-color: var(--border-bright); }
.pallet-card:active { transform: scale(0.985); }

.pallet-thumb {
  aspect-ratio: 4 / 3;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.pallet-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pallet-thumb.thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.pallet-code-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent);
  color: #1a1208;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: var(--radius);
}

.pallet-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 60px;
}

.pallet-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pallet-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: auto;
}

/* ---------- Row cards (boxes, items, templates) ---------- */

.row-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  margin-bottom: 8px;
  width: 100%;
  text-align: left;
}
.row-card:hover {
  border-color: var(--border-bright);
  background: var(--surface-2);
}
.row-card:active { background: var(--surface-3); }

.box-row { border-left: 3px solid var(--accent-dim); }
.item-row { }

.row-thumb {
  width: 60px;
  height: 60px;
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.row-thumb.sm { width: 48px; height: 48px; }
.row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qty-pill {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.78);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: var(--radius);
  border: 1px solid var(--border-bright);
}

.row-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.row-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.row-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
}

.row-cat {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.row-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Tags ---------- */

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.tag.cond { border: 1px solid var(--border); }
.tag.cond.cond-new      { background: rgba(111, 175, 92, 0.14); color: var(--success); border-color: rgba(111, 175, 92, 0.35); }
.tag.cond.cond-used     { background: var(--surface-2); color: var(--text-dim); }
.tag.cond.cond-damaged  { background: rgba(229, 80, 58, 0.14); color: var(--danger); border-color: rgba(229, 80, 58, 0.4); }
.tag.cond.cond-unknown  { background: var(--surface-2); color: var(--muted); }

/* ---------- Detail screens ---------- */

.detail-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  cursor: pointer;
}
.detail-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.notes-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 12px 0;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
}

.info-block {
  margin: 14px 0;
}

.info-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.info-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.info-text {
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.text-block {
  background: var(--bg-grain);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--text-dim);
}

/* spec grid (template fields readout) */

.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.spec {
  background: var(--surface);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 50px;
}

.spec-key {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.spec-val {
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
}
.spec-val.muted { color: var(--muted); font-style: italic; }

/* ---------- Photo viewer (zoom) ---------- */

.photo-viewer { margin: 0 0 16px; }

.photo-main {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
}
.photo-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-strip {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.photo-strip::-webkit-scrollbar { height: 4px; }
.photo-strip::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }

.photo-thumb {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.12s;
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-thumb:hover { border-color: var(--border-bright); }
.photo-thumb.active { border-color: var(--accent); }

.zoom {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.zoom img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.zoom-close {
  position: absolute;
  top: calc(16px + var(--safe-top));
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Forms ---------- */

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.field:last-child { margin-bottom: 0; }
.field.full { grid-column: 1 / -1; }

.field > label,
.form-label-row {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 420px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="number"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea,
select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  transition: border-color 0.12s, background 0.12s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}
input.mono { font-family: var(--font-mono); }

select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 50%,
    calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

/* segmented toggle */
.seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.seg button {
  flex: 1;
  background: var(--bg);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 6px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.seg button:last-child { border-right: none; }
.seg button:hover { background: var(--surface-2); color: var(--text); }
.seg button.on {
  background: var(--accent);
  color: #1a1208;
  font-weight: 600;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.form-actions.sticky {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 18%);
  padding-top: 16px;
  padding-bottom: calc(8px + var(--safe-bot));
  margin-left: -16px;
  margin-right: -16px;
  padding-left: 16px;
  padding-right: 16px;
  z-index: 5;
}

.row-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 4px;
}

.confirm {
  background: rgba(229, 80, 58, 0.1);
  border: 1px solid rgba(229, 80, 58, 0.4);
  border-radius: var(--radius);
  padding: 12px;
  margin: 12px 0;
  font-size: 13px;
  color: var(--danger);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Buttons ---------- */

.btn-primary,
.btn-ghost,
.btn-danger,
.btn-danger-ghost,
.btn-mini,
.btn-ai {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.06s;
  padding: 11px 18px;
  min-height: 44px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.btn-primary:active,
.btn-ghost:active,
.btn-danger:active,
.btn-danger-ghost:active,
.btn-mini:active,
.btn-ai:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: #1a1208;
}
.btn-primary:hover { background: #ffa14b; }
.btn-primary:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-bright);
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #f0604a; }

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: rgba(229, 80, 58, 0.5);
}
.btn-danger-ghost:hover {
  background: rgba(229, 80, 58, 0.12);
  border-color: var(--danger);
}

.btn-mini {
  font-size: 11px;
  padding: 6px 10px;
  min-height: 28px;
  letter-spacing: 0.08em;
  background: var(--surface-2);
  color: var(--text-dim);
  border-color: var(--border);
}
.btn-mini:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-bright);
}

.btn-ai {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: #1a1208;
  width: 100%;
  position: relative;
  overflow: hidden;
}
.btn-ai:hover { filter: brightness(1.05); }
.btn-ai:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

.full { width: 100%; }

/* ---------- Photo section (form) ---------- */

.photo-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.photo-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
  flex-wrap: wrap;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.photo-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s;
}
.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-tile.main {
  border-color: var(--accent);
}

.main-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--accent);
  color: #1a1208;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 2px 5px;
  border-radius: var(--radius);
}

.photo-x {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
  width: 22px;
  height: 22px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.photo-x:hover { background: var(--danger); border-color: var(--danger); }

.photo-add {
  aspect-ratio: 1 / 1;
  background: var(--bg);
  border: 2px dashed var(--border-bright);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.photo-add:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

/* ---------- AI suggest panel ---------- */

.ai-result {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
  position: relative;
}

.ai-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.conf {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.conf.conf-high   { background: rgba(111, 175, 92, 0.14); color: var(--success); border-color: rgba(111, 175, 92, 0.4); }
.conf.conf-medium { background: var(--accent-glow); color: var(--accent); border-color: rgba(255, 139, 46, 0.4); }
.conf.conf-low    { background: rgba(229, 80, 58, 0.14); color: var(--danger); border-color: rgba(229, 80, 58, 0.4); }

.ai-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.ai-field:last-child { border-bottom: none; padding-bottom: 0; }

.ai-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.ai-field-val {
  font-size: 14px;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}
.ai-field-val.mono { font-family: var(--font-mono); font-size: 12px; }

.ai-tpl {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.ai-tpl-head {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.ai-tpl-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 1;
}

.ai-tpl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.ai-tpl-row:last-child { border-bottom: none; }
.ai-tpl-row .ai-field-val { flex: 2; }

/* ---------- Templates UI ---------- */

.tpl-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tpl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.tpl-card:hover {
  border-color: var(--border-bright);
  background: var(--surface-2);
}

.tpl-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.tpl-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.tpl-preview {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.tpl-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tpl-fields-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.tpl-field-edit {
  background: var(--bg-grain);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tpl-field-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tpl-label-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--radius);
}
.tpl-label-input:focus {
  outline: none;
  border-color: var(--accent);
}

.tpl-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* ---------- FAB ---------- */

.fab-wrap {
  position: fixed;
  bottom: calc(20px + var(--safe-bot));
  right: calc(20px + var(--safe-r));
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #1a1208;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-soft), 0 0 0 4px rgba(255, 139, 46, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, background 0.12s;
}
.fab:hover { background: #ffa14b; transform: translateY(-2px); }
.fab:active { transform: scale(0.95); }

.fab-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  animation: fab-pop 0.18s ease;
}
@keyframes fab-pop {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fab-menu button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-bright);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 28px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  transition: background 0.12s, border-color 0.12s;
}
.fab-menu button:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}
.fab-menu button svg { color: var(--accent); }

/* ---------- Settings ---------- */

.key-input {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.key-input input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
}

.about-block {
  background: var(--bg-grain);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.55;
}
.about-block strong { color: var(--text); }

/* ---------- Selection list (export, etc.) ---------- */

.select-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
}

.select-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s;
}
.select-item:hover { background: var(--surface-2); }
.select-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- Empty / toast / spinner ---------- */

.empty,
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}

.empty-title {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0 0 6px;
  color: var(--text);
}

.empty-sub {
  font-size: 13px;
  color: var(--muted);
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(90px + var(--safe-bot));
  background: var(--surface);
  border: 1px solid var(--border-bright);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 150;
  box-shadow: var(--shadow-soft);
  animation: toast-in 0.22s ease;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.toast-ok  { border-color: var(--success); }
.toast.toast-err { border-color: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.spin {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Misc utility ---------- */

.mono       { font-family: var(--font-mono); }
.muted      { color: var(--muted); }
.muted-mini { color: var(--muted); font-size: 11px; }
.danger     { color: var(--danger); }
.small      { font-size: 12px; }

.err-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
}

/* ---------- Scrollbars ---------- */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---------- Small screens ---------- */

@media (max-width: 380px) {
  .screen { padding: 12px; }
  .pallet-grid { grid-template-columns: repeat(2, 1fr); }
  .screen-title { font-size: 22px; }
}

/* iOS — disable autoshrink for inputs */
@media (max-width: 600px) {
  input, textarea, select { font-size: 16px; } /* prevents iOS zoom on focus */
}
