:root {
  color-scheme: light;
  --bg: #f6f4ee;
  --panel: #fffdf8;
  --ink: #202220;
  --muted: #6b6c66;
  --line: #ded8ca;
  --accent: #4b6f44;
  --accent-strong: #25452c;
  --gold: #d79a2b;
  --rose: #9b3d45;
  --blue: #386982;
  --shadow: 0 18px 50px rgba(54, 45, 28, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #242820;
  color: #fffdf8;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  aspect-ratio: 1;
  background: var(--gold);
  color: #20180a;
  font-weight: 900;
  border-radius: 8px;
}

.brand h1,
.brand p,
.view-header h2,
.view-header p,
.section-heading h2 {
  margin: 0;
}

.brand h1 {
  font-size: 1.18rem;
}

.brand p,
.eyebrow,
.hint,
.entry-type,
.entry-footer {
  color: var(--muted);
}

.sidebar .brand p,
.sidebar .section-heading span {
  color: #c8c6bb;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #fffdf8;
  text-align: left;
}

.nav-tab.active {
  background: #fffdf8;
  color: #242820;
}

.type-manager {
  display: grid;
  gap: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading h2 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.inline-form input,
.sidebar select {
  width: 100%;
}

input,
select,
textarea {
  position: relative;
  z-index: 1;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fffefb;
  color: var(--ink);
  caret-color: var(--ink);
  outline: none;
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(75, 111, 68, 0.15);
}

.inline-form button,
.primary-button,
.ghost-button,
.danger-button {
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 750;
}

.inline-form button,
.primary-button {
  background: var(--accent);
  color: #fff;
}

.ghost-button {
  background: #ebe5d7;
  color: var(--ink);
}

.danger-button {
  background: #f0d9d8;
  color: #7a1e25;
}

.type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.type-chip,
.tag-chip,
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf8;
  color: var(--ink);
  padding: 7px 10px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.sidebar .type-chip {
  background: rgba(255, 255, 255, 0.1);
  color: #fffdf8;
  border-color: rgba(255, 255, 255, 0.16);
}

.chip-x {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0 2px;
}

main {
  padding: 26px;
  min-width: 0;
}

.topbar,
.view {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

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

.storage-status {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffefb;
  color: var(--accent-strong);
  font-weight: 850;
}

.auth-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: var(--shadow);
}

.auth-panel[hidden] {
  display: none;
}

.auth-panel h2,
.auth-panel h3,
.auth-panel p {
  margin: 0;
}

.auth-panel p {
  color: var(--muted);
  line-height: 1.45;
}

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

.auth-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
}

.auth-message {
  min-height: 1.4em;
  color: var(--accent-strong);
  font-weight: 750;
}

.auth-message.error {
  color: var(--rose);
}

body.auth-required .view,
body.auth-required .type-manager,
body.auth-required #seedButton,
body.auth-required #clearButton {
  display: none;
}

.view {
  display: none;
  padding: 24px;
}

.active-view {
  display: block;
}

.view-header {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.view-header h2 {
  font-size: clamp(1.55rem, 2.4vw, 2.2rem);
}

.eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
}

.rating-form {
  display: grid;
  gap: 20px;
}

.field,
label {
  display: grid;
  gap: 7px;
  color: #3a3b36;
  font-weight: 700;
}

.field > label {
  display: block;
}

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

.rating-control {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.rating-control input {
  grid-column: 1 / -1;
  padding: 0;
  accent-color: var(--accent);
}

.rating-readout {
  color: var(--accent-strong);
}

.field-label {
  display: block;
}

.draft-box {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
  color: var(--ink);
  padding: 11px 12px;
  text-align: left;
  font-weight: 800;
}

.draft-box.empty {
  color: #777a76;
}

.draft-box.active,
.keyboard-target.active {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(75, 111, 68, 0.16);
}

.notes-draft {
  min-height: 118px;
  align-items: flex-start;
  line-height: 1.45;
  white-space: pre-wrap;
}

.tag-draft {
  flex: 1 1 180px;
  min-width: 160px;
}

.choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffefb;
  color: var(--ink);
  padding: 9px 12px;
  font-weight: 800;
}

.choice-button.active {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

.step-control,
.rating-buttons,
.keyboard-targets,
.keyboard-keys {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.step-control button,
.rating-button,
.keyboard-target,
.keyboard-keys button,
.compact-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
  color: var(--ink);
  padding: 9px 12px;
  font-weight: 850;
}

.step-control strong {
  min-width: 110px;
  text-align: center;
}

.rating-button {
  min-width: 42px;
  min-height: 42px;
}

.rating-button.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #20180a;
}

.button-keyboard {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f4ea;
}

.keyboard-target.active {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

.keyboard-keys button {
  min-width: 38px;
  min-height: 38px;
  padding: 7px 10px;
}

.keyboard-keys .wide-key {
  min-width: 76px;
}

.tag-composer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 52px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
}

.tag-composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(75, 111, 68, 0.15);
}

.selected-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-composer input {
  flex: 1 1 220px;
  min-width: 160px;
  border: 0;
  box-shadow: none;
  padding: 7px;
}

.tag-composer input:focus {
  box-shadow: none;
}

.tag-chip {
  background: #e9f0e5;
  border-color: #d5e1ce;
}

.suggestions {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 8px;
  min-width: min(320px, calc(100vw - 48px));
  background: #fffefb;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.suggestions:empty {
  display: none;
}

.inline-suggestions {
  position: static;
  min-width: 0;
}

.suggestion {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: #fffefb;
  color: var(--ink);
  text-align: left;
  padding: 10px 12px;
}

.food-suggestion {
  display: grid;
  gap: 2px;
}

.food-suggestion span {
  color: var(--muted);
  font-size: 0.84rem;
}

.suggestion:hover,
.suggestion:focus {
  background: #edf3e9;
}

.hint {
  font-size: 0.86rem;
  font-weight: 500;
}

.entries-header {
  align-items: end;
}

.entries-tools {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  width: min(1120px, 100%);
}

.entries-tools label,
.entry-tool {
  font-size: 0.86rem;
}

.tag-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tag-filter-bar:empty {
  display: none;
}

.filter-chip {
  background: #f8f4ea;
}

.filter-chip.active {
  background: var(--accent-strong);
  color: #fff;
  border-color: var(--accent-strong);
}

.entries-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.entry-card {
  display: grid;
  gap: 14px;
  min-height: 235px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
}

.entry-main,
.entry-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.entry-main h3 {
  margin: 3px 0 0;
  font-size: 1.2rem;
}

.entry-type {
  margin: 0;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 850;
}

.score-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f1d89c;
  color: #2e2109;
}

.score-pill strong {
  font-size: 1.45rem;
}

.entry-notes {
  margin: 0;
  color: #4a4b45;
  line-height: 1.45;
}

.entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.entry-footer {
  align-items: center;
  margin-top: auto;
  font-size: 0.86rem;
}

.entry-user {
  color: var(--accent-strong);
  font-weight: 850;
}

.delete-entry {
  border: 0;
  background: transparent;
  color: var(--rose);
  font-weight: 800;
}

.empty-state {
  display: none;
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--ink);
}

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

  .sidebar {
    position: static;
  }

  .entries-header,
  .view-header,
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .entries-tools,
  .form-grid,
  .auth-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  main,
  .sidebar {
    padding: 18px;
  }

  .view {
    padding: 18px;
  }

  .top-actions,
  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
