:root {
  --bg: #f7f6f2;
  --panel: #fffdf8;
  --line: #ddd4c4;
  --text: #1f1a13;
  --muted: #6f6658;
  --brand: #14532d;
  --brand-strong: #0e3d21;
  --danger: #8a1b1b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #f2f8eb, var(--bg) 45%);
  min-height: 100vh;
}

h1,
h2,
p {
  margin: 0;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-gate-card {
  width: min(480px, 100%);
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(31, 26, 19, 0.08);
  display: grid;
  gap: 1rem;
}

.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 700;
}

.auth-gate-copy {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--muted);
}

.auth-gate-actions {
  display: flex;
  gap: 0.75rem;
}

#appShell {
  min-height: 100vh;
}

.topbar {
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-brand {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  min-width: 180px;
}

.sub {
  color: var(--muted);
  font-size: 0.9rem;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr 360px;
  gap: 1rem;
  padding: 1rem;
  min-height: calc(100vh - 84px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  min-height: 300px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

label {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.75rem;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  background: #fff;
}

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

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

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

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

.split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.recipe-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.recipe-item {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.55rem;
  cursor: pointer;
}

.recipe-item.active {
  border-color: var(--brand);
  background: #f4fbf5;
}

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

.empty {
  display: grid;
  place-content: center;
  text-align: center;
  height: 100%;
  color: var(--muted);
  gap: 0.25rem;
}

.hidden {
  display: none;
}

.actions {
  display: flex;
  gap: 0.5rem;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.chat-messages {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0.65rem;
  overflow-y: auto;
  max-height: 62vh;
}

.message {
  margin-bottom: 0.6rem;
  padding: 0.5rem;
  border-radius: 8px;
  max-width: 95%;
}

.message.user {
  margin-left: auto;
  background: #e8f5ea;
}

.message.bot {
  background: #f8f3ea;
}

.chat-form {
  margin-top: 0.7rem;
  display: flex;
  gap: 0.5rem;
}

.chat-card {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.55rem;
  background: #fffdf9;
}

.chat-card-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.chat-card-list {
  margin: 0 0 0.6rem;
  padding-left: 1rem;
}

.versions-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.version-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.version-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
}

.version-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.version-meta small {
  color: var(--muted);
}

.version-badge {
  font-size: 0.75rem;
  color: #fff;
  background: var(--brand);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.version-notice {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.4rem 0 0.8rem;
}

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

  .chat-panel {
    grid-column: 1 / -1;
  }
}

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

  .auth-gate-card {
    padding: 1.5rem;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .auth-status {
    align-items: flex-start;
  }

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

  .recipes-panel,
  .recipe-panel,
  .chat-panel {
    min-height: auto;
  }

  .chat-messages {
    max-height: 40vh;
  }

  .split-2 {
    grid-template-columns: 1fr;
  }
}
