/* ── Cooking Mode Overlay ─────────────────────────────────────────────────── */

#cooking-mode-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500; /* above modal (1000), below loading (2000) */
  background: #0f172a;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 250ms ease, transform 250ms ease;
  overflow: hidden;
}

#cooking-mode-overlay.cm-active {
  opacity: 1;
  transform: none;
}

/* ── Wrapper ─────────────────────────────────────────────────────────────── */

.cm-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  font-family: var(--font-body, system-ui, sans-serif);
  color: #f1f5f9;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.cm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}

.cm-close-btn {
  background: transparent;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.cm-close-btn:hover {
  background: #334155;
  color: #f1f5f9;
}

.cm-header-center {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.cm-meal-name {
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.cm-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Progress bar */
.cm-progress-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 120px;
}

.cm-progress-track {
  width: 100%;
  height: 5px;
  background: #334155;
  border-radius: 3px;
  overflow: hidden;
}

.cm-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease;
}

.cm-progress-label {
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
}

/* ── Main layout ─────────────────────────────────────────────────────────── */

.cm-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Step Sidebar ────────────────────────────────────────────────────────── */

.cm-step-sidebar {
  width: 340px;
  flex-shrink: 0;
  border-right: 1px solid #1e293b;
  overflow-y: auto;
  background: #0f172a;
  padding: 8px 0;
}

.cm-step-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 8px;
}

/* Step item */
.cm-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
  outline: none;
}

.cm-step-item:hover {
  background: #1e293b;
}

.cm-step-item:focus-visible {
  border-color: #3b82f6;
}

.cm-step-item.cm-active-step {
  background: #1e3a5f;
  border-color: #3b82f6;
}

.cm-step-item.cm-done .cm-step-text {
  text-decoration: line-through;
  color: #475569;
}

.cm-step-item.cm-done .cm-step-num {
  color: #22c55e;
}

/* Checkbox button */
.cm-step-check {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #334155;
  background: transparent;
  color: #22c55e;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 1px;
}

.cm-step-check:hover {
  border-color: #22c55e;
}

.cm-step-item.cm-done .cm-step-check {
  background: #22c55e;
  border-color: #22c55e;
}

/* Step content */
.cm-step-content {
  flex: 1;
  min-width: 0;
}

.cm-step-num {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  display: block;
  margin-bottom: 3px;
}

.cm-step-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #cbd5e1;
}

/* ── Timer Area (inside step item) ──────────────────────────────────────── */

.cm-timer-area {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 6px 10px;
  transition: border-color 0.2s;
}

.cm-timer-area.cm-timer-running {
  border-color: #f59e0b;
  background: #1c1a0e;
}

.cm-timer-area.cm-timer-done {
  border-color: #22c55e;
  background: #0a1f0d;
}

.cm-timer-display {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #f1f5f9;
  min-width: 48px;
  letter-spacing: 0.04em;
}

.cm-timer-area.cm-timer-running .cm-timer-display {
  color: #fbbf24;
}

.cm-timer-area.cm-timer-done .cm-timer-display {
  color: #22c55e;
}

