#searchform input:disabled {
  opacity: 1;
}

#respond {
  margin-top: 1em;
}

.versio-impressio {
  background: #fff;
  font-size: 1rem;
  line-height: 1.6;
  margin: 1.5rem auto;
  max-width: 42rem;
  padding: 0 1rem;
}

.versio-impressio .contenttitle h1 {
  line-height: 1.15;
}

.versio-impressio img {
  height: auto;
  max-width: 100%;
}

@media screen and (max-width: 983px) {
  #container, #content, #header, #navbar, #footer {
    box-sizing: border-box;
    width: 100%;
  }

  #container, #wrap {
    background: #fff;
  }

  #header {
    height: auto;
  }

  #header img {
    display: block;
    height: auto;
    margin: 0;
    width: 100%;
  }

  #navbar {
    height: auto;
    margin: 0;
  }

  #navegacion {
    display: flex;
    flex-wrap: wrap;
    float: none;
    justify-content: center;
    margin: 0;
  }

  #navbar li {
    flex: 0 1 113px;
  }

  #content {
    display: flex;
    flex-direction: column;
    font-size: 1rem;
  }

  #contentmiddle, #l_sidebar, #r_sidebar, #commentblock {
    box-sizing: border-box;
    float: none;
    margin: 0;
    padding: 1rem;
    width: 100%;
  }

  #contentmiddle {
    order: -1;
  }

  #contentmiddle img {
    height: auto;
    max-width: 100%;
  }

  #contentmiddle p {
    line-height: 1.6;
    overflow-wrap: break-word;
    text-align: start !important;
  }

  #contentmiddle .contenttitle table {
    font-size: 0.875rem;
  }

  #contentmiddle .commenttext, #contentmiddle .commenttext-admin {
    box-sizing: border-box;
    overflow-wrap: break-word;
    width: 100%;
  }

  #giraffe_calendar {
    max-width: 10rem;
  }

  #r_sidebar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
  }

  #r_sidebar > :first-child {
    grid-column: 1 / -1;
  }

  #r_sidebar div.categoria {
    margin: 0;
  }

  #r_sidebar img {
    max-width: 100%;
  }
}

@media print {
  body.versio-impressio {
    color: #000;
    margin: 0;
    max-width: none;
    padding: 0;
  }

  .versio-impressio .tornar {
    display: none;
  }

  .versio-impressio img {
    break-inside: avoid;
  }
}

.arxiu-mesos time {
  color: #666;
  margin-right: 0.4em;
  font-variant-numeric: tabular-nums;
}

.arxiu-mesos section {
  margin-bottom: 0.75rem;
}

.imatge-arxivada {
  display: inline-block;
  border: 1px solid #ddd;
  color: #555;
  padding: 0.6em 0.8em;
  margin: 0.4em 0 0.65em;
}

.enllac-arxivat {
  color: inherit;
  text-decoration: underline dotted;
}

#cerca-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#cerca-form label {
  width: 100%;
  font-weight: bold;
}

#cerca-form input,
#cerca-form button {
  font: inherit;
  padding: 0.45em 0.65em;
}

#cerca-form input {
  flex: 1 1 auto;
  min-width: 0;
}

#cerca-resultats {
  padding-left: 0;
}

#contentmiddle #cerca-resultats li {
  list-style: none;
  margin: 0 0 0.7rem;
  border-bottom: 1px solid #ddd;
}

#cerca-resultats h2 {
  font-size: 1.1rem;
  border: 0;
}

@media screen and (max-width: 983px) {
  #wrapnlb {
    background: #fff;
  }
}

