:root {
  --bg: #f2f0ea;
  --bg-strong: #e8efe9;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: #fffdfa;
  --text: #182026;
  --muted: #50606b;
  --line: rgba(24, 32, 38, 0.1);
  --accent: #1f6f78;
  --accent-deep: #144a51;
  --warm: #ad6b2b;
  --shadow: 0 22px 60px rgba(24, 32, 38, 0.12);
  --radius: 24px;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Newsreader", serif;
  background:
    radial-gradient(circle at top left, rgba(31, 111, 120, 0.16), transparent 28%),
    radial-gradient(circle at right bottom, rgba(173, 107, 43, 0.14), transparent 20%),
    linear-gradient(180deg, #fcfbf8 0%, var(--bg) 100%);
}

img {
  display: block;
  max-width: 100%;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border-radius: 12px;
  color: var(--accent-deep);
}

.hero,
.layout {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.hero > *,
.layout > *,
.top-nav > *,
.panel,
.dog-card,
.dog-card__body {
  min-width: 0;
}

.top-nav {
  width: min(1180px, calc(100% - 2rem));
  margin: 0.9rem auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.5rem;
  padding: 2rem 0;
}

.eyebrow,
.section-label,
.search-field span,
.help-text,
.source-note,
.status-message,
.dog-card__registration,
.dog-card__facts dt,
.fact-health,
.fact-notes {
  font-family: "Space Grotesk", sans-serif;
}

.eyebrow,
.section-label {
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent-deep);
  font-size: 0.76rem;
  font-weight: 700;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

h1 {
  font-size: clamp(2.2rem, 7vw, 5rem);
  line-height: 0.95;
  max-width: 9ch;
}

.lead,
.source-note {
  max-width: 60ch;
  color: var(--muted);
  line-height: 1.7;
}

.hero__stats,
.panel,
.dog-card {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.hero__stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  overflow: hidden;
  width: 75%;
  justify-self: end;
}

.hero__stats article {
  padding: 1.5rem;
  background: rgba(255, 253, 250, 0.72);
}

.hero__stats span {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 2.4rem;
  font-weight: 700;
}

.hero__stats p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 0.9fr 1.2fr;
  gap: 1.5rem;
  padding-bottom: 2rem;
}

.panel {
  padding: 1.5rem;
}

.panel__heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.heading-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.heading-filters {
  display: grid;
  gap: 0.7rem;
  justify-items: end;
}

.list-controls-row {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.7rem;
}

.filter-menu {
  position: relative;
}

.filter-menu summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.62rem 0.8rem;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.filter-menu summary::-webkit-details-marker {
  display: none;
}

.filter-menu[open] summary {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.filter-menu__content {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 14rem;
  display: grid;
  gap: 0.55rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 26px rgba(17, 33, 44, 0.18);
  z-index: 10;
}

.filter-menu__content .toggle-field {
  justify-content: flex-start;
  color: var(--text);
}

.filter-option {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: var(--text);
}

.filter-option input[type="radio"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

.search-field,
.field-group {
  display: grid;
  gap: 0.5rem;
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.toggle-field input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

.import-panel {
  display: grid;
  gap: 1rem;
  padding: 1.1rem;
  margin-bottom: 1.25rem;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(31, 111, 120, 0.08), rgba(255, 255, 255, 0.5));
  border: 1px solid rgba(31, 111, 120, 0.1);
}

.import-form {
  display: grid;
  gap: 0.8rem;
}

.bulk-import-form {
  margin-top: 0.4rem;
  padding-top: 0.9rem;
  border-top: 1px dashed rgba(31, 111, 120, 0.25);
}

.validation-report {
  width: 100%;
  border: 1px solid rgba(24, 32, 38, 0.12);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, monospace;
  font-size: 0.78rem;
  line-height: 1.4;
}

.import-actions {
  margin-top: 0;
}

.search-field input,
input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.85rem 0.95rem;
  background: rgba(255, 255, 255, 0.86);
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible {
  outline: none;
  border-color: rgba(31, 111, 120, 0.55);
  box-shadow: 0 0 0 4px rgba(31, 111, 120, 0.16);
}

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

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

button {
  border: 0;
  cursor: pointer;
  padding: 0.8rem 1.1rem;
  border-radius: 999px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.secondary-button {
  background: rgba(31, 111, 120, 0.1);
  color: var(--accent-deep);
}

.ghost-button {
  background: rgba(24, 32, 38, 0.07);
  color: var(--text);
}

.dog-list {
  display: grid;
  gap: 1rem;
}

.dog-list--compact {
  max-height: 68vh;
  overflow: auto;
  align-content: start;
}

.dog-list-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
  display: block;
  text-align: left;
  padding: 0.9rem;
}

.dog-list-item__name {
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  font-size: 0.94rem;
}

.dog-list-item--active {
  border-color: rgba(31, 111, 120, 0.4);
  background: linear-gradient(180deg, rgba(31, 111, 120, 0.14), rgba(255, 255, 255, 0.92));
}

.selected-dog-view {
  min-height: 240px;
}

.dog-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  overflow: hidden;
}

.dog-card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 180px;
  background: linear-gradient(180deg, rgba(31, 111, 120, 0.14), rgba(173, 107, 43, 0.08));
}

.dog-card__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #e8e8e8;
}

