:root {
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-size: 16px;
  color: #102018;
  background: #e8eeeb;
  font-synthesis: none;
  color-scheme: light;
  --green: #14532d;
  --ink: #102018;
  --muted: #3e5145;
  --line: #dfe7e2;
  --surface: #fff;
  --soft: #eff5f0;
  --red: #b42324;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  border: 0;
  background: transparent;
  min-height: 44px;
  padding: 6px 10px;
  cursor: pointer;
  touch-action: manipulation;
  color: var(--green);
  font-weight: 600;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
button:active {
  background: var(--soft);
}
button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}
:focus-visible {
  outline: 2px solid #b17a20;
  outline-offset: -2px;
}
a {
  color: var(--green);
}
[hidden] {
  display: none !important;
}
h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
}
h2 {
  font-size: 16px;
  margin: 20px 0 8px;
}
p {
  line-height: 1.5;
}
label {
  display: grid;
  gap: 5px;
  font-size: 14px;
}
input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  padding: 9px;
  font-size: 16px;
}
input,
select {
  min-height: 44px;
}
input[type="checkbox"] {
  width: 21px;
  height: 21px;
  min-height: 0;
  accent-color: var(--green);
}
textarea {
  resize: vertical;
  line-height: 1.5;
}
input[type="file"] {
  font-size: 13px;
}
small,
.muted {
  font-size: 12px;
  color: var(--muted);
}
.primary {
  background: var(--green);
  color: #fff;
  border-radius: 6px;
}
.primary:active {
  background: #26673b;
}
.wide {
  width: 100%;
}
.icon {
  width: 44px;
  flex: 0 0 44px;
  padding: 0;
  font-size: 21px;
}
#app {
  width: 100%;
  max-width: 360px;
  margin: auto;
  min-height: 100dvh;
  background: var(--surface);
  padding-bottom: calc(58px + env(safe-area-inset-bottom));
}
.page-bar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 0 8px;
}
.page-bar h1 {
  flex: 1;
}
.brand-mark {
  color: var(--green);
  font-size: 24px;
  width: 36px;
  text-align: center;
}
.start-screen {
  padding: 16px;
}
.start-label {
  margin-bottom: 18px;
  color: var(--muted);
}
.start-label input,
.start-label select {
  font-size: 21px;
  font-weight: 650;
  padding: 12px 8px;
  color: var(--ink);
}
.home-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-top: -14px;
  margin-bottom: 14px;
}
.home-tools small {
  flex-basis: 100%;
  padding: 0 10px;
}
.gps-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px;
  border-top: 1px solid var(--line);
  margin-bottom: 18px;
}
.start-button {
  width: 100%;
  min-height: 56px;
  font-size: 21px;
}
.home-nav {
  display: flex;
  justify-content: space-around;
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.settings-list {
  padding: 12px 16px;
  display: grid;
  gap: 12px;
}
.settings-list h2,
.settings-list p {
  margin: 0;
}
.settings-list h2:not(:first-child) {
  margin-top: 12px;
}
.location-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.location-item small {
  display: block;
  margin-top: 4px;
}
.location-item button {
  flex-shrink: 0;
}
.line-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
}
details {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}
summary {
  cursor: pointer;
  min-height: 36px;
  display: list-item;
  align-content: center;
}
details label,
details a {
  margin: 8px 0;
}
.group-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 14px;
  font-size: 13px;
}
.counter-top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
}
.stats {
  display: flex;
  align-items: center;
  height: 44px;
  gap: 12px;
  padding-left: 10px;
  background: var(--green);
  color: white;
  font-variant-numeric: tabular-nums;
}
.stats b {
  font-size: 20px;
}
.stats > span {
  white-space: nowrap;
  font-size: 14px;
}
.stats .current-location {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
.stats .icon {
  color: white;
}
.search {
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.search input {
  height: 40px;
  min-height: 40px;
  padding: 6px 10px;
  background: var(--soft);
  border: 0;
}
#number-hint {
  display: block;
  padding: 3px 6px 0;
  font-size: 12px;
  color: var(--green);
}
.group-heading {
  display: flex;
  align-items: center;
  min-height: 34px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}
.group-heading button {
  min-height: 34px;
  color: var(--muted);
}
.group-toggle {
  flex: 1;
  text-align: left;
  font-size: 13px;
  padding-left: 12px;
}
.group-toggle small {
  margin-left: 5px;
}
.group-edit {
  width: 42px;
  font-size: 19px;
}
.bird {
  position: relative;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 112px;
}
.bird-line {
  display: grid;
  grid-template-columns: 37px 33px 32px minmax(70px, 1fr) 44px 43px 32px;
  align-items: center;
  min-height: 49px;
  padding: 0 4px;
}
.bird-line > button {
  min-width: 0;
  padding: 0;
  height: 48px;
  font-size: 15px;
}
.bird-line > button:first-child,
.bird-line > button:nth-child(2) {
  font-size: 13px;
}
.bird-line .bird-main {
  padding-left: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  color: var(--ink);
}
.total {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  color: var(--green);
  min-width: 0;
  text-align: left;
  flex-shrink: 0;
}
.bird-name {
  font-size: 15px;
  line-height: 1.2;
  overflow-wrap: anywhere;
  font-weight: 600;
}
.bird-line .breed {
  font-size: 15px;
  color: var(--muted);
}
.bird-line .heard {
  display: flex;
  padding-left: 4px;
  justify-content: flex-start;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 15px;
}
.heard b {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  color: var(--green);
}
.recorded {
  background: #f4faf1;
}
.bird-description {
  margin: 0;
  padding: 0 12px 7px;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
}
.unmapped {
  color: #986416;
  font-size: 9px;
  display: block;
}
.invalid .total,
.invalid .heard b,
.record-error,
.danger {
  color: var(--red);
}
.record-error {
  padding: 0 10px 5px;
  font-size: 11px;
}
.bird.invalid {
  border-left: 3px solid var(--red);
}
.counter-footer {
  position: fixed;
  z-index: 6;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 360px);
  display: flex;
  align-items: center;
  gap: 4px;
  height: calc(54px + env(safe-area-inset-bottom));
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.counter-footer .icon {
  width: 34px;
  flex-basis: 34px;
}
.totals {
  flex: 1;
  white-space: nowrap;
  font-size: 14px;
  padding: 0 4px;
}
.totals.active {
  background: var(--soft);
  border-radius: 5px;
}
.stop {
  width: 100px;
  font-size: 18px;
}
.bird-editor {
  position: static;
  left: 6px;
  right: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  padding: 8px;
  box-shadow: inset 0 1px 4px #12332120;
}
.bird:has(.bird-editor) {
  z-index: auto;
}
.editor-actions {
  display: flex;
  justify-content: space-between;
}
.editor-actions button {
  min-width: 44px;
}
.bird-editor textarea {
  margin-top: 8px;
}
.edit-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding: 0 6px;
}
.drag-handle {
  touch-action: none;
  cursor: grab;
  color: var(--muted);
  user-select: none;
  -webkit-user-select: none;
  width: 28px;
}
.bird-line.reordering {
  grid-template-columns: 26px 33px 28px 28px minmax(62px, 1fr) 40px 39px 28px;
}
.organizing .bird-line.reordering {
  grid-template-columns: 28px minmax(0, 1fr) 66px 48px;
  gap: 4px;
  padding-inline: 6px;
}
.organize-name {
  min-width: 0;
  overflow-wrap: anywhere;
}
.frequency {
  text-align: right;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.drop-target {
  box-shadow: inset 0 3px 0 var(--green);
  background: #d4e9d8;
}
.sheet {
  max-width: 420px;
  width: calc(100% - 20px);
  max-height: 85dvh;
  padding: 16px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  overflow: auto;
}
.sheet::backdrop {
  background: #10271e80;
}
.sheet h2 {
  margin: 0 0 12px;
}
.sheet form {
  display: grid;
  gap: 12px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.dialog-actions button {
  min-width: 80px;
}
.breeding-options {
  display: grid;
}
.breeding-option {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  text-align: left;
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  border-bottom: 1px solid var(--line);
}
.breeding-option strong {
  color: var(--green);
  font-size: 16px;
}
.breeding-option b {
  font-weight: 800;
  font-size: 15px;
}
.breeding-option.selected {
  background: var(--soft);
}
.summary-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 16px;
}
.warning {
  padding: 10px;
  border-left: 3px solid #c38d25;
  background: #fff7e6;
  color: #795412;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.warning.danger {
  border-color: var(--red);
  color: var(--red);
  background: #fff0f0;
}
#notice {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(68px + env(safe-area-inset-bottom));
  width: min(400px, calc(100% - 24px));
  background: #203b30;
  color: white;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 20;
}
#storage-warning {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--red);
  color: #fff;
  padding: 10px;
  z-index: 30;
}
#update-prompt {
  position: fixed;
  z-index: 25;
  left: 50%;
  bottom: calc(70px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(336px, calc(100% - 24px));
  padding: 8px 12px;
  border-radius: 8px;
  background: #203b30;
  color: #fff;
  box-shadow: 0 4px 16px #10201866;
}
#update-prompt button {
  float: right;
  min-height: 32px;
  padding: 2px 8px;
  background: #fff;
  border-radius: 4px;
}
@keyframes count-flash {
  0%,
  60% {
    background: #b9e5ab;
    color: #154c26;
  }
  100% {
    background: transparent;
  }
}
.count-changed {
  animation: count-flash 0.8s ease-out;
  border-radius: 4px;
}
@keyframes error-flash {
  0%,
  50% {
    background: #ffd3d3;
  }
  100% {
    background: transparent;
  }
}
.warning-flash {
  animation: error-flash 0.6s 3;
}
@media (max-width: 359px) {
  .bird-line {
    grid-template-columns: 33px 28px 27px minmax(65px, 1fr) 38px 37px 28px;
    padding-inline: 2px;
  }
  .bird-line.reordering {
    grid-template-columns: 24px 28px 25px 24px minmax(55px, 1fr) 36px 34px 26px;
  }
  .bird-line .bird-main {
    gap: 3px;
  }
  .bird-name {
    font-size: 13px;
  }
  .total {
    font-size: 18px;
    min-width: 15px;
  }
  .stats {
    gap: 8px;
  }
}

