.pub-header {
  gap: 16px;
  width: 100%;
  display: flex;
  align-items: center;
  margin:100px 0 15px 0;
  justify-content: flex-start;
}

.pub-header h2 {
  margin: 0;
}

.pub-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.search-toggle {
  background: var(--primary);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1.05rem;
  transition: background .18s;
}

.search-field {
  position: relative;
  width: 0;
  overflow: hidden;
  transition: width .28s ease;
  height: 40px;
}

.pub-search.open .search-field {
  width: 350px;
}

.search-input {
  width: 100%;
  height: 100%;
  padding: 8px 38px 8px 12px;
  border-radius: 10px;
  border: 2px solid var(--primary);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
}

.clear-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  color: var(--primary);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: none; 
  font-weight: 700;
  font-size: 18px;
  transition: color 150ms ease, transform 150ms ease;
  transform-origin: center center;
}

.clear-btn img {
  display: block;
  width: 18px;
  height: 18px;
  object-fit: contain;
  transition: opacity 120ms ease;
}

.clear-btn:hover,.clear-btn:focus {
  color: var(--accent);
  outline: none;
}

.submit-btn {
  position: absolute;
  top: 50%;
  right: 30px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  color: var(--primary);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: none;
  font-weight: 700;
  font-size: 16px;
  transition: color 150ms ease, transform 150ms ease;
  transform-origin: center center;
}

.submit-btn img {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
  transition: opacity 120ms ease;
}

.submit-btn:hover, .submit-btn:focus {
  color: var(--accent);
  outline: none;
}

.search-field.has-value .submit-btn {
  display: block;
}

.search-field.has-value .clear-btn {
  display: block;
}

.search-field .search-input:focus {
  box-shadow: 0 0 0 3px rgba(46,84,151,0.12);
}

.author-highlight {
  padding: 2px;
  border-radius: 5px;
  color: var(--accent);
  display: inline-block;
  box-decoration-break: clone;
  border: 1.2px solid var(--primary);
  -webkit-box-decoration-break: clone;
}


input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
}
input[type="search"]::-ms-clear,
input[type="search"]::-ms-reveal {
  display: none;
  width: 0;
  height: 0;
}
input[type="text"]::-ms-clear { display:none; }

@media (max-width: 860px) {
  .nav.open {
    display: flex;
  }
  .hamburger {
    display: block;
  }
  .search-toggle { 
    width: 38px; 
    height: 38px; 
  }
  .pub-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .pub-header h2 {
    flex: 0 0 auto;
  }
  .pub-search {
    justify-content: flex-start;
    width: 100%;
  }
  .pub-search.open .search-field {
    width:320px;
  }
  .search-field .search-input {
    width: 100%;
  }
  .search-field { 
    height: 38px; 
  }
}

@media (max-width: 640px) {
  .pub-search.open .search-field {
    width:calc(100% - 48px)
  }
}