@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700&family=Work+Sans:wght@400;500;600;700&display=swap");

:root {
  --bg-base: #f6f1e8;
  --bg-surface: #fffefb;
  --bg-soft: #f9f4eb;
  --bg-strong: #4d2c1b;
  --text-main: #2a1f18;
  --text-muted: #6f6056;
  --line: #ddcfbc;
  --line-strong: #c8b599;
  --accent: #c2572d;
  --accent-strong: #94391a;
  --success: #2f7b4f;
  --danger: #8f3023;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-soft: 0 10px 24px rgba(50, 29, 18, 0.05);
  --shadow-card: 0 3px 10px rgba(50, 29, 18, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Work Sans", "Avenir Next", "Helvetica Neue", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 10% 0%, rgba(255, 197, 130, 0.35) 0, rgba(255, 197, 130, 0) 35%),
    radial-gradient(circle at 100% 20%, rgba(126, 196, 170, 0.3) 0, rgba(126, 196, 170, 0) 33%),
    repeating-linear-gradient(
      -45deg,
      rgba(77, 44, 27, 0.02),
      rgba(77, 44, 27, 0.02) 8px,
      rgba(77, 44, 27, 0) 8px,
      rgba(77, 44, 27, 0) 16px
    ),
    var(--bg-base);
}

.container {
  width: min(1100px, calc(100% - 2rem));
  margin: 1.25rem auto 2rem;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 254, 251, 0.98), rgba(255, 254, 251, 0.95));
  box-shadow: var(--shadow-soft);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.92);
}

h1,
h2,
h3,
h4 {
  font-family: "Fraunces", Georgia, serif;
  letter-spacing: 0.01em;
}

h1 {
  margin: 0;
  font-size: clamp(1.3rem, 2vw, 1.7rem);
}

h2 {
  margin: 1.1rem 0 0.5rem;
  font-size: clamp(1.25rem, 1.8vw, 1.5rem);
}

h3 {
  margin-bottom: 0.45rem;
}

