:root {
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  color: #20312a;
  background: #fff;
  font-synthesis: none;
  --green: #174c3c;
  --muted: #64716a;
  --line: #dce3de;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
[hidden] {
  display: none !important;
}
button,
input,
select {
  font: inherit;
}
button,
input,
select {
  min-height: 44px;
  border-radius: 7px;
}
button {
  padding: 8px 12px;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  font-weight: 600;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
input,
select {
  width: 100%;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: inherit;
  font-size: 16px;
  scroll-margin-block: 16px;
}
input[type='number'],
strong {
  font-variant-numeric: tabular-nums;
}
h2,
p {
  margin: 0;
}
h2 {
  font-size: 1rem;
  font-weight: 650;
  white-space: nowrap;
}
main {
  max-width: 760px;
  margin: auto;
  padding: max(12px, env(safe-area-inset-top)) 12px
    max(12px, env(safe-area-inset-bottom));
}
.mixes {
  display: grid;
  gap: 8px;
  align-items: start;
}
.mix {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px;
}
.mix-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.column-labels,
.ingredient-fields,
.material {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px 44px;
  gap: 6px;
  align-items: center;
}
.column-labels {
  font-size: 0.7rem;
  color: var(--muted);
  padding: 0 0 4px;
}
.ingredient + .ingredient {
  margin-top: 6px;
}
.remove {
  padding: 0;
  width: 44px;
  color: #956557;
  background: transparent;
  font-size: 1.35rem;
  font-weight: 400;
}
.ingredient-error {
  margin: 4px 0;
  color: #92502c;
  font-size: 0.75rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.mix-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}
.add-button {
  background: transparent;
  color: var(--green);
  font-size: 0.85rem;
  padding-inline: 4px;
}
.mix-rate {
  min-width: 0;
  text-align: right;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}
.mix-rate small {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 400;
}
.result {
  margin-top: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
#materials-panel {
  border-bottom: 1px solid var(--line);
}
#materials-panel summary {
  min-height: 44px;
  padding: 11px 0;
  cursor: pointer;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 600;
}
#materials-panel summary:focus-visible,
.grade-card > summary:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
#materials-panel[open] {
  padding-bottom: 8px;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.form-actions .add-button {
  margin-right: auto;
}

.result-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.result-line > span {
  font-size: 0.85rem;
  white-space: nowrap;
}
.result-line strong {
  color: var(--green);
  font-size: 1.7rem;
  line-height: 1.2;
  text-align: right;
  overflow-wrap: anywhere;
  min-width: 0;
}
.result-message {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
  margin-top: 4px;
  overflow-wrap: anywhere;
}
#save-state {
  color: var(--muted);
  font-size: 0.8rem;
}
.secondary {
  color: var(--green);
  background: #f0f4f1;
  font-size: 0.8rem;
}
.material-list {
  display: grid;
  gap: 6px;
}
.primary {
  color: white;
  background: var(--green);
}
.notice {
  margin-bottom: 8px;
  color: #92502c;
  font-size: 0.8rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.unsaved {
  color: #92502c !important;
}
.empty {
  color: var(--muted);
  padding: 12px 0;
  font-size: 0.85rem;
}
.connection {
  margin-top: 24px;
  font-size: 0.9rem;
}
.connection p {
  margin-bottom: 8px;
}
#connection-message {
  color: var(--muted);
}
@media (min-width: 680px) {
  .mixes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.danger {
  background: transparent;
  color: #a33f30;
  font-size: 0.8rem;
}

.grades-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 4px;
}
.text-button {
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
}
.grade-card {
  border-bottom: 1px solid var(--line);
}
.grade-card > summary {
  min-height: 48px;
  padding: 12px 0;
  cursor: pointer;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.grade-card > summary small {
  float: right;
  margin-left: 8px;
  color: #92502c;
  font-size: 0.7rem;
  font-weight: 400;
}
.grade-body {
  padding-bottom: 12px;
}
.grade-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.split-control {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 340px;
}
.split-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 4px;
}
.share-input {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.share-input input {
  padding-inline: 6px;
}
.split-divider {
  color: var(--muted);
}
.grade-actions {
  position: relative;
  margin-left: auto;
}
.more-button {
  width: 44px;
  padding: 0;
  font-size: 1.5rem;
}
.grade-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 10;
  min-width: 140px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 12px #20312a14;
}
.grade-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  font-size: 0.85rem;
}
.grade-state {
  margin-right: auto;
  font-size: 0.75rem;
  color: var(--muted);
}
.grade-message {
  margin: 6px 0 0;
}
