:root {
  --green-900: #063f35;
  --green-800: #075443;
  --green-700: #007755;
  --green-100: #d8e8e5;
  --green-50: #eef6f3;
  --paper: #f7f8f5;
  --ink: #17211f;
  --muted: #5e6b67;
  --line: #b7cbc6;
  --accent: #c7b07a;
  --danger: #8a433d;
  font-family: Inter, Segoe UI, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #d6ddd8 0%, #eff3ef 38%, #d1c4a7 100%);
  color: var(--ink);
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 18px auto;
  background: rgba(247, 248, 245, 0.96);
  border: 1px solid rgba(6, 63, 53, 0.28);
  box-shadow: 0 18px 50px rgba(20, 31, 27, 0.18);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 26px 30px;
  border-bottom: 4px solid var(--green-800);
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--green-900);
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 850;
}

.nav-link.active {
  border-color: var(--green-900);
  background: var(--green-800);
  color: #fff;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green-700);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  letter-spacing: 0;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 96px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  color: var(--green-900);
  text-align: center;
  font-weight: 750;
  background: var(--green-50);
}

.tasting-form {
  padding: 20px 28px 30px;
}

.identity {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 20px;
}

.identity label,
.field > span,
.scale-value {
  font-weight: 800;
}

input,
select,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

.sat-section {
  margin-top: 22px;
  border-bottom: 2px solid var(--line);
}

.sat-section h2 {
  margin: 0;
  padding: 9px 12px;
  color: white;
  background: linear-gradient(90deg, var(--green-900), var(--green-700));
  font-size: 1.05rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.field {
  min-width: 0;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 13px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.field:nth-child(4n + 1),
.field:nth-child(4n + 2) {
  background: var(--green-100);
}

.wide {
  grid-column: 1 / -1;
}

.slider-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.scale-value {
  color: var(--green-800);
  text-align: right;
}

input[type='range'] {
  padding: 0;
  min-height: 24px;
  accent-color: var(--green-700);
}

.scale-labels {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.76rem;
}

.scale-labels span {
  max-width: 90px;
  overflow-wrap: anywhere;
}

.toggle-field {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.toggle-field input {
  width: 28px;
  min-height: 28px;
  accent-color: var(--green-700);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 38px;
  align-items: center;
}

.chips.empty::before {
  content: 'No descriptors selected';
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid #9dbab3;
  border-radius: 999px;
  background: #f8fbf9;
  color: var(--green-900);
  padding: 5px 10px 5px 12px;
  cursor: pointer;
}

.chip b {
  color: var(--danger);
  font-size: 0.9rem;
}

.field.disabled {
  color: #8b9692;
  background: #edf1ef;
}

.field.disabled input[type='range'] {
  opacity: 0.45;
}

.actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
  padding: 16px 0 0;
  background: linear-gradient(180deg, rgba(247, 248, 245, 0), var(--paper) 30%);
}

button {
  min-height: 44px;
  border: 1px solid var(--green-900);
  border-radius: 4px;
  background: var(--green-800);
  color: #fff;
  padding: 9px 18px;
  font-weight: 850;
  cursor: pointer;
}

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

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.viewer-shell {
  min-height: calc(100vh - 36px);
}

.viewer-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  min-height: calc(100vh - 142px);
}

.note-list-panel {
  border-right: 1px solid var(--line);
  background: var(--green-50);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  margin: 0;
  font-size: 1rem;
  text-transform: uppercase;
}

.panel-heading span {
  min-width: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--green-900);
  padding: 4px 8px;
  text-align: center;
  font-weight: 850;
}

.note-list {
  display: grid;
  max-height: calc(100vh - 204px);
  overflow: auto;
}

.mobile-note-picker {
  display: none;
}

.note-list-item {
  min-height: 58px;
  display: grid;
  gap: 4px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 10px 14px;
  text-align: left;
  font-size: 0.92rem;
}

.note-list-item span {
  font-weight: 850;
}

.note-list-item small {
  font-size: 0.76rem;
}

.note-list-item small,
.muted {
  color: var(--muted);
}

.note-list-item.active {
  background: var(--green-800);
  color: #fff;
}

.note-list-item.active small {
  color: var(--green-100);
}

.empty-list {
  padding: 16px;
  color: var(--muted);
}

.note-viewer {
  min-width: 0;
  padding: 20px 24px 30px;
}

.viewer-controls {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.viewer-controls h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.viewer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.compact-button {
  min-height: 36px;
  padding: 7px 12px;
}

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

.danger-button:hover {
  background: #fff7f6;
}

.arrow-button {
  width: 52px;
  min-height: 52px;
  padding: 0;
  font-size: 1.5rem;
}

.note-detail.empty-state {
  border: 1px solid var(--line);
  background: #fff;
  padding: 18px;
  color: var(--muted);
}

.readonly-section {
  margin-top: 18px;
}

.readonly-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.readonly-field {
  min-width: 0;
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 13px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.readonly-field:nth-child(4n + 1),
.readonly-field:nth-child(4n + 2) {
  background: var(--green-100);
}

.readonly-field span {
  color: var(--muted);
  font-weight: 800;
}

.readonly-field strong {
  color: var(--green-900);
  overflow-wrap: anywhere;
}

.edit-grid .edit-field {
  align-content: stretch;
}

.checkbox-edit-field {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.checkbox-edit-field input {
  width: 28px;
  min-height: 28px;
  accent-color: var(--green-700);
}

.edit-form-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
  padding: 16px 0 0;
  background: linear-gradient(180deg, rgba(247, 248, 245, 0), var(--paper) 30%);
}

.readonly-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.readonly-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid #9dbab3;
  border-radius: 999px;
  background: #f8fbf9;
  color: var(--green-900);
  padding: 5px 10px;
  font-weight: 800;
}

@media (max-width: 760px) {
  .topbar,
  .identity,
  .section-grid,
  .viewer-layout,
  .readonly-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 20px 16px;
  }

  .tasting-form {
    padding: 16px;
  }

  .topnav {
    justify-content: stretch;
  }

  .topnav > * {
    flex: 1 1 auto;
  }

  .viewer-layout {
    min-height: auto;
  }

  .note-list-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .panel-heading {
    padding-bottom: 10px;
  }

  .mobile-note-picker {
    display: grid;
    gap: 7px;
    padding: 0 16px 16px;
  }

  .mobile-note-picker span {
    color: var(--muted);
    font-weight: 800;
  }

  .note-list {
    display: none;
  }

  .note-viewer {
    padding: 16px;
  }

  .viewer-controls {
    grid-template-columns: 46px minmax(0, 1fr) 46px;
  }

  .arrow-button {
    width: 46px;
    min-height: 46px;
  }

  .wide {
    grid-column: auto;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button,
  .edit-form-actions button {
    flex: 1;
  }

  .edit-form-actions {
    justify-content: stretch;
  }
}