.cm-timer-controls {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.cm-timer-btn {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.cm-timer-btn:hover:not(:disabled) {
  background: #334155;
  color: #f1f5f9;
}

.cm-timer-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.cm-timer-start:hover:not(:disabled) {
  background: #14532d;
  border-color: #22c55e;
  color: #22c55e;
}

.cm-timer-pause:hover:not(:disabled) {
  background: #451a03;
  border-color: #f59e0b;
  color: #f59e0b;
}

/* ── Right Panel ─────────────────────────────────────────────────────────── */

.cm-right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0f172a;
}

/* ── Detail Panel ────────────────────────────────────────────────────────── */

.cm-detail-panel {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.cm-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.cm-detail-step-num {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}

.cm-detail-done-badge {
  font-size: 11px;
  background: #14532d;
  color: #4ade80;
  border: 1px solid #166534;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.cm-detail-text {
  font-size: 22px;
  font-weight: 500;
  line-height: 1.6;
  color: #f1f5f9;
  margin: 0 0 32px 0;
}

/* ── Detail Navigation ───────────────────────────────────────────────────── */

.cm-detail-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cm-nav-btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.cm-nav-btn:hover:not(:disabled) {
  background: #334155;
  color: #f1f5f9;
}

.cm-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.cm-nav-next {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

.cm-nav-next:hover:not(:disabled) {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.cm-check-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid #166534;
  background: #14532d;
  color: #4ade80;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.cm-check-btn:hover {
  background: #166534;
}

.cm-check-btn.cm-uncheck {
  background: #1e293b;
  border-color: #334155;
  color: #64748b;
}

.cm-check-btn.cm-uncheck:hover {
  background: #334155;
  color: #94a3b8;
}

/* ── Ingredients Drawer ──────────────────────────────────────────────────── */

.cm-ing-section {
  border-top: 1px solid #1e293b;
  flex-shrink: 0;
}

.cm-ing-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #1e293b;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.cm-ing-toggle:hover {
  background: #334155;
  color: #f1f5f9;
}

.cm-toggle-icon {
  font-size: 10px;
  transition: transform 0.2s;
}

.cm-ing-drawer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.cm-ing-drawer.cm-ing-open {
  max-height: 260px;
  overflow-y: auto;
}

.cm-ing-list {
  list-style: none;
  margin: 0;
  padding: 4px 12px 8px;
}

.cm-ing-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  font-size: 13px;
}

.cm-ing-item:hover {
  background: #1e293b;
}

.cm-ing-item.cm-ing-done .cm-ing-name,
.cm-ing-item.cm-ing-done .cm-ing-amount {
  text-decoration: line-through;
  color: #475569;
}

.cm-ing-check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid #334155;
  background: transparent;
  color: #22c55e;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s;
}

.cm-ing-item.cm-ing-done .cm-ing-check {
  background: #22c55e;
  border-color: #22c55e;
}

.cm-ing-name {
  flex: 1;
  color: #cbd5e1;
}

.cm-ing-name small {
  color: #64748b;
  font-style: italic;
  font-size: 11px;
  margin-left: 4px;
}

.cm-ing-amount {
  color: #475569;
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Completion Banner ───────────────────────────────────────────────────── */

.cm-completion-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(90deg, #14532d, #166534);
  border-top: 1px solid #22c55e;
  font-size: 14px;
  font-weight: 600;
  color: #bbf7d0;
  animation: cm-slide-up 0.3s ease;
}

.cm-completion-banner.cm-hidden {
  display: none;
}

.cm-completion-icon {
  font-size: 20px;
}

.cm-completion-close {
  margin-left: auto;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid #22c55e;
  background: transparent;
  color: #4ade80;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.cm-completion-close:hover {
  background: rgba(34, 197, 94, 0.15);
}

/* ── Timer Toast ─────────────────────────────────────────────────────────── */

.cm-timer-toast {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #f59e0b;
  color: #1c1a0e;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 8px;
  z-index: 10;
  animation: cm-toast-in 0.2s ease, cm-toast-out 0.3s ease 3.7s forwards;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Animations ──────────────────────────────────────────────────────────── */

@keyframes cm-slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@keyframes cm-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes cm-toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ── Mobile Layout ───────────────────────────────────────────────────────── */

@media (max-width: 680px) {
  .cm-main {
    flex-direction: column;
  }

  .cm-step-sidebar {
    width: 100%;
    max-height: 38vh;
    border-right: none;
    border-bottom: 1px solid #1e293b;
  }

  .cm-right-panel {
    flex: 1;
  }

  .cm-detail-panel {
    padding: 20px 16px;
    justify-content: flex-start;
  }

  .cm-detail-text {
    font-size: 17px;
  }

  .cm-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .cm-progress-wrap {
    min-width: 100px;
  }
}

@media (max-width: 400px) {
  .cm-detail-nav {
    flex-wrap: wrap;
  }
  .cm-check-btn {
    order: -1;
    flex: 0 0 100%;
  }
}