:root {
  --bg: #f5efe1;
  --surface: #ffffff;
  --surface-raised: #fffdf9;
  --text: #143036;
  --text-soft: #3d5559;
  --muted: #6b7f83;
  --accent: #143036;
  --accent-hover: #1c4249;
  --accent-soft: #a9b9a6;
  --accent-soft-bg: #e8efe6;
  --border: #d8cfc0;
  --border-strong: #c4b8a8;
  --danger: #b33a3a;
  --danger-bg: #fdeeee;
  --info-bg: #eef4f5;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(20, 48, 54, 0.08);
  --shadow-lg: 0 8px 24px rgba(20, 48, 54, 0.12);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --touch: 44px;
  --header-h: 3.75rem;
  --cook-header-h: 7.5rem;
}

* { box-sizing: border-box; }

html[data-theme="dark"] {
  --bg: #1c282b;
  --surface: #263438;
  --surface-raised: #2e3f44;
  --text: #e8f0f2;
  --text-soft: #b8cace;
  --muted: #8aa3a8;
  --border: #3d5258;
  --border-strong: #4d656c;
  --accent-soft-bg: #2a4038;
  --info-bg: #243238;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

a { color: var(--accent-hover); text-decoration-thickness: 1px; }
a:hover { text-decoration: underline; }

/* Icons */
.icon {
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
  vertical-align: -0.2em;
}
.icon-lg { width: 1.75rem; height: 1.75rem; }
.icon-xl { width: 2.5rem; height: 2.5rem; }

/* Header — fixed; only main scrolls */
.site-header {
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 100;
  overflow: visible;
}

.site-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(0.65rem, env(safe-area-inset-top)) 1rem 0.65rem;
}

.header-tools {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 0.45rem 1rem 0.55rem;
  display: flex;
  justify-content: center;
}
.header-tools[hidden] { display: none !important; }

body.cook-mode { --header-h: var(--cook-header-h); }

.cook-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.header-nav-btn,
.header-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #fff;
  text-decoration: none;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  min-height: var(--touch);
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}
.header-nav-btn:hover,
.header-nav-link:hover { background: rgba(255, 255, 255, 0.12); text-decoration: none; }
.header-icon-btn {
  width: var(--touch);
  height: var(--touch);
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.header-icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.header-icon-btn .icon { width: 1.35rem; height: 1.35rem; }

.tools-menu-wrap { position: relative; }

/* Dims recipe content only — sits below header (z-index 100) so Tools menu stays clickable */
.tools-menu-backdrop {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.35);
  border: none;
  padding: 0;
  margin: 0;
  cursor: default;
}
.tools-menu-backdrop[hidden] { display: none !important; }

body.tools-menu-open .site-header {
  z-index: 110;
}

.tools-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  width: min(18rem, calc(100vw - 2rem));
  min-width: 12rem;
  max-height: min(70dvh, 28rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  z-index: 2;
  box-sizing: border-box;
}

/* Phone: full-width panel inside safe area (avoids clipping off-screen left) */
@media (max-width: 720px) {
  .tools-menu {
    position: fixed;
    left: max(0.75rem, env(safe-area-inset-left));
    right: max(0.75rem, env(safe-area-inset-right));
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: min(65dvh, calc(100dvh - 6rem - env(safe-area-inset-bottom)));
    z-index: 120;
  }
}
.tools-menu[hidden] { display: none !important; }
.tools-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}
.tools-menu-item:hover { background: var(--accent-soft-bg); }
.tools-menu-item label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  flex: 1;
}
.tools-menu-item .icon-btn {
  background: var(--surface-raised);
  color: var(--accent);
  border: 1px solid var(--border);
}
.tools-menu-item .servings-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.tools-menu-item .servings-stepper span {
  font-weight: 700;
  min-width: 1.5ch;
  text-align: center;
}
.tools-menu-btn {
  width: 100%;
  justify-content: flex-start;
  gap: 0.5rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
}
.tools-menu-btn:hover { background: var(--accent-soft-bg); }
.tools-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0;
}
.tools-menu-hint {
  margin: 0;
  padding: 0.35rem 0.65rem 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
}
.logo:hover { text-decoration: none; opacity: 0.95; }
.logo-mark { border-radius: 8px; background: #fff; }

#main-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #fff;
  text-decoration: none;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  min-height: var(--touch);
}
#main-nav a:hover { background: rgba(255,255,255,0.12); text-decoration: none; }

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
  padding-bottom: max(2.5rem, env(safe-area-inset-bottom));
}

