/* ClipChef Web Test - Dual Theme Design System (Dark & Light Mode) */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root, [data-theme="dark"] {
  --primary: #ff6b35;
  --primary-hover: #e85a26;
  --primary-light: rgba(255, 107, 53, 0.15);
  --secondary: #2ec4b6;
  --secondary-hover: #25a094;
  
  --bg-body: #0f172a;
  --bg-gradient-1: rgba(255, 107, 53, 0.12);
  --bg-gradient-2: rgba(46, 196, 182, 0.1);
  
  --header-bg: rgba(15, 23, 42, 0.85);
  --card-bg: rgba(30, 41, 59, 0.75);
  --card-border: rgba(255, 255, 255, 0.1);
  --modal-bg: #1e293b;
  --modal-header-bg: #1e293b;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --input-bg: rgba(15, 23, 42, 0.6);
  --input-border: rgba(255, 255, 255, 0.15);
  --item-bg: rgba(15, 23, 42, 0.5);
  --item-border: rgba(255, 255, 255, 0.05);
  
  --tab-bg: rgba(255, 255, 255, 0.05);
  --tab-border: rgba(255, 255, 255, 0.1);
  --tab-color: #94a3b8;
  
  --btn-sec-bg: rgba(255, 255, 255, 0.08);
  --btn-sec-hover: rgba(255, 255, 255, 0.15);
  --btn-sec-border: rgba(255, 255, 255, 0.12);
  --btn-sec-color: #f8fafc;
  
  --scrollbar-track: rgba(15, 23, 42, 0.6);
  --scrollbar-thumb: rgba(255, 255, 255, 0.2);
  
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.2);
  --danger-color: #fca5a5;
  --danger-border: rgba(239, 68, 68, 0.3);
  
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  --primary: #ff6b35;
  --primary-hover: #e85a26;
  --primary-light: rgba(255, 107, 53, 0.1);
  --secondary: #0d9488;
  --secondary-hover: #0f766e;
  
  --bg-body: #f8fafc;
  --bg-gradient-1: rgba(255, 107, 53, 0.08);
  --bg-gradient-2: rgba(46, 196, 182, 0.06);
  
  --header-bg: rgba(255, 255, 255, 0.92);
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --modal-bg: #ffffff;
  --modal-header-bg: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  
  --input-bg: #f8fafc;
  --input-border: #cbd5e1;
  --item-bg: #f8fafc;
  --item-border: #e2e8f0;
  
  --tab-bg: #f1f5f9;
  --tab-border: #e2e8f0;
  --tab-color: #64748b;
  
  --btn-sec-bg: #f1f5f9;
  --btn-sec-hover: #e2e8f0;
  --btn-sec-border: #cbd5e1;
  --btn-sec-color: #1e293b;
  
  --scrollbar-track: #f1f5f9;
  --scrollbar-thumb: #cbd5e1;
  
  --danger-bg: rgba(239, 68, 68, 0.1);
  --danger-color: #dc2626;
  --danger-border: rgba(239, 68, 68, 0.2);
  
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-body);
  background-image: 
    radial-gradient(at 0% 0%, var(--bg-gradient-1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, var(--bg-gradient-2) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* App Header & Navbar */
header.app-header {
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.85rem 1.5rem;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
}

.logo-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25));
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo:hover .logo-img {
  transform: rotate(-10deg) scale(1.1);
}

.user-nav {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.user-email {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* User Dropdown Container & Menu */
.user-dropdown-container {
  position: relative;
  display: inline-block;
}

.user-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-dropdown-btn:hover {
  background: var(--bg-input);
  border-color: var(--primary);
}

.user-avatar-icon {
  font-size: 1.1rem;
}

.user-display-name {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.dropdown-chevron {
  font-size: 0.65rem;
  opacity: 0.7;
  margin-left: 0.2rem;
  transition: transform 0.2s ease;
}

.user-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  width: 210px;
  background: var(--modal-bg, #ffffff);
  border: 1px solid var(--card-border, #e2e8f0);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 0.4rem 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  animation: fadeInDown 0.15s ease-out;
  backdrop-filter: none !important;
  opacity: 1 !important;
}

.user-dropdown-menu.hidden {
  display: none !important;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  width: 100%;
}

.user-dropdown-item:hover {
  background: var(--bg-input);
  color: var(--primary);
}

.user-dropdown-item.danger:hover {
  background: var(--danger-bg);
  color: var(--danger-color);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.3rem 0;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  font-size: 0.85rem;
  padding: 0.45rem 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  transform: translateY(-1px);
}

/* Buttons */
.btn {
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
}

.btn-secondary {
  background: var(--btn-sec-bg);
  color: var(--btn-sec-color);
  border: 1px solid var(--btn-sec-border);
}

.btn-secondary:hover {
  background: var(--btn-sec-hover);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-color);
  border: 1px solid var(--danger-border);
}

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

/* Container & Layout */
main.app-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
  flex: 1;
}

/* Auth Card */
.auth-wrapper {
  max-width: 420px;
  margin: 4rem auto;
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.auth-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-header h2 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, background 0.3s;
}

.form-control:focus {
  border-color: var(--primary);
}

/* Input with inside action button */
.input-action-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-action-wrapper .form-control {
  padding-right: 145px;
}

.btn-input-paste-send {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(255, 107, 53, 0.25);
}

.btn-input-paste-send:hover {
  background: var(--primary-hover);
  transform: translateY(-50%) scale(1.02);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.35);
}

.btn-input-paste-send:active {
  transform: translateY(-50%) scale(0.97);
}

@keyframes flashHighlight {
  0% { border-color: var(--secondary); box-shadow: 0 0 12px var(--secondary); background: rgba(46, 196, 182, 0.15); }
  100% { border-color: var(--input-border); box-shadow: none; background: var(--input-bg); }
}

.form-control.flash-highlight {
  animation: flashHighlight 0.6s ease-out;
}

.auth-toggle {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-toggle a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

/* Stats Counter Banner */
.stats-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.total {
  background: rgba(46, 196, 182, 0.15);
  color: var(--secondary);
}

.stat-icon.queue {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-main);
  transition: all 0.3s ease;
}

.stat-value.pulse {
  color: var(--warning);
  animation: statPulse 1.8s infinite;
}

@keyframes statPulse {
  0% { transform: scale(1); filter: drop-shadow(0 0 0px rgba(245, 158, 11, 0)); }
  50% { transform: scale(1.12); filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.6)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0px rgba(245, 158, 11, 0)); }
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Category Filter Tabs */
.tabs-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.category-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.tab-btn {
  padding: 0.5rem 1.1rem;
  border-radius: 30px;
  background: var(--tab-bg);
  border: 1px solid var(--tab-border);
  color: var(--tab-color);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.cookbooks-panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin: 0 0 1.25rem;
  box-shadow: var(--shadow);
}

