:root {
  color-scheme: light;
  --bg: #fbfaf6;
  --surface: #ffffff;
  --surface-soft: #f3efe4;
  --ink: #22201c;
  --muted: #6c675c;
  --line: #d8d0bf;
  --green: #2d6a4f;
  --green-dark: #1f4c39;
  --red: #9b2c2c;
  --gold: #c68a12;
  --blue: #315f7d;
  --shadow: 0 12px 28px rgba(34, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.95);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 17px;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions,
.inline-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-email {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-view {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(45, 106, 79, 0.12), rgba(198, 138, 18, 0.10)),
    var(--bg);
}

.auth-card {
  display: grid;
  width: min(920px, 100%);
  gap: 22px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.auth-form {
  display: grid;
  align-content: start;
  min-width: 0;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.auth-form h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

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

.recipe-browser {
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
}

.recipe-browser,
.workspace {
  min-width: 0;
  padding: 20px;
}

.workspace {
  display: grid;
  gap: 18px;
  align-content: start;
}

.search-panel,
.import-panel,
.recipe-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  min-width: 0;
  gap: 6px;
}

label > span,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 92px;
  resize: vertical;
  padding: 10px 12px;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.14);
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  color: var(--muted);
  font-weight: 700;
}

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

.recipe-item {
  display: grid;
  width: 100%;
  min-height: 92px;
  gap: 4px;
  padding: 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  box-shadow: 0 4px 16px rgba(34, 32, 28, 0.06);
  cursor: pointer;
}

.recipe-item:hover,
.recipe-item[aria-pressed="true"] {
  border-color: var(--green);
}

.recipe-item strong,
.recipe-item span,
.recipe-item small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-item span {
  color: var(--muted);
}

.recipe-item small {
  color: var(--blue);
}

.empty-state {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
}

.import-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.import-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.import-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid rgba(198, 138, 18, 0.5);
  border-radius: 8px;
  background: #fff7df;
}

.import-preview[hidden] {
  display: none;
}

.import-preview-body {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.import-preview strong,
.import-preview span,
.import-preview p {
  display: block;
  min-width: 0;
}

.import-preview strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-preview span {
  color: var(--muted);
  font-size: 13px;
}

.import-preview p {
  margin: 0;
  color: var(--ink);
}

.import-preview ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.import-preview li {
  max-width: 220px;
  overflow: hidden;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--green-dark);
  background: #ffffff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.form-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.form-head h1 {
  margin: 2px 0 0;
  font-size: 28px;
  line-height: 1.15;
}

.favorite-toggle {
  display: inline-flex;
  align-items: center;
  grid-auto-flow: column;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.favorite-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--gold);
}

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

.span-2 {
  grid-column: span 2;
}

.form-actions {
  justify-content: end;
  flex-wrap: wrap;
  padding-top: 4px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  color: #fff;
  background: var(--green);
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  color: #fff;
  background: var(--blue);
}

.ghost-button {
  color: var(--green-dark);
  background: transparent;
  border-color: var(--line);
  text-decoration: none;
  display: inline-grid;
  place-items: center;
}

.danger-button {
  color: #fff;
  background: var(--red);
}

.icon-button {
  display: grid;
  width: 42px;
  padding: 0;
  place-items: center;
  color: var(--green-dark);
  background: #fff;
  border-color: var(--line);
  font-size: 24px;
  line-height: 1;
}

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

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

  .recipe-browser {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .form-actions,
  .inline-actions {
    width: 100%;
  }

  .topbar-actions > *,
  .form-actions > *,
  .inline-actions > * {
    flex: 1;
  }

  .recipe-browser,
  .workspace {
    padding: 14px;
  }

  .filter-grid,
  .auth-grid,
  .form-grid,
  .import-form {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .form-head,
  .import-preview {
    align-items: stretch;
    grid-template-columns: 1fr;
  }
}
