:root {
  color-scheme: dark;
  --bg: #050505;
  --ink: #22231f;
  --muted: #70695f;
  --line: #ded4c5;
  --panel: #fffaf1;
  --green: #315f4a;
  --green-soft: #dce9df;
  --tomato: #d85a3a;
  --tomato-dark: #a33d27;
  --shadow: 0 16px 40px rgba(49, 43, 35, 0.13);
}

* {
  box-sizing: border-box;
}

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

html {
  background: #050505;
}

body {
  margin: 0;
  background: #050505;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  color: #fff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  letter-spacing: 0;
}

body[data-view="home"],
body[data-view="loading"] {
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  min-height: 100svh;
  height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  display: flex;
}

.view {
  display: none;
  width: 100%;
}

.view.is-active {
  display: flex;
  flex-direction: column;
}

#homeView.is-active {
  height: 100%;
  min-height: 0;
}

.top-copy {
  flex: 0 0 auto;
  padding-top: clamp(0px, 1.4svh, 12px);
}

.eyebrow {
  margin: 0 0 8px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.78rem;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  line-height: 1.12;
}

h1 {
  font-size: clamp(2rem, 5.8svh, 2.35rem);
}

h2 {
  font-size: 1.65rem;
}

.lead {
  margin: clamp(8px, 1.8svh, 14px) 0 0;
  color: rgba(255, 255, 255, 0.84);
  line-height: 1.62;
}

.camera-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #050505;
}

.camera-backdrop[hidden] {
  display: none;
}

.camera-backdrop video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.46) 0%, rgba(0, 0, 0, 0.06) 42%, rgba(0, 0, 0, 0.64) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.28), transparent 32%, transparent 68%, rgba(0, 0, 0, 0.28));
}

body.has-camera {
  background: #050505;
}

body[data-view="result"],
body[data-view="error"] {
  background:
    radial-gradient(circle at 28% 18%, rgba(216, 90, 58, 0.24), transparent 28rem),
    linear-gradient(145deg, #eef4ee 0%, #f7f1e7 56%, #e3ece4 100%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  color: var(--ink);
}

body[data-view="result"] .app-shell,
body[data-view="error"] .app-shell {
  height: auto;
  min-height: 100svh;
}

body[data-view="result"] .view.is-active,
body[data-view="error"] .view.is-active {
  min-height: calc(100svh - max(18px, env(safe-area-inset-top)) - max(24px, env(safe-area-inset-bottom)));
}

body[data-view="result"] .camera-backdrop,
body[data-view="error"] .camera-backdrop {
  display: none;
}

body[data-view="result"] .eyebrow,
body[data-view="error"] .eyebrow {
  color: var(--tomato-dark);
}

body[data-view="result"] .secondary-button,
body[data-view="error"] .secondary-button {
  border-color: var(--green);
  color: var(--green);
}

body.has-camera #homeView {
  color: #fff;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.32);
}

body.has-camera #homeView .eyebrow,
body.has-camera #homeView .lead,
body.has-camera #homeView .microcopy {
  color: rgba(255, 255, 255, 0.88);
}

body[data-view="loading"].has-camera .loading-view {
  color: #fffaf1;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.32);
}

body[data-view="loading"].has-camera .loading-view p {
  color: rgba(255, 250, 241, 0.86);
}

.text-fallback {
  flex: 0 0 auto;
  margin: clamp(8px, 1.8svh, 18px) 0 0;
}

.text-fallback summary {
  width: fit-content;
  margin: 0 auto;
  list-style: none;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  padding: 8px 14px;
  background: transparent;
  color: #fff;
  font-size: 0.86rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: none;
  backdrop-filter: blur(8px);
}

.text-fallback summary::-webkit-details-marker {
  display: none;
}

body.has-camera .text-fallback summary {
  border-color: rgba(255, 255, 255, 0.56);
  background: transparent;
  color: #fff;
}

.text-fallback-body {
  margin: 10px 0 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.52);
  box-shadow: none;
  backdrop-filter: blur(14px);
}

.text-fallback-body label {
  display: block;
  margin-bottom: 9px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  max-height: 18svh;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  line-height: 1.55;
}

textarea::placeholder {
  color: rgba(255, 255, 255, 0.48);
}

textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.26);
  outline-offset: 2px;
}

.record-zone {
  flex: 1;
  min-height: 0;
  padding: clamp(8px, 2svh, 16px) 0 4px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(8px, 2svh, 18px);
}

.record-button {
  position: relative;
  width: min(70vw, 38svh, 286px);
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  box-shadow: none;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transform: translateZ(0);
}

#homeView:has(.text-fallback[open]) .record-button {
  width: min(56vw, 25svh, 190px);
}

#homeView:has(.text-fallback[open]) .record-zone {
  padding-top: 6px;
  gap: 8px;
}

.record-button span {
  position: relative;
  z-index: 1;
  display: block;
  padding: 0 26px;
  font-size: clamp(1rem, 2.8svh, 1.28rem);
  font-weight: 900;
  line-height: 1.35;
}

.record-button.is-recording {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 14px rgba(255, 255, 255, 0.08);
  transform: scale(1.02);
}

.progress-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg,
.ring-meter {
  fill: none;
  stroke-width: 6;
}

.ring-bg {
  stroke: rgba(255, 255, 255, 0.2);
}

.ring-meter {
  stroke: #fff;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 120ms linear;
}

.microcopy {
  max-width: 360px;
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
  font-size: clamp(0.76rem, 1.7svh, 0.82rem);
  line-height: 1.45;
  text-align: center;
}

.secondary-button {
  min-height: 46px;
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 8px;
  padding: 0 16px;
  background: transparent;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.full-width {
  width: 100%;
  margin-top: 18px;
}

.loading-view {
  min-height: calc(100svh - 48px);
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 16px;
}

.loading-view p {
  max-width: 320px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.pot-loader {
  display: flex;
  gap: 8px;
  align-items: end;
  height: 46px;
}

.pot-loader span {
  width: 11px;
  height: 26px;
  border-radius: 999px;
  background: var(--tomato);
  animation: steam 900ms ease-in-out infinite;
}

.pot-loader span:nth-child(2) {
  animation-delay: 130ms;
  background: var(--green);
}

.pot-loader span:nth-child(3) {
  animation-delay: 260ms;
}

@keyframes steam {
  0%,
  100% {
    transform: translateY(8px);
    opacity: 0.48;
  }
  50% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.result-head {
  padding-top: 10px;
}

.quip {
  margin: 14px 0 0;
  padding: 14px;
  border-left: 5px solid var(--tomato);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  line-height: 1.75;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 18px 0 14px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 243, 234, 0.94);
  backdrop-filter: blur(8px);
}

.tab-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}

.tab-button.is-active {
  background: var(--green);
  color: #fff;
}

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

.recipe-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.recipe-card img {
  width: 104px;
  height: 104px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--green-soft);
}

.recipe-body {
  min-width: 0;
}

.recipe-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.recipe-meta span {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 800;
}

.hook {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.recipe-link {
  color: var(--tomato-dark);
  font-size: 0.86rem;
  font-weight: 900;
  text-decoration: none;
}

.recipe-link:hover {
  text-decoration: underline;
}

.empty-state,
.error-card {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  line-height: 1.7;
}

.error-card {
  margin: auto 0;
}

@media (max-width: 360px) {
  .recipe-card {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .recipe-card img {
    width: 88px;
    height: 88px;
  }
}