.cookbooks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.cookbooks-title {
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 700;
}

.cookbooks-subtitle {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 0.15rem;
}

.btn-cookbook-add {
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
}

.recipe-books-list {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.book-filter-chip,
.book-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--tab-border);
  border-radius: 999px;
  background: var(--tab-bg);
  color: var(--tab-color);
  overflow: hidden;
}

.book-filter-chip,
.book-chip-main,
.book-chip-action {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.book-filter-chip,
.book-chip-main {
  padding: 0.45rem 0.75rem;
}

.book-filter-chip span,
.book-chip-main span {
  color: var(--text-muted);
  margin-left: 0.25rem;
}

.book-chip-action {
  padding: 0.45rem 0.35rem;
  color: var(--text-muted);
}

.book-chip-action.danger {
  color: #ef4444;
  padding-right: 0.65rem;
}

.book-filter-chip:hover,
.book-chip:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.book-filter-chip.active,
.book-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.25);
}

.book-filter-chip.active span,
.book-chip.active span,
.book-chip.active .book-chip-action {
  color: rgba(255, 255, 255, 0.82);
}

.recipe-book-picker-wrap {
  margin-top: 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.recipe-book-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.recipe-book-picker {
  display: flex;
  gap: 0.4rem;
  flex: 1 1 100%;
  overflow-x: auto;
  padding: 0.1rem 0 0.35rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.recipe-book-picker::-webkit-scrollbar {
  display: none;
}

.recipe-book-choice {
  flex: 0 0 auto;
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--tab-bg);
  border: 1px solid var(--tab-border);
  color: var(--tab-color);
  white-space: nowrap;
  transition: all 0.2s ease;
}

.recipe-book-choice:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.recipe-book-choice.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.recipe-book-modal-card {
  max-width: 460px;
  text-align: center;
}

.recipe-book-modal-hero {
  width: 4rem;
  height: 4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 1.25rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.14), rgba(32, 201, 151, 0.14));
  font-size: 2.1rem;
}

.recipe-book-modal-hero.danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.14), rgba(255, 107, 53, 0.12));
}

.recipe-book-modal-title {
  color: var(--text-main);
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 0.4rem;
}

.recipe-book-modal-subtitle {
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.45;
  margin: 0 0 1.25rem;
}

.recipe-book-form-group {
  text-align: left;
  margin-bottom: 1.25rem;
}

.recipe-book-form-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.recipe-book-form-control {
  width: 100%;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 0.8rem 0.95rem;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.recipe-book-form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.14);
}

.recipe-book-form-error {
  color: #ef4444;
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 0.45rem;
}

.recipe-book-icon-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.recipe-book-selected-icon {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 107, 53, 0.22);
  border-radius: 0.75rem;
  background: rgba(255, 107, 53, 0.08);
  font-size: 1.2rem;
}

.recipe-book-icon-picker {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.45rem;
  max-height: 180px;
  overflow-y: auto;
  padding: 0.35rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: rgba(148, 163, 184, 0.06);
}

.recipe-book-icon-option {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid transparent;
  border-radius: 0.85rem;
  background: var(--input-bg);
  color: var(--text-main);
  cursor: pointer;
  font-size: 1.3rem;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.recipe-book-icon-option:hover {
  border-color: rgba(255, 107, 53, 0.35);
  transform: translateY(-1px);
}

.recipe-book-icon-option.active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(255, 107, 53, 0.28);
  transform: translateY(-1px) scale(1.03);
}

.recipe-book-delete-note {
  background: rgba(255, 107, 53, 0.08);
  border: 1px solid rgba(255, 107, 53, 0.18);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.4;
  padding: 0.85rem;
  margin-bottom: 1.25rem;
}

.recipe-book-modal-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.recipe-book-modal-actions .btn {
  flex: 1;
  justify-content: center;
}

/* Recipe Grid */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.recipe-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
}

.recipe-card:hover {
  transform: translateY(-5px);
  border-color: rgba(255, 107, 53, 0.4);
  box-shadow: 0 15px 35px rgba(255, 107, 53, 0.15);
}

.recipe-thumb-container {
  position: relative;
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: #000;
}

.recipe-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.recipe-card:hover .recipe-thumb {
  transform: scale(1.05);
}

