:root {
  --bg-base: #eef2f6;
  --bg-overlay: #e6efe9;
  --panel: #ffffff;
  --ink: #14211b;
  --muted: #5a6a62;
  --accent: #1d7f57;
  --accent-strong: #0f5f3f;
  --danger: #ae3d2e;
  --border: #d4ddd7;
  --select: #e5f5ed;
  --shadow-soft: 0 14px 38px rgba(10, 25, 19, 0.08);
  --shadow-card: 0 8px 26px rgba(10, 25, 19, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Manrope", "Avenir Next", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 8% 10%, rgba(145, 201, 174, 0.24), transparent 38%),
    radial-gradient(circle at 90% 12%, rgba(116, 169, 224, 0.2), transparent 42%),
    linear-gradient(160deg, var(--bg-base), var(--bg-overlay));
  min-height: 100vh;
}

body.modal-open {
  overflow: hidden;
}

#workspaceBackInventoryLink {
  display: none;
}

html[data-app-route="inventory"] #landingView,
html[data-app-route="inventory"] #authView,
html[data-app-route="inventory"] #householdPanel {
  display: none !important;
}

html[data-app-route="inventory"] #workspaceManageHouseholdLink {
  display: inline-flex !important;
}

html[data-app-route="inventory"] #workspaceBackInventoryLink {
  display: none !important;
}

html[data-app-route="household"] #landingView,
html[data-app-route="household"] #authView,
html[data-app-route="household"] #searchPanel,
html[data-app-route="household"] #assistantPanel,
html[data-app-route="household"] #resultsPanel,
html[data-app-route="household"] #inventoryTreePanel,
html[data-app-route="household"] #verificationPanel,
html[data-app-route="household"] #workspaceManageHouseholdLink {
  display: none !important;
}

html[data-app-route="household"] #workspaceBackInventoryLink {
  display: inline-flex !important;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: clamp(30px, 4.4vw, 48px);
  line-height: 1.08;
  letter-spacing: -0.02em;
}

h2 {
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: clamp(20px, 2.3vw, 27px);
  line-height: 1.14;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 15px;
}

.site-shell {
  width: min(1160px, 100% - 28px);
  margin: 20px auto 44px;
}

.view {
  display: grid;
  gap: 12px;
  animation: view-fade 140ms ease-out;
}

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

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow-card);
  padding: 14px;
}

.stack {
  display: grid;
  gap: 8px;
}

.hint,
#meta,
.status {
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  color: var(--accent-strong);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
}

.brand-block {
  display: grid;
  gap: 4px;
}

.brand-btn {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: 24px;
  font-weight: 700;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.brand-btn:hover {
  color: var(--accent-strong);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  background: #f8faf8;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-panel {
  padding: 28px 24px;
  display: grid;
  gap: 14px;
  background:
    radial-gradient(circle at 82% 22%, rgba(159, 207, 183, 0.36), transparent 42%),
    linear-gradient(140deg, #ffffff, #f7fbf8);
}

.hero-copy {
  color: var(--muted);
  font-size: clamp(15px, 1.6vw, 18px);
  max-width: 66ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.feature-card {
  display: grid;
  gap: 8px;
  min-height: 132px;
}

.feature-card p {
  color: var(--muted);
  line-height: 1.35;
}

.auth-view,
.inventory-view {
  gap: 12px;
}

.auth-shell {
  padding: 16px;
}

.auth-head-copy {
  gap: 4px;
}

.auth-panel {
  gap: 10px;
}

.compact-head {
  margin-bottom: 2px;
}

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

.auth-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fcfefc;
  padding: 12px;
}

.auth-recovery {
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fafdfb;
  padding: 8px 10px;
}

.auth-recovery summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
}

.auth-grid-recovery {
  margin-top: 8px;
}

.workspace-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  font-size: 13px;
  color: var(--muted);
}

.search-row {
  display: flex;
  gap: 8px;
}

.search-row input {
  flex: 1;
  min-width: 0;
}

.search-row select {
  min-width: 132px;
}

#searchPanel .search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 152px auto;
  align-items: center;
}

#searchPanel #query {
  width: 100%;
}

#searchPanel #searchMode {
  width: 100%;
  min-width: 0;
}

#searchPanel #searchBtn {
  white-space: nowrap;
}

input,
select,
button {
  border-radius: 10px;
  border: 1px solid #b5c2bb;
  font-family: inherit;
  font-size: 14px;
}