.bird-editor {
  left: 0;
  right: 0;
  padding: 0;
  border-inline: 0;
}
.editor-grid {
  display: grid;
  grid-template-columns: 37px 33px 32px minmax(70px, 1fr) 44px 43px 32px;
  align-items: center;
  padding: 4px;
}
.editor-grid.reordering {
  grid-template-columns: 26px 33px 28px 28px minmax(62px, 1fr) 40px 39px 28px;
}
.editor-grid button {
  padding: 0;
  font-size: 15px;
  min-width: 0;
}
.editor-grid button:first-child,
.editor-grid button:nth-child(2) {
  font-size: 13px;
}
.editor-grid input {
  padding: 6px 3px;
  font-size: 18px;
  font-weight: 650;
  appearance: textfield;
  -moz-appearance: textfield;
}
.editor-grid input::-webkit-inner-spin-button,
.editor-grid input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.editor-note {
  display: flex;
  align-items: end;
  gap: 4px;
  padding: 0 8px 8px;
}
.editor-note textarea {
  margin: 0;
  flex: 1;
}
.editor-note button {
  padding-inline: 7px;
  font-size: 13px;
}
.bird-line .bird-main {
  height: auto;
  min-height: 48px;
}
.month-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.drop-target,
.drop-after {
  position: relative;
  box-shadow: none;
  background: inherit;
}
.drop-target::before,
.drop-after::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  height: 4px;
  background: var(--green);
  border-radius: 3px;
  box-shadow:
    0 -3px 0 var(--surface),
    0 3px 0 var(--surface);
  z-index: 6;
  pointer-events: none;
}
.drop-target::before {
  top: -2px;
}
.drop-after::after {
  bottom: -2px;
}
@media (max-width: 359px) {
  .editor-grid {
    grid-template-columns: 33px 28px 27px minmax(65px, 1fr) 38px 37px 28px;
    padding-inline: 2px;
  }
  .editor-grid.reordering {
    grid-template-columns: 24px 28px 25px 24px minmax(55px, 1fr) 36px 34px 26px;
  }
}