/* Platform Badges */
.platform-pill {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.platform-youtube { background: rgba(239, 68, 68, 0.88); color: #fff; border: 1px solid #ef4444; }
.platform-instagram { background: rgba(236, 72, 153, 0.88); color: #fff; border: 1px solid #ec4899; }
.platform-tiktok { background: rgba(15, 23, 42, 0.9); color: #fff; border: 1px solid #06b6d4; }

.recipe-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.badge-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.recipe-badge {
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-salgado { background: rgba(255, 107, 53, 0.15); color: #ea580c; border: 1px solid rgba(255, 107, 53, 0.3); }
.badge-doce { background: rgba(236, 72, 153, 0.15); color: #db2777; border: 1px solid rgba(236, 72, 153, 0.3); }
.badge-bebida { background: rgba(46, 196, 182, 0.15); color: #0d9488; border: 1px solid rgba(46, 196, 182, 0.3); }
.badge-outro { background: rgba(148, 163, 184, 0.15); color: #475569; border: 1px solid rgba(148, 163, 184, 0.3); }

.recipe-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.3;
  color: var(--text-main);
}

.recipe-meta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding-top: 0.75rem;
  border-top: 1px solid var(--card-border);
}

/* View Mode Toggle Button */
.btn-icon-toggle {
  background: var(--surface-card);
  border: 1px solid var(--item-border);
  color: var(--text-main);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
}

.btn-icon-toggle:hover {
  background: var(--item-bg);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

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

/* List Mode Styling (Single Column with Rounded Square Thumbs) */
.recipe-grid.is-list-mode {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.recipe-list-item {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
}

.recipe-list-item:hover {
  transform: translateX(4px);
  border-color: rgba(255, 107, 53, 0.4);
  box-shadow: 0 8px 24px rgba(255, 107, 53, 0.12);
}

.recipe-list-thumb-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  min-width: 72px;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.recipe-list-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.recipe-list-item:hover .recipe-list-thumb {
  transform: scale(1.08);
}

.recipe-list-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.recipe-list-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.recipe-list-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.recipe-list-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--card-border);
  grid-column: 1 / -1;
  box-shadow: var(--shadow);
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--modal-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  padding: 2rem;
  position: relative;
  transition: background 0.3s ease;
}

/* Fixed Top + Scrollable Body for Recipe Detail Modal */
.modal-recipe-card {
  padding: 0 !important;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
}

.modal-recipe-fixed-top {
  padding: 1.5rem 1.75rem 1rem 1.75rem;
  background: var(--modal-header-bg);
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  transition: background 0.3s ease;
}

.modal-detail-thumb {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.modal-recipe-scrollable-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.75rem 1.75rem 1.75rem;
  scroll-behavior: smooth;
}

.modal-recipe-scrollable-body::-webkit-scrollbar {
  width: 6px;
}

.modal-recipe-scrollable-body::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.modal-recipe-scrollable-body::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

.modal-recipe-scrollable-body::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(239, 68, 68, 0.9);
  border-color: #ef4444;
  transform: scale(1.08);
}

/* Ingredient Clean Table List with Icons */
.ingredient-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--item-border);
}

.ingredient-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.25rem;
  border-bottom: 1px solid var(--item-border);
  transition: background 0.2s ease;
}

.ingredient-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.ing-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.ing-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  flex-shrink: 0;
}

.ing-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.4;
}

.ing-qty {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
  text-align: right;
  white-space: nowrap;
  padding-left: 1rem;
}

/* Preparation Methods Chips */
.prep-methods-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--item-border);
}

.prep-method-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--item-bg);
  border: 1px solid var(--item-border);
  border-radius: 50px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.prep-method-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

/* Category Picker In Modal */
.category-picker {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.cat-chip {
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--tab-bg);
  border: 1px solid var(--tab-border);
  color: var(--tab-color);
  transition: all 0.2s ease;
}

.cat-chip:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.cat-chip.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

/* Fun Message Animating Modal */
.fun-box {
  text-align: center;
  padding: 1.5rem 0;
}

.cooking-emoji {
  font-size: 4rem;
  animation: bounce 1.5s infinite alternate ease-in-out;
  margin-bottom: 1rem;
}

@keyframes bounce {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-15px) scale(1.1); }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: var(--card-bg);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  color: var(--text-main);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.tabs-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Responsive & Mobile First Adaptations */
@media (max-width: 900px) {
  .recipe-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
  }
}

@media (max-width: 640px) {
  /* Header */
  header.app-header {
    padding: 0.65rem 0.85rem;
  }

  .header-container {
    gap: 0.5rem;
  }

  .logo {
    font-size: 1.2rem;
    gap: 0.45rem;
  }

  .logo-icon {
    width: 34px;
    height: 34px;
    font-size: 1.15rem;
    border-radius: 10px;
  }

  .theme-toggle-btn {
    padding: 0.4rem 0.6rem;
  }

  .theme-label {
    display: none;
  }

  .user-nav {
    gap: 0.35rem;
  }

  .user-email {
    display: none;
  }

  #btnNewRecipeHeader {
    padding: 0.45rem 0.7rem;
    font-size: 0.82rem;
  }

  #btnLogout {
    padding: 0.45rem 0.6rem;
    font-size: 0.82rem;
  }

  /* Main Content Layout */
  .app-content {
    padding: 1rem 0.75rem 2.5rem 0.75rem;
  }

  /* Stats Banner */
  .stats-banner {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
  }

  .stat-card {
    padding: 0.75rem 0.85rem;
    gap: 0.6rem;
    border-radius: var(--radius-md);
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 1.15rem;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .stat-label {
    font-size: 0.68rem;
    letter-spacing: 0;
  }

  /* Tabs & Horizontal Scroll */
  .tabs-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }

  .category-tabs {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.35rem;
    width: 100%;
  }

  .category-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    flex-shrink: 0;
  }

  .tabs-actions {
    display: flex;
    width: 100%;
  }

  .tabs-actions .btn {
    width: 100%;
    justify-content: center;
    font-size: 0.88rem;
    padding: 0.5rem 1rem;
  }

  /* Recipe Grid & Cards on Mobile */
  .recipe-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .recipe-card {
    border-radius: var(--radius-md);
  }

  .recipe-thumb-container {
    height: 190px;
  }

  .recipe-body {
    padding: 1rem;
  }

  .recipe-title {
    font-size: 1.05rem;
  }

  /* Modals on Mobile: Bottom Sheet / Full Mobile Experience */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card {
    max-width: 100%;
    width: 100%;
    max-height: 94vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding: 1.5rem 1.25rem;
  }

  .modal-recipe-card {
    max-height: 92vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .modal-recipe-fixed-top {
    padding: 1.25rem 1rem 0.75rem 1rem;
  }

  .modal-detail-thumb {
    height: 140px;
    margin-bottom: 0.75rem;
  }

  #detailTitle {
    font-size: 1.25rem !important;
  }

  .modal-close {
    top: 0.75rem;
    right: 0.75rem;
    width: 34px;
    height: 34px;
    font-size: 1.2rem;
  }

  .modal-recipe-scrollable-body {
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
  }

  .ingredient-item {
    padding: 0.65rem 0.85rem;
  }

  .ingredient-name {
    font-size: 0.98rem;
  }

  .ingredient-qty {
    font-size: 0.88rem;
  }

  /* Toasts on Mobile */
  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 380px) {
  .stats-banner {
    grid-template-columns: 1fr;
  }
}

