:root {
  color-scheme: light dark;
  --bg: #f2f5f1;
  --surface: #ffffff;
  --field: #fbfcf9;
  --ink: #17211c;
  --muted: #59665e;
  --line: #d7ded6;
  --line-strong: #b4c0b7;
  --accent: #0b6b5a;
  --accent-hover: #085447;
  --accent-soft: #e0f0eb;
  --accent-ink: #ffffff;
  --danger: #a12a2f;
  --danger-soft: #f8e7e6;
  --focus: #165ac2;
  --shadow: 0 1px 2px rgba(23, 33, 28, 0.05), 0 10px 30px -24px rgba(23, 33, 28, 0.5);
  --sans: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1713;
    --surface: #16211b;
    --field: #1b2821;
    --ink: #eef4ef;
    --muted: #a4b5aa;
    --line: #2b3b32;
    --line-strong: #405448;
    --accent: #63d6ba;
    --accent-hover: #8ce6d0;
    --accent-soft: #173d33;
    --accent-ink: #06251d;
    --danger: #ffa3a7;
    --danger-soft: #3a2022;
    --focus: #8fb7ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 34px -26px rgba(0, 0, 0, 0.9);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

main.wrap {
  padding-top: 18px;
  padding-bottom: 28px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -48px;
  left: 16px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 10px;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 0 16px;
}

.page-icon {
  width: 26px;
  height: 26px;
  flex: none;
  color: var(--accent);
}

.page-head h1 {
  margin: 0;
  font-size: clamp(1.25rem, 5vw, 1.45rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.panel {
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.field {
  min-width: 0;
  margin-bottom: 12px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.85rem;
  font-weight: 650;
}

.field input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1.3;
  appearance: none;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.65;
}

.field input:hover {
  border-color: var(--muted);
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.coord-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.error {
  margin: 5px 0 0;
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
}

button,
input {
  font-family: inherit;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.button:active {
  transform: translateY(1px);
}

.button:focus-visible,
.text-button:focus-visible,
.marker-url:focus-visible,
.skip-link:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.button.primary {
  width: 100%;
  margin-top: 12px;
  background: var(--accent);
  color: var(--accent-ink);
}

.button.primary:hover {
  background: var(--accent-hover);
}

.text-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.text-button:hover {
  color: var(--accent-hover);
}

.text-button.danger {
  color: var(--danger);
}

.text-button.locate {
  margin-top: 2px;
}

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.list-head h2 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.list-head h2:focus {
  outline: none;
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

.empty {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

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

.marker {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
}

.marker-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.marker-coords {
  margin: 3px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.4;
}

.marker-url {
  display: block;
  margin-top: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
  word-break: break-all;
  user-select: all;
  -webkit-user-select: all;
}

.marker-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.button.copy {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
}

.button.copy:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.button.copy.copied {
  background: var(--accent);
  color: var(--accent-ink);
}

.clipboard-fallback {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 30;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.82rem;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 360px) {
  .coord-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .panel {
    padding: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