/* Page structure */
.page-header { margin-bottom: 1.25rem; }
.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.5rem, 4vw, 2rem);
  letter-spacing: -0.02em;
}
.page-subtitle {
  margin: 0;
  color: var(--text-soft);
  font-size: 1.05rem;
  max-width: 42rem;
}

.guide {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  background: var(--info-bg);
  border: 1px solid #c5d8dc;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.95rem;
  color: var(--text-soft);
}
.guide p { margin: 0; }
.guide .icon { color: var(--accent); margin-top: 0.1rem; }

.steps-guide {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  counter-reset: step;
}
.steps-guide li {
  counter-increment: step;
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.steps-guide li:last-child { border-bottom: none; }
.steps-guide li::before {
  content: counter(step);
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
}
.steps-guide strong { display: block; color: var(--text); }

/* Toolbar & buttons */
.toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.search-wrap {
  flex: 1;
  min-width: min(100%, 220px);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.search-wrap:focus-within {
  border-color: var(--accent-soft);
  outline: 2px solid var(--accent-soft-bg);
}
.search-wrap .icon { color: var(--muted); }
.search-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.75rem 0;
  font: inherit;
  min-width: 0;
}
.search-wrap input:focus { outline: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  min-height: var(--touch);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--surface-raised); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
}
.btn.ghost:hover { background: var(--accent-soft-bg); }
.btn.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #e8b4b4;
}
.btn-lg { padding: 0.85rem 1.35rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-help {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.panel summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.panel summary::-webkit-details-marker { display: none; }
.panel details[open] summary { margin-bottom: 0.75rem; }

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
  font-size: 0.92rem;
}
.field-hint {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.panel input[type="text"],
.panel input[type="url"],
.panel input[type="number"],
.panel input[type="password"],
.panel textarea,
#passphrase-dialog input,
#auth-dialog input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface-raised);
}
.panel input:focus,
.panel textarea:focus,
#passphrase-dialog input:focus,
#auth-dialog input:focus {
  outline: 2px solid var(--accent-soft-bg);
  border-color: var(--accent-soft);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error {
  color: var(--danger);
  padding: 0.75rem 1rem;
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
}

.status-msg {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.bulk-import-progress {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.bulk-import-log {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  font-size: 0.9rem;
}

.bulk-import-log li {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.bulk-import-log li:last-child {
  border-bottom: none;
}

.bulk-import-ok {
  color: var(--text);
}

.bulk-import-fail {
  color: var(--danger);
}

.bulk-import-url {
  word-break: break-all;
}

.bulk-import-done {
  margin-top: 1rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem 1rem 2.5rem;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty-illustration {
  width: 96px;
  height: 96px;
  margin: 0 auto 1rem;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
}
.empty-state h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}
.empty-state > p {
  margin: 0 auto 1.25rem;
  max-width: 28rem;
  color: var(--text-soft);
}
.getting-started {
  text-align: left;
  max-width: 26rem;
  margin: 0 auto 1.5rem;
}

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

.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s, transform 0.15s;
}
.recipe-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-media {
  height: 148px;
  background: var(--accent-soft-bg);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media .placeholder-icon { width: 56px; height: 56px; opacity: 0.55; }

.recipe-card h2 {
  font-size: 1.08rem;
  margin: 0.85rem 1rem 0.35rem;
  line-height: 1.3;
}
.recipe-card h2 a { color: var(--text); text-decoration: none; }
.recipe-card h2 a:hover { color: var(--accent-hover); text-decoration: underline; }

.recipe-card .meta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 1rem 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.card-actions {
  padding: 0 1rem 1rem;
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}
.card-actions .btn { flex: 1; }

/* Edit view */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 1.5rem 0 0.5rem;
}
.section-head h2 {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ing-table-wrap { overflow-x: auto; margin: 0 -0.25rem; }
.ing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.ing-table th {
  text-align: left;
  padding: 0.5rem 0.35rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--border);
}
.ing-table td {
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.ing-table input {
  font: inherit;
  padding: 0.4rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
  min-width: 0;
  background: var(--surface-raised);
}
.ing-table .col-hide { width: 2.5rem; text-align: center; }
.ing-table .col-qty { width: 4rem; }
.ing-table .col-unit { width: 4.5rem; }

/* Edit hub navigation */
.edit-hub-nav {
  display: none;
  position: sticky;
  top: var(--header-h);
  z-index: 50;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.edit-hub-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: var(--touch);
  padding: 0.5rem 0.35rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.edit-hub-tab .icon { width: 1.15rem; height: 1.15rem; }
.edit-hub-tab:hover { background: var(--accent-soft-bg); color: var(--text); }
.edit-hub-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.edit-hub { display: block; }

/* Mobile ingredient cards */
.ing-mobile { display: none; }
.ing-help-mobile { display: none; }

.ing-section-hub { margin-bottom: 0.75rem; }

.ing-section-details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  overflow: hidden;
}

.ing-section-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  cursor: pointer;
  list-style: none;
  min-height: var(--touch);
}
.ing-section-summary::-webkit-details-marker { display: none; }

.ing-section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.ing-section-count {
  flex-shrink: 0;
  min-width: 1.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft-bg);
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.ing-section-details[open] .ing-section-summary {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.ing-cards { padding: 0.65rem; }

.ing-row {
  padding: 0.85rem;
  margin-bottom: 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ing-row:last-child { margin-bottom: 0; }

.ing-hide-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  min-height: var(--touch);
}
.ing-hide-label input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }

.ing-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.ing-field label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.ing-field input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  min-height: var(--touch);
}
.ing-field input:focus {
  outline: 2px solid var(--accent-soft-bg);
  border-color: var(--accent-soft);
}

.ing-item-field,
.ing-group-field { grid-column: 1 / -1; }

.step-list { list-style: none; padding: 0; margin: 0; }
.step-list li {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin-bottom: 0.65rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.step-list li.dragging { opacity: 0.5; }
.drag-handle {
  cursor: grab;
  color: var(--muted);
  user-select: none;
  padding: 0.25rem;
  font-size: 1.1rem;
  line-height: 1;
}
.step-list textarea {
  flex: 1;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  background: var(--surface);
  resize: vertical;
  min-height: 3rem;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* Cook view */
.cook-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.control-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.control-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.control-value {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.control-card .stepper {
  width: var(--touch);
  height: var(--touch);
  font-size: 1.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}
.control-card .stepper:hover { background: var(--accent-soft-bg); }

#servings-val {
  font-size: 1.5rem;
  font-weight: 700;
  min-width: 2ch;
}

.toggle-btn {
  width: 100%;
  text-transform: capitalize;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: var(--touch);
}
.toggle-row input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

.cook-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem 1.75rem;
  box-shadow: var(--shadow);
}
.cook-content h1 {
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}
.cook-content .notes {
  color: var(--text-soft);
  font-style: italic;
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--accent-soft-bg);
  border-radius: var(--radius-sm);
}
.cook-content h2 {
  font-size: 1.15rem;
  margin: 1.75rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--accent-soft);
}
.cook-content .ing-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 1.12rem;
}
.cook-content .ing-list li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.cook-content .ing-list li:last-child { border-bottom: none; }

