:root {
  --bg: #f5f4f0;
  --bg-strong: #ffffff;
  --ink: #10233d;
  --muted: #5a6475;
  --line: rgba(16, 35, 61, 0.12);
  --card: #ffffff;
  --accent: #b6914b;
  --accent-deep: #8f6a2a;
  --accent-cool: #132b4a;
  --accent-fresh: #1c5a65;
  --shadow: 0 10px 24px rgba(16, 35, 61, 0.08);
  --radius: 24px;
  --radius-sm: 16px;
  --safe-top: max(20px, env(safe-area-inset-top));
  --safe-bottom: max(22px, env(safe-area-inset-bottom));
  font-family: "Avenir Next", "Helvetica Neue", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #fcfbf7 0%, #f2eee6 100%);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(16, 35, 61, 0.14);
  background: #ffffff;
  border-radius: 14px;
  padding: 14px 15px;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(182, 145, 75, 0.7);
  box-shadow: 0 0 0 4px rgba(182, 145, 75, 0.14);
}

#app {
  min-height: 100vh;
}

.page-shell {
  min-height: 100vh;
  padding: var(--safe-top) 18px calc(240px + var(--safe-bottom));
  animation: rise 240ms ease;
}

.page-shell-compact {
  display: grid;
  place-items: center;
}

.hero-card,
.setup-card,
.loading-card {
  width: min(100%, 470px);
  margin: 0 auto;
  padding: 28px;
  border-radius: 30px;
  background: var(--bg-strong);
  box-shadow: var(--shadow);
  border: 1px solid rgba(16, 35, 61, 0.08);
}

.hero-card h1,
.setup-card h1,
.loading-card h1,
.topbar h1,
.section-heading h2,
.profile-sheet h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero-card p,
.setup-card p,
.empty-card p,
.install-card p,
.history-card small,
.item-card small,
.member-row small {
  color: var(--muted);
  line-height: 1.55;
}

.section-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.brand-pill,
.eyebrow,
.section-label {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(182, 145, 75, 0.14);
  color: var(--accent-deep);
  font-size: 0.79rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stack-form,
.content-stack,
.store-editor-list,
.history-list,
.member-list {
  display: grid;
  gap: 14px;
}

.stack-form label,
.filter-select,
.composer-main,
.composer-meta label {
  display: grid;
  gap: 8px;
}

.stack-form span,
.filter-select span,
.composer-main span,
.composer-meta span {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 6px;
  margin: 24px 0 18px;
  background: #eef1f4;
  border-radius: 999px;
}

.segmented button {
  padding: 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(16, 35, 61, 0.08);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.profile-button,
.item-toggle,
.recent-item {
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.icon-button:active,
.profile-button:active,
.item-toggle:active,
.recent-item:active {
  transform: scale(0.98);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  padding: 14px 18px;
  border-radius: 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--accent-cool);
  color: #ffffff;
  box-shadow: none;
}

.secondary-button {
  background: #f6efe0;
  color: var(--accent-deep);
}

.ghost-button,
.icon-button {
  background: #eef1f4;
  color: var(--ink);
}

.danger-button {
  color: #be123c;
}

.banner {
  margin: 0 auto 14px;
  width: min(100%, 720px);
  padding: 14px 16px;
  border-radius: 20px;
  background: #eef7f0;
  color: #21563d;
}

.banner-error {
  background: #fff1f1;
  color: #a61d24;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

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

.topbar h1 {
  font-size: clamp(2rem, 7vw, 3rem);
}

.refresh-button {
  padding: 12px 14px;
  border-radius: 999px;
  white-space: nowrap;
}

.profile-button {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-cool);
  font-weight: 800;
  box-shadow: none;
}

.glass-card,
.store-card,
.empty-card,
.history-card,
.store-editor-card,
.composer-card,
.profile-sheet {
  background: var(--card);
  border: 1px solid rgba(16, 35, 61, 0.08);
  box-shadow: var(--shadow);
}

.glass-card,
.store-card,
.empty-card,
.history-card,
.store-editor-card,
.composer-card {
  border-radius: var(--radius);
  padding: 18px;
}

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

.header-inline {
  margin-bottom: 10px;
}

.list-mode-toggle {
  margin: 10px 0 18px;
}

.shopping-toolbar {
  margin-bottom: 18px;
}

.shopping-toolbar .primary-button {
  width: 100%;
}

.tap-hint {
  margin-bottom: 14px;
  color: var(--muted);
}

.recent-card {
  margin-bottom: 18px;
}

.recent-items,
.store-groups {
  display: grid;
  gap: 14px;
}

.recent-items {
  margin-top: 16px;
}

.recent-item {
  display: grid;
  gap: 4px;
  justify-items: start;
  padding: 14px 16px;
  border-radius: 18px;
  background: #faf8f2;
}

.recent-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot);
}