@media screen and (max-width: 767px) {
  #navbar #navegacion {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: min(100%, calc(100vw - 14px), 31rem);
    box-sizing: border-box;
    margin: 0 auto;
    padding: 2px 3px;
  }

  #navbar li {
    float: none;
    min-width: 0;
  }

  /* Each GIF contains the original normal and selected 34px-tall frames. */
  #navegacion > #home { --menu-width: 69px; --menu-ratio: 69 / 34; }
  #navegacion > #archive { --menu-width: 78px; --menu-ratio: 78 / 34; }
  #navegacion > #photo { --menu-width: 77px; --menu-ratio: 77 / 34; }
  #navegacion > #maps { --menu-width: 75px; --menu-ratio: 75 / 34; }
  #navegacion > #contact { --menu-width: 98px; --menu-ratio: 98 / 34; }

  #navbar #navegacion a {
    position: relative;
    float: none;
    width: 100%;
    height: 44px !important;
    padding: 0;
    background-size: 0 0;
  }

  #navbar a::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(84%, calc(var(--menu-width) * 0.84));
    aspect-ratio: var(--menu-ratio);
    background-image: inherit;
    background-position: center top;
    background-size: 100% 200%;
    transform: translate(-50%, -50%);
  }

  #navbar a:is(.selected, :hover, :focus-visible, :active)::before {
    background-position: center bottom;
  }

  #navbar a:focus-visible {
    outline: 2px solid #507aa5;
    outline-offset: -2px;
  }

  #navbar a span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  #content:has(> #contentmiddle:not(.mapa-pagina)) {
    max-width: 40rem;
  }

  #contentmiddle, #l_sidebar, #r_sidebar {
    padding-inline: clamp(0.85rem, 4vw, 1.75rem);
  }

  #contentmiddle, body.versio-impressio {
    font-size: 0.875rem;
  }

  #contentmiddle {
    overflow-wrap: anywhere;
  }

  #contentmiddle .contenttitle table {
    border-spacing: 0;
    font-size: 0.8125rem;
    line-height: 1.5;
  }

  #contentmiddle .contenttitle td:first-child {
    padding-right: 0.5rem;
  }

  #contentmiddle .contenttitle td:first-child a {
    white-space: nowrap;
  }

  #contentmiddle .contenttitle td[align="right"] {
    vertical-align: top;
    white-space: nowrap;
  }

  #contentmiddle:not(.mapa-pagina) h1 {
    font-size: clamp(1.3125rem, 5.4vw, 1.625rem);
    line-height: 1.15;
    padding-block: 0.625rem 0.875rem;
  }

  #contentmiddle:not(.mapa-pagina) p {
    line-height: 1.6;
    padding-bottom: 1rem;
  }

  #contentmiddle .arxiu-mesos ul {
    margin-left: 0;
    padding-bottom: 0.5rem;
  }

  #contentmiddle .arxiu-mesos li {
    margin-left: 1rem;
    line-height: 1.45;
  }

  #contentmiddle p img {
    float: none;
    margin: 0.5rem 0;
  }

  #contentmiddle img.aligncenter {
    display: block;
    float: none;
    margin: 0 auto 0.875rem;
  }

  #contentmiddle .postspace {
    margin-block: 0.5rem;
    background-position: center;
    background-repeat: no-repeat;
  }

  #contentmiddle #commentblock {
    padding: 0.875rem;
  }

  #contentmiddle #commentblock ol {
    margin: 0;
    padding: 0;
  }

  #contentmiddle #commentblock li {
    margin: 0 0 0.875rem;
  }

  #l_sidebar, #r_sidebar {
    border-top: 1px solid #ccc;
  }

  #l_sidebar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
    gap: 1.25rem;
    font-size: 0.875rem;
  }

  #l_sidebar > br {
    display: none;
  }

  #l_sidebar div {
    padding-right: 0;
  }

  #l_sidebar #s {
    width: 100%;
    max-width: 13rem;
    min-height: 44px;
    box-sizing: border-box;
    margin-left: 0;
    padding-inline: 0.5rem 1.75rem;
    background-position: right 6px center;
    background-repeat: no-repeat;
    font-size: 1rem;
  }

  #r_sidebar {
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 0.75rem;
  }

  #r_sidebar .categoria {
    padding: 0;
  }

  #r_sidebar .categoria img {
    display: block;
    height: auto;
  }

  #footer {
    padding-inline: 0.875rem;
    line-height: 1.5;
  }
}