/* Nutrition Facts Styling (ANVISA RDC 429/2020) */
.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 480px) {
  .nutrition-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.nutrition-stat-card {
  background: var(--item-bg);
  border: 1px solid var(--item-border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  text-align: center;
  transition: transform 0.2s, border-color 0.2s;
}

.nutrition-stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--secondary);
}

.nutrition-stat-val {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
  margin-bottom: 0.2rem;
}

.nutrition-stat-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.nutrition-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.nutrition-table th, .nutrition-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--item-border);
  text-align: center;
}

.nutrition-table th {
  background: var(--item-bg);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nutrition-table th:first-child, .nutrition-table td:first-child {
  text-align: left;
}

.nutrition-table td.num {
  font-weight: 600;
  color: var(--text-main);
  text-align: center;
}

.nutrition-legal-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.hidden { display: none !important; }

/* Mobile Web Polish: touch-first layout, safe areas and compact controls */
html {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: rgba(255, 107, 53, 0.18);
}

button,
.btn,
.tab-btn,
.cat-chip,
.book-filter-chip,
.book-chip-main,
.book-chip-action,
.user-dropdown-btn {
  touch-action: manipulation;
}

.btn,
.tab-btn,
.cat-chip,
.book-filter-chip,
.book-chip-main,
.book-chip-action,
.user-dropdown-btn,
.btn-input-paste-send,
.recipe-book-choice {
  min-height: 44px;
}

.form-control,
.form-input,
.recipe-book-form-control {
  min-height: 46px;
  font-size: 16px;
}

.form-control::placeholder,
.form-input::placeholder,
.recipe-book-form-control::placeholder {
  color: color-mix(in srgb, var(--text-muted) 78%, transparent);
}

@supports not (color: color-mix(in srgb, white 50%, black)) {
  .form-control::placeholder,
  .form-input::placeholder,
  .recipe-book-form-control::placeholder {
    color: var(--text-muted);
  }
}

@media (max-width: 760px) {
  header.app-header {
    padding: calc(0.55rem + env(safe-area-inset-top)) 0.85rem 0.65rem;
  }

  .header-container {
    max-width: 100%;
    gap: 0.65rem;
  }

  .logo {
    min-width: 0;
    flex: 1;
    font-size: 1.18rem;
    gap: 0.5rem;
  }

  .logo-img {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }

  .user-nav {
    flex: 0 0 auto;
    gap: 0.45rem;
  }

  .user-display-name,
  .dropdown-chevron {
    display: none;
  }

  .user-dropdown-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    border-radius: 14px;
  }

  .user-avatar-icon {
    font-size: 1.2rem;
  }

  .user-dropdown-menu {
    position: fixed;
    right: 0.85rem;
    top: calc(58px + env(safe-area-inset-top));
    width: min(260px, calc(100vw - 1.7rem));
  }

  .theme-toggle-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    border-radius: 14px;
  }

  #btnNewRecipeHeader {
    min-width: 44px;
    height: 44px;
    padding: 0 0.8rem;
    border-radius: 14px;
    white-space: nowrap;
  }

  .app-content {
    padding: 1rem 0.85rem calc(2rem + env(safe-area-inset-bottom));
  }

  .auth-wrapper {
    margin: 1.25rem auto;
    max-width: 100%;
  }

  .card {
    padding: 1.35rem;
  }

  .stats-banner {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
    margin-bottom: 0.95rem;
  }

  .stat-card {
    min-width: 0;
    padding: 0.8rem;
    gap: 0.7rem;
  }

  .stat-card > div:last-child {
    min-width: 0;
  }

  .stat-label {
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .cookbooks-panel {
    padding: 0.85rem;
    margin-bottom: 1rem;
  }

  .cookbooks-header {
    align-items: flex-start;
  }

  .cookbooks-subtitle {
    max-width: 34ch;
    line-height: 1.35;
  }

  .btn-cookbook-add {
    min-height: 40px;
    padding: 0.45rem 0.75rem;
    white-space: nowrap;
  }

  .recipe-books-list,
  .category-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.35rem;
    margin-inline: -0.15rem;
  }

  .recipe-books-list::-webkit-scrollbar,
  .category-tabs::-webkit-scrollbar {
    display: none;
  }

  .book-filter-chip,
  .book-chip {
    flex: 0 0 auto;
  }

  .book-filter-chip,
  .book-chip-main,
  .tab-btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.84rem;
  }

  .book-chip-action {
    min-width: 36px;
    padding: 0.45rem 0.35rem;
  }

  .tabs-container {
    gap: 0.75rem;
  }

  .tabs-actions {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 0.55rem;
  }

  .tabs-actions .btn,
  .btn-icon-toggle {
    min-height: 46px;
    padding: 0.55rem 0.8rem;
  }

  .btn-icon-toggle {
    width: 48px !important;
  }

  .recipe-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .recipe-card {
    min-height: auto;
  }

  .recipe-thumb-container {
    height: clamp(168px, 46vw, 220px);
  }

  .recipe-meta {
    align-items: flex-start;
    gap: 0.45rem 0.7rem;
    flex-wrap: wrap;
  }

  .recipe-grid.is-list-mode .recipe-list-item {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .recipe-list-thumb-wrap {
    width: 74px;
    height: 74px;
    min-width: 74px;
  }

  .recipe-list-title {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .recipe-list-meta {
    gap: 0.35rem 0.6rem;
    font-size: 0.78rem;
  }

  .empty-state {
    padding: 2.4rem 1rem;
  }

  .input-action-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .input-action-wrapper .form-control {
    padding-right: 1rem;
  }

  .btn-input-paste-send {
    position: static;
    transform: none;
    width: 100%;
    justify-content: center;
    padding: 0.78rem 1rem;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
  }

  .btn-input-paste-send:hover,
  .btn-input-paste-send:active {
    transform: none;
  }

  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card {
    max-width: 100%;
    width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top));
    border-radius: 22px 22px 0 0;
    padding: 1.35rem 1rem calc(1.35rem + env(safe-area-inset-bottom));
  }

  .modal-recipe-card {
    height: calc(100dvh - env(safe-area-inset-top));
    max-height: calc(100dvh - env(safe-area-inset-top));
  }

  .modal-recipe-fixed-top {
    padding: 1rem 0.85rem 0.7rem;
  }

  .modal-detail-thumb {
    height: min(34vh, 170px);
    border-radius: 14px;
  }

  #titleViewContainer {
    padding-right: 2.25rem;
  }

  #titleViewContainer #detailTitle {
    flex-basis: 100%;
  }

  #titleEditContainer {
    display: grid !important;
    grid-template-columns: 1fr auto;
  }

  #titleEditContainer.hidden {
    display: none !important;
  }

  #titleEditContainer .form-control {
    grid-column: 1 / -1;
  }

  .category-picker,
  .prep-methods-wrap {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.35rem;
  }

  .category-picker::-webkit-scrollbar,
  .prep-methods-wrap::-webkit-scrollbar {
    display: none;
  }

  .cat-chip,
  .prep-method-chip {
    flex: 0 0 auto;
  }

  .recipe-book-picker-wrap {
    align-items: stretch;
  }

  .recipe-book-label {
    flex-basis: 100%;
  }

  .recipe-book-picker {
    width: 100%;
    min-width: 0;
  }

  .modal-recipe-scrollable-body {
    padding: 1rem 0.85rem calc(1.25rem + env(safe-area-inset-bottom));
  }

  .ingredient-row {
    align-items: flex-start;
    gap: 0.65rem;
  }

  .ingredient-name-wrap {
    min-width: 0;
  }

  .ingredient-qty {
    max-width: 45%;
    text-align: right;
    overflow-wrap: anywhere;
  }

  .step-item,
  .prep-step {
    font-size: 1rem;
    line-height: 1.55;
  }

  .recipe-book-modal-card,
  .recipe-book-delete-card {
    text-align: left;
  }

  .recipe-book-modal-hero {
    width: 3.35rem;
    height: 3.35rem;
    margin-bottom: 0.8rem;
  }

  .recipe-book-icon-picker {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    max-height: 156px;
  }

  .recipe-book-modal-actions {
    flex-direction: column-reverse;
  }

  .recipe-book-modal-actions .btn {
    width: 100%;
    min-height: 48px;
  }

  .nutrition-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nutrition-table-wrap,
  .nutrition-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table.nutrition-table,
  .nutrition-table table {
    min-width: 520px;
  }
}

