:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-subtle: #fafbfc;
  --text: #1e252d;
  --muted: #667481;
  --muted-strong: #485562;
  --line: #dce2e8;
  --line-strong: #c7d0d9;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #e6f4f2;
  --blue: #1d4ed8;
  --blue-soft: #eaf1ff;
  --green: #047857;
  --green-soft: #e8f6ef;
  --amber: #b45309;
  --amber-soft: #fff4df;
  --red: #b91c1c;
  --red-soft: #fff0f0;
  --violet: #6d28d9;
  --violet-soft: #f4efff;
  --stone: #57534e;
  --stone-soft: #f5f5f4;
  --shadow: 0 1px 3px rgb(15 23 42 / 8%);
  --focus: 0 0 0 3px rgb(15 118 110 / 18%);
  --icon-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 5v14M5 12h14' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m5 12 5 5L20 7' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 8h11v11H8zM5 16H4a1 1 0 0 1-1-1V5a2 2 0 0 1 2-2h10a1 1 0 0 1 1 1v1' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --icon-download: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3v12m0 0 5-5m-5 5-5-5M5 19h14' fill='none' stroke='black' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --icon-external: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6' fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --icon-table: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 5h16v14H4zM4 10h16M9 5v14M15 5v14' fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

body.has-modal-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select,
summary {
  outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  box-shadow: var(--focus);
}

button,
.source-link,
.photo-action {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

button {
  padding: 0 12px;
  cursor: pointer;
}

button:disabled,
.photo-action[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

button:not(:disabled):hover,
.source-link:hover,
.photo-action:not([aria-disabled="true"]):hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

#resetButton.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 750;
}

#resetButton.is-active:not(:disabled):hover {
  border-color: var(--accent-strong);
  background: var(--accent);
  color: #fff;
}

.shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 24px;
  font-weight: 760;
  letter-spacing: 0;
}

h2,
h3 {
  margin-bottom: 0;
  letter-spacing: 0;
}

.topbar p,
.section-heading p,
.result-bar p,
.candidate-panel p,
.ai-assistant-panel p,
.overview p {
  margin-bottom: 0;
  color: var(--muted);
}

.topbar p,
.section-heading p,
.result-bar p {
  font-size: 14px;
}

