.diary-page {
  background: radial-gradient(ellipse at 100% 0%, #e4f3e9, transparent 62%);
}

.diary {
  max-width: 810px;
  margin: 0 auto;
}

.diary-header {
  margin: 24px 0 22px;
}

.diary-header label,
.diary-panel label {
  display: block;
  font-weight: 700;
}

.diary input:not([type="radio"]),
.diary select {
  box-sizing: border-box;
  min-height: 46px;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid #8eaa9d;
  border-radius: 11px;
  background: #f9fcfa;
  color: #193c30;
}

.diary-total {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 18px clamp(18px, 5vw, 32px);
  border-radius: 20px;
  background: #144b3d;
  color: #fff;
}

.diary-total h2,
.diary-total p {
  margin: 0;
}

.diary-total strong {
  color: #f5dd94;
  font-size: clamp(2.2rem, 7vw, 3.2rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.diary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr));
  gap: 14px;
  margin-top: 14px;
}

.diary-panel {
  min-width: 0;
  padding: clamp(15px, 4vw, 24px);
  border: 1px solid #d1e1d8;
  border-radius: 18px;
  background: #fff;
}

.diary-panel h2 {
  margin: 0 0 14px;
}

.diary-panel label span,
#diary-empty,
#diary-status {
  color: #4b6259;
  font-size: 0.9rem;
}

.diary-panel label span {
  margin-left: 5px;
  font-weight: 400;
}

.diary-panel input,
.diary-panel select {
  width: 100%;
  margin: 4px 0 12px;
}

.diary-save,
.diary-remove {
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  min-height: 44px;
}

.diary-save {
  width: 100%;
  background: #075d45;
  color: #fff;
  margin-top: 4px;
}

.diary-save:hover:not(:disabled) {
  background: #064a38;
}

.diary-save:disabled {
  opacity: 0.55;
}

#diary-status {
  margin: 8px 0 0;
  min-height: 1.5em;
}

#diary-entries {
  margin: 0;
  padding: 0;
  list-style: none;
}

#diary-entries li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #dce8e0;
  overflow-wrap: anywhere;
}

.diary-remove {
  flex: none;
  padding: 6px 10px;
  background: #eff5f1;
  color: #255448;
}

.diary-remove:hover {
  background: #dcece2;
}

.diary-controls,
.diary-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px 22px;
}

.diary-period {
  display: flex;
  gap: 3px;
  min-width: 0;
  margin: 0;
  padding: 3px;
  border: 1px solid #c6dcd1;
  border-radius: 13px;
  background: #ecf5ef;
}

.diary-period legend {
  padding: 0 4px;
  font-weight: 700;
}

.diary-period label {
  position: relative;
  cursor: pointer;
}

.diary-period input {
  position: absolute;
  opacity: 0;
}

.diary-period span {
  display: grid;
  place-items: center;
  min-width: 46px;
  min-height: 40px;
  border-radius: 9px;
}

.diary-period input:checked + span {
  background: #075d45;
  color: #fff;
}

.diary-period input:focus-visible + span {
  outline: 3px solid #1b7f64;
  outline-offset: 2px;
}

.diary-metrics .diary-vape-total {
  padding-bottom: 4px;
}

.diary-metrics .diary-vape-total strong {
  font-size: 1.5rem;
}

#diary-range {
  margin-top: 3px;
  color: #dceee5;
  font-size: 0.875rem;
}

#diary-brand-hint,
#diary-entries time {
  color: #4b6259;
  font-size: 0.85rem;
}

#diary-brand-hint {
  margin: -5px 0 12px;
}

#diary-entries time {
  display: block;
}

.diary-analysis {
  margin-top: 14px;
}

.diary-analysis-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.diary-analysis-header h2,
.diary-analysis-header select {
  width: auto;
  margin: 0;
}

.diary-insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 8px;
  margin: 0 0 22px;
}

.diary-insights div {
  border-radius: 12px;
  padding: 10px 14px;
  background: #edf5ef;
}

.diary-insights dt,
.diary-chart-note {
  font-size: .875rem;
  color: #405b51;
}

.diary-insights dd {
  margin: 2px 0 0;
  font-weight: 700;
}

.diary-analysis h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.diary-chart-note {
  margin: 0 0 8px;
}

.diary-chart-scroll {
  overflow-x: auto;
}

.diary-chart {
  display: grid;
  grid-template-columns: repeat(var(--days), minmax(22px, 1fr));
  gap: 2px;
  padding: 4px;
}

@media (max-width: 600px) {
  .diary-chart {
    grid-template-columns: repeat(var(--days), minmax(36px, 1fr));
  }
}

.diary-chart button {
  display: grid;
  align-items: end;
  gap: 5px;
  min-width: 0;
  min-height: 44px;
  padding: 4px 1px;
  border: 0;
  border-radius: 7px;
  background: #f4f8f5;
  color: #244c3e;
  font: inherit;
  font-size: .73rem;
  cursor: pointer;
}

.diary-chart button:hover,
.diary-chart button[aria-pressed="true"] {
  background: #dceee4;
  font-weight: 700;
}

.diary-chart button:focus-visible {
  outline: 2px solid #075d45;
}

.diary-chart-track {
  display: flex;
  align-items: end;
  justify-content: center;
  height: 108px;
  border-bottom: 1px solid #b2c9bc;
}

.diary-chart-bar {
  width: 62%;
  max-width: 38px;
  height: max(3px, var(--height));
  border-radius: 4px 4px 0 0;
  background: #247c62;
}

.diary-chart-bar.is-unlogged {
  height: 0;
  border-top: 2px dashed #70897d;
  border-radius: 0;
  background: none;
}

#analysis-detail {
  margin: 6px 0 22px;
  font-weight: 700;
}

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

.diary-brand-breakdown li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  overflow-wrap: anywhere;
}

.diary-brand-share {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: 8px;
  background: #e2eee7;
}

.diary-brand-share::before {
  display: block;
  width: var(--share);
  height: 100%;
  border-radius: inherit;
  background: #247c62;
  content: "";
}

.diary-nicotine {
  margin-top: 14px;
  background: #f5faf7;
}

.diary-nicotine h2 {
  margin-bottom: 5px;
  font-size: 1.1rem;
}

.diary-nicotine p {
  margin: 4px 0;
  color: #38574b;
  font-size: .9rem;
}

.diary-nicotine-figure {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

#diary-nicotine-total {
  color: #144b3d;
  font-size: 1.55rem;
}

#diary-entries small {
  display: block;
  color: #4b6259;
}

.diary-history-jump {
  margin-top: 14px;
}
