:root {
  --color-bg: #FFFFFF;
  --color-surface: #FFFFFF;
  --color-subtle: #F7F7F7;
  --color-text: #111111;
  --color-muted: #767676;
  --color-line: #E5E5E5;
  --color-danger: #C62828;
  --radius: 12px;
  --page-max: 1080px;
  --topbar-space: 136px;
  --tabbar-height: 76px;
  --sticky-space: 88px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.6;
  letter-spacing: 0;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.page {
  width: min(100%, var(--page-max));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px calc(var(--tabbar-height) + 40px + env(safe-area-inset-bottom));
}

.page--list {
  padding-top: calc(var(--topbar-space) + 16px);
}

.page--detail {
  width: 100%;
  max-width: none;
  padding: 0 0 calc(var(--tabbar-height) + var(--sticky-space) + 40px + env(safe-area-inset-bottom));
  background: var(--color-bg);
}

.page--form,
.page--message {
  padding-bottom: calc(var(--tabbar-height) + 44px + env(safe-area-inset-bottom));
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--color-text);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 10px 16px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.button--primary {
  border-color: var(--color-text);
  background: var(--color-text);
  color: var(--color-surface);
}

.button--secondary,
.button--danger,
.button--ghost {
  border-color: var(--color-text);
  background: var(--color-surface);
  color: var(--color-text);
}

.button--start {
  width: 100%;
  min-height: 64px;
  font-size: 1.08rem;
  font-weight: 800;
}

.app-topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 30;
  border-bottom: 1px solid var(--color-line);
  background: var(--color-surface);
}

.app-topbar__inner {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
  width: min(100%, var(--page-max));
  margin: 0 auto;
  padding: 10px 16px 12px;
}

.app-topbar__logo {
  display: flex;
  min-height: 44px;
  align-items: center;
  overflow: hidden;
  text-decoration: none;
}

.app-logo {
  width: 92px;
  height: auto;
}

.top-search {
  position: relative;
  display: block;
  min-width: 0;
}

.top-search input,
.recipe-form input,
.recipe-form textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 11px 12px;
}

.top-search input {
  min-height: 50px;
  border-radius: 999px;
  background: var(--color-subtle);
  padding-right: 15px;
  padding-left: 44px;
}

.top-search input::placeholder,
.recipe-form input::placeholder,
.recipe-form textarea::placeholder {
  color: var(--color-muted);
}

.top-search__icon {
  position: absolute;
  top: 15px;
  left: 15px;
  display: inline-flex;
  width: 20px;
  height: 20px;
  color: var(--color-muted);
  pointer-events: none;
}

.top-search__icon svg,
.recipe-card__meta svg,
.detail-meta svg,
.bottom-tabbar__item svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.category-scroll {
  display: flex;
  grid-column: 1 / -1;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 2px;
  scrollbar-width: none;
}

.category-scroll::-webkit-scrollbar {
  display: none;
}

.category-chip {
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  padding: 6px 14px;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}

.category-chip.is-active {
  border-color: var(--color-text);
  background: var(--color-text);
  color: var(--color-surface);
}

.top-search input:focus,
.recipe-form input:focus,
.recipe-form textarea:focus,
.icon-button:focus,
.button:focus,
.category-chip:focus,
.bottom-tabbar__item:focus {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

.list-section,
.form-page,
.message-panel {
  margin-top: 0;
}

.storage-notice {
  margin: 0 0 16px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-subtle);
  color: var(--color-muted);
  padding: 10px 12px;
  font-size: 0.85rem;
  font-weight: 700;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 16px;
}

.section-heading h1,
.section-heading h2 {
  margin: 0;
  color: var(--color-text);
  font-size: 1.2rem;
  line-height: 1.3;
}

.section-heading--compact {
  align-items: center;
  margin-bottom: 12px;
}

.result-count,
.hint {
  color: var(--color-muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.hint {
  margin: 2px 0 0;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 12px;
}

.recipe-card {
  display: block;
  min-width: 0;
  color: var(--color-text);
  text-decoration: none;
}

.recipe-card__image {
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-subtle);
}

.recipe-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recipe-card__body {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px 2px 0;
}

.recipe-card h2 {
  display: -webkit-box;
  min-height: 2.56em;
  margin: 0;
  overflow: hidden;
  color: var(--color-text);
  font-size: 0.94rem;
  font-weight: 800;
  line-height: 1.28;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.recipe-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: var(--color-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.recipe-card__meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.recipe-card__meta svg {
  width: 14px;
  height: 14px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  min-width: 0;
  min-height: 28px;
  max-width: 100%;
  align-items: center;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-subtle);
  color: var(--color-text);
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-subtle);
  color: var(--color-muted);
  padding: 18px;
  text-align: center;
}

.detail-page {
  margin: 0;
}

.detail-hero {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 240px;
  max-height: 420px;
  background: var(--color-subtle);
}

.detail-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-back-link {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
}

.detail-card {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 24px;
  width: min(calc(100% - 32px), 840px);
  margin: -24px auto 0;
  border: 1px solid var(--color-line);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--color-surface);
  padding: 20px 16px 24px;
}

.detail-header {
  display: grid;
  gap: 12px;
}

.detail-header h1,
.form-header h1,
.message-panel h1 {
  margin: 0;
  color: var(--color-text);
  line-height: 1.3;
}

