:root {
  --bg: #141210;
  --surface: #1d1a17;
  --surface-2: #26211d;
  --text: #f2e7d5;
  --muted: #b7ab98;
  --accent: #c88a2a;
  --accent-strong: #e1a549;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  --radius-lg: 18px;
  --radius-md: 12px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
}

* {
  box-sizing: border-box;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: 'Inter', Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, #110f0d 100%);
  color: var(--text);
}

html, body {
  overscroll-behavior: none;
}

/* ── TOPBAR / BRAND ── */

.topbar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(20, 18, 16, 0.92);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.brand {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}

.brand-title {
  display: inline-flex;
  flex-direction: row-reverse; /* logo po prawej, tekst po lewej */
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.brand-logo {
  width: 72px;
  height: 72px;
  border-radius: 0;
  object-fit: contain;
  box-shadow: none;
  border: none;
  background: transparent;
}

.brand h1 {
  margin: 0;
  font-family: 'Playfair Display', serif;
  font-size: 30px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}

@media (max-width: 640px) {
  .topbar {
    padding: 16px 12px 12px;
  }

  .brand-logo {
    width: 64px;
    height: 64px;
  }

  .brand-title {
    flex-direction: row-reverse;
    justify-content: center;
    gap: 8px;
  }

  .brand h1 {
    font-size: 28px;
  }

  .brand p {
    font-size: 13px;
    line-height: 1.35;
  }
}

/* ── BUTTONS ── */

.theme-toggle,
.secondary-btn,
.text-btn,
.nav-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.theme-toggle,
.secondary-btn,
.text-btn,
.primary-btn,
.nav-btn {
  border-radius: 999px;
  padding: 10px 14px;
}

.primary-btn {
  background: var(--accent);
  color: #1a1209;
  border: none;
  font-weight: 700;
}

.primary-btn.small-btn {
  padding: 8px 12px;
  font-size: 13px;
}

.small-btn {
  padding: 10px 14px;
}

.text-btn {
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition:
    color 180ms ease,
    background 180ms ease,
    border-color 180ms ease;
}

.text-btn:hover {
  background: rgba(200, 138, 42, 0.1);
  border-color: rgba(200, 138, 42, 0.25);
}

.text-btn:active {
  transform: translateY(1px);
}

.secondary-btn,
.danger-btn {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.secondary-btn:hover,
.danger-btn:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}

.secondary-btn:active,
.danger-btn:active {
  transform: translateY(1px);
}

.danger-btn {
  color: #f2d6d2;
  border-color: rgba(214, 120, 110, 0.35);
  background: rgba(214, 120, 110, 0.08);
}

.danger-btn:hover {
  background: rgba(214, 120, 110, 0.14);
  border-color: rgba(214, 120, 110, 0.55);
}

/* ── ICON BUTTONS ── */

.icon-btn {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--muted);
  color: var(--text);
}

.icon-btn:active {
  transform: translateY(1px);
}

.icon-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(200, 138, 42, 0.45);
}

.icon-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(200, 138, 42, 0.65);
}

.icon-btn-danger {
  color: #f2d6d2;
  border-color: rgba(214, 120, 110, 0.35);
  background: rgba(214, 120, 110, 0.08);
}

.icon-btn-danger:hover {
  background: rgba(214, 120, 110, 0.14);
  border-color: rgba(214, 120, 110, 0.55);
}

.icon-btn-accent {
  color: #1a1209;
  background: var(--accent);
  border-color: transparent;
}

.icon-btn-accent:hover {
  background: var(--accent-strong);
  color: #1a1209;
  border-color: transparent;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.stock-icon-btn {
  color: #1a1209;
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(200, 138, 42, 0.22);
}

.stock-icon-btn:hover {
  background: var(--accent-strong);
  border-color: transparent;
  color: #1a1209;
}

.stock-icon-btn:active {
  transform: translateY(1px);
}

/* ── LAYOUT ── */

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-4);
  padding-bottom: 100px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow);
  margin-bottom: var(--space-4);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