.cook-content .cook-steps {
  padding-left: 1.35rem;
  font-size: 1.12rem;
  line-height: 1.65;
}
.cook-content .cook-steps li { margin-bottom: 1rem; }
.cook-content .ing-list li.voice-current,
.cook-content .cook-steps li.voice-current {
  background: var(--accent-soft-bg);
  border-radius: var(--radius-sm);
  margin: 0 -0.35rem;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.voice-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.voice-panel.voice-active {
  border-color: var(--accent);
  background: var(--accent-soft-bg);
}
.voice-panel.voice-listening {
  animation: voice-pulse 1.5s ease-in-out infinite;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
}
.voice-status {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0 0 0.25rem;
}
.voice-label {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
}
.voice-hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-soft);
  line-height: 1.45;
}
.voice-unsupported {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.voice-control-card .btn { margin-top: 0.25rem; }

/* Cook mode — mobile-first */
.cook-view {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cook-quick-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.15rem 0 0.35rem;
  scrollbar-width: none;
}
.cook-quick-bar::-webkit-scrollbar { display: none; }

.quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  min-height: var(--touch);
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 0.92rem;
  font-weight: 600;
}
.servings-chip #servings-val {
  font-size: 1.15rem;
  min-width: 1.5ch;
  text-align: center;
}
.chip-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.btn-chip {
  cursor: pointer;
  color: var(--text);
  border: 1px solid var(--border);
  background: var(--surface);
}
.toggle-chip { cursor: pointer; }
.toggle-chip input { accent-color: var(--accent); }