@media (max-width: 480px) {
  .logo span {
    font-size: 1.05rem;
  }

  .stats-banner {
    grid-template-columns: 1fr;
  }

  .stat-card {
    min-height: 76px;
  }

  .cookbooks-header {
    display: grid;
    grid-template-columns: 1fr;
  }

  .btn-cookbook-add {
    width: 100%;
    justify-content: center;
  }

  #btnNewRecipeHeader {
    font-size: 0;
    width: 44px;
    padding: 0;
    justify-content: center;
  }

  #btnNewRecipeHeader::before {
    content: '+';
    font-size: 1.35rem;
    line-height: 1;
  }

  .recipe-book-icon-picker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .modal-detail-thumb {
    height: 118px;
  }

  #detailTitle {
    font-size: 1.12rem !important;
  }

  .ingredient-row {
    padding: 0.75rem 0;
  }
}

@media (max-width: 360px) {
  .app-content {
    padding-inline: 0.65rem;
  }

  .logo-img {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .logo span {
    font-size: 0.98rem;
  }

  .theme-toggle-btn,
  .user-dropdown-btn,
  #btnNewRecipeHeader {
    width: 40px;
    height: 40px;
    min-height: 40px;
  }
}

.prep-steps-list {
  list-style: none;
  padding: 0;
}

.prep-step {
  margin-bottom: 0.85rem;
  line-height: 1.55;
  font-size: 0.98rem;
}

@media (max-width: 760px) {
  .prep-methods-wrap {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.35rem;
  }

  .prep-methods-wrap::-webkit-scrollbar {
    display: none;
  }


  #formEditProfile > div:first-of-type {
    flex-direction: column !important;
  }

  #formEditProfile > div:last-child,
  #formChangePassword > div:last-child,
  #formEnqueue > div:last-child {
    display: grid !important;
    grid-template-columns: 1fr;
  }

  #formEditProfile > div:last-child .btn,
  #formChangePassword > div:last-child .btn,
  #formEnqueue > div:last-child .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }
}


/* Mobile dashboard refinement: compact counters and cookbook actions */
@media (max-width: 640px) {
  .stats-banner {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    margin-bottom: 0.75rem;
  }

  .stat-card {
    justify-content: center;
    padding: 0.75rem 0.55rem;
    gap: 0.55rem;
    min-height: 66px;
  }

  .stat-icon {
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
  }

  .stat-value {
    font-size: 1.45rem;
  }

  .stat-label {
    display: none;
  }

  .cookbooks-panel {
    padding: 0.75rem;
    margin-bottom: 0.85rem;
  }

  .cookbooks-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.55rem;
  }

  .cookbooks-subtitle {
    display: none;
  }

  .btn-cookbook-add {
    width: auto;
    min-height: 38px;
    padding: 0.4rem 0.65rem;
    justify-content: center;
    white-space: nowrap;
    font-size: 0.8rem;
  }
}

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

  .stat-card {
    padding: 0.65rem 0.45rem;
  }

  .stat-icon {
    width: 34px;
    height: 34px;
  }
}

