:root {
  --terracotta: #c65a3a;
  --terracotta-dark: #a8492f;
  --burnt-orange: #e07a3f;
  --olive: #6f7452;
  --sage: #a9b39a;
  --sand: #f3ede4;
  --cream: #faf7f2;
  --paper: #fffcf8;
  --charcoal: #2d2a26;
  --muted: #756f68;
  --line: #e8dfd5;
  --soft-line: #f0e9e1;
  --danger: #a83f32;
  --success: #58714b;
  --shadow: 0 12px 34px rgba(66, 45, 31, 0.07);
  --radius: 14px;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--cream); color: var(--charcoal); font: 15px/1.45 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; background: #fff; outline: 0; }
input:focus, select:focus, textarea:focus { border-color: #d9876d; box-shadow: 0 0 0 3px rgba(198, 90, 58, 0.09); }
.mobile-only { display: none; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); grid-template-rows: 76px 1fr; }
.topbar { grid-column: 1 / -1; position: sticky; top: 0; z-index: 30; height: 76px; padding: 0 26px; display: flex; align-items: center; gap: 30px; border-bottom: 1px solid var(--line); background: rgba(255, 252, 248, 0.96); backdrop-filter: blur(14px); }
.brand { min-width: 212px; padding: 0; border: 0; background: transparent; display: flex; align-items: center; gap: 11px; text-align: left; }
.brand-mark { width: 38px; height: 42px; display: grid; place-items: center; border: 1px solid #d7a08e; border-radius: 50% 50% 45% 45%; color: var(--terracotta-dark); background: #fbefe9; font: 600 23px var(--serif); }
.brand strong, .brand small { display: block; }
.brand strong { font: 600 20px/1.05 var(--serif); }
.brand small { margin-top: 5px; color: var(--muted); font-size: 10px; letter-spacing: 0.03em; }
.top-search-shell { width: min(390px, 36vw); }
.top-search { width: 100%; height: 42px; padding: 0 12px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.top-search span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.top-search input { min-width: 0; flex: 1; border: 0; box-shadow: none; }
.top-import { margin-left: auto; }

.sidebar { grid-row: 2; min-height: calc(100vh - 76px); padding: 23px 16px; border-right: 1px solid var(--line); background: var(--paper); }
.sidebar nav { display: grid; gap: 5px; }
.nav-link { min-height: 44px; width: 100%; padding: 0 13px; border: 0; border-radius: 8px; display: flex; align-items: center; justify-content: space-between; background: transparent; text-align: left; }
.nav-link b { min-width: 25px; padding: 3px 7px; border-radius: 20px; background: var(--sand); color: var(--muted); font-size: 11px; text-align: center; }
.nav-link.active { background: #f7eae4; color: var(--terracotta-dark); font-weight: 700; }
.nav-link.active b { background: white; color: var(--terracotta-dark); }
.sidebar-rule { margin: 21px 5px; border-top: 1px solid var(--soft-line); }
.sidebar-label { margin: 0 10px 9px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.13em; }

.main-area { min-width: 0; }
.view { display: none; min-height: calc(100vh - 76px); }
.view.active { display: block; }
.page-header { min-height: 200px; padding: 50px 42px 38px; display: flex; align-items: flex-end; justify-content: space-between; border-bottom: 1px solid var(--line); background: linear-gradient(115deg, #fffcf8, #fbf6ef 72%, #f7efe6); }
.page-header h1, .recipe-header h1 { margin: 0; font: 500 clamp(42px, 5vw, 64px)/1.04 var(--serif); letter-spacing: -0.025em; }
.eyebrow { margin: 0 0 8px; color: var(--terracotta-dark); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.16em; }
.recipe-total { width: 110px; height: 110px; display: grid; place-content: center; border: 1px solid var(--line); border-radius: 50%; background: rgba(255, 252, 248, 0.84); text-align: center; box-shadow: var(--shadow); }
.recipe-total strong { display: block; color: #653426; font: 600 32px/1 var(--serif); }
.recipe-total span { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }

.button { min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 700; transition: 0.15s ease; }
.button.primary { color: white; background: var(--terracotta); box-shadow: 0 6px 14px rgba(198, 90, 58, 0.18); }
.button.primary:hover:not(:disabled) { background: var(--terracotta-dark); }
.button.secondary { border-color: var(--line); background: white; color: #514b45; }
.button.secondary:hover:not(:disabled) { border-color: #d7a08e; color: var(--terracotta-dark); }
.button.danger { border-color: #ecc9c3; background: #fff7f5; color: var(--danger); }
.button.small { min-height: 34px; padding: 0 12px; font-size: 12px; }

.library-tools { position: sticky; top: 76px; z-index: 10; padding: 16px 42px; display: flex; align-items: end; gap: 10px; border-bottom: 1px solid var(--line); background: rgba(255, 252, 248, 0.94); backdrop-filter: blur(12px); }
.library-search-shell { width: min(540px, 100%); }
.library-search { width: 100%; display: grid; gap: 6px; }
.library-search span, .paste-card label > span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; }
.library-search input { height: 42px; padding: 0 12px; }
.search-shell { position: relative; }
.suggestion-list { position: absolute; top: calc(100% + 7px); left: 0; right: 0; z-index: 45; max-height: 330px; padding: 6px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: 0 18px 45px rgba(66, 45, 31, 0.16); }
.suggestion-item { width: 100%; min-height: 54px; padding: 9px 11px; border: 0; border-radius: 7px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: transparent; text-align: left; }
.suggestion-item:hover, .suggestion-item.active { background: #f7eae4; }
.suggestion-item strong { display: block; font: 600 15px var(--serif); }
.suggestion-item span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.recipe-directory { padding: 0 42px 60px; background: var(--paper); }
.directory-row { width: 100%; min-height: 80px; padding: 14px 6px; border: 0; border-bottom: 1px solid var(--soft-line); display: grid; grid-template-columns: minmax(260px, 1.7fr) repeat(3, minmax(95px, 0.45fr)) 30px; gap: 18px; align-items: center; background: transparent; text-align: left; }
.directory-row:hover { background: #fcf8f3; }
.directory-title strong { display: block; font: 600 18px var(--serif); }
.directory-title small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.directory-meta { color: var(--muted); font-size: 12px; }
.directory-meta b { display: block; margin-bottom: 2px; color: var(--charcoal); font-size: 13px; font-weight: 600; }
.row-arrow { color: var(--terracotta); font-size: 22px; text-align: right; }
.loading-state, .empty-state, .error-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-state strong, .error-state strong { display: block; margin-bottom: 8px; color: var(--charcoal); font: 600 24px var(--serif); }

.detail-topline { max-width: 1180px; margin: 0 auto; padding: 27px 38px 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.back-button { padding: 8px 0; border: 0; background: transparent; color: #514b45; font-weight: 700; }
.back-button::before { content: "←"; margin-right: 8px; color: var(--terracotta); }
.language-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.language-switch button { min-height: 32px; padding: 0 11px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; }
.language-switch button.active { background: #f7eae4; color: var(--terracotta-dark); font-weight: 700; }
.compact-switch { width: calc(100% - 10px); margin: 0 5px; display: grid; grid-template-columns: 1fr 1fr; }
.recipe-header { max-width: 1104px; margin: 0 auto; padding: 47px 0 30px; }
.recipe-header h1 { max-width: 880px; }
.recipe-facts { margin-top: 30px; display: grid; grid-template-columns: repeat(3, minmax(145px, 210px)); gap: 12px; }
.fact { min-height: 110px; padding: 17px 19px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: var(--shadow); }
.fact span { display: block; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.fact strong { display: block; margin-top: 9px; color: #653426; font: 600 30px/1 var(--serif); }
.fact small { display: block; margin-top: 7px; color: var(--muted); }
.cooking-stage span { color: #514b45; font-size: 13px; }
.cooking-stage strong { color: var(--terracotta-dark); font-size: 35px; line-height: 1.05; }
.cooking-stage small { margin-top: 10px; color: var(--olive); font-size: 20px; font-weight: 700; line-height: 1; }
.recipe-attribution { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.recipe-controls { max-width: 1104px; margin: 0 auto 16px; padding: 14px 17px; display: flex; align-items: end; gap: 28px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); }
.control-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.segmented { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--cream); }
.segmented button { min-width: 42px; height: 32px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; }
.segmented button.active { background: var(--terracotta); color: white; font-weight: 700; }
.unit-control { margin-left: auto; }
.unit-control select { height: 40px; min-width: 150px; padding: 0 31px 0 11px; }
.recipe-content { max-width: 1104px; margin: 0 auto; display: grid; grid-template-columns: minmax(300px, 0.78fr) minmax(420px, 1.22fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); box-shadow: var(--shadow); }
.recipe-panel { padding: 28px 30px 35px; }
.recipe-panel + .recipe-panel { border-left: 1px solid var(--line); }
.recipe-panel h2 { margin: 0 0 19px; color: #5e5851; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.ingredient-section, .instruction-section { margin: 22px 0 8px; color: var(--olive); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.ingredient-alternative, .editor-alternative { margin: 8px 0; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.ingredient-choice-group { margin: 10px 0 14px; padding: 4px 12px; border: 1px solid #ded4c9; border-radius: 10px; background: #fffdfa; }
.ingredient-choice-group .ingredient-alternative { position: relative; margin: 2px 0; text-align: center; }
.ingredient-choice-group .ingredient-alternative::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; border-top: 1px solid #e8dfd5; }
.ingredient-choice-group .ingredient-alternative span { position: relative; padding: 0 8px; background: #fffdfa; }
.ingredient-choice-group .ingredient-choice-option:last-child .ingredient-row:last-child { border-bottom: 0; }
.ingredient-row { padding: 9px 0; display: grid; grid-template-columns: minmax(58px, auto) 1fr; gap: 10px; border-bottom: 1px dashed #efe7df; }
.ingredient-amount { color: var(--terracotta-dark); font-weight: 700; white-space: nowrap; }
.ingredient-name b { font-weight: 600; }
.ingredient-name span { color: var(--muted); }
.instructions-panel ol { margin: 0; padding: 0; list-style: none; counter-reset: instruction; }
.recipe-notes { margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--soft-line); }
.recipe-notes p { margin: 10px 0 0; white-space: pre-wrap; line-height: 1.6; }
.instruction-row { counter-increment: instruction; padding: 0 0 21px; display: grid; grid-template-columns: 30px 1fr; gap: 13px; line-height: 1.58; }
.instruction-row::before { content: counter(instruction); width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #f4e8df; color: var(--terracotta-dark); font-size: 12px; font-weight: 700; }
.recipe-view { padding-bottom: 70px; }

.import-view { padding-bottom: 70px; }
.import-header { min-height: 185px; }
.import-tabs { max-width: 1040px; margin: 30px auto 0; display: flex; gap: 28px; border-bottom: 1px solid var(--line); }
.import-tabs button { padding: 12px 0; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); }
.import-tabs button.active { border-color: var(--terracotta); color: var(--terracotta-dark); font-weight: 700; }
.import-panel { display: none; max-width: 1040px; margin: 20px auto 0; }
.import-panel.active { display: block; }
.upload-card, .paste-card, .review-shell { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.drop-zone { width: calc(100% - 36px); min-height: 210px; margin: 18px; border: 1px dashed #d7b5a5; border-radius: 11px; display: grid; place-content: center; gap: 9px; background: #fcf8f3; color: var(--muted); text-align: center; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--terracotta); background: #fbf0ea; }
.drop-zone strong { color: var(--terracotta-dark); font: 600 25px var(--serif); }
.drop-zone span { font-size: 12px; }
.upload-actions { min-height: 72px; padding: 13px 18px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.upload-actions > span { min-width: 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.photo-actions > span { flex: 1; }
.source-select { display: flex; align-items: center; gap: 8px; }
.source-select > span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; }
.source-select select { height: 40px; padding: 0 30px 0 10px; }
.paste-card label { padding: 22px; display: grid; gap: 8px; }
.paste-card textarea { width: 100%; padding: 13px; resize: vertical; line-height: 1.5; }
.review-shell { max-width: 1040px; margin: 30px auto 0; overflow: hidden; }
.review-header { padding: 23px 25px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.review-header h2 { margin: 0; font: 600 28px var(--serif); }
.review-status { margin: 7px 0 0; color: var(--muted); }
.progress-track { height: 4px; overflow: hidden; background: var(--sand); }
.progress-track span { display: block; height: 100%; width: 0; background: var(--terracotta); transition: width 0.25s ease; }
.progress-track span.indeterminate { width: 35% !important; animation: progress-scan 1.4s ease-in-out infinite; }
@keyframes progress-scan { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }
.progress-summary { padding: 18px 25px; display: grid; grid-template-columns: minmax(150px, 0.8fr) minmax(300px, 1.5fr) minmax(180px, 0.8fr); align-items: center; gap: 24px; border-bottom: 1px solid var(--soft-line); background: #fcf8f3; }
.progress-primary strong, .progress-primary span { display: block; }
.progress-primary strong { color: #653426; font: 600 28px var(--serif); }
.progress-primary span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.progress-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.progress-counts span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.progress-counts b { display: block; margin-bottom: 2px; color: var(--charcoal); font-size: 17px; letter-spacing: 0; }
.progress-time { display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.progress-time span { display: flex; justify-content: space-between; gap: 12px; }
.progress-time b { color: var(--charcoal); }
.candidate-list { padding: 8px 25px 22px; }
.candidate-card { padding: 18px 0; border-bottom: 1px solid var(--soft-line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; }
.candidate-card:last-child { border-bottom: 0; }
.candidate-position { margin-right: 8px; color: var(--muted); font-size: 12px; }
.candidate-card h3 { margin: 0; font: 600 18px var(--serif); }
.candidate-meta { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 7px 14px; color: var(--muted); font-size: 12px; }
.status-pill { padding: 3px 8px; border-radius: 20px; background: var(--sand); color: var(--muted); text-transform: capitalize; }
.status-pill.needs_review { background: #faeae2; color: var(--terracotta-dark); }
.status-pill.saved { background: #eaf0e5; color: var(--success); }
.status-pill.failed { background: #fae6e2; color: var(--danger); }
.candidate-actions { display: flex; gap: 7px; }
.uncertainty { color: var(--burnt-orange); font-weight: 700; }
.candidate-error { color: var(--danger); }
.pagination { min-height: 70px; padding: 12px 25px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 18px; }
.pagination span { color: var(--muted); font-size: 12px; }

.editor-dialog { width: min(1460px, calc(100vw - 30px)); max-height: calc(100vh - 30px); padding: 0; border: 0; border-radius: 16px; background: var(--paper); box-shadow: 0 25px 70px rgba(45, 42, 38, 0.28); }
.editor-dialog::backdrop { background: rgba(45, 42, 38, 0.48); backdrop-filter: blur(3px); }
.dialog-shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: calc(100vh - 30px); }
.dialog-header, .dialog-footer { padding: 19px 23px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font: 600 28px var(--serif); }
.dialog-footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }
.close-button { border: 0; background: transparent; color: var(--muted); }
.editor-body { min-height: 0; padding: 22px 23px 30px; overflow: auto; }
.review-warning { margin: 0 0 16px; padding: 10px 12px; border: 1px solid #efd4be; border-radius: 8px; background: #fff7ee; color: #8b582b; }
.review-warning > strong { display: block; }
.review-warning ul { margin: 8px 0 0; padding-left: 20px; }
.review-warning li { margin-top: 5px; }
.review-warning li span { font-weight: 700; }
.review-warning code { display: block; margin-top: 2px; color: #5e5851; font: 12px/1.45 var(--sans); }
.duplicate-panel { margin: 0 0 18px; padding: 14px; border: 1px solid #e6bcae; border-radius: 10px; background: #fff7f3; }
.duplicate-panel h3 { margin: 0 0 5px; color: var(--terracotta-dark); font: 600 20px var(--serif); }
.duplicate-panel > p { margin: 0 0 10px; color: var(--muted); }
.duplicate-match { width: 100%; min-height: 48px; margin-top: 7px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: space-between; gap: 14px; background: white; text-align: left; }
.duplicate-match:hover { border-color: #d7a08e; }
.duplicate-match strong { font: 600 15px var(--serif); }
.duplicate-match span { color: var(--muted); font-size: 11px; }
.candidate-duplicate { color: var(--danger); font-weight: 700; }
.editor-compare { min-width: 0; }
.editor-compare.has-source { display: grid; grid-template-columns: minmax(320px, 0.8fr) minmax(650px, 1.5fr); gap: 22px; align-items: start; }
.editor-source { position: sticky; top: 0; max-height: calc(100vh - 190px); overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #f8f3ed; }
.editor-source h3 { position: sticky; top: 0; z-index: 1; margin: 0; padding: 12px 15px; border-bottom: 1px solid var(--line); background: #f8f3ed; color: #5e5851; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.editor-source pre { margin: 0; padding: 16px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--charcoal); font: 14px/1.65 var(--sans); }
.editor-form { min-width: 0; }
.editor-grid { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 12px; }
.editor-field { display: grid; gap: 6px; }
.editor-field span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.editor-field input, .editor-field select { height: 40px; padding: 0 10px; min-width: 0; width: 100%; }
.editor-section { margin-top: 28px; }
.editor-section-head { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.editor-section h3 { margin: 0; color: #5e5851; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.editor-ingredient { margin-bottom: 7px; display: grid; grid-template-columns: minmax(225px, 0.8fr) 1.2fr 1fr 34px; gap: 7px; align-items: start; }
.editor-alternative { text-align: center; }
.editor-amounts { display: grid; grid-template-columns: repeat(2, minmax(68px, 1fr)) minmax(72px, 1fr); gap: 4px; }
.editor-amounts > :last-child:nth-child(2) { grid-column: 2 / 4; }
.editor-ingredient input, .editor-instruction textarea, #editor-notes { width: 100%; min-width: 0; padding: 8px; }
.editor-instruction { margin-bottom: 8px; display: grid; grid-template-columns: 1fr 34px; gap: 7px; }
.editor-cooking-stage { margin-bottom: 7px; display: grid; grid-template-columns: 1fr 1fr 1fr 34px; gap: 7px; }
.editor-cooking-stage input { width: 100%; min-width: 0; padding: 8px; }
.editor-instruction textarea { min-height: 72px; resize: vertical; }
.remove-row { width: 34px; border: 0; border-radius: 7px; background: #fff2ef; color: var(--danger); }
.field-error { margin: 7px 0 0; color: var(--danger); font-size: 12px; }

@media (max-width: 1050px) {
  .editor-compare.has-source { grid-template-columns: 1fr; }
  .editor-source { position: static; max-height: 38vh; }
}

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(420px, calc(100vw - 44px)); padding: 13px 17px; border-radius: 9px; background: var(--charcoal); color: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: 0.2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.menu-button { border: 0; background: transparent; color: var(--terracotta-dark); font-weight: 700; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 39; background: rgba(45, 42, 38, 0.35); }

.auth-shell { min-height: 100vh; padding: 32px 18px; display: grid; place-items: center; background: linear-gradient(135deg, #faf7f2, #f5e7dc); }
.auth-card { width: min(470px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 22px 60px rgba(66, 45, 31, 0.12); }
.auth-brand { margin-bottom: 35px; display: flex; align-items: center; gap: 12px; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand strong { font: 600 22px var(--serif); }
.auth-brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.auth-form { display: grid; gap: 17px; }
.auth-form h1 { margin: 0; font: 500 38px var(--serif); }
.auth-form label, .settings-form label { display: grid; gap: 6px; }
.auth-form label > span, .settings-form label > span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; }
.auth-form input, .auth-form textarea, .settings-form input { width: 100%; min-height: 44px; padding: 10px 12px; }
.auth-form textarea { resize: vertical; }
.auth-form .field-error { min-height: 18px; margin: -3px 0; }

.profile-button { min-height: 42px; padding: 4px 10px 4px 5px; border: 1px solid var(--line); border-radius: 22px; display: flex; align-items: center; gap: 8px; background: white; }
.profile-button span { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #f7eae4; color: var(--terracotta-dark); font-weight: 700; }
.profile-button strong { font-size: 12px; }
.profile-menu { position: fixed; top: 67px; right: 24px; z-index: 50; min-width: 150px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: 0 18px 45px rgba(66, 45, 31, 0.16); }
.profile-menu button { width: 100%; min-height: 40px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent; text-align: left; }
.profile-menu button:hover { background: #f7eae4; }

.settings-view { padding-bottom: 70px; }
.settings-grid { max-width: 1040px; margin: 30px auto; display: grid; gap: 18px; }
.settings-card { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.settings-card h2 { margin: 0; font: 600 25px var(--serif); }
.settings-card p { margin: 5px 0 0; color: var(--muted); }
.settings-form { margin-top: 20px; }
.inline-form { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; align-items: end; gap: 10px; }
.password-grid { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 10px; }
.member-list { margin-top: 20px; border-top: 1px solid var(--soft-line); }
.member-row { min-height: 61px; display: grid; grid-template-columns: minmax(140px, 1fr) auto auto auto; align-items: center; gap: 9px; border-bottom: 1px solid var(--soft-line); }
.member-row input { min-width: 0; height: 39px; padding: 0 10px; }
.member-row input:disabled { border-color: transparent; background: transparent; font-weight: 700; opacity: 1; }
.settings-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.activity-list { margin-top: 16px; border-top: 1px solid var(--soft-line); }
.activity-row { min-height: 74px; padding: 11px 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--soft-line); }
.activity-row strong, .activity-row span, .activity-row small { display: block; }
.activity-row strong { font: 600 16px var(--serif); }
.activity-row span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.activity-row small { margin-top: 2px; color: #99918a; font-size: 10px; }

@media (max-width: 1120px) {
  .recipe-header, .recipe-controls, .recipe-content { margin-left: 38px; margin-right: 38px; }
  .import-tabs, .import-panel, .review-shell { margin-left: 38px; margin-right: 38px; }
  .directory-row { grid-template-columns: minmax(220px, 1.5fr) repeat(2, minmax(90px, 0.5fr)) 30px; }
  .directory-row .hide-tablet { display: none; }
  .settings-grid { margin-left: 38px; margin-right: 38px; }
}

@media (max-width: 760px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: inline-flex; }
  .app-shell { display: block; }
  .topbar { height: 66px; padding: 0 16px; gap: 13px; }
  .brand { min-width: 0; margin-right: auto; }
  .brand-mark, .brand small { display: none; }
  .brand strong { font-size: 18px; }
  .top-import { min-height: 38px; padding: 0 12px; font-size: 12px; }
  .profile-button { padding-right: 5px; }
  .profile-button strong { display: none; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; width: 250px; min-height: 100vh; padding-top: 83px; transform: translateX(-102%); transition: transform 0.2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .view { min-height: calc(100vh - 66px); }
  .page-header { min-height: 150px; padding: 34px 20px 28px; }
  .page-header h1, .recipe-header h1 { font-size: 40px; }
  .recipe-total { width: 82px; height: 82px; }
  .recipe-total strong { font-size: 25px; }
  .library-tools { top: 66px; padding: 13px 16px; }
  .library-search span, .library-tools .secondary { display: none; }
  .library-search { width: 100%; }
  .recipe-directory { padding: 8px 16px 45px; }
  .directory-row { min-height: 92px; padding: 14px 5px; grid-template-columns: 1fr auto; gap: 10px; }
  .directory-row .directory-meta { display: none; }
  .directory-title strong { font-size: 17px; }
  .detail-topline { padding: 18px 20px 0; }
  .recipe-header { margin: 0; padding: 36px 20px 24px; }
  .recipe-facts { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .fact { min-height: 92px; padding: 13px 11px; }
  .fact strong { font-size: 23px; }
  .fact small { font-size: 10px; }
  .cooking-stage span { font-size: 11px; }
  .cooking-stage strong { font-size: 28px; }
  .cooking-stage small { font-size: 16px; }
  .recipe-controls { margin: 0 16px 12px; padding: 12px; gap: 14px; }
  .unit-control select { min-width: 118px; }
  .segmented button { min-width: 35px; }
  .recipe-content { margin: 0 16px; display: block; }
  .recipe-panel { padding: 24px 21px 28px; }
  .recipe-panel + .recipe-panel { border-top: 1px solid var(--line); border-left: 0; }
  .import-tabs, .import-panel, .review-shell { margin-left: 16px; margin-right: 16px; }
  .review-header { align-items: flex-start; }
  .candidate-card { align-items: flex-start; display: block; }
  .progress-summary { grid-template-columns: 1fr; gap: 14px; }
  .candidate-actions { margin-top: 13px; }
  .editor-grid { grid-template-columns: 1fr 1fr; }
  .editor-field:first-child { grid-column: 1 / -1; }
  .editor-ingredient { padding: 10px; border: 1px solid var(--soft-line); border-radius: 8px; grid-template-columns: 1fr 1fr 34px; }
  .editor-ingredient input:nth-child(4), .editor-ingredient input:nth-child(5) { grid-column: span 2; }
  .editor-ingredient .remove-row { grid-column: 3; grid-row: 1; }
  .upload-actions { align-items: stretch; flex-direction: column; }
  .settings-grid { margin: 20px 16px; }
  .inline-form, .password-grid { grid-template-columns: 1fr; }
  .member-row { padding: 11px 0; grid-template-columns: 1fr auto; }
  .member-row input { grid-column: 1 / -1; }
}

@media (max-width: 460px) {
  .recipe-total { display: none; }
  .recipe-facts { grid-template-columns: 1fr; }
  .fact { min-height: 82px; }
  .recipe-controls { align-items: stretch; flex-direction: column; }
  .unit-control { margin-left: 0; }
  .unit-control select { width: 100%; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor-field:first-child { grid-column: auto; }
}