h4 {
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

h1 a {
  text-decoration: none;
  color: var(--text-main);
}

p {
  line-height: 1.55;
}

a {
  color: #8f381b;
}

table,
article,
form.filters,
form.servings-form,
.container > form {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: var(--shadow-card);
}

article {
  padding: 1rem 1rem 0.5rem;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.45rem 0 0.9rem;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.26rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #f8efdf;
  font-size: 0.86rem;
  color: #5e4739;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

thead th {
  font-weight: 700;
  font-size: 0.83rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #f3ebdc;
}

th,
td {
  border-bottom: 1px solid #eadfce;
  text-align: left;
  padding: 0.72rem 0.7rem;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background-color 0.18s ease;
  animation: row-in 0.35s ease both;
}

tbody tr:hover {
  background: #fff6eb;
}

form {
  display: grid;
  gap: 0.78rem;
  max-width: 100%;
  margin: 0.8rem 0 1rem;
  padding: 0.95rem;
}

.actions form,
.actions.compact form {
  margin: 0;
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
  display: block;
}

label {
  font-weight: 600;
  color: #4f3e32;
}

.field-hint {
  margin: -0.35rem 0 0.05rem;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.field-hint.inline {
  margin: 0;
  width: 100%;
}

input,
select,
textarea,
button,
.button {
  font: inherit;
  font-size: 16px;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.66rem 0.72rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  background: #fffdf8;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194, 87, 45, 0.18);
  background: #ffffff;
}

textarea {
  resize: vertical;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 0.58rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #a44623;
  background: linear-gradient(180deg, #cb6437, #a84422);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.15s ease;
  box-shadow: 0 2px 8px rgba(148, 57, 26, 0.18);
  min-height: 2.4rem;
}

button:hover,
.button:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
}

button:active,
.button:active {
  transform: translateY(0);
}

.button.ghost,
button.ghost,
.nav-link {
  border-color: var(--line-strong);
  background: #f9f2e6;
  color: #5d4537;
  box-shadow: none;
}

.nav-link.is-active {
  border-color: #9e4c2a;
  color: #7f2f14;
  background: #ffe4cf;
  box-shadow: 0 3px 10px rgba(159, 67, 33, 0.18);
}

.danger {
  background: linear-gradient(180deg, #b74a3b, #942e22);
  border-color: #7e281f;
  color: #fff;
}

.error,
.info {
  margin: 0.8rem 0;
  padding: 0.72rem 0.9rem;
  border-radius: 12px;
  border: 1px solid;
  font-weight: 600;
}

.error {
  color: #7e1f15;
  border-color: #d9aaa4;
  background: #f9ebe9;
}

.info {
  color: #225839;
  border-color: #afd5be;
  background: #eaf6ee;
}

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

.header-actions .logout-form {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  display: block;
}

.actions {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.actions.compact {
  margin-top: 0;
  gap: 0.45rem;
}

.filters {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 0.65rem 0.95rem;
  margin-top: 0.55rem;
}

.filter-field {
  display: grid;
  gap: 0.35rem;
  align-content: start;
}

.filter-field-wide {
  grid-column: 1 / -1;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

.checkbox input {
  width: auto;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.filters-panel {
  margin: 0.45rem 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fcf8f1;
  box-shadow: var(--shadow-card);
  overflow: clip;
}

.filters-panel > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.75rem 0.9rem;
  font-weight: 700;
  color: #5d4537;
  user-select: none;
}

.filters-panel > summary::-webkit-details-marker {
  display: none;
}

.filters-panel > summary::after {
  content: "▾";
  float: right;
  color: #85624d;
  transition: transform 0.15s ease;
}

.filters-panel[open] > summary::after {
  transform: rotate(180deg);
}

.filters-panel > .filters {
  margin: 0;
  border: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  background: var(--bg-surface);
}

.result-count {
  margin: 0.35rem 0 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.recipe-list,
.category-list {
  display: grid;
  gap: 0.6rem;
}

.recipe-card,
.category-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffef9;
  box-shadow: var(--shadow-card);
}

.recipe-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 0.78rem 0.86rem;
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.16s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.recipe-card:hover {
  transform: translateY(-1px);
  border-color: #d4b590;
  background: #fff8ef;
}

.recipe-card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194, 87, 45, 0.18);
}

.recipe-card-main {
  min-width: 0;
}

.recipe-card h3 {
  margin: 0 0 0.2rem;
  font-size: 1.02rem;
}

.recipe-card-category {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.category-card {
  padding: 0.78rem 0.86rem;
}

.category-card h3 {
  margin: 0;
  font-size: 1.02rem;
}

.category-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
}

.category-count {
  font-size: 0.86rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.empty-state {
  margin: 0.75rem 0;
  padding: 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: #fbf6ed;
}

.empty-state.subtle {
  padding: 0.7rem 0.8rem;
  background: #f9f3e8;
}

.empty-state h3 {
  margin-top: 0;
}

.servings-form {
  margin: 0.8rem 0 1rem;
  padding: 0.65rem 0.75rem;
  display: grid;
  gap: 0.4rem;
}

.servings-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.servings-form input[type="number"] {
  width: 5.2rem;
  text-align: center;
  padding: 0.45rem 0.5rem;
}

.servings-controls button {
  min-height: 2rem;
  padding: 0.38rem 0.62rem;
  font-size: 0.92rem;
}

.servings-controls button[name="delta"] {
  min-width: 1.9rem;
  width: 1.9rem;
  padding-left: 0;
  padding-right: 0;
}

.ingredients-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.75fr 0.75fr 1.3fr 1fr 0.9fr;
  gap: 0.42rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
}

.ingredients-head-row {
  margin-bottom: 0.35rem;
}

.ingredient-row {
  margin-bottom: 0.35rem;
}

.row-actions {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.row-actions button {
  min-width: 2rem;
  width: 2rem;
  padding-left: 0;
  padding-right: 0;
}

#ingredient-rows,
#step-rows {
  display: grid;
  gap: 0.35rem;
}

.step-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
}

.step-index {
  width: 2rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: right;
}

.ingredients-head {
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
}

ul,
ol {
  margin-top: 0.38rem;
  padding-left: 1.2rem;
}

.ingredient-list {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.45rem;
  margin-bottom: 0.7rem;
  padding-left: 1.3rem;
}

.ingredient-list li {
  line-height: 1.55;
}

.detail-section-title {
  margin: 1rem 0 0.45rem;
}

.detail-group-title {
  margin: 0.7rem 0 0.3rem;
}

.steps-list {
  display: grid;
  gap: 0.42rem;
  margin-top: 0.45rem;
  margin-bottom: 0.7rem;
  padding-left: 1.3rem;
}

.steps-list li {
  line-height: 1.55;
}

.notes-text {
  margin-top: 0.45rem;
  margin-bottom: 0.7rem;
}

.detail-empty {
  margin-top: 0.45rem;
  margin-bottom: 0.7rem;
}

.raw-text {
  white-space: pre-wrap;
  background: #fbf5ea;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  padding: 0.74rem;
}

.raw-text-panel {
  margin-top: 0.9rem;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: #fbf5ea;
  padding: 0.5rem 0.75rem;
}

.raw-text-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: #6b4d3b;
}

.raw-text-panel[open] summary {
  margin-bottom: 0.5rem;
}

.category-browse {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.6rem 0 0.75rem;
}

.browse-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #f8efdf;
  color: #614b3c;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.browse-pill span {
  display: inline-flex;
  min-width: 1.3rem;
  justify-content: center;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: #ead7bf;
  font-size: 0.78rem;
}

.browse-pill.is-active {
  border-color: #9e4c2a;
  background: #ffe4cf;
  color: #7f2f14;
}

.browse-pill.favorite-pill {
  border-color: #d2b67c;
  background: #fff2cf;
}

.status-icons {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.status-icon {
  line-height: 1;
  font-size: 1rem;
}

.status-icon.favorite {
  color: #d08a17;
}

.status-icon.muted {
  color: #b8a897;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.7rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-chip.ai {
  color: #1a4f63;
  background: #d9eef7;
  border: 1px solid #9ac8da;
}

.import-submit-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #5e4a3a;
  font-weight: 600;
  font-size: 0.92rem;
}

.loading-indicator[hidden] {
  display: none;
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid #d7c0a5;
  border-top-color: #a44523;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.container > *:not(.header) {
  animation: fade-up 0.38s ease both;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .container {
    width: calc(100% - 1rem);
    margin: 0.6rem auto 1.2rem;
    padding: 0.85rem;
  }

  .header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    flex-wrap: nowrap;
  }

  .header-actions .button {
    white-space: nowrap;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .category-card-head {
    flex-wrap: wrap;
  }

  .category-browse {
    flex-wrap: wrap;
  }

  .responsive-table {
    display: block;
    border: none;
    box-shadow: none;
    background: transparent;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody {
    display: grid;
    gap: 0.6rem;
  }

  .responsive-table tr {
    display: grid;
    gap: 0.35rem;
    padding: 0.7rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fffef9;
    box-shadow: var(--shadow-card);
  }

  .responsive-table td {
    display: grid;
    grid-template-columns: 6.5rem 1fr;
    gap: 0.4rem;
    border-bottom: none;
    padding: 0;
    white-space: normal;
    align-items: start;
  }

  .responsive-table td::before {
    content: attr(data-label);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 700;
  }
}

@media (max-width: 700px) {
  .ingredients-grid {
    grid-template-columns: 1fr;
  }

  .ingredients-head {
    display: none;
  }

  .ingredients-head-row {
    display: none;
  }

  .step-row {
    grid-template-columns: 1fr;
  }

  .step-index {
    text-align: left;
    width: auto;
  }

  .button,
  button {
    width: 100%;
  }

  .row-actions button {
    width: 2rem;
  }

  .servings-controls {
    width: 100%;
    flex-wrap: nowrap;
  }

  .servings-controls button[name="delta"] {
    width: 2rem;
    min-width: 2rem;
  }

  .servings-controls button {
    width: auto;
  }

  .servings-controls .ghost {
    margin-left: auto;
  }

  .actions,
  .filter-actions,
  .header-actions {
    width: 100%;
  }

  .recipe-card {
    align-items: flex-start;
    gap: 0.6rem;
  }

  .recipe-card .status-icons {
    align-self: center;
  }

  .category-list .actions.compact {
    width: 100%;
  }

  .recipe-meta {
    gap: 0.35rem;
  }

  .meta-chip {
    font-size: 0.82rem;
  }

  .responsive-table td {
    grid-template-columns: 1fr;
  }

  .responsive-table td::before {
    margin-bottom: 0.12rem;
  }
}