/* Daylight: dark text and controls on light surfaces, independent of extensions. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: light;
    color: #102018;
    background: #e8eeeb;
    --green: #14532d;
    --ink: #102018;
    --muted: #3e5145;
    --line: #becbc3;
    --surface: #fff;
    --soft: #eff5f0;
    --red: #a51016;
  }
}
.bird-name,
.organize-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}
.group-toggle {
  font-size: 17px;
  font-weight: 700;
}
.page-title {
  flex: 1;
  min-width: 0;
}
.page-title small {
  display: block;
  font-size: 10px;
  line-height: 1.1;
}
.organizing .bird-line > button:last-child {
  font-size: 13px;
}
.search {
  position: relative;
}
.search input {
  padding-right: 44px;
}
.search input::-webkit-search-cancel-button {
  display: none;
}
.clear-query {
  position: absolute;
  right: 6px;
  top: 0;
  width: 44px;
  height: 44px;
  font-size: 25px;
  color: var(--ink);
}
.sheet-heading {
  position: sticky;
  top: -16px;
  z-index: 2;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.sheet-heading h2 {
  margin: 0;
  font-size: 18px;
}
.sheet-heading button {
  font-size: 28px;
  min-width: 44px;
  color: var(--ink);
}
@media (max-width: 359px) {
  .bird-name,
  .organize-name {
    font-size: 16px;
  }
}

/* Sorting uses four columns at every screen width, including narrow phones. */
.organizing .bird-line.reordering > button:last-child {
  padding-inline: 0;
  white-space: nowrap;
}
.output-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.output-actions > button {
  min-width: 0;
  padding-inline: 4px;
  font-size: 14px;
  white-space: nowrap;
}