@media (max-width: 640px) {
  #formEnqueue .btn-extract-submit {
    display: none;
  }
}

/* Mobile header cookbook trigger and signed user identity */
.logo-text-wrap {
  display: inline-flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.05;
}

.logo-title {
  display: inline-block;
}

.mobile-user-display-name {
  display: none;
}

.btn-cookbooks-header {
  display: none;
}

@media (max-width: 640px) {
  .logo {
    align-items: center;
  }

  .logo-text-wrap {
    max-width: 112px;
  }

  .logo-title,
  .mobile-user-display-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-user-display-name:not(.hidden) {
    display: block;
    margin-top: 0.18rem;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  .btn-cookbooks-header {
    display: inline-flex;
    height: 44px;
    min-height: 44px;
    padding: 0 0.75rem;
    border-radius: 14px;
    white-space: nowrap;
    justify-content: center;
  }

  .btn-cookbooks-header[aria-expanded="true"] {
    border-color: var(--primary);
    color: var(--primary);
  }

  #cookbooksPanel {
    display: none;
  }

  #cookbooksPanel.open {
    display: block;
  }

  .tabs-container {
    margin-top: 0;
  }
}

@media (max-width: 420px) {
  .logo-text-wrap {
    max-width: 88px;
  }

  .btn-cookbooks-header {
    min-width: 44px;
    width: 44px;
    padding: 0;
    font-size: 0;
  }

  .btn-cookbooks-header::before {
    content: '📖';
    font-size: 1.15rem;
  }
}

/* Mobile header final layout: keep labeled action buttons side by side */
@media (max-width: 640px) {
  #btnNewRecipeHeader,
  .btn-cookbooks-header {
    width: auto;
    min-width: auto;
    height: 44px;
    min-height: 44px;
    padding: 0 0.72rem;
    font-size: 0.78rem;
    border-radius: 14px;
    white-space: nowrap;
    justify-content: center;
  }

  #btnNewRecipeHeader::before,
  .btn-cookbooks-header::before {
    content: none;
  }

  .stats-banner {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  #btnNewRecipeHeader,
  .btn-cookbooks-header {
    width: auto;
    min-width: auto;
    padding: 0 0.58rem;
    font-size: 0.74rem;
  }

  .stats-banner {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Mobile final composition: two-line header, full labels, hidden cookbook panel */
@media (max-width: 640px) {
  .header-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand utility"
      "actions actions";
    align-items: center;
    row-gap: 0.65rem;
  }

  .logo {
    grid-area: brand;
    width: 100%;
  }

  .header-container > div:not(.user-nav) {
    display: contents !important;
  }

  .theme-toggle-btn {
    grid-area: utility;
    justify-self: end;
  }

  .user-nav {
    grid-area: actions;
    display: grid !important;
    grid-template-columns: 1fr 1fr auto;
    width: 100%;
    gap: 0.55rem;
  }

  .user-nav.hidden {
    display: none !important;
  }

  #btnNewRecipeHeader,
  .btn-cookbooks-header {
    width: 100%;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    padding: 0 0.65rem;
    font-size: 0.8rem;
    border-radius: 14px;
    white-space: nowrap;
    justify-content: center;
  }

  #btnNewRecipeHeader::before,
  .btn-cookbooks-header::before {
    content: none !important;
  }

  #userDropdownContainer {
    justify-self: end;
  }

  .user-dropdown-menu {
    top: calc(104px + env(safe-area-inset-top));
  }

  .stats-banner {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.6rem;
  }

  .stat-card {
    justify-content: center;
    min-width: 0;
  }

  #cookbooksPanel {
    display: none !important;
  }

  #cookbooksPanel.open {
    display: block !important;
  }
}

@media (max-width: 420px) {
  .logo-text-wrap {
    max-width: 160px;
  }

  #btnNewRecipeHeader,
  .btn-cookbooks-header {
    font-size: 0.74rem;
    padding: 0 0.45rem;
  }
}

/* Mobile enqueue actions: paste+send and manual send side by side */
.input-action-buttons {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.input-action-buttons .btn-input-paste-send {
  position: static;
  right: auto;
  top: auto;
  transform: none;
}

.btn-input-send-only {
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--btn-sec-border);
  background: var(--btn-sec-bg);
  color: var(--btn-sec-color);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .input-action-buttons {
    position: static;
    transform: none;
    display: grid;
    grid-template-columns: 1fr 0.72fr;
    gap: 0.6rem;
    width: 100%;
  }

  .input-action-buttons .btn-input-paste-send,
  .btn-input-send-only {
    width: 100%;
    min-height: 48px;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
  }

  .btn-input-send-only {
    display: inline-flex;
  }
}

/* Recipe detail: compact header with collapsible options */
.recipe-detail-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  padding-right: 2.4rem;
}

.recipe-detail-title-view {
  min-width: 0;
  flex: 1;
}

.recipe-detail-title-view h2 {
  color: var(--text-main);
  font-size: 1.35rem;
  line-height: 1.18;
  margin: 0;
}

.btn-recipe-info-toggle {
  min-height: 40px;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  flex: 0 0 auto;
}

.btn-recipe-info-toggle::before {
  content: '⚙️';
  margin-right: 0.35rem;
}

.btn-recipe-info-toggle[aria-expanded="true"] {
  border-color: var(--primary);
  color: var(--primary);
}

.recipe-detail-info-panel {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--card-border);
}

.recipe-detail-author {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0.28rem 0 0;
}

.recipe-detail-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.recipe-detail-action-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.26rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.1;
  text-align: center;
}

.recipe-detail-actions .btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  padding: 0;
  border-radius: 16px;
}

.detail-action-icon,
.detail-action-label {
  display: inline-flex;
  align-items: center;
}

