.horse-icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
  flex: 0 0 24px;
}

.horse-capacity {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.horse-search {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 2rem;
}

.index-filters {
  margin-bottom: 1.5rem;
}

.index-filters > summary {
  width: fit-content;
  min-height: 44px;
  padding: 0.65rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-background-secondary);
  color: var(--color-foreground);
  box-sizing: border-box;
  cursor: pointer;
  font-weight: 600;
}

.index-filters > summary:focus-visible {
  outline: 2px solid var(--color-foreground);
  outline-offset: 3px;
}

.index-filters[open] > summary {
  margin-bottom: 1rem;
}

.index-filters .horse-search {
  margin-bottom: 0;
}

.horse-search .form-group {
  flex: 1 1 150px;
  margin: 0;
}

.horse-search .form-group:first-child {
  flex-grow: 2;
}

.horse-search input:not([type='submit']), .horse-search select {
  color: var(--color-foreground);
}

.horses-page [hidden] {
  display: none;
}

.horse-picture {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--color-background-tertiary);
}

.horse-picture-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-foreground-secondary);
}

.horse-picture-placeholder .horse-icon {
  width: 88px;
  height: 88px;
  flex-basis: 88px;
  opacity: 0.7;
}

.horse-registered-name {
  color: var(--color-text-muted);
}

.horse-card-location {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.horse-card-location .material-icons {
  font-size: 1.1rem;
}

.horse-status {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-foreground);
  background: var(--color-background-tertiary);
}

.horse-status-inactive {
  color: var(--color-text-muted);
}

.horse-profile-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin: 1.5rem 0 2rem;
}

.horse-profile-header > .horse-picture {
  width: 220px;
  border-radius: 16px;
  flex-shrink: 0;
}

.horse-profile-header h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  overflow-wrap: anywhere;
}

.horse-profile-header > .stable-primary-action {
  margin-left: auto;
  flex-shrink: 0;
}

.horse-profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.horse-panel {
  padding: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  background: var(--color-background-secondary);
  min-width: 0;
  overflow-wrap: anywhere;
}

.horse-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.6rem;
}

.horse-panel h3 {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
}

.horse-section {
  margin-top: 1.5rem;
}

.horse-panel [data-camera-retry]:not([hidden]) + .horse-section {
  margin-top: 2.5rem;
}

.horse-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.horse-section-heading h2 {
  margin: 0;
}

.horse-current-value {
  font-size: 1.2rem;
  font-weight: 600;
}

.horse-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem 1.5rem;
}

.horse-details dt {
  color: var(--color-text-muted);
}

.horse-details dd {
  margin: 0;
}

.horse-relationship, .horse-history-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--color-border);
}

.horse-history-row p, .horse-relationship p {
  margin: 0.4rem 0;
  font-size: 0.9rem;
}

.horse-history-edit {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem;
  text-decoration: none;
  flex-shrink: 0;
}

.horse-history-edit .material-icons {
  font-size: 1.15rem;
}

.horse-icon-button {
  border: 0;
  background: transparent;
  color: var(--color-foreground);
  cursor: pointer;
}

.horse-relationship-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.horses-page a:not(.index-card):not(.btn-primary), .horse-panel a {
  color: var(--color-foreground);
  text-underline-offset: 0.2em;
}

.horse-secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 48px;
  text-align: center;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  background: var(--color-background-secondary);
  color: var(--color-foreground);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.horse-secondary-button:hover {
  transition: 0.3s ease;
  background: var(--color-background-tertiary);
  border-color: var(--color-foreground-secondary);
}

.horse-text-button {
  border: 0;
  padding: 0.4rem 0;
  background: none;
  color: var(--color-foreground);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

.horse-client-row {
  padding: 1rem;
  margin: 1rem 0;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-background-tertiary);
}

.horse-photo-editor {
  display: flex;
  gap: 1rem;
  margin: 1rem 0;
}

.horse-photo-editor .horse-picture {
  width: 130px;
  border-radius: 8px;
}

.horse-photo-editor [hidden] {
  display: none;
}

.photo-crop-editor {
  width: min(100%, 36rem);
  margin: 1rem 0;
}

.photo-crop-editor[hidden] {
  display: none;
}

.photo-crop-editor p {
  margin: 0 0 0.75rem;
  color: var(--color-text-muted);
}

.photo-crop-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  background: transparent;
  cursor: grab;
  touch-action: none;
}

.photo-crop-canvas:active {
  cursor: grabbing;
}

.photo-crop-editor > input {
  display: block;
  width: 100%;
  margin: 0.5rem 0 1rem;
}

.horse-inline-form {
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
}

.horse-inline-form input, .horse-inline-form select {
  width: 100%;
  color: var(--color-foreground);
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.65rem;
}

.horse-documents-page > .stable-back-link {
  display: inline-block;
  margin-bottom: 1rem;
}

.horse-document-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--color-border);
}

.horse-document-row p {
  margin: 0.35rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.horse-document-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.horses-page input[type='file']::file-selector-button {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  margin-right: 0.75rem;
  background: var(--color-background-secondary);
  color: var(--color-foreground);
  font: inherit;
  cursor: pointer;
}

.horse-document-row .horse-document-expired {
  color: var(--color-red);
}

.horse-reminder-row {
  padding: 1rem 0;
  border-top: 1px solid var(--color-border);
}

.horse-reminder-row[hidden] {
  display: none;
}

.horse-reminder-form {
  padding: 1rem 0;
}

.horse-reminder-form fieldset {
  border: 0;
  padding: 0;
  margin: 1rem 0;
}

@media (max-width: 700px) {
  .horse-document-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

.horse-inline-form .form-group {
  margin-bottom: 0;
}

.horse-panel summary, .horse-section > summary {
  cursor: pointer;
  padding: 0.5rem 0;
  font-weight: 600;
}

.horse-fee-history {
  margin-top: 0.6rem;
}

.horse-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1.5rem;
  margin-top: 2rem;
}

.horses-page :is(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--color-foreground);
  outline-offset: 3px;
}

@media (max-width: 768px) {
  .horse-profile-header {
    flex-wrap: wrap;
    gap: 1.25rem;
  }

  .horse-profile-header > .horse-picture {
    width: 130px;
  }

  .horse-profile-header > .stable-primary-action {
    margin-left: 0;
  }

  .horse-profile-grid {
    grid-template-columns: 1fr;
  }

  .horse-section-heading, .horse-relationship {
    flex-wrap: wrap;
  }

  .horse-relationship-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .horse-panel {
    padding: 1.25rem;
  }

}

.horse-document-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  overflow-wrap: anywhere;
}

.horse-document-card .index-card__title a {
  color: inherit;
  text-decoration: none;
}

.horse-document-card .index-card__title a:hover {
  text-decoration: underline;
}

.horse-document-card .horse-document-actions {
  justify-content: flex-end;
  gap: 0.5rem;
}

.horse-document-card .horse-document-expired {
  color: var(--color-red);
}

.horse-document-card .horse-history-edit .material-icons {
  color: var(--color-text-muted);
  opacity: 0.75;
  transition: color 180ms ease, opacity 180ms ease;
}

.horse-document-card .horse-history-edit:is(:hover, :focus-visible) .material-icons {
  color: var(--color-foreground);
  opacity: 1;
}
