#author-highlighter-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #94a3b8;
  border-radius: 12px;
  background: #ffffff;
  color: #334155;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
  opacity: 0.68;
  z-index: 9998;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

#author-highlighter-button:hover,
#author-highlighter-button:focus-visible {
  opacity: 1;
  transform: translateY(-1px);
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

#author-highlighter-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
  z-index: 9999;
}

#author-highlighter-overlay.ah-hidden {
  display: none;
}

.ah-panel {
  width: min(520px, 100%);
  max-height: min(720px, 88vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  background: #ffffff;
  color: #1e293b;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.3);
  padding: 20px;
}

.ah-header,
.ah-list-header,
.ah-entry,
.ah-entry-actions,
.ah-add-actions,
.ah-global-toggle {
  display: flex;
  align-items: center;
}

.ah-header,
.ah-list-header,
.ah-entry {
  justify-content: space-between;
  gap: 12px;
}

.ah-header {
  flex: 0 0 auto;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
}

.ah-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ah-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.ah-close {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}

.ah-global-toggle {
  gap: 8px;
  margin-top: 18px;
  font-weight: 600;
}

.ah-help {
  margin: 12px 0 8px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

.ah-textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 10px;
  color: #0f172a;
  background: #ffffff;
  font: inherit;
  font-size: 14px;
}

.ah-textarea:focus {
  border-color: #3b82f6;
  outline: 2px solid rgba(59, 130, 246, 0.2);
}

.ah-add-actions {
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}

.ah-color-label,
.ah-enabled-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #475569;
  font-size: 13px;
}

.ah-color-input {
  width: 34px;
  height: 28px;
  padding: 1px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #ffffff;
  cursor: pointer;
}

.ah-primary,
.ah-delete,
.ah-clear {
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}

.ah-primary {
  border: 0;
  padding: 8px 12px;
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
}

.ah-list-header {
  margin-top: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

.ah-list-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.ah-clear,
.ah-delete {
  border: 1px solid #fecaca;
  background: #ffffff;
  color: #dc2626;
}

.ah-clear {
  padding: 5px 8px;
}

.ah-entry {
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

.ah-entry code {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #0f172a;
  font-size: 13px;
}

.ah-entry-actions {
  flex: 0 0 auto;
  gap: 9px;
}

.ah-delete {
  padding: 5px 7px;
}

.ah-empty,
.ah-status {
  color: #64748b;
  font-size: 13px;
  text-align: center;
}

.ah-empty {
  padding: 18px 0 6px;
}

.ah-status {
  min-height: 20px;
  margin: 8px 0 0;
}

@media (max-width: 640px) {
  #author-highlighter-button {
    right: 12px;
    bottom: 12px;
  }

  #author-highlighter-overlay {
    align-items: flex-start;
    padding: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
  }

  #author-highlighter-overlay.ah-keyboard-open {
    top: 0;
    bottom: auto;
    height: 100vh;
    height: var(--ah-visual-viewport-height, 100dvh);
    align-items: flex-start;
  }

  .ah-panel {
    max-height: 90vh;
    padding: 16px;
  }

  .ah-body {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
    scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  #author-highlighter-overlay.ah-keyboard-open .ah-panel {
    max-height: calc(100vh - 20px);
    max-height: calc(var(--ah-visual-viewport-height, 100dvh) - 20px);
  }

  .ah-entry {
    align-items: flex-start;
    flex-direction: column;
  }

  .ah-entry-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
