/* Cook Simple — senior-friendly recipe manager
   Base ≥18px, 48px targets, WCAG AA, one accent */

:root {
  --bg: #f7f2eb;
  --bg-card: #ffffff;
  --bg-soft: #f0e8dc;
  --text: #1f1a14;
  --text-muted: #5c5348;
  --border: #d9cfc0;
  --accent: #c45c26;
  --accent-dark: #9a4518;
  --accent-soft: #f8e6d9;
  --ok: #2d6a4f;
  --ok-soft: #d8f3e4;
  --danger: #9b2226;
  --danger-soft: #fde8e8;
  --shadow: 0 2px 12px rgba(31, 26, 20, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --space: 1rem;
  --space-lg: 1.5rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --focus: 3px solid var(--accent);
  --header-h: auto;
  --touch: 48px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

img,
svg {
  max-width: 100%;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -100px;
  z-index: 1000;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 0.5rem;
}

/* Header */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 0.85rem var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  font-size: 2rem;
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.tagline {
  margin: 0.1rem 0 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Tabs */
.tab-nav {
  max-width: 920px;
  margin: 0 auto;
  padding: 0.65rem var(--space-lg) 0;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.tab {
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.65rem 1.1rem;
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 3px solid transparent;
}

.tab:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.tab.active,
.tab[aria-selected="true"] {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
  background: var(--accent-soft);
}

/* Main */
#main {
  max-width: 920px;
  margin: 0 auto;
  padding: var(--space-lg);
  padding-bottom: 3rem;
}

.panel[hidden] {
  display: none !important;
}

.panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.panel-lead {
  margin: 0 0 var(--space-lg);
  color: var(--text-muted);
  font-size: 1.05rem;
}

.panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.panel-head-row .panel-title {
  margin-bottom: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-soft);
  border-color: var(--text-muted);
}

.btn-accent {
  background: var(--ok);
  color: #fff;
  border-color: var(--ok);
}

.btn-accent:hover:not(:disabled) {
  background: #1b4332;
  border-color: #1b4332;
}

.btn-text {
  background: transparent;
  color: var(--accent-dark);
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-text:hover:not(:disabled) {
  background: var(--accent-soft);
}

.btn-danger-text {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-danger-text:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-icon {
  width: var(--touch);
  height: var(--touch);
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
}

.btn-icon:hover:not(:disabled) {
  background: var(--bg-soft);
}

.btn-large {
  min-height: 56px;
  padding: 0.85rem 1.25rem;
  font-size: 1.05rem;
  flex: 1 1 140px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

/* Cards & stats */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow);
}

.card h3,
.card h4 {
  margin: 0 0 0.65rem;
  font-size: 1.15rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.card-head h3 {
  margin: 0;
}

.card-note {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.sample-card {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg-card) 55%);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.stat-card.accent {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.stat-label {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  margin: 0.2rem 0 0.5rem;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
}

.stat-link {
  min-height: var(--touch);
  padding: 0.4rem 0;
  border: none;
  background: none;
  color: var(--accent-dark);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Filters */
.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  margin-bottom: var(--space);
  padding: var(--space);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

@media (min-width: 640px) {
  .filters {
    grid-template-columns: 1.5fr 1fr auto;
    align-items: end;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-weight: 600;
  font-size: 0.95rem;
}

.field input[type="text"],
.field input[type="search"],
.field input[type="number"],
.field select,
.field textarea {
  min-height: var(--touch);
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  width: 100%;
}

.field textarea {
  min-height: 8rem;
  resize: vertical;
  line-height: 1.45;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  border-color: var(--accent);
}

.field-check {
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  min-height: var(--touch);
}

.field-check input[type="checkbox"] {
  width: 1.35rem;
  height: 1.35rem;
  min-width: 1.35rem;
  accent-color: var(--accent);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.field-hint {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.req {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.form-error {
  margin: 0.5rem 0;
  padding: 0.75rem 1rem;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.form-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem 1rem;
  margin: 0 0 1rem;
}

.form-fieldset legend {
  font-weight: 700;
  padding: 0 0.35rem;
}

.list-meta {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.empty-msg {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.status-msg {
  margin: 0.75rem 0 0;
  color: var(--ok);
  font-weight: 600;
  min-height: 1.4em;
}

/* Recipe list */
.recipe-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.recipe-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  text-align: left;
  width: 100%;
  min-height: var(--touch);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.recipe-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(196, 92, 38, 0.12);
}

.recipe-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.recipe-card h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.recipe-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
}

.badge-pill {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-pill.sample {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.badge-pill.fav {
  background: #fff3cd;
  color: #7a5b00;
}

.recipe-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.recipe-card-actions .btn {
  min-height: var(--touch);
}

.recipe-list.compact .recipe-card {
  padding: 0.85rem 1rem;
}

/* Cook mode */
.cook-session {
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

.cook-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space);
  flex-wrap: wrap;
}

.cook-title-block h3 {
  margin: 0;
  font-size: 1.35rem;
}

.cook-progress {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-weight: 600;
}

.servings-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1.15rem;
}

.servings-label {
  font-weight: 700;
}

.servings-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.servings-value {
  min-width: 2.5rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
}

.servings-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  flex: 1 1 100%;
}

@media (min-width: 560px) {
  .servings-note {
    flex: 1 1 auto;
    text-align: right;
  }
}

.ingredients-card {
  margin-bottom: 0;
}

.ingredient-list {
  margin: 0;
  padding-left: 1.35rem;
  font-size: 1.05rem;
}

.ingredient-list li {
  margin-bottom: 0.4rem;
}

.step-card {
  background: var(--bg-card);
  border: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.5rem 1.35rem;
  min-height: 10rem;
  box-shadow: var(--shadow);
}

.step-badge {
  margin: 0 0 0.65rem;
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.95rem;
}

.step-text {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.45;
  font-weight: 500;
}

.step-meta {
  margin: 0.85rem 0 0;
  color: var(--text-muted);
  font-weight: 600;
}

.cook-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.voice-bar,
.timer-bar {
  margin-bottom: 0;
}

.timer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
}

.timer-row .field {
  max-width: 8rem;
}

.timer-display {
  margin: 0.85rem 0 0;
  font-size: 2.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-dark);
}

.cook-finish-row {
  margin-top: 0.25rem;
}

/* Insights */
.breakdown-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.breakdown-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  min-height: var(--touch);
  font-size: 1.05rem;
}

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

.breakdown-list.numbered {
  list-style: decimal;
  padding-left: 1.5rem;
}

.breakdown-list.numbered li {
  display: list-item;
  padding-left: 0.35rem;
}

.breakdown-list .count {
  font-weight: 700;
  color: var(--accent-dark);
  white-space: nowrap;
}

/* Modal */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: min(640px, calc(100vw - 1.5rem));
  width: 100%;
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(31, 26, 20, 0.25);
}

.modal.modal-sm {
  max-width: min(420px, calc(100vw - 1.5rem));
}

.modal::backdrop {
  background: rgba(31, 26, 20, 0.55);
}

.modal-inner {
  display: flex;
  flex-direction: column;
  max-height: min(90vh, 900px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-body {
  padding: 1.15rem;
  overflow-y: auto;
}

.modal-footer,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 1rem 1.15rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.form-body .modal-footer,
.form-body .form-actions {
  padding: 1rem 0 0;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.detail-section {
  margin-bottom: 1.25rem;
}

.detail-section h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-weight: 600;
}

.detail-section ul,
.detail-section ol {
  margin: 0;
  padding-left: 1.35rem;
}

.detail-section li {
  margin-bottom: 0.45rem;
  line-height: 1.45;
}

/* Footer */
.app-footer {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.25rem var(--space-lg) 2.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  border-top: 1px solid var(--border);
}

.app-footer p {
  margin: 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  max-width: min(90vw, 420px);
  padding: 0.9rem 1.25rem;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.toast[hidden] {
  display: none !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* Print */
@media print {
  .app-header,
  .tab-nav,
  .app-footer,
  .btn,
  .filters,
  .sample-card {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .panel[hidden] {
    display: none !important;
  }
}