.detail-header h1 {
  font-size: 1.34rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.detail-header p,
.message-panel p {
  margin: 0;
  color: var(--color-muted);
}

.detail-header p {
  overflow-wrap: anywhere;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-meta > span:not(.tag),
.timer-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-subtle);
  color: var(--color-text);
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.detail-meta svg {
  width: 15px;
  height: 15px;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
}

.detail-section {
  border-top: 1px solid var(--color-line);
  padding-top: 20px;
}

.section-heading--ingredients {
  align-items: flex-start;
  margin-bottom: 12px;
}

.servings-control {
  display: inline-grid;
  grid-template-columns: 44px minmax(76px, auto) 44px;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.servings-control strong {
  color: var(--color-text);
  font-size: 0.96rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--color-text);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1;
}

.ingredient-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ingredient-list li + li {
  border-top: 1px solid var(--color-line);
}

.ingredient-check {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 56px;
  padding: 8px 0;
}

.ingredient-check__box {
  width: 24px;
  height: 24px;
  accent-color: var(--color-text);
}

.ingredient-check__main {
  display: flex;
  min-width: 0;
  align-items: flex-end;
  gap: 8px;
  padding-bottom: 2px;
}

.ingredient-check__name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.ingredient-check__leader {
  flex: 1 1 20px;
  min-width: 18px;
  border-bottom: 1px solid var(--color-line);
}

.ingredient-check__amount {
  flex: 0 1 auto;
  max-width: min(42vw, 13rem);
  color: var(--color-text);
  font-weight: 800;
  overflow-wrap: anywhere;
  text-align: right;
}

.ingredient-check:has(input:checked) {
  color: var(--color-muted);
}

.ingredient-check:has(input:checked) .ingredient-check__name,
.ingredient-check:has(input:checked) .ingredient-check__amount {
  text-decoration: line-through;
}

.step-preview-list {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step-preview-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.step-index {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--color-text);
  border-radius: 999px;
  background: var(--color-text);
  color: var(--color-surface);
  font-weight: 800;
}

.step-preview-list p {
  margin: 3px 0 8px;
  font-weight: 700;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.step-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.step-badges small {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-subtle);
  color: var(--color-text);
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.sticky-actions {
  position: fixed;
  right: 0;
  bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  left: 0;
  z-index: 25;
  border-top: 1px solid var(--color-line);
  background: var(--color-surface);
  padding: 10px 16px;
}

.sticky-actions .button--start {
  display: flex;
  width: min(100%, var(--page-max));
  margin: 0 auto;
}

.bottom-tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 35;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: var(--tabbar-height);
  border-top: 1px solid var(--color-line);
  background: var(--color-surface);
  padding: 7px 12px calc(7px + env(safe-area-inset-bottom));
}

.bottom-tabbar__item {
  display: grid;
  min-width: 0;
  min-height: 56px;
  place-items: center;
  gap: 2px;
  border: 0;
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-muted);
  padding: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

.bottom-tabbar__item svg {
  width: 23px;
  height: 23px;
}

.bottom-tabbar__item.is-active {
  background: var(--color-subtle);
  color: var(--color-text);
}

.back-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--color-text);
  font-weight: 700;
  text-decoration: none;
}

.form-page {
  width: min(100%, 820px);
  margin-right: auto;
  margin-left: auto;
}

.form-header {
  display: grid;
  gap: 4px;
  margin: 8px 0 20px;
}

.form-header h1 {
  font-size: 1.86rem;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--color-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.recipe-form {
  display: grid;
  gap: 20px;
}

.field-grid {
  display: grid;
  gap: 14px;
}

.recipe-form label {
  display: grid;
  gap: 6px;
  color: var(--color-muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.recipe-form input,
.recipe-form textarea {
  color: var(--color-text);
}

.recipe-form textarea {
  resize: vertical;
}

.form-block {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--color-line);
  padding-top: 18px;
}

.dynamic-list {
  display: grid;
  gap: 12px;
}

.dynamic-row {
  display: grid;
  gap: 10px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: 12px;
}

.dynamic-row--step {
  gap: 12px;
}

.form-actions {
  display: grid;
  gap: 10px;
  padding-bottom: 20px;
}

.form-error {
  margin: 0;
  border: 1px solid var(--color-danger);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-danger);
  padding: 12px;
  font-weight: 800;
}

.message-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: 22px;
}

.is-fallback {
  object-fit: contain;
  background: var(--color-subtle);
  padding: 14px;
}

noscript {
  display: block;
  margin: 16px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: 16px;
}

@media (min-width: 680px) {
  :root {
    --topbar-space: 128px;
  }

  .page {
    padding-right: 24px;
    padding-left: 24px;
  }

  .page--list {
    padding-top: calc(var(--topbar-space) + 18px);
  }

  .app-topbar__inner {
    grid-template-columns: 116px minmax(0, 1fr);
    padding-right: 24px;
    padding-left: 24px;
  }

  .app-logo {
    width: 112px;
  }

  .recipe-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px 16px;
  }

  .detail-card {
    padding: 24px 24px 30px;
  }

  .detail-header h1 {
    font-size: 1.58rem;
  }

  .detail-actions {
    grid-template-columns: minmax(120px, 0.2fr) minmax(120px, 0.2fr);
  }

  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-grid label:nth-child(2),
  .field-grid label:nth-child(5) {
    grid-column: 1 / -1;
  }

  .dynamic-row {
    grid-template-columns: minmax(160px, 1fr) minmax(100px, 0.6fr) minmax(130px, 0.7fr) auto;
    align-items: end;
  }

  .dynamic-row--step {
    grid-template-columns: minmax(220px, 1fr) minmax(100px, 0.35fr) minmax(160px, 0.7fr) auto;
  }

  .form-actions {
    grid-template-columns: minmax(180px, 0.3fr) minmax(140px, 0.2fr);
  }
}

@media (min-width: 920px) {
  .recipe-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .detail-card {
    width: min(calc(100% - 48px), 900px);
  }
}
