.hw-topbar-search { position: relative; flex: 0 1 400px; min-width: 220px; margin-right: auto; }
.homework-app-header:has(.hw-topbar-search) { gap: 12px; }
.homework-app-header:has(.hw-topbar-search) .homework-sidebar-collapse-toggle { margin-right: 0; }
.homework-app-header:has(.hw-topbar-search) .account-area { width: auto; flex: 0 0 auto; }
.hw-search-field { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-soft, #fafbfc); }
.hw-search-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.hw-search-field svg, .hw-search-toggle svg { width: 18px; height: 18px; flex: 0 0 auto; }
.hw-search-field input { width: 100%; min-width: 0; height: 40px; padding: 0; border: 0; outline: none; box-shadow: none; background: transparent; color: var(--text); font: inherit; font-size: 14px; }
.hw-search-field input::-webkit-search-cancel-button { display: none; }
.hw-topbar-search .hw-search-field input:focus { border: 0; outline: none; box-shadow: none; }
.hw-search-field button, .hw-search-toggle { min-height: 42px; min-width: 32px; padding: 4px; border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; }
.hw-search-field [data-search-close], .hw-search-toggle { display: none; }
.hw-search-panel { position: absolute; top: calc(100% + 8px); left: 0; width: max(100%, 360px); max-width: calc(100vw - 32px); max-height: min(65dvh, 540px); overflow-y: auto; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-card, 0 8px 24px #1e1f241a); z-index: 60; }
.hw-search-status, .hw-search-group { margin: 0; padding: 8px; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.hw-search-group { font-weight: 700; }
.hw-search-result { display: grid; gap: 4px; padding: 10px; border-radius: 8px; cursor: pointer; }
.hw-search-result strong { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.hw-search-result small { color: var(--text-secondary); font-size: 12px; }
.hw-search-result:hover, .hw-search-result[aria-selected="true"] { background: var(--primary-soft); color: var(--primary); }
.hw-search-more { width: 100%; min-height: 42px; border: 0; background: var(--primary-soft); color: var(--primary); border-radius: 8px; cursor: pointer; }
.hw-topbar-search [hidden] { display: none !important; }
.hw-topbar-search button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (max-width: 640px) {
  .hw-topbar-search { min-width: 42px; flex: 0 0 42px; }
  .hw-search-toggle { display: grid; place-items: center; width: 42px; }
  .hw-search-field { display: none; }
  .hw-topbar-search.is-search-open { position: absolute; inset: 8px 12px auto; min-width: 0; z-index: 60; }
  .hw-topbar-search.is-search-open .hw-search-toggle { display: none; }
  .hw-topbar-search.is-search-open .hw-search-field { display: flex; background: var(--surface); }
  .hw-search-field [data-search-close] { display: block; white-space: nowrap; }
  .hw-search-field input { font-size: 16px; }
  .hw-search-panel { width: 100%; max-width: none; max-height: 65dvh; }
}