.dog-card__media--no-image {
  background: linear-gradient(180deg, rgba(24, 32, 38, 0.1), rgba(24, 32, 38, 0.14));
}

.dog-card__media--no-image::after {
  content: "Ei kuvaa";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(24, 32, 38, 0.56);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.dog-card__body {
  padding: 1.25rem;
}

.dog-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dog-card__registration {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.dog-card__registry-link {
  display: inline-block;
  margin: 0 0 0.45rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.82rem;
  color: var(--accent-deep);
  text-decoration: underline;
  text-underline-offset: 0.16rem;
}

.dog-card__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 0 0 1rem;
}

.dog-card__facts div {
  padding: 0.8rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
}

.dog-card__facts dt {
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.dog-card__facts dd {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
}

.fact-health,
.fact-notes {
  margin: 0.45rem 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.relatives-list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.family-groups {
  display: grid;
  gap: 0.9rem;
  margin-top: 0.5rem;
}

.family-groups h5 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  color: var(--accent-deep);
}

.relative-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
}

.relative-thumb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.relative-thumb--empty {
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(24, 32, 38, 0.08), rgba(24, 32, 38, 0.13));
  color: rgba(24, 32, 38, 0.52);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.44rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.05;
  padding: 0.18rem;
}

.relative-text {
  margin: 0;
  color: var(--muted);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.relative-text strong {
  color: var(--text);
}

.relative-link {
  color: var(--accent-deep);
  text-decoration: underline;
  text-underline-offset: 0.15rem;
  cursor: pointer;
  font-weight: 700;
}

.relative-link::after {
  content: " ->";
  font-weight: 700;
}

.relative-link:hover,
.relative-link:focus-visible {
  color: var(--accent);
}

.relative-item--linked {
  border: 1px solid rgba(31, 111, 120, 0.18);
  background: linear-gradient(180deg, rgba(31, 111, 120, 0.12), rgba(255, 255, 255, 0.72));
}

.boot-indicator {
  margin: 0;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(24, 32, 38, 0.14);
  background: rgba(24, 32, 38, 0.06);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 18px;
}

.runtime-error {
  color: #8d1720;
  border-color: rgba(141, 23, 32, 0.35);
  background: rgba(141, 23, 32, 0.08);
  font-weight: 600;
}

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

.change-request-item {
  padding: 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(24, 32, 38, 0.14);
  background: rgba(255, 255, 255, 0.82);
}

.change-request-item--pending {
  border-color: rgba(31, 111, 120, 0.35);
  box-shadow: inset 0 0 0 1px rgba(31, 111, 120, 0.12);
}

.change-request-title {
  margin: 0 0 0.3rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.96rem;
}

.change-request-meta {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--muted);
  font-size: 0.82rem;
}

.change-request-diff {
  margin: 0.65rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.change-request-diff li {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(31, 111, 120, 0.09);
  border: 1px solid rgba(31, 111, 120, 0.18);
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
}

.change-request-actions {
  margin-top: 0.65rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.change-request-thumb {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #e8e8e8;
  border-radius: 8px;
  margin: 0.65rem 0;
}

.debug-panel {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.debug-heading {
  margin-bottom: 0.75rem;
}

.debug-console {
  margin: 0;
  padding: 1rem;
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(24, 32, 38, 0.12);
  background: #172028;
  color: #e7f0f3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.link-button {
  border: 0;
  background: transparent;
  padding: 0;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  color: var(--accent-deep);
  text-decoration: underline;
  text-underline-offset: 0.18rem;
}

.editor-modal {
  border: 0;
  padding: 0;
  border-radius: 24px;
  width: min(960px, calc(100% - 1.5rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: transparent;
}

.editor-modal::backdrop {
  background: rgba(13, 18, 22, 0.48);
  backdrop-filter: blur(3px);
}

.editor-modal .editor-panel {
  margin: 0;
}

@media (max-width: 960px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    order: 1;
  }

  .list-panel {
    order: 2;
  }

  .hero__stats {
    width: 100%;
    justify-self: stretch;
  }
}

@media (max-width: 720px) {
  .top-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .panel__heading,
  .dog-card__header,
  .grid-two {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .heading-actions {
    width: 100%;
  }

  .heading-filters {
    width: 100%;
    justify-items: stretch;
  }

  .list-controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-menu {
    width: 100%;
  }

  .filter-menu summary {
    width: 100%;
  }

  .filter-menu__content {
    position: static;
    margin-top: 0.45rem;
    min-width: 0;
  }

  .toggle-field {
    justify-content: flex-start;
  }

  .dog-card__facts {
    grid-template-columns: 1fr;
  }

  .form-actions button,
  .search-field input,
  .import-actions button {
    width: 100%;
  }
}
