:root {
  --ink: #101410;
  --paper: #fbfaf4;
  --panel: #ffffff;
  --line: #c8cdc3;
  --green: #14532d;
  --green-ink: #ffffff;
  --danger: #991b1b;
  --danger-ink: #ffffff;
  --muted: #4b5563;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.4;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 48px;
  min-width: 48px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0.6rem 1rem;
  font-weight: 700;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #1d4ed8;
  outline-offset: 2px;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 1rem calc(96px + env(safe-area-inset-bottom));
}

.screen h1 {
  font-size: 1.6rem;
  line-height: 1.2;
  margin: 0.25rem 0 1rem;
}

.screen h2 {
  font-size: 1.25rem;
  margin: 1.25rem 0 0.5rem;
}

.primary {
  background: var(--green);
  color: var(--green-ink);
}

.secondary {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

.danger {
  background: var(--danger);
  color: var(--danger-ink);
}

.field {
  display: block;
  margin: 0 0 1rem;
}

.field > span,
.field > label,
.field-label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.location-list {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
}

.location-card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.location-card .location-copy {
  min-width: 0;
}

.location-card strong {
  display: block;
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.location-card .meta {
  color: var(--muted);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.location-card button {
  flex: 0 0 auto;
  background: #e8ece3;
  color: var(--ink);
  border-color: #aeb7a6;
}

.start-button {
  width: 100%;
  min-height: 72px;
  font-size: 1.4rem;
  margin-top: 0.5rem;
}

.location-button {
  width: 100%;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.15rem;
  text-align: left;
}

.location-button-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

.location-button strong {
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}

.gps-button {
  width: 100%;
  min-height: 56px;
  margin: 0.25rem 0 0.5rem;
}

.status {
  min-height: 1.4em;
  margin: 0.25rem 0 0.75rem;
  color: var(--muted);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.lookup-block {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin: 0 0 1rem;
}

.count-screen {
  text-align: center;
}

.count-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.count-head .label {
  font-weight: 700;
  color: var(--muted);
}

.countdown {
  font-variant-numeric: tabular-nums;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.total-row {
  font-size: 1.2rem;
  margin: 0.25rem 0 1rem;
}

.total-row .number {
  font-size: 2.4rem;
  font-weight: 800;
  margin-left: 0.4rem;
  font-variant-numeric: tabular-nums;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.tap-button {
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border-radius: var(--radius);
  border: 3px solid rgba(0, 0, 0, 0.25);
}

.tap-button .color-name {
  font-size: 1rem;
}

.tap-button .color-count {
  font-size: 1.9rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.count-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-top: 1rem;
}

.count-actions .undo {
  grid-column: 1 / -1;
  background: #e8ece3;
  color: var(--ink);
  border-color: #aeb7a6;
}

.count-actions .stop {
  background: var(--danger);
  color: var(--danger-ink);
}

.count-actions .cancel {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--ink);
}

.mic-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.mic-indicator,
.mic-error {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
}

.mic-indicator {
  background: var(--green);
  color: var(--green-ink);
}

.mic-error {
  background: var(--danger);
  color: var(--danger-ink);
}

.review-panel {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}

.review-total {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}

.review-total .number,
.review-total [data-testid="review-total"] {
  font-size: 2.2rem;
  font-weight: 800;
  margin-left: 0.35rem;
}

.review-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.review-meta {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.review-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-top: 1rem;
}

.entry-list {
  display: grid;
  gap: 0.75rem;
}

.entry-card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem;
}

.entry-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

.entry-type {
  font-weight: 800;
}

.entry-total {
  font-size: 1.35rem;
  font-weight: 800;
}

.entry-notes {
  margin-top: 0.35rem;
  overflow-wrap: anywhere;
}

.entry-weather {
  margin-top: 0.35rem;
  color: var(--muted);
}

.log-filters {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 1rem;
}

.log-filters .field {
  margin-bottom: 0.6rem;
}

.entry-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.entry-actions button {
  flex: 1 1 auto;
}

.edit-weather {
  border-top: 2px solid var(--line);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

.edit-weather h3 {
  margin: 0.5rem 0;
}

.empty-state {
  color: var(--muted);
  padding: 1rem 0;
}

.settings-actions {
  margin-top: 1rem;
}

.backup-panel {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.backup-actions button {
  flex: 1 1 160px;
}

.import-preview {
  border-top: 2px solid var(--line);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
}

.error {
  color: var(--danger);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 0.4rem;
}

.week-cell {
  min-height: 48px;
  padding: 0.25rem;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: #eef1ea;
  color: var(--ink);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.week-cell[data-state="count"] {
  background: #15803d;
  color: #ffffff;
  border-color: #166534;
}

.week-cell[data-state="low"] {
  background: #fde047;
  color: #101410;
  border-color: #a16207;
}

.week-cell[data-state="weather-skip"] {
  background: #1d4ed8;
  color: #ffffff;
  border-color: #1e3a8a;
}

.week-cell[data-state="off-season"] {
  background: #d1d5db;
  color: #101410;
  border-color: #9ca3af;
}

.week-cell[data-state="missed"] {
  background: #ffffff;
  color: #4b5563;
  border-color: #c8cdc3;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: #d8ddd4;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.12);
}

.bottom-nav button {
  border-radius: 0;
  min-height: 60px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.98rem;
}

.bottom-nav button.active {
  background: var(--green);
  color: var(--green-ink);
}

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-backdrop.confirm-layer {
  z-index: 60;
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  border-radius: 18px;
  padding: 1.1rem;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

.modal h2 {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.modal-actions button {
  flex: 1 1 120px;
}

@media (min-width: 640px) {
  .color-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-height: 520px) {
  .countdown {
    font-size: 1.7rem;
  }

  .tap-button {
    min-height: 72px;
  }
}

.credit-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem 1rem;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.credit-footer img {
  display: block;
  width: 20px;
  height: 20px;
}

.credit-footer a {
  color: var(--green);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.about-panel {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  margin-top: 1rem;
}

.about-panel img[data-testid="about-logo"] {
  display: block;
  width: 64px;
  height: 64px;
}

.about-panel a {
  color: var(--green);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.entry-audio {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 0.5rem;
}

.entry-audio audio {
  display: none;
}

.entry-audio button {
  min-height: 48px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.checkbox-field input {
  width: auto;
  min-height: 24px;
  flex: 0 0 auto;
}

.checkbox-field span {
  margin-bottom: 0;
}

.storage-warning {
  background: #fef3c7;
  border: 2px solid #92400e;
  color: #3f2200;
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.auto-backup {
  border-top: 2px solid var(--line);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}

.auto-backup p {
  margin: 0 0 0.5rem;
}
