:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #68746d;
  --line: #dfe5de;
  --surface: #fbfcf9;
  --panel: #ffffff;
  --accent: #2f7651;
  --accent-strong: #1d5d3a;
  --accent-soft: #e7f3eb;
  --tomato: #c95842;
  --sun: #f1b84b;
  --blue: #527da3;
  --shadow: 0 18px 45px rgba(29, 45, 35, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(47, 118, 81, 0.08), transparent 36%),
    linear-gradient(300deg, rgba(241, 184, 75, 0.14), transparent 32%),
    var(--surface);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--accent-soft);
}

.brand-mark svg {
  width: 34px;
  height: 34px;
  fill: var(--accent);
}

.brand-mark path + path {
  fill: none;
  stroke: var(--surface);
  stroke-linecap: round;
  stroke-width: 2.4;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.2rem;
}

.brand p,
.muted,
.recipe-meta {
  color: var(--muted);
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab,
.ghost-button,
.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.tab span {
  width: 20px;
  color: var(--accent);
}

.tab.is-active {
  color: var(--ink);
  border-color: var(--line);
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(29, 45, 35, 0.06);
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.account-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 10px;
  color: var(--ink);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.account-button > span:last-child {
  display: grid;
  min-width: 0;
}

.account-button strong,
.account-button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-button small {
  color: var(--muted);
}

.account-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  color: white;
  font-weight: 800;
  border-radius: 50%;
  background: var(--accent);
}

.file-button {
  display: grid;
  place-items: center;
}

.file-button input {
  display: none;
}

.main {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 26px;
  padding: 28px;
  overflow: hidden;
}

.topbar,
.shopping-layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2,
.dialog-head h2 {
  margin-top: 4px;
  font-size: clamp(1.7rem, 2vw, 2.35rem);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  color: white;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.ghost-button {
  padding: 0 14px;
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}

.danger-button {
  padding: 0 14px;
  color: #8d2417;
  background: #fff1ef;
  border-color: #f1c5bd;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  min-height: 38px;
  color: var(--muted);
  background: transparent;
}

.view {
  display: none;
  min-height: 0;
}

.view.is-visible {
  display: block;
}

.planner-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 12px;
  min-height: 0;
}

.day-card,
.recipe-card,
.shopping-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 35px rgba(29, 45, 35, 0.08);
}

.day-card {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
  min-height: 430px;
  padding: 14px;
}

.day-card h3 {
  font-size: 1rem;
}

.day-card select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.planned-recipe {
  display: grid;
  align-content: start;
  gap: 12px;
}

.empty-day {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed #cfd8d1;
  border-radius: 8px;
  background: rgba(231, 243, 235, 0.42);
}

.mini-ingredients {
  display: grid;
  gap: 6px;
  padding: 0;
  margin: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 380px) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: white;
}

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-panel {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-brand {
  padding: 0;
  margin-bottom: 24px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.auth-tabs button {
  min-height: 44px;
  color: var(--muted);
  font-weight: 700;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
}

.auth-tabs button.is-active {
  color: var(--accent-strong);
  border-bottom-color: var(--accent);
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form .primary-button {
  margin-top: 4px;
}

.form-error {
  min-height: 20px;
  color: #9d2d20;
  font-size: 0.88rem;
}

.form-hint {
  color: var(--muted);
  font-size: 0.82rem;
}

textarea {
  resize: vertical;
}

.tag-filter,
.chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid #cfd8d1;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: white;
  font-size: 0.82rem;
  font-weight: 700;
}

.chip.is-active {
  color: var(--accent-strong);
  border-color: #9dc9ad;
  background: var(--accent-soft);
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

.recipe-card {
  overflow: hidden;
}

.recipe-art {
  height: 92px;
  background:
    radial-gradient(circle at 18% 34%, rgba(255, 255, 255, 0.88) 0 8%, transparent 9%),
    radial-gradient(circle at 67% 38%, rgba(255, 255, 255, 0.72) 0 10%, transparent 11%),
    linear-gradient(135deg, var(--accent), var(--sun) 62%, var(--tomato));
}

.recipe-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.recipe-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.recipe-card h3 {
  font-size: 1.05rem;
}

details {
  color: var(--muted);
}

summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 800;
}

.recipe-steps {
  margin-top: 8px;
  white-space: pre-wrap;
}

.shopping-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.shopping-group {
  padding: 16px;
}

.shopping-group h3 {
  margin-bottom: 10px;
}

.shopping-group ul {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.shopping-group li {
  display: flex;
  gap: 8px;
  color: var(--muted);
}

.shopping-group input {
  width: auto;
}

.recipe-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.recipe-dialog::backdrop {
  background: rgba(23, 33, 27, 0.36);
  backdrop-filter: blur(4px);
}

.recipe-form {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.dialog-actions {
  align-items: center;
}

.dialog-actions div {
  display: flex;
  gap: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr 0.6fr 1.2fr;
  gap: 12px;
}

.account-dialog .recipe-form {
  gap: 20px;
}

.account-summary {
  display: grid;
  gap: 3px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.account-summary span {
  color: var(--muted);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
}

.invite-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
}

.data-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.data-tool-actions {
  display: flex;
  gap: 8px;
}

.invite-code {
  padding: 14px;
  color: var(--accent-strong);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  border: 1px dashed var(--accent);
  border-radius: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 12px 14px;
  color: white;
  border-radius: 8px;
  background: var(--ink);
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .planner-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .day-card {
    min-height: 330px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    gap: 14px;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    padding: 0;
  }

  .tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .tab {
    justify-content: center;
    padding: 0 8px;
  }

  .tab span {
    display: none;
  }

  .sidebar-footer {
    grid-template-columns: 1fr;
  }

  .account-button {
    grid-column: auto;
  }

  .main {
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    padding: 18px;
  }

  .view,
  .topbar {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .topbar,
  .shopping-layout,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .planner-grid,
  .filters,
  .form-grid {
    width: 100%;
    grid-template-columns: 1fr;
    min-width: 0;
    max-width: 100%;
  }

  .filters > * {
    min-width: 0;
    max-width: 100%;
  }

  .recipe-grid {
    display: flex;
    gap: 12px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 2px 0 16px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-padding-inline: 0;
    scroll-snap-type: inline mandatory;
    scrollbar-width: none;
    touch-action: pan-x;
  }

  .recipe-grid::-webkit-scrollbar {
    display: none;
  }

  .recipe-grid > .recipe-card {
    flex: 0 0 calc(100% - 28px);
    width: calc(100% - 28px);
    min-width: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .recipe-grid > .muted {
    flex: 0 0 100%;
    width: 100%;
  }

  .tag-filter {
    flex-wrap: nowrap;
    width: 100%;
    min-width: 0;
    padding-bottom: 4px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }

  .tag-filter::-webkit-scrollbar {
    display: none;
  }

  .tag-filter .chip {
    flex: 0 0 auto;
  }

  .dialog-actions div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .data-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .data-tool-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