.detail-action-label {
  font-weight: 400;
}

.detail-action-icon {
  line-height: 1;
}

.recipe-limit-card {
  max-width: 420px;
  text-align: center;
}

.recipe-limit-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 22px;
  background: rgba(255, 107, 53, 0.12);
  font-size: 2rem;
}

.recipe-limit-card h3 {
  color: var(--text-main);
  font-size: 1.45rem;
  margin: 0 0 0.65rem;
}

.recipe-limit-card p {
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 1.35rem;
}

.recipe-limit-card .btn {
  width: 100%;
  justify-content: center;
}

.btn-nutrition-detail {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #059669;
}

.recipe-title-edit-container {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.95rem;
}

.recipe-title-edit-container.hidden {
  display: none !important;
}

.recipe-title-edit-container .btn {
  min-height: 42px;
  padding: 0.45rem 0.75rem;
}

.recipe-meta-controls {
  margin-top: 0.5rem;
}

.recipe-meta-controls label {
  color: var(--text-muted);
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

@media (max-width: 640px) {
  .modal-recipe-fixed-top {
    padding: 0.9rem 0.85rem 0.7rem;
  }

  .recipe-detail-summary {
    align-items: center;
    gap: 0.65rem;
    padding-right: 2.25rem;
  }

  .recipe-detail-title-view h2 {
    font-size: 1.08rem;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .btn-recipe-info-toggle {
    min-height: 38px;
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
  }

  .recipe-detail-info-panel {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
  }

  .recipe-detail-info-panel .modal-detail-thumb {
    height: 104px;
    margin-bottom: 0.65rem;
  }

  .recipe-detail-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .recipe-detail-action-item {
    justify-self: center;
    min-width: 0;
  }

  .recipe-detail-actions .btn {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 16px;
  }

  .recipe-detail-actions .detail-action-icon {
    font-size: 1.05rem;
  }

  .recipe-detail-actions .detail-action-label {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.68rem;
    font-weight: 400;
    line-height: 1;
  }

  .recipe-title-edit-container {
    grid-template-columns: 1fr 1fr;
  }

  .recipe-title-edit-container .form-control {
    grid-column: 1 / -1;
  }

  .recipe-title-edit-container .btn {
    width: 100%;
    justify-content: center;
  }

  .recipe-book-picker-wrap {
    margin-top: 0.65rem;
  }
}

/* Recipe section titles without copy actions */
.recipe-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.recipe-section-title.secondary {
  color: var(--secondary);
}

.recipe-section-title.primary {
  color: var(--primary);
}

/* Recipe detail expand button sits beside the title and keeps ingredients first */
.btn-recipe-info-toggle::before {
  content: '⌄';
  margin-right: 0.35rem;
  font-size: 1rem;
  line-height: 1;
}

.btn-recipe-info-toggle[aria-expanded="true"]::before {
  content: '⌃';
}

@media (max-width: 640px) {
  .recipe-detail-summary {
    padding-right: 2.45rem;
  }

  .btn-recipe-info-toggle {
    min-width: 92px;
  }

  .modal-recipe-fixed-top:has(#recipeDetailInfoPanel.hidden) {
    padding-bottom: 0.85rem;
  }
}

/* Recipe detail final mobile hierarchy: image, title+expand, then ingredients */
.modal-recipe-fixed-top > .modal-detail-thumb {
  display: block;
  margin: 0 0 0.9rem;
}

.recipe-detail-summary {
  align-items: center;
}

.recipe-detail-title-view h2 {
  padding-right: 0;
}

@media (max-width: 640px) {
  .modal-recipe-fixed-top {
    padding: 0.75rem 0.85rem 0.7rem;
  }

  .modal-recipe-fixed-top > .modal-detail-thumb {
    height: min(30vh, 138px);
    margin: 0 0 0.65rem;
    border-radius: 14px;
  }

  .recipe-detail-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
    padding-right: 0;
  }

  .recipe-detail-title-view h2 {
    font-size: 1.08rem !important;
    line-height: 1.2;
    margin: 0;
  }

  .btn-recipe-info-toggle {
    min-width: 98px;
    height: 40px;
    min-height: 40px;
    padding: 0 0.7rem;
  }

  .modal-recipe-fixed-top .modal-close {
    top: 0.65rem;
    right: 0.65rem;
  }

  .recipe-detail-info-panel {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
  }

  .modal-recipe-scrollable-body {
    padding-top: 0.85rem;
  }
}

/* Mobile bottom floating actions: book left, add recipe right */
@media (max-width: 640px) {
  .header-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "brand theme user";
    align-items: center;
    gap: 0.55rem;
  }

  .header-container > div:not(.user-nav) {
    display: contents !important;
  }

  .logo {
    grid-area: brand;
  }

  .theme-toggle-btn {
    grid-area: theme;
    justify-self: end;
  }

  .user-nav {
    grid-area: user;
    display: flex !important;
    width: auto;
    gap: 0;
  }

  .user-nav.hidden {
    display: none !important;
  }

  #userDropdownContainer {
    display: block;
  }

  .user-dropdown-btn {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    justify-content: center;
    border-radius: 999px;
  }

  .user-dropdown-menu {
    top: calc(60px + env(safe-area-inset-top));
    right: 0.85rem;
  }

  #btnNewRecipeHeader,
  .btn-cookbooks-header {
    position: fixed;
    z-index: 70;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    width: 58px;
    height: 58px;
    min-width: 58px;
    min-height: 58px;
    padding: 0;
    border-radius: 999px;
    font-size: 0;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.22), 0 5px 14px rgba(15, 23, 42, 0.16);
  }

  #btnNewRecipeHeader {
    right: max(1rem, env(safe-area-inset-right));
  }

  .btn-cookbooks-header {
    left: max(1rem, env(safe-area-inset-left));
    background: var(--btn-sec-bg);
    color: var(--btn-sec-color);
    border: 1px solid var(--btn-sec-border);
  }

  #btnNewRecipeHeader::before {
    content: '+' !important;
    font-size: 2rem;
    line-height: 1;
    font-weight: 800;
  }

  .btn-cookbooks-header::before {
    content: '📖' !important;
    font-size: 1.45rem;
    line-height: 1;
  }

  .btn-cookbooks-header[aria-expanded="true"] {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
  }

  .app-content {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
  }

  .toast-container {
    bottom: calc(5.1rem + env(safe-area-inset-bottom));
  }
}