.icon-btn {
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

/* Voice row in cook header (compact: − mic +) */
.voice-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}
.voice-toolbar.voice-listening .voice-mic-btn {
  background: #fff;
  color: var(--accent);
  animation: voice-pulse 1.2s ease-in-out infinite;
}
.voice-toolbar.voice-speaking .voice-mic-btn {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55);
}
.voice-toolbar.voice-speaking .voice-hear-glyph .hear-bar {
  background: rgba(255, 255, 255, 0.35);
  animation: none;
}

/* Live “hearing you” meter beside mic */
.voice-hear-glyph {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  width: 1.35rem;
  height: 1.35rem;
  flex-shrink: 0;
}
.voice-hear-glyph[hidden] { display: none !important; }
.voice-hear-glyph .hear-bar {
  display: block;
  width: 3px;
  min-height: 0.2rem;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.45);
  transition: height 0.06s ease-out, background 0.12s ease;
}
.voice-hear-glyph.hearing-wait .hear-bar {
  animation: hear-idle 1s ease-in-out infinite;
}
.voice-hear-glyph.hearing-wait .hear-bar:nth-child(2) { animation-delay: 0.12s; }
.voice-hear-glyph.hearing-wait .hear-bar:nth-child(3) { animation-delay: 0.24s; }
.voice-hear-glyph.hearing-wait .hear-bar:nth-child(4) { animation-delay: 0.36s; }
.voice-hear-glyph.hearing-voice .hear-bar {
  background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.55);
}
@keyframes hear-idle {
  0%, 100% { transform: scaleY(0.45); opacity: 0.55; }
  50% { transform: scaleY(1); opacity: 1; }
}
.voice-toolbar .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.dock-btn {
  width: var(--touch);
  height: var(--touch);
  min-height: var(--touch);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
}
.dock-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.dock-btn.voice-mic-btn {
  width: 52px;
  height: 52px;
  min-height: 52px;
  font-size: 1.45rem;
  border-width: 2px;
  background: rgba(255, 255, 255, 0.14);
}
.dock-btn.voice-mic-btn:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Recipe photo (edit) */
.recipe-photo-field { margin-bottom: 1.25rem; }
.recipe-photo-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  margin: 0.5rem 0 0.75rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  overflow: hidden;
}
.recipe-photo-preview img {
  max-width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}
.recipe-photo-preview .muted { color: var(--muted); font-size: 0.95rem; }
.recipe-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.btn.danger-soft {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid transparent;
}

.voice-settings-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 440px;
  width: calc(100% - 1.5rem);
  max-height: min(90dvh, 640px);
  overflow: auto;
  box-shadow: var(--shadow-lg);
}
.voice-settings-dialog::backdrop { background: rgba(20, 48, 54, 0.45); }