input,
select {
  width: 100%;
  height: 42px;
  background: #fff;
  color: var(--ink);
  padding: 0 11px;
}

button {
  height: 42px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 0 12px;
  font-weight: 600;
  transition: 120ms ease;
}

a.button-subtle,
a.button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

button:hover {
  filter: brightness(0.96);
}

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

.button-subtle {
  background: #ffffff;
  border-color: #b8c6be;
  color: var(--ink);
}

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

.button-row {
  display: flex;
  gap: 8px;
}

.upload-row {
  display: flex;
  gap: 8px;
}

.upload-row input[type="file"] {
  height: auto;
  padding: 8px 10px;
  background: #fff;
  flex: 1;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.inline-check input {
  width: auto;
  height: auto;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}

.actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.setup-list {
  margin: 0 0 12px;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  display: grid;
  gap: 4px;
}

.household-top {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.household-create,
.household-invite {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fcfefc;
  padding: 10px;
}

.household-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.management-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.management-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fcfefc;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.management-main {
  min-width: 0;
}

.management-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.management-subtle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.management-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.management-actions select {
  min-width: 98px;
}

.management-empty {
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fcfefc;
}

.item-history-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fcfefc;
  padding: 10px;
  margin-bottom: 10px;
}

.history-event {
  align-items: flex-start;
}

.history-path {
  font-family: Menlo, Monaco, monospace;
  font-size: 12px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.history-arrow {
  color: var(--muted);
  margin: 0 4px;
}

.verify-item {
  align-items: flex-start;
}

.verify-item select {
  min-width: 120px;
}

.verify-meta {
  font-family: Menlo, Monaco, monospace;
  font-size: 12px;
  color: var(--muted);
}

.plus-btn {
  width: 42px;
  min-width: 42px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
  font-weight: 700;
  border-radius: 999px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 32, 24, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 20;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: min(560px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 18px 46px rgba(7, 26, 18, 0.22);
  animation: modal-in 140ms ease-out;
}

.modal-small {
  width: min(340px, 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.modal-close {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.crumb {
  margin: 6px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-family: Menlo, Monaco, monospace;
}

.results {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.result {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fcfefc;
}

.result-title {
  font-weight: 700;
}

.result-main {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #eef2ef;
  cursor: zoom-in;
}

.result-path {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.result-scores {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-family: Menlo, Monaco, monospace;
}

.chat-history {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.chat-entry {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fcfefc;
}

.chat-entry.user {
  border-left: 4px solid #86b79f;
}

.chat-entry.assistant {
  border-left: 4px solid var(--accent);
}

.chat-role {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-text {
  margin-top: 4px;
  font-size: 14px;
}

.chat-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  font-family: Menlo, Monaco, monospace;
}

.move-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.move-row select {
  flex: 1;
}

.tree-view {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfdfb;
  padding: 8px;
  min-height: 120px;
}

.tree-list {
  list-style: none;
  margin: 0;
  padding-left: 16px;
}

.tree-node,
.tree-item {
  margin: 4px 0;
}

.tree-label,
.item-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.tree-label:hover,
.item-label:hover {
  background: #edf4ef;
}

.tree-label.selected,
.item-label.selected {
  background: var(--select);
  border: 1px solid #bdd9ca;
}

.item-tag {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
}

.tree-thumb {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #eef2ef;
  cursor: zoom-in;
}

.modal-image {
  width: min(860px, 100%);
}

.lightbox-img {
  display: block;
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f3f5f3;
}

.tree {
  margin: 10px 0 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfdfb;
  min-height: 120px;
  overflow: auto;
  font-family: Menlo, Monaco, monospace;
  font-size: 13px;
  line-height: 1.35;
}

.status {
  min-height: 20px;
  margin: 8px 4px 0;
}

@media (max-width: 980px) {
  .landing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .household-top,
  .household-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .site-shell {
    width: min(100% - 16px, 1160px);
    margin: 12px auto 26px;
  }

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

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
  }

  .auth-grid,
  .landing-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .search-row,
  .move-row,
  .button-row,
  .upload-row,
  .management-actions,
  .hero-actions,
  .actions-row {
    flex-direction: column;
  }

  #searchPanel .search-row {
    grid-template-columns: 1fr;
  }

  .workspace-panel,
  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel {
    padding: 12px;
  }

  .hero-panel {
    padding: 18px;
  }

  .modal-card {
    padding: 12px;
  }
}