.store-card header,
.store-editor-top,
.member-row,
.history-actions,
.store-editor-actions,
.inline-code,
.store-actions-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.store-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--ink);
}

.store-chip::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chip);
  box-shadow: 0 0 0 4px #f4efe4;
}

.item-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.item-card-build {
  grid-template-columns: auto 1fr auto;
}

.item-toggle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #f2f5f7;
  display: grid;
  place-items: center;
}

.item-toggle span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent);
}

.item-content {
  text-align: left;
  background: transparent;
  padding: 0;
}

.item-content-shop strong {
  margin-bottom: 4px;
}

.item-content-shop small {
  color: var(--ink);
  font-weight: 600;
}

.item-remove-inline {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(16, 35, 61, 0.12);
  background: #faf7ef;
  color: #9f2d2d;
  font-size: 1.5rem;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
}

.item-content strong,
.history-main strong {
  display: block;
  font-size: 1rem;
}

.empty-card,
.loading-card {
  text-align: center;
}

.empty-mini {
  padding-top: 14px;
  color: var(--muted);
}

.composer-card {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: calc(78px + var(--safe-bottom));
  z-index: 10;
  padding: 16px;
  border: 1px solid rgba(16, 35, 61, 0.12);
}

.build-composer-card {
  position: static;
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid rgba(16, 35, 61, 0.12);
  box-shadow: var(--shadow);
}

.edit-inline-card {
  background: #fcfaf4;
}

.composer-row,
.composer-meta,
.color-row {
  display: grid;
  gap: 12px;
}

.composer-row {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.quick-add-suggestions {
  margin-top: 12px;
}

.suggestion-list,
.frequent-list {
  display: grid;
  gap: 10px;
}

.suggestion-chip,
.frequent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f8f6f0;
  border: 1px solid rgba(16, 35, 61, 0.08);
}

.suggestion-chip {
  width: 100%;
  text-align: left;
}

.suggestion-chip strong,
.frequent-item strong {
  display: block;
}

.suggestion-chip small,
.frequent-item small {
  color: var(--muted);
}

.composer-meta {
  margin-top: 12px;
  grid-template-columns: 1fr 1fr;
}

.composer-note {
  grid-column: 1 / -1;
}

.color-row {
  grid-template-columns: repeat(6, 1fr);
}

.color-option {
  display: block;
}

.color-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.color-option span {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 18px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.9);
}

.color-option input:checked + span {
  outline: 4px solid rgba(182, 145, 75, 0.22);
}

.history-card,
.frequent-card,
.member-card,
.install-card {
  display: grid;
  gap: 12px;
}

.edit-helper {
  color: var(--muted);
}

.edit-actions {
  display: grid;
  gap: 10px;
}

.history-main {
  display: grid;
  gap: 8px;
}

.bottom-nav {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: 22px;
  background: var(--accent-cool);
  box-shadow: 0 12px 28px rgba(16, 35, 61, 0.18);
  z-index: 12;
}

.bottom-nav button {
  padding: 13px 8px;
  border-radius: 20px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  font-weight: 700;
}

.bottom-nav button.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 35, 61, 0.24);
  z-index: 20;
}

.profile-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  border-radius: 30px 30px 0 0;
  padding: 16px 18px calc(26px + var(--safe-bottom));
  max-height: 85vh;
  overflow: auto;
  display: grid;
  gap: 14px;
}

.edit-sheet {
  max-height: 78vh;
}

.sheet-handle {
  width: 54px;
  height: 6px;
  border-radius: 999px;
  background: rgba(16, 35, 61, 0.14);
  margin: 0 auto 8px;
}

.inline-code {
  padding: 12px 14px;
  border-radius: 14px;
  background: #f7f4ec;
}

.loader {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 5px solid rgba(182, 145, 75, 0.2);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 720px) {
  .page-shell {
    max-width: 760px;
    margin: 0 auto;
  }

  .composer-card,
  .bottom-nav {
    max-width: 724px;
    margin: 0 auto;
  }
}