.external-links {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.source-link {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  font-weight: 650;
  white-space: nowrap;
}

.task-panel,
.search-panel,
.result-bar,
.candidate-panel,
.ai-assistant-panel,
.overview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.task-panel,
.search-panel {
  margin-bottom: 14px;
  padding: 16px;
}

.task-mode-details > summary {
  display: none;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.mobile-sheet-header,
.mobile-sheet-close-button {
  display: none;
}

.section-heading h2 {
  font-size: 17px;
  font-weight: 760;
}

.task-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 8px;
}

.task-mode {
  display: grid;
  align-content: center;
  min-height: 54px;
  padding: 8px 10px;
  text-align: left;
}

.task-mode strong,
.task-mode span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.task-mode strong {
  font-size: 14px;
  line-height: 1.2;
}

.task-mode span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.task-mode.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.task-mode.is-active span {
  color: var(--accent-strong);
}

.primary-search {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 280px) minmax(150px, 220px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.index-boundary-note {
  margin: -2px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

input {
  padding: 0 11px;
}

select {
  padding: 0 32px 0 10px;
}

.enhanced-select-native {
  display: none;
}

.enhanced-select {
  position: relative;
  min-width: 0;
}

.enhanced-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  background: #fff;
  text-align: left;
}

.enhanced-select-trigger span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.enhanced-select-trigger::after {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-top: 5px solid var(--muted);
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  content: "";
}

.enhanced-select-trigger.is-empty {
  color: var(--muted);
}

.enhanced-select-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.enhanced-select-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  display: grid;
  gap: 6px;
  width: min(520px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgb(15 23 42 / 16%);
}

.enhanced-select-panel[hidden] {
  display: none;
}

.enhanced-select-search {
  height: 34px;
}

.enhanced-select-options {
  display: grid;
  gap: 2px;
  max-height: min(260px, 48vh);
  overflow: auto;
  overscroll-behavior: contain;
}

.enhanced-select-option {
  min-height: 32px;
  padding: 6px 8px;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
  text-overflow: ellipsis;
  text-align: left;
  white-space: nowrap;
}

.candidate-title-button {
  display: inline;
  width: fit-content;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.enhanced-select-option::before {
  display: inline-block;
  width: 18px;
  color: var(--muted);
  content: "";
}

.enhanced-select-option.is-selected::before {
  content: "✓";
}

.enhanced-select-option:hover,
.enhanced-select-option.is-selected {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.enhanced-select-option.is-empty {
  color: var(--muted);
}

.enhanced-select-empty {
  margin: 0;
  padding: 8px;
  color: var(--muted);
  font-size: 13px;
}

.autocomplete-input {
  position: relative;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.autocomplete-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.autocomplete-token {
  min-height: 24px;
  padding: 0 8px;
  border-color: var(--line);
  background: var(--panel-subtle);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 700;
}

.autocomplete-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgb(15 23 42 / 16%);
}

.autocomplete-panel[hidden] {
  display: none;
}

.autocomplete-options {
  display: grid;
  gap: 2px;
  max-height: min(260px, 48vh);
  overflow: auto;
  overscroll-behavior: contain;
}

.autocomplete-option {
  min-height: 32px;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.autocomplete-option:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.autocomplete-empty {
  margin: 0;
  padding: 8px;
  color: var(--muted);
  font-size: 13px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(128px, 1fr));
  gap: 10px;
}

.advanced-filter-panel {
  margin-top: 12px;
}

.advanced-filter-panel summary {
  width: fit-content;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 800;
}

.advanced-filter-grid {
  margin-top: 10px;
}

.result-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
}

.result-bar strong {
  display: block;
  margin-bottom: 2px;
  font-size: 16px;
}

.selected-notice {
  margin-top: 6px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 750;
}

.pwa-status {
  margin-top: 6px;
  color: #7a4a05;
  font-size: 13px;
  font-weight: 750;
}

.mobile-action-bar {
  display: none;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  min-width: 220px;
}

.filter-chip,
.tag,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-subtle);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.filter-chip {
  gap: 6px;
  min-height: 30px;
  padding: 0 6px 0 10px;
}

.filter-chip button {
  width: 22px;
  min-width: 22px;
  min-height: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.muted-chip {
  padding-right: 10px;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.side-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.candidate-panel,
.ai-assistant-panel,
.overview {
  padding: 14px;
}

.ai-assistant-panel {
  display: grid;
  gap: 10px;
}

.ai-assistant-intro,
.ai-assistant-example,
.ai-assistant-steps {
  font-size: 13px;
}

.ai-assistant-steps {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted-strong);
}

.ai-assistant-steps li {
  padding-left: 2px;
}

.ai-assistant-example {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-subtle);
  color: var(--muted-strong);
}

.ai-assistant-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.ai-assistant-actions a,
.ai-assistant-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.candidate-list {
  display: grid;
  gap: 8px;
  max-height: 330px;
  overflow: auto;
}

.candidate-empty {
  min-height: 72px;
  margin: 0;
  padding: 18px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel-subtle);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.candidate-item {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-subtle);
}

.candidate-thumb {
  display: grid;
  place-items: center;
  width: 68px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #e9eef3;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.candidate-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.candidate-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.candidate-item strong,
.candidate-item a,
.candidate-item .candidate-title-button,
.candidate-item p,
.candidate-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.candidate-item strong,
.candidate-item a,
.candidate-item .candidate-title-button {
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
  text-decoration: none;
}

.candidate-item p,
.candidate-item span {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.candidate-item button {
  justify-self: end;
  min-height: 32px;
  padding: 0 10px;
}

.candidate-item .candidate-thumb {
  justify-self: start;
  padding: 0;
}

.candidate-item .candidate-title-button {
  justify-self: start;
  min-height: 0;
  padding: 0;
}

.candidate-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.candidate-copy-menu {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.candidate-copy-button,
.candidate-copy-menu-button,
.candidate-toggle-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.candidate-copy-button:not(:disabled):hover,
.candidate-copy-menu-button:not(:disabled):hover,
.candidate-toggle-button:not(:disabled):hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #fff;
}

.candidate-copy-button {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.candidate-copy-menu-button {
  min-width: 38px;
  padding: 0 10px;
  border-left-color: rgb(255 255 255 / 35%);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.candidate-copy-menu-label {
  display: none;
}

.candidate-copy-menu-list {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.candidate-copy-menu-list[hidden] {
  display: none;
}

.candidate-copy-menu-list button {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  text-align: left;
}

.candidate-toggle-button.is-selected {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
}

.overview-grid {
  display: grid;
  gap: 10px;
}

.overview-item {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-subtle);
}

.overview-item h3 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.overview-item strong {
  color: var(--text);
  font-size: 20px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.overview-item p,
.overview-breakdown dt,
.overview-breakdown dd {
  color: var(--muted);
  font-size: 12px;
}

.overview-breakdown {
  display: grid;
  gap: 4px;
  margin: 0;
}

.overview-breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.overview-breakdown dt,
.overview-breakdown dd {
  margin: 0;
}

.overview-breakdown dt {
  min-width: 0;
  overflow-wrap: anywhere;
}

.overview-breakdown dd {
  flex: 0 0 auto;
  color: var(--text);
  font-weight: 750;
}

.results-area {
  min-width: 0;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.photo-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.photo-card:hover,
.photo-card:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 8px 22px rgb(15 23 42 / 12%);
}

.photo-card:focus-within {
  box-shadow:
    0 8px 22px rgb(15 23 42 / 12%),
    var(--focus);
}

.photo-link {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #e9eef3;
  color: #fff;
}

.photo-link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 180ms ease;
}

.photo-link::after {
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(to top, rgb(15 23 42 / 58%), rgb(15 23 42 / 0%));
  content: "";
  pointer-events: none;
}

.photo-card-actions {
  position: absolute;
  z-index: 1;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: calc(100% - 20px);
}

.photo-link-hint,
.photo-candidate-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgb(255 255 255 / 68%);
  border-radius: 6px;
  background: rgb(15 23 42 / 74%);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.photo-link-hint {
  pointer-events: none;
}

.photo-candidate-button {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.photo-candidate-button.is-selected {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.photo-link-hint::before,
.photo-candidate-button::before {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  background: currentColor;
  content: "";
}

.photo-link-hint::before {
  -webkit-mask: var(--icon-external) center / contain no-repeat;
  mask: var(--icon-external) center / contain no-repeat;
}

.photo-candidate-button::before {
  -webkit-mask: var(--action-icon) center / contain no-repeat;
  mask: var(--action-icon) center / contain no-repeat;
}

.photo-card .photo-candidate-button.is-selected {
  border-color: rgb(255 255 255 / 78%);
  background: var(--accent);
  color: #fff;
}

.photo-link:hover img,
.photo-link:focus-visible img,
.photo-card:hover .photo-link img,
.photo-card:focus-within .photo-link img {
  transform: scale(1.025);
}

.photo-card:hover .photo-link-hint,
.photo-card:focus-within .photo-link-hint,
.photo-candidate-button:not(:disabled):hover {
  background: var(--accent-strong);
  border-color: #fff;
}

@media (hover: hover) and (pointer: fine) {
  .photo-card:hover .photo-candidate-button,
  .photo-card:focus-within .photo-candidate-button {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
  }
}

.photo-statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-badge {
  padding: 4px 8px;
  overflow-wrap: anywhere;
}

.status-success,
.status-ready,
.status-approved,
.status-reviewed,
.status-high,
.status-complete {
  border-color: #b7e4cc;
  background: var(--green-soft);
  color: var(--green);
}

.status-warning,
.status-review,
.status-needs_review,
.status-ai,
.status-medium,
.status-partial {
  border-color: #f5d08a;
  background: var(--amber-soft);
  color: var(--amber);
}

.status-danger,
.status-avoid,
.status-unreviewed,
.status-missing,
.status-low {
  border-color: #fecaca;
  background: var(--red-soft);
  color: var(--red);
}

.status-info,
.status-candidate,
.status-default {
  border-color: #bfdbfe;
  background: var(--blue-soft);
  color: var(--blue);
}

.status-normal {
  border-color: #bfdbfe;
  background: var(--blue-soft);
  color: var(--blue);
}

.status-neutral {
  border-color: #d6d3d1;
  background: var(--stone-soft);
  color: var(--stone);
}

.status-ai_labeled {
  border-color: #ddd6fe;
  background: var(--violet-soft);
  color: var(--violet);
}

.status-album,
.status-collection {
  border-color: #ddd6fe;
  background: var(--violet-soft);
  color: var(--violet);
}

.photo-reference {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 2.6em;
  margin: 0;
  color: var(--muted-strong);
  font-size: 13px;
}

.photo-id-button {
  min-height: 26px;
  padding: 0 8px;
  border-color: var(--line-strong);
  background: var(--panel-subtle);
  color: var(--muted-strong);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 12px;
  font-weight: 700;
}

.sort-signal-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.detail-row dt,
.detail-row dd {
  min-width: 0;
  margin: 0;
  font-size: 12px;
}

.detail-row dt {
  color: var(--muted);
  font-weight: 750;
}

.detail-row dd {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.tag {
  padding: 3px 7px;
}

.candidate-toggle-button {
  --action-icon: var(--icon-plus);
}

.candidate-toggle-button.is-selected {
  --action-icon: var(--icon-check);
}

.download-large-image-button {
  --action-icon: var(--icon-download);
}

.original-image-link {
  --action-icon: var(--icon-external);
}

.copy-flickr-link-button,
.copy-finder-link-button {
  --action-icon: var(--icon-copy);
}

.sheet-row-link {
  --action-icon: var(--icon-table);
}

.load-more-panel {
  display: grid;
  gap: 10px;
  justify-items: center;
  margin: 18px 0 4px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.load-more-panel[hidden] {
  display: none;
}

.load-more-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.load-more-panel button {
  min-width: 160px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 750;
}

.load-more-panel button:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #fff;
}

.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  background: rgb(15 23 42 / 42%);
}

.modal-backdrop[hidden] {
  display: none;
}

.photo-preview-dialog {
  position: fixed;
  z-index: 90;
  top: 50%;
  left: 50%;
  display: grid;
  gap: 14px;
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgb(15 23 42 / 24%);
  transform: translate(-50%, -50%);
}

.photo-preview-dialog[hidden] {
  display: none;
}

.dialog-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.dialog-header h2 {
  font-size: 18px;
}

.dialog-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.preview-image-frame {
  display: grid;
  place-items: center;
  min-height: 220px;
  overflow: hidden;
  border-radius: 8px;
  background: #111827;
}

.preview-image-link {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  color: inherit;
}

.preview-image-link::after {
  position: absolute;
  inset: auto 0 0;
  height: 34%;
  background: linear-gradient(to top, rgb(15 23 42 / 58%), rgb(15 23 42 / 0%));
  content: "";
  pointer-events: none;
}

.preview-image-hint {
  position: absolute;
  z-index: 1;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  max-width: calc(100% - 20px);
  padding: 0 9px;
  border: 1px solid rgb(255 255 255 / 68%);
  border-radius: 6px;
  background: rgb(15 23 42 / 74%);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.preview-image-hint::before {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  background: currentColor;
  content: "";
  -webkit-mask: var(--icon-external) center / contain no-repeat;
  mask: var(--icon-external) center / contain no-repeat;
}

.preview-image-frame img {
  display: block;
  width: 100%;
  max-height: min(62vh, 620px);
  object-fit: contain;
}

.preview-details {
  display: grid;
  gap: 8px;
  margin: 0;
}

.preview-statuses {
  min-height: 0;
}

.preview-reference {
  min-height: 0;
  margin: 0;
}

.preview-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.preview-actions a,
.preview-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  font-weight: 750;
}

.preview-actions a::before,
.preview-actions button::before {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  background: currentColor;
  content: "";
  -webkit-mask: var(--action-icon) center / contain no-repeat;
  mask: var(--action-icon) center / contain no-repeat;
}

.empty {
  grid-column: 1 / -1;
  padding: 36px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}

.loading-state {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 32px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}

.loading-state strong {
  color: var(--text);
  font-size: 15px;
}

.loading-state p {
  margin: 0;
  font-size: 13px;
}

.loading-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: loading-spin 840ms linear infinite;
}

.loading-card {
  min-height: 188px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent, rgb(255 255 255 / 70%), transparent),
    linear-gradient(135deg, #e9eef3, #f7f9fb);
  background-size: 180px 100%, 100% 100%;
  box-shadow: var(--shadow);
  animation: loading-shimmer 1200ms ease-in-out infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loading-shimmer {
  0% {
    background-position: -180px 0, 0 0;
  }

  100% {
    background-position: calc(100% + 180px) 0, 0 0;
  }
}

.photo-card:target {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(15 118 110 / 18%);
}

@media (max-width: 1180px) {
  .filter-grid {
    grid-template-columns: repeat(4, minmax(128px, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    max-height: none;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    overflow: visible;
  }

  .candidate-list {
    max-height: 260px;
  }

  .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 14px 14px 110px;
  }

  .task-panel {
    padding: 0;
  }

  .task-mode-details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 0 14px;
    color: var(--muted-strong);
    cursor: pointer;
    font-size: 14px;
    font-weight: 760;
  }

  .task-mode-details > summary::after {
    flex: 0 0 auto;
    color: var(--muted);
    content: "展開";
    font-size: 12px;
  }

  .task-mode-details[open] > summary::after {
    content: "收合";
  }

  .task-mode-details > summary strong {
    min-width: 0;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .task-mode-details .section-heading {
    display: none;
  }

  .topbar,
  .result-bar {
    display: grid;
    justify-content: stretch;
  }

  .external-links {
    justify-self: start;
    justify-content: flex-start;
  }

  .primary-search,
  .overview-grid {
    grid-template-columns: 1fr;
  }

  .search-panel:not(.is-filter-open) .primary-search {
    display: grid;
    grid-template-columns: 1fr;
    margin-bottom: 0;
  }

  .search-panel:not(.is-filter-open) .primary-search label:not(.search-field),
  .search-panel:not(.is-filter-open) #resetButton {
    display: none;
  }

  button,
  .source-link,
  .photo-action,
  input,
  select,
  .enhanced-select-trigger {
    min-height: 44px;
  }

  .mobile-sheet-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
  }

  .mobile-sheet-header strong {
    font-size: 16px;
  }

  .mobile-action-bar {
    position: fixed;
    z-index: 80;
    right: 14px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    max-width: 520px;
    margin: 0 auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgb(255 255 255 / 94%);
    box-shadow: 0 12px 28px rgb(15 23 42 / 18%);
    backdrop-filter: blur(8px);
  }

  .mobile-action-bar button {
    border-color: var(--accent);
    font-weight: 800;
  }

  .mobile-action-bar button:last-child {
    background: var(--accent);
    color: #fff;
  }

  .task-panel,
  .search-panel,
  .result-bar {
    margin-bottom: 10px;
  }

  .task-mode-details[open] {
    padding: 0 14px 14px;
  }

  .search-panel .filter-grid,
  .search-panel .advanced-filter-panel {
    display: none;
  }

  .search-panel.is-filter-open {
    position: fixed;
    z-index: 90;
    inset: auto 0 0;
    display: grid;
    max-height: 86vh;
    margin: 0;
    padding: 14px;
    overflow: auto;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -16px 38px rgb(15 23 42 / 24%);
  }

  .search-panel.is-filter-open .mobile-sheet-header {
    display: flex;
  }

  .search-panel.is-filter-open .filter-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .search-panel.is-filter-open .advanced-filter-panel {
    display: block;
  }

  .active-filters {
    flex-wrap: nowrap;
    justify-content: flex-start;
    min-width: 0;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .filter-chip {
    flex: 0 0 auto;
    min-height: 44px;
    padding-left: 12px;
  }

  .filter-chip button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    height: 44px;
  }

  .enhanced-select-option,
  .autocomplete-option {
    min-height: 44px;
    padding: 10px;
  }

  .search-panel.is-filter-open .enhanced-select-options {
    max-height: min(38vh, 300px);
  }

  .autocomplete-token {
    min-height: 44px;
    padding: 0 12px;
  }

  .workspace {
    display: block;
  }

  .side-panel {
    display: none;
  }

  .side-panel.is-candidate-open {
    position: fixed;
    z-index: 90;
    inset: auto 0 0;
    display: block;
    max-height: 82vh;
    padding: 0;
    overflow: auto;
    border-radius: 12px 12px 0 0;
    background: var(--panel);
    box-shadow: 0 -16px 38px rgb(15 23 42 / 24%);
  }

  .side-panel.is-candidate-open .candidate-panel {
    border: 0;
    border-radius: 12px 12px 0 0;
    box-shadow: none;
  }

  .side-panel.is-candidate-open .section-heading {
    align-items: center;
  }

  .side-panel.is-candidate-open .mobile-sheet-close-button {
    display: inline-flex;
    align-items: center;
  }

  .side-panel.is-candidate-open .ai-assistant-panel,
  .side-panel.is-candidate-open .overview {
    display: none;
  }

  .candidate-list {
    max-height: min(48vh, 430px);
  }

  .task-modes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .photo-reference {
    min-height: 0;
    font-size: 12px;
  }

  .candidate-actions {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .candidate-copy-menu {
    display: contents;
  }

  .candidate-copy-menu-button {
    order: 1;
    grid-column: 1;
    min-width: 0;
    border-color: var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text);
  }

  .candidate-copy-menu-button:not(:disabled):hover {
    border-color: var(--accent);
    background: var(--panel);
    color: var(--accent-strong);
  }

  .candidate-copy-menu-icon {
    display: none;
  }

  .candidate-copy-menu-label {
    display: inline;
  }

  .candidate-copy-button {
    order: 2;
    grid-column: 2;
    border-radius: 6px;
  }

  #clearCandidatesButton {
    order: 3;
    grid-column: 1 / -1;
  }

  .candidate-copy-menu-list {
    position: static;
    order: 0;
    grid-column: 1 / -1;
    min-width: 0;
  }

  .ai-assistant-actions {
    grid-template-columns: 1fr;
  }

  .photo-id-button {
    min-height: 44px;
  }

  .candidate-item {
    grid-template-columns: 76px minmax(0, 1fr) auto;
  }

  .candidate-item button {
    min-height: 44px;
  }

  .photo-preview-dialog {
    inset: auto 0 0;
    top: auto;
    left: auto;
    width: 100%;
    max-height: 92vh;
    padding-bottom: 188px;
    border-radius: 12px 12px 0 0;
    transform: none;
  }

  .dialog-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .preview-image-frame {
    min-height: 180px;
  }

  .preview-actions {
    position: fixed;
    z-index: 95;
    right: 0;
    bottom: 0;
    left: 0;
    grid-template-columns: 1fr 1fr;
    margin: 0;
    padding: 10px 16px max(10px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgb(255 255 255 / 96%);
    box-shadow: 0 -10px 24px rgb(15 23 42 / 12%);
    backdrop-filter: blur(8px);
  }
}

@media (max-width: 430px) {
  .task-modes {
    grid-template-columns: 1fr;
  }

  .detail-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
