:root {
  color-scheme: light dark;
  --accent: #7b2d3a;
  --accent-bar: #7b2d3a;
  --track: rgba(127, 127, 127, 0.18);
  --error: #b00020;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent-bar: #c96b7e;
    --error: #ff6b6b;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
}

/* Comfortable touch targets everywhere — this app is used as much on
   phones and a kiosk touchscreen as with a mouse. */
button,
input,
select,
textarea {
  font-size: 1rem;
  font-family: inherit;
}

button,
input[type="submit"],
input[type="button"] {
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border-radius: 0.35rem;
  border: 1px solid rgba(127, 127, 127, 0.4);
  background: transparent;
  cursor: pointer;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="password"],
select,
textarea {
  min-height: 2.75rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.35rem;
  border: 1px solid rgba(127, 127, 127, 0.4);
  background: transparent;
  color: inherit;
}

textarea {
  min-height: 5rem;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(127, 127, 127, 0.3);
}

.site-header .brand {
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1rem;
  flex: 1;
}

#install-btn {
  background: var(--accent);
  color: #faf6f0;
  border: none;
  border-radius: 0.35rem;
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  color: inherit;
  text-decoration: none;
}

.site-main {
  padding: 1rem;
  max-width: 60rem;
  margin: 0 auto;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

.error {
  color: var(--error);
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 1rem;
}

.user-card {
  border: 1px solid rgba(127, 127, 127, 0.3);
  border-radius: 0.5rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
  text-decoration: none;
  color: inherit;
}

.user-card .user-name {
  font-weight: 600;
}

.wine-list, .bottle-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.wine-list li, .bottle-list li {
  border: 1px solid rgba(127, 127, 127, 0.3);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

form.inline {
  display: inline;
}

.form-grid {
  display: grid;
  gap: 0.75rem;
  max-width: 32rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.muted {
  color: rgba(127, 127, 127, 0.9);
  font-size: 0.85rem;
}

.stat-tile {
  margin: 1rem 0;
}

.stat-tile .stat-label {
  color: rgba(127, 127, 127, 0.9);
  font-size: 0.85rem;
}

.stat-tile .stat-value {
  font-size: 2.5rem;
  font-weight: 600;
  line-height: 1.1;
}

.dimension-filter {
  margin: 0.75rem 0 1rem;
}

.dimension-filter label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.viz-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.viz-row {
  display: grid;
  grid-template-columns: 10rem 1fr 2.5rem;
  align-items: center;
  gap: 0.75rem;
}

.viz-label {
  font-size: 0.85rem;
  color: rgba(127, 127, 127, 0.9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viz-track {
  background: var(--track);
  border-radius: 4px;
  height: 20px;
  overflow: hidden;
}

.viz-bar {
  height: 100%;
  background: var(--accent-bar);
  border-radius: 0 4px 4px 0;
}

.viz-value {
  font-size: 0.85rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Phone-width layout: the header wraps instead of squeezing, list rows
   stack instead of crushing long wine names against their action button,
   and the breakdown bars trade label width for track width. */
@media (max-width: 640px) {
  .site-header {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  .site-nav {
    order: 3;
    flex-basis: 100%;
    justify-content: space-between;
  }

  .wine-list li,
  .bottle-list li {
    flex-direction: column;
    align-items: stretch;
  }

  .viz-row {
    grid-template-columns: 6rem 1fr 2.25rem;
    gap: 0.5rem;
  }

  .stat-tile .stat-value {
    font-size: 2rem;
  }
}
