/* Ultra Black with Blue & White Highlights */
:root {
  --bg-primary: #000000;
  --bg-surface: #000000;
  --bg-surface-elevated: #050507;
  --bg-subtle: #08080a;
  --bg-hover: #121216;
  
  --text-main: #ffffff;
  --text-secondary: #9e9ea6;
  --text-muted: #5e5e66;
  
  --primary: #2997ff;
  --primary-text: #ffffff;
  --primary-hover: #40a4ff;
  --primary-light: rgba(41, 151, 255, 0.08);
  --primary-glow: rgba(41, 151, 255, 0.3);
  
  --border-subtle: #16161a;
  --border-strong: #26262e;
  --border-focus: #2997ff;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.9);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.95);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 1);
  
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="light"] {
  --bg-primary: #000000;
  --bg-surface: #000000;
  --bg-surface-elevated: #050507;
  --bg-subtle: #08080a;
  --bg-hover: #121216;
  --text-main: #ffffff;
  --text-secondary: #9e9ea6;
  --text-muted: #5e5e66;
  --primary: #2997ff;
  --primary-text: #ffffff;
  --primary-hover: #40a4ff;
  --primary-light: rgba(41, 151, 255, 0.08);
  --border-subtle: #16161a;
  --border-strong: #26262e;
  --border-focus: #2997ff;
}

* {
  box-sizing: border-box;
  min-width: 0;
  margin: 0;
  padding: 0;
}

html {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
  touch-action: pan-y;
}