.hidden {
  display: none !important;
}

/* ── HERO ── */

.hero h2 {
  margin-top: 8px;
  margin-bottom: 12px;
  font-size: 32px;
  line-height: 1.15;
}

.hero p {
  color: var(--muted);
}

.hero-card h2 {
  color: var(--accent-strong);
  font-family: 'Playfair Display', serif;
}

.eyebrow {
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.section-header h2,
.section-header h3 {
  margin: 0;
}

.section-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ── STATS ── */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.stats-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 700px) {
  .stats-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.stat-card {
  margin-bottom: 0;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-label {
  color: var(--muted);
  margin: 0 0 8px;
  font-size: 14px;
}

.stat-value {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

/* ── FORMS ── */

.app-form {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.app-form label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.app-form input,
.app-form select,
.app-form textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.app-form textarea {
  resize: vertical;
  min-height: 110px;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-mode-title {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.form-hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 4px 0 0;
  max-width: 100%;
}

.form-context {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.9rem;
  color: var(--muted);
}

.form-context strong {
  color: var(--text);
  font-weight: 600;
}

#sessionForm,
#pipeForm,
#tobaccoForm,
#stockForm {
  scroll-margin-top: 116px;
}

.form-open .filters-card {
  display: none;
}

textarea {
  resize: none;
  overflow: hidden;
  min-height: 80px;
}

/* ── DATE/TIME PICKERS ── */

.app-form input[type="date"],
.app-form input[type="time"],
.filters-grid input[type="date"],
.filters-grid input[type="time"] {
  color-scheme: dark;
}

.app-form input[type="date"]::-webkit-calendar-picker-indicator,
.app-form input[type="time"]::-webkit-calendar-picker-indicator,
.filters-grid input[type="date"]::-webkit-calendar-picker-indicator,
.filters-grid input[type="time"]::-webkit-calendar-picker-indicator {
  filter: brightness(0) invert(0.78) sepia(1) saturate(3) hue-rotate(5deg);
  opacity: 0.9;
  cursor: pointer;
}

.app-form input[type="date"]::-webkit-calendar-picker-indicator:hover,
.app-form input[type="time"]::-webkit-calendar-picker-indicator:hover,
.filters-grid input[type="date"]::-webkit-calendar-picker-indicator:hover,
.filters-grid input[type="time"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

.input-readonly,
input[readonly] {
  background: rgba(255, 255, 255, 0.035);
  color: rgba(243, 237, 230, 0.82);
  border: 1px dashed rgba(212, 159, 74, 0.2);
  box-shadow: none;
  cursor: default;
}

.input-readonly:focus,
input[readonly]:focus {
  outline: none;
  border-color: rgba(212, 159, 74, 0.24);
  box-shadow: none;
}

.input-readonly::placeholder,
input[readonly]::placeholder {
  color: rgba(243, 237, 230, 0.42);
}

#durationMin {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.input-error {
  border-color: rgba(214, 120, 110, 0.6) !important;
}

/* ── FILTERS ── */

.filters-card {
  padding: var(--space-4);
}

.filters-grid {
  display: grid;
  gap: var(--space-4);
}

.filters-grid label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.filters-grid input,
.filters-grid select {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.filters-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 180ms ease;
}

.filters-toggle:hover {
  color: var(--text);
}

.filters-toggle span {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.filters-chevron {
  transition: transform 200ms ease;
  flex-shrink: 0;
}

.filters-toggle[aria-expanded="true"] .filters-chevron {
  transform: rotate(180deg);
}

.filters-collapsible {
  display: none;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  margin-top: var(--space-2);
}

.filters-collapsible.open {
  display: grid;
}

/* ── LISTS / ITEMS ── */

#sessionsList,
#pipesList,
#tobaccosList,
#homeRecentSessions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#sessionsList {
  grid-column: 1 / -1;
  width: 100%;
}

#sessionsList > .list-item {
  width: 100%;
}

.list-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

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

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item > div:first-child {
  flex: 1;
  min-width: 0;
}

.list-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.list-item p {
  margin: 0;
  color: var(--muted);
}

.list-item .inline-details-card,
.pipe-list-item .inline-details-card {
  width: 100%;
  flex-basis: 100%;
}

.item-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.empty-state {
  color: var(--muted);
  margin: 0;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: var(--space-4) 0 var(--space-2);
}

.load-more-count {
  font-size: 12px;
  opacity: 0.6;
  margin-left: 4px;
}

/* ── PIPES ── */

.pipe-main {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex: 1 1 auto;
  min-width: 0;
}

.pipe-main-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.pipe-thumb {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border-radius: 14px;
  flex-shrink: 0;
  /* Kluczowe dla lightboxa na mobile */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.pipe-detail-image {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.pipe-image-preview-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.pipe-image-preview {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  /* Kluczowe dla lightboxa na mobile */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.pipe-list-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.pipe-list-item > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.pipe-list-item .item-actions {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  margin-left: auto;
}

/* ── ZOOMABLE THUMBNAILS ── */

.pipe-thumb[data-zoomable],
.pipe-image-preview[data-zoomable] {
  cursor: zoom-in;
  transition: opacity 180ms ease;
}

.pipe-thumb[data-zoomable]:hover,
.pipe-image-preview[data-zoomable]:hover {
  opacity: 0.85;
}

/* ── TOBACCOS ── */

.tobacco-card {
  display: flex;
  flex-direction: column;
}

.tobacco-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.tobacco-main {
  flex: 1 1 auto;
  min-width: 0;
}

.tobacco-card .item-actions {
  flex-shrink: 0;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Tobacco name hierarchy */
.tobacco-main h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 3px;
  letter-spacing: 0.01em;
}

.tobacco-main p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.tobacco-brand {
  color: var(--muted);
}

.tobacco-cut {
  color: var(--muted);
  opacity: 0.7;
  font-style: italic;
}

.tobacco-stocks {
  width: 100%;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

#homeRecentSessions .meta-badges {
  margin-top: 6px;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(200, 138, 42, 0.14);
  border: 1px solid rgba(200, 138, 42, 0.28);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}

.meta-badge-muted {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
  color: var(--muted);
}

.meta-badge-time {
  font-weight: 700;
  color: #c5b9ac;
  border-color: rgba(212, 159, 74, 0.28);
  background: rgba(212, 159, 74, 0.12);
}

/* ── STOCKS ── */

.stock-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  margin-left: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.stock-item > div:first-child {
  flex: 1;
  min-width: 0;
}

.stock-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
  color: var(--text);
}

.stock-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.stock-item .item-actions {
  flex-shrink: 0;
  justify-content: flex-end;
}

.subsection-label {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stock-toggle-btn {
  align-self: flex-start;
  padding: 6px 0;
  border: none;
  background: transparent;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.stock-toggle-btn:hover {
  color: var(--accent);
}

/* ── DETAILS ── */

.details-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.details-grid p,
.details-notes p {
  margin: 0;
}

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

.details-notes p {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  max-width: 65ch;
  color: var(--muted);
}

.inline-details-card {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.details-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.details-actions .danger-btn,
.details-actions .secondary-btn {
  min-height: 36px;
}

@media (max-width: 640px) {
  .details-actions {
    justify-content: flex-start;
    gap: 8px;
  }

  .details-actions .danger-btn,
  .details-actions .secondary-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── BOTTOM NAV ── */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(20, 18, 16, 0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index: 999;
}

.bottom-nav .nav-btn {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  max-width: 56px;
  min-height: 48px;
  padding: 0;
  margin: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  line-height: 1;
}

.bottom-nav .nav-btn .nav-icon {
  width: 30px;
  height: 30px;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.bottom-nav .nav-btn:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}

.bottom-nav .nav-btn:active {
  transform: translateY(1px);
}

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

.bottom-nav .nav-btn.active .nav-icon {
  filter: brightness(0.15);
}

@media (min-width: 768px) {
  .bottom-nav {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(700px, calc(100% - 32px));
    bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 999px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* ── DIALOG ── */

.app-dialog {
  border: none;
  padding: 0;
  background: transparent;
  width: min(92vw, 430px);
  max-width: 430px;
  margin: auto;
}

.app-dialog::backdrop {
  background: rgba(10, 9, 8, 0.64);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.app-dialog-card {
  width: min(100%, 430px);
  max-width: 430px;
  margin: 0;
  padding: 24px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #211c18;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.app-dialog-header {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.app-dialog-eyebrow {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(240, 230, 220, 0.52);
}

.app-dialog-title {
  margin: 0;
  font-size: 1.32rem;
  line-height: 1.15;
  font-weight: 700;
  color: #f2eadf;
}

.app-dialog-message {
  margin: 0;
  color: rgba(240, 230, 220, 0.76);
  line-height: 1.6;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.app-dialog .secondary-btn,
.app-dialog .primary-btn {
  min-width: 112px;
  min-height: 46px;
  border-radius: 999px;
}

.app-dialog .secondary-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(242, 234, 223, 0.92);
}

.app-dialog .secondary-btn:hover {
  background: rgba(255, 255, 255, 0.04);
}

.app-dialog-confirm-danger {
  background: #a85732;
  color: #fff8f3;
  border: 1px solid #a85732;
}

.app-dialog-confirm-danger:hover {
  background: #b7623b;
  border-color: #b7623b;
}

.app-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.45);
}

/* ── LIGHTBOX ── */

.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: obFadeIn 200ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.photo-lightbox.hidden {
  display: none !important;
}

.photo-lightbox-img {
  max-width: 100%;
  max-height: 90dvh;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  object-fit: contain;
  animation: obSlideUp 240ms cubic-bezier(0.16, 1, 0.3, 1) both;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.photo-lightbox-close {
  position: absolute;
  top: 18px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f2e7d5;
  font-size: 26px;
  line-height: 1;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 180ms ease;
}

.photo-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ── CROP MODAL ── */

.crop-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10002;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.crop-modal-card {
  width: min(100%, 520px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: #211c18;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.crop-container {
  width: 100%;
  max-height: 55dvh;
  overflow: hidden;
  border-radius: 12px;
  background: #111;
}

.crop-container img {
  display: block;
  max-width: 100%;
}

/* ── SETTINGS & MISC ── */

.settings-note {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
}

.settings-note.muted {
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.65;
}

.quick-actions {
  margin-bottom: 0;
}

#exportJsonBtn,
#importJsonBtn {
  font-size: 1.05rem;
}

.finish-btn {
  color: #6daa45;
}

.finish-btn:hover {
  color: #4d8f25;
}

[data-smoke-again] {
  color: var(--accent);
}

[data-smoke-again]:hover {
  color: var(--accent-strong);
}

/* ── BACKUP & OFFLINE BANNERS ── */

.backup-banner,
.offline-banner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
  margin: 0 0 var(--space-4) 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 13px;
  color: var(--muted);
}

.backup-banner-main,
.offline-banner-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.backup-banner-main svg,
.offline-banner-main svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.backup-banner-main span,
.offline-banner-main span {
  flex: 1;
  line-height: 1.5;
}

.backup-banner-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── ONBOARDING ── */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 7, 6, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: obFadeIn 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.onboarding-overlay.hidden {
  display: none !important;
}

@keyframes obFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.onboarding-card {
  width: min(100%, 440px);
  background: #211c18;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 22px;
  padding: 32px 28px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
  animation: obSlideUp 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

.onboarding-steps {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
}

.onboarding-step {
  height: 4px;
  flex: 1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 300ms ease;
}

.onboarding-step.active {
  background: var(--accent);
}

.onboarding-panel {
  display: none;
}

.onboarding-panel.active {
  display: block;
  animation: obPanelIn 280ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes obPanelIn {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0); }
}

.onboarding-title {
  margin: 6px 0 10px;
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
}

.onboarding-desc {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  max-width: 100%;
}

.onboarding-form-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 4px;
}

.onboarding-label {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.onboarding-label input {
  flex-basis: 100%;
}

.onboarding-required {
  color: var(--accent-strong);
}

.onboarding-input {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 15px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.onboarding-input:focus {
  outline: none;
  border-color: rgba(200, 138, 42, 0.55);
  box-shadow: 0 0 0 3px rgba(200, 138, 42, 0.14);
}

.onboarding-input::placeholder {
  color: rgba(183, 171, 152, 0.45);
}

.onboarding-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.onboarding-btn {
  min-width: 110px;
  min-height: 46px;
  font-size: 14px;
  font-weight: 600;
}

.onboarding-welcome-icon {
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-welcome-icon img {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.onboarding-actions-center {
  justify-content: center;
}

#obPanel0 {
  text-align: center;
}

#obPanel0 .onboarding-desc {
  max-width: 30ch;
  margin-left: auto;
  margin-right: auto;
}

.install-steps {
  margin: 16px 0 0 0;
  padding-left: 20px;
  color: rgba(240, 230, 220, 0.76);
  line-height: 1.8;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.install-steps strong {
  color: var(--text);
}

/* ── MOBILE OVERRIDES ── */

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
    padding-bottom: 112px;
  }

  .card {
    padding: 16px;
    border-radius: 16px;
  }

  .section-header {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
  }

  .section-header h2,
  .section-header h3 {
    line-height: 1.15;
  }

  #sessionForm,
  #pipeForm,
  #tobaccoForm,
  #stockForm {
    scroll-margin-top: 100px;
  }

  #sessionsList,
  #pipesList,
  #tobaccosList,
  #homeRecentSessions {
    gap: 10px;
  }

  .list-item,
  .pipe-list-item,
  .tobacco-top-row,
  .stock-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 12px;
  }

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

  .list-item > div:first-child,
  .pipe-list-item > div:first-child,
  .tobacco-main,
  .stock-item > div:first-child,
  .pipe-main,
  .pipe-main-copy {
    width: 100%;
    min-width: 0;
  }

  .pipe-main {
    gap: 12px;
    align-items: flex-start;
  }

  .pipe-thumb {
    width: 60px;
    height: 60px;
    border-radius: 12px;
  }

  .item-actions,
  .pipe-list-item .item-actions,
  .tobacco-card .item-actions,
  .stock-item .item-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .icon-btn svg {
    width: 18px;
    height: 18px;
  }

  .inline-details-card {
    width: 100%;
    margin-top: 12px;
    padding: 14px;
    border-radius: 14px;
  }

  .inline-details-card .section-header {
    margin-bottom: 12px;
  }

  .details-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 12px;
  }

  .details-grid p,
  .details-notes p {
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .details-notes {
    margin-top: 10px;
    padding-top: 10px;
  }

  .meta-badges {
    gap: 6px;
    margin-top: 6px;
  }

  .meta-badge {
    font-size: 11px;
    padding: 5px 9px;
  }

  .tobacco-stocks {
    margin-top: 14px;
    padding-top: 14px;
    gap: 10px;
  }

  .stock-item {
    margin-left: 0;
    padding: 12px 14px;
  }

  .stock-item strong {
    font-size: 14px;
  }

  .stock-item p {
    font-size: 13px;
    line-height: 1.4;
  }

  .pipe-detail-image {
    width: 100%;
    max-width: 100%;
    margin-bottom: 12px;
  }

  .secondary-btn.small-btn,
  .primary-btn.small-btn {
    min-height: 36px;
    padding: 8px 12px;
  }

  .filters-card {
    padding: 14px;
  }

  .filters-grid {
    gap: 12px;
  }

  .app-form {
    gap: 12px;
  }

  .app-form input,
  .app-form select,
  .app-form textarea,
  .filters-grid input,
  .filters-grid select {
    padding: 13px 14px;
  }
}

.app-footer {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--muted);
  font-size: 12px;  /* zamiast var(--text-xs) */
}