@media (max-width: 360px) {
  #btnNewRecipeHeader,
  .btn-cookbooks-header {
    width: 54px;
    height: 54px;
    min-width: 54px;
    min-height: 54px;
  }
}

/* Force mobile primary actions to stay at the bottom, outside the header flow */
@media (max-width: 768px) {
  #btnNewRecipeHeader,
  #btnToggleCookbooksHeader.btn-cookbooks-header {
    position: fixed !important;
    top: auto !important;
    bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
    z-index: 1000 !important;
    display: inline-flex !important;
    width: 58px !important;
    height: 58px !important;
    min-width: 58px !important;
    min-height: 58px !important;
    max-width: 58px !important;
    padding: 0 !important;
    border-radius: 999px !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important;
  }

  #btnNewRecipeHeader {
    right: max(1rem, env(safe-area-inset-right)) !important;
    left: auto !important;
  }

  #btnToggleCookbooksHeader.btn-cookbooks-header {
    left: max(1rem, env(safe-area-inset-left)) !important;
    right: auto !important;
  }

  #btnNewRecipeHeader::before {
    content: '+' !important;
    display: block !important;
    font-size: 2rem !important;
    font-weight: 800 !important;
    line-height: 1 !important;
  }

  #btnToggleCookbooksHeader.btn-cookbooks-header::before {
    content: '📖' !important;
    display: block !important;
    font-size: 1.45rem !important;
    line-height: 1 !important;
  }

  .app-content {
    padding-bottom: calc(5.75rem + env(safe-area-inset-bottom)) !important;
  }
}

/* Definitive mobile action placement: only bottom bar floats */
.mobile-bottom-actions {
  display: none;
}

@media (min-width: 641px) {
  .desktop-header-action {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  .desktop-header-action {
    display: none !important;
  }

  .mobile-bottom-actions:not(.hidden) {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
    padding: 0 1rem;
  }

  .mobile-bottom-actions .mobile-fab {
    pointer-events: auto;
    width: 58px !important;
    height: 58px !important;
    min-width: 58px !important;
    min-height: 58px !important;
    max-width: 58px !important;
    padding: 0 !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.22), 0 5px 14px rgba(15, 23, 42, 0.16);
  }

  .mobile-bottom-actions #btnNewRecipeHeader,
  .mobile-bottom-actions #btnToggleCookbooksHeader {
    position: static !important;
    inset: auto !important;
  }

  .mobile-bottom-actions #btnNewRecipeHeader::before {
    content: '+' !important;
    display: block !important;
    font-size: 2rem !important;
    font-weight: 800 !important;
    line-height: 1 !important;
  }

  .mobile-bottom-actions #btnToggleCookbooksHeader::before {
    content: '📖' !important;
    display: block !important;
    font-size: 1.45rem !important;
    line-height: 1 !important;
  }
}

/* Perfect optical centering for mobile floating action icons */
@media (max-width: 640px) {
  .mobile-bottom-actions .mobile-fab {
    position: relative !important;
    line-height: 1 !important;
    text-align: center !important;
  }

  .mobile-bottom-actions .mobile-fab::before {
    position: absolute !important;
    inset: 50% auto auto 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
    display: block !important;
    line-height: 1 !important;
  }

  .mobile-bottom-actions #btnNewRecipeHeader::before {
    transform: translate(-50%, -54%) !important;
  }

  .mobile-bottom-actions #btnToggleCookbooksHeader::before {
    transform: translate(-50%, -51%) !important;
  }
}

/* Correct FAB icon centering: center inside each circular button, not on screen */
@media (max-width: 640px) {
  .mobile-bottom-actions .mobile-fab {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    line-height: 1 !important;
  }

  .mobile-bottom-actions .mobile-fab::before {
    position: static !important;
    inset: auto !important;
    transform: none !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
  }

  .mobile-bottom-actions #btnNewRecipeHeader::before {
    transform: none !important;
    padding-bottom: 0.12rem;
  }

  .mobile-bottom-actions #btnToggleCookbooksHeader::before {
    transform: none !important;
  }
}

/* Final FAB centering: use real inner span, no pseudo icon displacement */
@media (max-width: 640px) {
  .mobile-bottom-actions .mobile-fab {
    display: grid !important;
    place-items: center !important;
    overflow: visible !important;
    line-height: 0 !important;
  }

  .mobile-bottom-actions .mobile-fab::before,
  .mobile-bottom-actions #btnNewRecipeHeader::before,
  .mobile-bottom-actions #btnToggleCookbooksHeader::before {
    content: none !important;
    display: none !important;
  }

  .mobile-fab-icon {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    line-height: 1;
    font-size: 1.45rem;
    font-weight: 800;
    text-align: center;
  }

  .mobile-fab-plus {
    font-size: 2rem;
    transform: translateY(-1px);
  }
}

@media (max-width: 640px) {
  #formEnqueue .btn-enqueue-cancel {
    display: none;
  }
}

/* Mobile recipe detail breathing room */
@media (max-width: 640px) {
  #modalRecipeDetail.modal-overlay {
    padding: calc(0.75rem + env(safe-area-inset-top)) 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
    align-items: center;
  }

  #modalRecipeDetail .modal-recipe-card {
    height: auto;
    max-height: calc(100dvh - 1.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-radius: 20px;
  }

  #modalRecipeDetail .modal-recipe-fixed-top {
    padding: 0.85rem 0.85rem 0.7rem;
  }

  #modalRecipeDetail .modal-recipe-scrollable-body {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
}
