:root {
  --ink: #20252d;
  --muted: #6f7785;
  --surface: #ffffff;
  --canvas: #f6f7f8;
  --line: #e4e7eb;
  --accent: #ea6a35;
  --accent-dark: #c95020;
  --danger: #b72f2f;
  --warning: #a26409;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #f4bca5; outline-offset: 2px; }
input, select, textarea { width: 100%; border: 1px solid #d7dbe1; border-radius: 9px; padding: .72rem .8rem; color: var(--ink); background: #fff; }
textarea { min-height: 8rem; resize: vertical; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .25rem; font-size: clamp(1.55rem, 3vw, 2rem); letter-spacing: -.04em; }
h2 { margin-bottom: .4rem; font-size: 1.2rem; letter-spacing: -.025em; }
h3 { margin-bottom: .25rem; font-size: 1rem; }
label { display: grid; gap: .4rem; font-size: .86rem; font-weight: 600; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: linear-gradient(135deg, #fff6f1, #f6f7f8 45%, #e9edf0); }
.auth-card { width: min(100%, 410px); padding: 2rem; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.9); box-shadow: 0 20px 70px rgba(22, 31, 43, .08); }
.auth-card form { display: grid; gap: 1rem; margin: 1.75rem 0 1rem; }
.auth-actions { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.brand-mark { display: inline-grid; place-items: center; width: 2.15rem; height: 2.15rem; border-radius: 9px; color: #fff; background: var(--accent); font-weight: 800; font-size: .8rem; letter-spacing: -.05em; }
.eyebrow { margin: 0 0 .32rem; color: var(--accent-dark); font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.5; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.35rem .85rem; border-right: 1px solid var(--line); background: #fff; }
.sidebar-brand { display: flex; align-items: center; gap: .65rem; padding: .15rem .55rem 1.8rem; font-weight: 800; letter-spacing: -.03em; }
.nav-list { display: grid; gap: .2rem; }
.nav-item { width: 100%; padding: .7rem .75rem; border: 0; border-radius: 8px; color: #59616e; text-align: left; background: transparent; font-weight: 650; }
.nav-item:hover, .nav-item.is-active { color: var(--ink); background: #fff1eb; }
.sidebar-footer { margin-top: auto; padding: 1rem .45rem 0; }
.account-email { margin: 0 0 .65rem; overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.app-content { width: min(1250px, 100%); margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 3.5rem) 3rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; }
.view { display: none; }
.view.is-visible { display: block; }

.button { border: 1px solid transparent; border-radius: 8px; padding: .68rem .9rem; font-weight: 750; transition: background .15s, border-color .15s, transform .15s; }
.button:active { transform: translateY(1px); }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover { background: var(--accent-dark); }
.button-ghost { color: #59616e; border-color: var(--line); background: #fff; }
.button-ghost:hover { border-color: #c5cad2; color: var(--ink); }
.button-block { width: 100%; }
.button-link { padding: 0; border: 0; color: var(--accent-dark); background: transparent; font-size: .88rem; font-weight: 750; }
.button-danger { color: var(--danger); }
.icon-button { display: inline-grid; place-items: center; width: 2rem; height: 2rem; padding: 0; border: 1px solid transparent; border-radius: 7px; color: #56606e; background: transparent; font-size: 1.25rem; line-height: 1; }
.icon-button:hover { background: #f1f3f5; }

.panel, .stat-card, .recipe-card, .review-card { border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: 0 5px 22px rgba(16, 24, 40, .025); }
.panel { padding: clamp(1rem, 3vw, 1.5rem); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat-card { padding: 1.15rem; }
.stat-card span { display: block; color: var(--muted); font-size: .84rem; font-weight: 650; }
.stat-card strong { display: block; margin-top: .3rem; font-size: 1.75rem; letter-spacing: -.06em; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.section-heading h2 { margin-bottom: 0; }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.recipe-card { min-height: 150px; display: flex; flex-direction: column; padding: 1rem; }
.recipe-card h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipe-card .category-pill { align-self: flex-start; }
.card-actions { display: flex; align-items: center; gap: .25rem; margin-top: auto; padding-top: 1rem; }
.card-actions .details-button { margin-right: auto; }
.category-pill { display: inline-flex; border-radius: 100px; padding: .27rem .53rem; color: #835137; background: #fff1eb; font-size: .72rem; font-weight: 750; }
.empty-state { min-height: 130px; place-content: center; color: var(--muted); text-align: center; }

.toolbar { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; padding: .8rem; }
.search-field { flex: 1 1 300px; }
.check-field { display: flex; align-items: center; gap: .5rem; width: auto; white-space: nowrap; }
.check-field input { width: auto; }
.import-intro { max-width: 760px; }
.drop-zone { min-height: 180px; display: grid; place-content: center; gap: .45rem; margin-top: 1.25rem; border: 2px dashed #ebc5b5; border-radius: 12px; color: #6c493a; text-align: center; background: #fffaf7; cursor: pointer; }
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--accent); background: #fff4ed; }
.drop-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.drop-zone span { color: var(--muted); font-size: .83rem; font-weight: 500; }
.import-list { display: grid; gap: .6rem; margin-top: 1rem; max-width: 760px; }
.import-item { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.import-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-item span { color: var(--muted); font-size: .82rem; }
.status-dot { width: .6rem; height: .6rem; border-radius: 50%; background: #a8afb8; }
.status-dot.is-working { background: #d39217; animation: pulse 1.2s infinite; }
.status-dot.is-done { background: #319669; }
.status-dot.is-error { background: #bd4040; }
@keyframes pulse { 50% { opacity: .3; } }

.review-list { display: grid; gap: 1rem; }
.review-card { padding: clamp(1rem, 3vw, 1.4rem); }
.review-card summary { cursor: pointer; }
.review-card summary h3 { display: inline; }
.review-card[open] summary { margin-bottom: 1.2rem; }
.review-status { margin-left: .5rem; color: var(--warning); font-size: .78rem; font-weight: 750; }
.review-warnings { margin: 0 0 1rem; padding: .7rem .85rem .7rem 2rem; border-radius: 8px; color: #80520b; background: #fff8e8; font-size: .83rem; }
.review-form { display: grid; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.form-grid .span-2 { grid-column: span 2; }
.ingredients-editor { display: grid; gap: .45rem; }
.ingredients-editor > header { display: flex; justify-content: space-between; align-items: center; }
.ingredient-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 100px auto; gap: .5rem; }
.review-actions { display: flex; justify-content: flex-end; gap: .5rem; padding-top: .25rem; }
.narrow-panel { max-width: 650px; }
.inline-form { display: flex; gap: .6rem; margin: 1rem 0; }
.category-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.category-token { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .35rem .2rem .7rem; border: 1px solid #f1d7ca; border-radius: 99px; background: #fff8f4; color: #6d4937; font-size: .83rem; font-weight: 650; }

.recipe-dialog { width: min(680px, calc(100% - 2rem)); max-height: min(800px, calc(100% - 2rem)); padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); box-shadow: 0 25px 80px rgba(0,0,0,.22); }
.recipe-dialog::backdrop { background: rgba(20, 26, 33, .42); }
.dialog-heading { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 1.25rem 1.4rem 1rem; border-bottom: 1px solid var(--line); background: #fff; }
.dialog-heading h2 { margin: 0; }
.dialog-content { padding: 1.25rem 1.4rem; }
.detail-list { display: grid; grid-template-columns: 150px 1fr; gap: .75rem 1rem; }
.detail-list dt { color: var(--muted); font-size: .82rem; font-weight: 750; }
.detail-list dd { margin: 0; white-space: pre-wrap; line-height: 1.55; }
.ingredients-table { width: 100%; margin-top: .5rem; border-collapse: collapse; }
.ingredients-table th, .ingredients-table td { padding: .55rem; border-bottom: 1px solid var(--line); text-align: left; font-size: .87rem; }
.toast-region { position: fixed; z-index: 10; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; width: min(360px, calc(100vw - 2rem)); }
.toast { padding: .85rem 1rem; border-radius: 9px; color: #fff; background: #26313d; box-shadow: 0 8px 25px rgba(0,0,0,.16); font-size: .9rem; }
.toast.is-error { background: #922e2e; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.mobile-only { display: none; }

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 5; width: 250px; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 10px 0 30px rgba(0,0,0,.1); }
  .sidebar.is-open { transform: translateX(0); }
  .app-content { padding: 1rem 1rem 2rem; }
  .mobile-only { display: inline-grid; }
  .topbar { margin-bottom: 1.25rem; }
  .topbar .button { display: none; }
  .stat-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar select { flex: none; }
  .review-heading { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .ingredient-row { grid-template-columns: minmax(0, 1fr) 90px 75px auto; }
  .detail-list { grid-template-columns: 1fr; gap: .2rem; }
}
@media (max-width: 430px) {
  .ingredient-row { grid-template-columns: 1fr 1fr auto; }
  .ingredient-name { grid-column: 1 / -1; }
  .inline-form { flex-direction: column; }
}