/* App Header */
.app-header {
  background: rgba(0, 0, 0, 0.92);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

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

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  background: #000000;
  border: 1px solid var(--primary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  color: var(--primary);
  letter-spacing: 0.04em;
}

.logo-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: #ffffff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Sync Status */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  background: #000000;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}

.sync-status.saving .sync-dot {
  background: #ffffff;
  box-shadow: 0 0 8px #ffffff;
  animation: pulseSync 0.8s infinite alternate;
}

.sync-status.offline .sync-dot {
  background: var(--text-muted);
  box-shadow: none;
}

@keyframes pulseSync {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.84rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
  background: #000000;
  color: #ffffff;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 14px var(--primary-glow);
}

.btn-secondary {
  background: #000000;
  color: #ffffff;
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: #ffffff;
}

.btn-outline {
  border: 1px solid var(--border-strong);
  background: #000000;
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-icon {
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  font-size: 0.82rem;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 0.8rem;
}

/* Layout */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 80px;
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 28px;
}

@media (max-width: 900px) {
  .app-container {
    grid-template-columns: 1fr;
  }
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-box {
  position: relative;
}

.search-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.88rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #000000;
  color: #ffffff;
  outline: none;
  transition: all 0.15s ease;
  font-family: inherit;
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.category-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.cat-chip {
  padding: 5px 11px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: #000000;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
  font-family: inherit;
}

.cat-chip.active, .cat-chip:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.recipe-cards-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 2px;
}

.recipe-card-item {
  background: #000000;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.recipe-card-item:hover {
  border-color: var(--border-strong);
  background: #050508;
}

.recipe-card-item.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.recipe-card-item.active .recipe-card-title {
  color: var(--primary);
}

.recipe-card-content {
  display: flex;
  align-items: center;
  gap: 11px;
}

.recipe-card-emoji {
  font-size: 1.35rem;
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.recipe-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.recipe-card-title {
  font-weight: 700;
  font-size: 0.94rem;
  color: #ffffff;
}

.recipe-card-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Main Content */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Recipe Hero */
.recipe-hero {
  background: #000000;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 24px;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}

.hero-title {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: #ffffff;
}

.hero-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: #000000;
  color: #ffffff;
  border: 1px solid var(--border-strong);
}

.hero-desc {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-top: 8px;
  line-height: 1.55;
}

/* Scaling Toolbar */
.scaling-toolbar {
  background: #000000;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ratio-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #ffffff;
}

.ratio-value {
  padding: 2px 9px;
  background: #000000;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.quick-scales {
  display: flex;
  gap: 3px;
  background: #000000;
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
}

.scale-btn {
  background: transparent;
  border: none;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.12s ease;
  font-family: inherit;
}

.scale-btn:hover {
  color: #ffffff;
}

.scale-btn.active {
  background: var(--primary);
  color: #ffffff;
}

/* Section */
.content-section {
  background: #000000;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 22px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.section-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* Ingredients */
.ingredients-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ingredient-row {
  display: grid;
  grid-template-columns: 1fr 130px 90px 65px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: #000000;
  border: 1px solid var(--border-subtle);
  transition: all 0.12s ease;
}

.ingredient-row:hover {
  border-color: var(--border-strong);
  background: #050508;
}

.ingredient-info {
  display: flex;
  align-items: center;
}

.ingredient-emoji {
  font-size: 1.2rem;
  margin-right: 12px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.ingredient-name {
  font-weight: 600;
  font-size: 0.94rem;
  color: #ffffff;
}

/* Stepper & Input */
.qty-input-wrapper {
  display: flex;
  align-items: center;
  background: #000000;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all 0.15s ease;
}

.qty-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.qty-input {
  width: 100%;
  padding: 6px 4px;
  border: none;
  outline: none;
  font-size: 0.98rem;
  font-weight: 800;
  text-align: right;
  background: transparent;
  color: #ffffff;
  font-family: inherit;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.qty-input[type=number] {
  -moz-appearance: textfield;
}

.qty-stepper-btn {
  background: #000000;
  border: none;
  color: var(--text-secondary);
  width: 26px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  user-select: none;
  transition: all 0.1s ease;
}

.qty-stepper-btn:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

.unit-label {
  font-size: 0.84rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.bakers-tag {
  text-align: right;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--primary);
  font-weight: 700;
}

/* Total Batch Row */
.ingredients-summary {
  margin-top: 14px;
  padding: 14px 16px;
  background: #000000;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.total-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: #ffffff;
}

.total-editor {
  display: flex;
  align-items: center;
  gap: 8px;
}

.total-input-box {
  width: 120px;
  font-size: 1rem;
}

/* Cooking Spec Card */
.cooking-spec-card {
  margin-top: 14px;
  padding: 14px 16px;
  background: #000000;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cooking-spec-content h4 {
  font-size: 0.88rem;
  color: var(--primary);
  font-weight: 700;
}

.cooking-spec-content p {
  font-size: 0.85rem;
  color: #ffffff;
  line-height: 1.5;
}

/* Steps */
.steps-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: #000000;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: flex-start;
  transition: all 0.12s ease;
}

.step-card:hover {
  border-color: var(--border-strong);
}

.step-card.completed {
  opacity: 0.4;
}

.step-card.completed .step-title {
  text-decoration: line-through;
}

.step-check-btn {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #000000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 0.75rem;
  margin-top: 2px;
  transition: all 0.12s ease;
}

.step-card.completed .step-check-btn {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.step-index-badge {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.step-card.completed .step-index-badge {
  display: none;
}

.step-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-title {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
}

.step-detail {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.step-actions {
  display: flex;
  align-items: center;
}

.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #000000;
  border: 1px solid var(--primary);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s ease;
}

.timer-pill:hover {
  background: var(--primary);
  color: #ffffff;
}

.timer-pill.running {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 0 14px var(--primary-glow);
}

/* Floating Timer */
.floating-timer-bar {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #000000;
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  box-shadow: 0 0 24px rgba(41, 151, 255, 0.25);
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 80;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.floating-timer-bar.hidden {
  transform: translateY(100px);
  opacity: 0;
  pointer-events: none;
}

.timer-digits {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--primary);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #000000;
  border: 1px solid var(--border-strong);
  color: #ffffff;
  padding: 9px 18px;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

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

.modal-box {
  background: #000000;
  border-radius: var(--radius-md);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-textarea {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #000000;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.88rem;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Responsive Mobile (iPhone & Small Screens) */
@media (max-width: 650px) {
  html, body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
  }

  .header-container {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
  }

  .header-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

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

  .app-container {
    padding: 12px 10px 60px;
    gap: 16px;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .content-section, .recipe-hero {
    padding: 16px 12px;
    border-radius: var(--radius-sm);
  }

  .hero-top {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .hero-top > div:last-child {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .hero-top > div:last-child .btn {
    flex: 1;
  }

  .hero-title {
    font-size: 1.35rem;
  }

  .scaling-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
  }

  .toolbar-left, .toolbar-right {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }

  .quick-scales {
    flex: 1;
    justify-content: space-between;
  }

  .scale-btn {
    padding: 4px 6px;
    font-size: 0.74rem;
    flex: 1;
    text-align: center;
  }

  .toolbar-right .btn {
    flex: 1;
    padding: 6px 8px;
    font-size: 0.76rem;
    text-align: center;
  }

  .ingredient-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto;
    gap: 8px 10px;
    padding: 10px 12px;
    width: 100%;
  }

  .ingredient-info {
    grid-column: 1 / -1;
    margin-bottom: 2px;
  }

  .qty-control-area {
    grid-column: 1;
    justify-self: start;
  }

  .qty-input-wrapper {
    width: 110px;
  }

  .unit-label {
    grid-column: 2;
    align-self: center;
    font-size: 0.8rem;
  }

  .bakers-tag {
    grid-column: 3;
    align-self: center;
    display: block !important;
    font-size: 0.75rem;
  }

  .ingredients-summary {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .total-editor {
    justify-content: space-between;
    width: 100%;
  }

  .total-input-box {
    flex: 1;
  }

  .step-card {
    grid-template-columns: 24px 1fr;
    gap: 10px;
    padding: 12px;
  }

  .step-actions {
    grid-column: 1 / -1;
    margin-top: 6px;
  }

  .floating-timer-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    justify-content: space-between;
  }
}

@media print {
  .app-header, .sidebar, .scaling-toolbar, .btn, .step-actions, .floating-timer-bar {
    display: none !important;
  }
  .app-container {
    display: block;
    padding: 0;
  }
  .content-section {
    border: none;
    padding: 0;
    margin-bottom: 20px;
  }
}