.voice-settings-details {
  margin-top: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 0.65rem;
}
.voice-settings-details summary {
  cursor: pointer;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  list-style: none;
}
.voice-settings-details summary::-webkit-details-marker { display: none; }
.voice-settings-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 0.75rem;
  margin-top: 0.75rem;
}
.voice-settings-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.voice-settings-form label.full-width { grid-column: 1 / -1; }
.voice-settings-form select,
.voice-settings-form input,
.voice-settings-form textarea {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text);
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}
.voice-settings-form #vs-save { grid-column: 1 / -1; }
@media (max-width: 520px) {
  .voice-settings-form { grid-template-columns: 1fr; }
}

.cook-content .cook-steps li::marker {
  font-weight: 700;
  color: var(--accent);
}

code {
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  background: var(--accent-soft-bg);
  border-radius: 4px;
}

.cook-image {
  width: 100%;
  max-height: min(42vh, 320px);
  object-fit: cover;
  border-radius: var(--radius);
  margin: 0 0 1rem;
  display: block;
}

.cook-tip {
  margin-top: 1.5rem;
}

/* Dialog */
#passphrase-dialog,
#auth-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 400px;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow-lg);
}
#passphrase-dialog::backdrop,
#auth-dialog::backdrop { background: rgba(20, 48, 54, 0.45); }
#passphrase-dialog h2,
#auth-dialog h2 { margin: 0 0 0.35rem; }
.auth-gate {
  max-width: 28rem;
  margin: 2rem auto;
  text-align: center;
}
.guide-text { color: var(--text-soft); margin: 0 0 1rem; font-size: 0.95rem; }

.dialog-actions { display: flex; gap: 0.5rem; margin-top: 1.25rem; }
.dialog-actions .btn { flex: 1; }

/* Print */
@media print {
  .no-print,
  .site-header,
  .cook-toolbar,
  .cook-quick-bar,
  .tools-menu-backdrop,
  .header-tools,
  .voice-toolbar,
  .voice-panel,
  .voice-settings-details,
  .voice-unsupported,
  .cook-tip,
  dialog { display: none !important; }

  body { background: #fff; color: #000; font-size: 12pt; }
  main { max-width: none; padding: 0; }

  .cook-content { border: none; box-shadow: none; padding: 0; }
  .cook-content h1 { font-size: 18pt; }
  .cook-content h2 { font-size: 14pt; page-break-after: avoid; }
  .cook-content .ing-list,
  .cook-content .cook-steps { font-size: 11pt; }
  .cook-image { display: none; }
  .print-footer { margin-top: 2rem; font-size: 9pt; color: #444; }

  body.print-images .cook-image { display: block; max-height: 200px; }
}

@media (max-width: 640px) {
  :root { --header-h: 5.75rem; --cook-header-h: 7.25rem; }
  main { padding: 0.85rem 0.85rem 2rem; }
  .recipe-grid { grid-template-columns: 1fr; }
  .cook-toolbar { grid-template-columns: 1fr 1fr; }
  .form-actions .btn { flex: 1; min-width: calc(50% - 0.35rem); }

  /* Edit hub: one section at a time on mobile */
  .edit-hub-nav { display: flex; }
  .edit-hub { display: none; }
  .edit-hub.active { display: block; }

  .ing-desktop,
  .ing-help-desktop { display: none; }
  .ing-mobile,
  .ing-help-mobile { display: block; }

  /* Larger touch-friendly inputs — 16px prevents iOS zoom */
  .panel input[type="text"],
  .panel input[type="url"],
  .panel input[type="number"],
  .panel textarea,
  .search-wrap input {
    font-size: 16px;
    padding: 0.85rem 0.9rem;
    min-height: var(--touch);
  }

  .step-list li {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.85rem;
  }

  .drag-handle {
    align-self: flex-start;
    min-height: var(--touch);
    min-width: var(--touch);
    display: grid;
    place-items: center;
  }

  .step-list textarea {
    font-size: 16px;
    padding: 0.85rem 0.9rem;
    min-height: 5.5rem;
    line-height: 1.5;
    border-radius: var(--radius-sm);
  }

  .ing-table input {
    font-size: 16px;
    padding: 0.65rem 0.75rem;
    min-height: var(--touch);
  }

  .section-head { margin-top: 0; }
  #edit-form.panel { padding: 1rem; }
}
