:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-muted: #eef3f1;
  --text: #171a1d;
  --muted: #667078;
  --border: #dce2e5;
  --accent: #d83b2d;
  --accent-dark: #9f251e;
  --accent-soft: rgba(216, 59, 45, 0.14);
  --accent-warm: #00766f;
  --danger: #a83232;
  --radius-sm: 10px;
  --radius-card: 14px;
  --shadow-sm: 0 6px 18px rgba(22, 32, 38, 0.065);
  --shadow: 0 12px 30px rgba(22, 32, 38, 0.085);
  --shadow-hover: 0 16px 34px rgba(22, 32, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  background:
    radial-gradient(circle at 12% -8%, rgba(216, 59, 45, 0.055), transparent 30rem),
    radial-gradient(circle at 88% 0%, rgba(0, 118, 111, 0.05), transparent 32rem),
    var(--bg);
}

body.lightbox-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(1320px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 0 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 12px 0;
  background: rgba(245, 246, 248, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-link {
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 22px;
  line-height: 1.1;
}

.brand span:not(.brand-mark) {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.status-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.logout-form {
  display: inline-flex;
  gap: 0;
}

.nav-button,
.account-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.nav-button {
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.nav-button:hover,
.nav-button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

.nav-button:active {
  transform: translateY(1px);
}

.top-action-button {
  background: #f8fafc;
}

.nav-ico {
  display: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-action-button {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: #ffffff;
}

.primary-action-button:hover,
.primary-action-button:focus-visible {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.account-pill {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.muted-button {
  color: var(--muted);
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.lang-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  transition: color 160ms ease, background 160ms ease;
}

.lang-option + .lang-option {
  border-left: 1px solid var(--border);
}

.lang-option:hover,
.lang-option:focus-visible {
  color: var(--accent-dark);
  outline: none;
}

.lang-option.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.status-pill,
.section-meta {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.search-panel,
.results-panel,
.gallery-panel,
.search-drawer {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-drawer {
  overflow: hidden;
  margin: 10px 0 18px;
  padding: 0;
  background:
    linear-gradient(135deg, rgba(0, 118, 111, 0.08), rgba(216, 59, 45, 0.05) 46%, rgba(255, 255, 255, 0) 74%),
    var(--surface);
}

.search-drawer-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(223, 226, 231, 0.72);
}

.search-drawer-heading h2 {
  margin-bottom: 0;
}

.search-subtitle {
  max-width: 560px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.drawer-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 38px;
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.84);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.drawer-close-button:hover,
.drawer-close-button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

.drawer-close-button:active {
  transform: translateY(1px);
}

.search-panel {
  padding: 22px;
}

.results-panel {
  min-height: 0;
  margin-bottom: 18px;
  padding: 18px;
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.panel-heading {
  display: block;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-warm);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 12px;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: 0;
}

p {
  color: var(--muted);
}

form {
  display: grid;
  gap: 14px;
}

.search-form {
  grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
  gap: 16px;
  align-items: stretch;
  padding: 18px;
}

.upload-box {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px dashed #a78bfa;
  border-radius: 8px;
  background: var(--surface-muted);
}

.upload-box input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.upload-label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.upload-label:hover,
.upload-box input[type="file"]:focus-visible + .upload-label {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.upload-label:active {
  transform: translateY(1px);
}

.upload-mark {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
}

.upload-label strong,
.upload-label small {
  display: block;
}

.upload-label strong {
  max-width: 250px;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-label small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.file-preview {
  justify-self: start;
  width: auto;
  max-width: min(360px, 100%);
  max-height: 320px;
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--border);
}

#submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.search-form #submit-button {
  position: relative;
  gap: 10px;
  min-height: 52px;
}

.search-upload-box {
  grid-template-columns: minmax(220px, 0.92fr) minmax(180px, 280px);
  align-items: stretch;
  min-height: 286px;
  padding: 12px;
  border: 1px solid rgba(223, 226, 231, 0.92);
  background: rgba(255, 255, 255, 0.76);
}

.search-upload-box .upload-label {
  min-height: 260px;
  padding: 18px;
  border: 1px solid rgba(223, 226, 231, 0.92);
  background:
    linear-gradient(135deg, rgba(0, 118, 111, 0.08), rgba(255, 255, 255, 0) 58%),
    #ffffff;
}

.search-upload-box.has-file .upload-label {
  align-self: stretch;
}

.search-upload-box .upload-mark {
  flex-basis: 42px;
  width: 42px;
  height: 42px;
  background: var(--accent-warm);
  box-shadow: 0 10px 20px rgba(0, 118, 111, 0.2);
}

.search-upload-box.has-file .upload-mark {
  background: var(--accent);
  box-shadow: 0 10px 20px rgba(216, 59, 45, 0.18);
}

.search-upload-box .upload-copy {
  min-width: 0;
}

.search-upload-box .upload-label strong {
  max-width: 100%;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.search-preview-frame {
  display: grid;
  place-items: center;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid rgba(223, 226, 231, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(245, 246, 248, 0.92), rgba(238, 243, 242, 0.82)),
    #f8faf9;
}

.search-preview-empty {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.search-upload-box.has-file .search-preview-empty {
  display: none;
}

.search-upload-box .file-preview {
  justify-self: stretch;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  object-fit: contain;
}

.search-actions-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.search-actions-panel .reference-consent-box {
  grid-column: auto;
}

.search-actions-panel .check-option {
  min-height: 0;
  padding: 13px;
  border-color: rgba(223, 226, 231, 0.92);
  background: rgba(255, 255, 255, 0.84);
  font-size: 13px;
}

.search-actions-panel .status-message {
  min-height: 20px;
  color: var(--accent-warm);
  text-align: left;
}

.button-spinner {
  display: none;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #ffffff;
  border-radius: 999px;
  animation: spin 820ms linear infinite;
}

#submit-button.is-busy .button-spinner {
  display: inline-block;
}

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

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 16px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-dark);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

.primary-button:active {
  transform: translateY(1px);
}

#submit-button:hover,
#submit-button:focus-visible {
  background: var(--accent-dark);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

#submit-button:active {
  transform: translateY(1px);
}

#submit-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.status-message {
  min-height: 24px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.empty-state {
  display: grid;
  place-content: center;
  min-height: 380px;
  text-align: center;
}

.empty-state p:last-child {
  max-width: 300px;
  margin: 0 auto;
}

.results-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.results-header p {
  margin: 0;
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(170px, 240px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.uploaded-card,
.match-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.uploaded-card span,
.match-card span {
  display: block;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.uploaded-image,
.similar-image {
  display: block;
  width: 100%;
  object-fit: cover;
}

.uploaded-image {
  aspect-ratio: 1 / 1;
}

.similar-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.similar-image {
  aspect-ratio: 1 / 1;
  background: #dde5e2;
}

.zoomable-image {
  cursor: zoom-in;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.zoomable-image:hover,
.zoomable-image:focus-visible {
  outline: none;
  box-shadow: 0 10px 22px rgba(22, 32, 38, 0.18);
}

.similarity-score {
  padding: 10px 12px 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.error-state {
  border: 1px solid rgba(168, 50, 50, 0.22);
  border-radius: 8px;
  padding: 16px;
  color: var(--danger);
  background: rgba(168, 50, 50, 0.08);
  font-weight: 800;
}

.auth-shell {
  width: min(760px, calc(100% - 32px));
}

.auth-card,
.editor-panel,
.editor-result-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(520px, 100%);
  margin: 36px auto 0;
  padding: 26px;
}

.auth-form {
  margin-top: 18px;
}

.field-label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.field-label input,
.field-label select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #ffffff;
  font-size: 15px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field-label input:focus,
.field-label select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.auth-switch {
  margin-top: 18px;
  text-align: center;
}

.auth-switch a {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.editor-panel,
.editor-result-panel {
  padding: 22px;
}

.editor-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.compact-field {
  grid-column: 1 / -1;
}

.check-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.check-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.auth-required-note {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: #ffffff;
  font-size: 14px;
  font-weight: 750;
}

.auth-required-note a {
  color: var(--accent-dark);
  font-weight: 850;
  text-decoration: none;
}

.upload-rules-box {
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
}

.reference-consent-box {
  display: grid;
  grid-column: 1 / -1;
}

.upload-rules-check {
  align-items: flex-start;
  min-height: 0;
}

.upload-rules-check input {
  flex: 0 0 auto;
  margin-top: 1px;
}

.upload-rules-check span {
  line-height: 1.35;
}

.rules-details {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  background: #ffffff;
  font-size: 13px;
  font-weight: 650;
}

.rules-details summary {
  color: var(--text);
  font-weight: 850;
  cursor: pointer;
}

.rules-details ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding-left: 20px;
}

.edited-preview-frame {
  display: grid;
  place-items: center;
  min-height: 430px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #eef0f4 25%, transparent 25%),
    linear-gradient(-45deg, #eef0f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef0f4 75%),
    linear-gradient(-45deg, transparent 75%, #eef0f4 75%);
  background-color: #ffffff;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}

.edited-preview {
  display: block;
  max-width: 100%;
  max-height: 620px;
  border-radius: 8px;
  object-fit: contain;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.download-button {
  min-width: 150px;
}

.gallery-panel {
  margin-top: 18px;
  padding: 22px;
}

.text-search {
  margin-top: 18px;
}

.text-search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.text-search-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.text-search-icon {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--muted);
}

.text-search-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.text-search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 8px 4px;
  outline: none;
}

.text-search-input::placeholder {
  color: var(--muted);
}

.text-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.text-search-clear {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.text-search-clear:hover {
  color: var(--text);
}

.text-search-button {
  flex: 0 0 auto;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 20px;
  cursor: pointer;
}

.text-search-button:hover {
  background: var(--accent-dark);
}

.text-search-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.feed-panel {
  margin-top: 18px;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading h2 {
  margin-bottom: 0;
}

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

.photo-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  object-fit: cover;
  background: #dde5e2;
  cursor: zoom-in;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.photo-grid img:hover,
.photo-grid img:focus-visible {
  transform: translateY(-2px);
  outline: none;
  box-shadow: 0 10px 22px rgba(22, 32, 38, 0.18);
}

.masonry-feed {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.feed-column {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.feed-card {
  display: block;
  width: 100%;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(22, 32, 38, 0.08);
}

.feed-card img {
  display: block;
  width: 100%;
  height: auto;
  background: #dde5e2;
  cursor: zoom-in;
  transition: filter 160ms ease, transform 160ms ease;
}

.feed-card:hover img,
.feed-card:focus-within img {
  filter: brightness(0.96);
}

.feed-card img:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.feed-card-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px 12px;
}

.feed-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent-warm);
  font-size: 11px;
  font-weight: 900;
}

.feed-card-text {
  min-width: 0;
}

.feed-card-text strong,
.feed-card-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-card-text strong {
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.2;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.feed-card-text span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.photo-stats {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  margin-left: auto;
}

.photo-stats svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-count {
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.like-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: none;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.like-button:hover,
.like-button:focus-visible {
  color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.like-button:active {
  transform: scale(0.92);
}

.like-button.liked {
  color: var(--accent);
}

.like-button.liked svg {
  fill: currentColor;
}

.views-badge,
.comments-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 4px;
  color: var(--muted);
}

.comments-badge {
  text-decoration: none;
  cursor: pointer;
  transition: color 140ms ease;
}

.comments-badge:hover,
.comments-badge:focus-visible {
  color: var(--accent-dark);
  outline: none;
}

.feed-actions {
  display: grid;
  place-items: center;
  min-height: 92px;
  padding-top: 8px;
}

.load-more-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  min-width: 180px;
  padding: 12px 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.load-more-button:hover,
.load-more-button:focus-visible {
  background: var(--accent-dark);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

.load-more-button:active {
  transform: translateY(1px);
}

.load-more-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 20, 24, 0.82);
}

.gallery-lightbox-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: min(1040px, 100%);
  min-height: min(720px, calc(100vh - 48px));
}

.gallery-lightbox-image {
  display: block;
  max-width: min(100%, 1040px);
  max-height: calc(100vh - 122px);
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.38);
}

.gallery-lightbox-close,
.gallery-lightbox-nav {
  position: absolute;
  z-index: 2;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #ffffff;
  background: rgba(16, 20, 24, 0.72);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 160ms ease, transform 160ms ease;
}

.gallery-lightbox-close:hover,
.gallery-lightbox-close:focus-visible,
.gallery-lightbox-nav:hover,
.gallery-lightbox-nav:focus-visible {
  background: var(--accent);
  outline: none;
}

.gallery-lightbox-close:active,
.gallery-lightbox-nav:active {
  transform: translateY(1px);
}

.gallery-lightbox-close {
  top: 0;
  right: 0;
  padding: 0 16px;
}

.gallery-lightbox-nav {
  top: 50%;
  width: 64px;
  transform: translateY(-50%);
}

.gallery-lightbox-nav:active {
  transform: translateY(calc(-50% + 1px));
}

.gallery-lightbox-prev {
  left: 0;
}

.gallery-lightbox-next {
  right: 0;
}

.gallery-lightbox-caption {
  position: absolute;
  left: 50%;
  bottom: 0;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(16, 20, 24, 0.72);
  font-size: 12px;
  font-weight: 800;
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.gallery-lightbox-stats {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
}

.gallery-lightbox-stats .photo-stats {
  margin-left: 0;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(16, 20, 24, 0.72);
  backdrop-filter: blur(10px);
}

.gallery-lightbox-stats .like-button,
.gallery-lightbox-stats .views-badge {
  color: rgba(255, 255, 255, 0.9);
}

.gallery-lightbox-stats .like-button:hover,
.gallery-lightbox-stats .like-button:focus-visible {
  color: #ffffff;
  background: var(--accent);
}

.gallery-lightbox-stats .like-button.liked {
  color: #ff7a6e;
}

@media (max-width: 1120px) {
  .masonry-feed {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 940px) {
  .masonry-feed {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 0;
  }

  .topbar,
  .workspace,
  .editor-layout,
  .result-layout,
  .results-header {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .status-row,
  .auth-nav {
    justify-content: flex-start;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .search-upload-box {
    grid-template-columns: minmax(0, 1fr) minmax(170px, 240px);
    min-height: 0;
  }

  .search-upload-box .upload-label,
  .search-preview-frame {
    min-height: 230px;
  }

  .search-form #submit-button {
    min-height: 48px;
  }

  h1 {
    font-size: 36px;
  }

  .results-panel {
    min-height: 0;
  }

  .empty-state {
    min-height: 270px;
  }
}

@media (max-width: 640px) {
  .masonry-feed {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .feed-column {
    gap: 10px;
  }

  .feed-card-footer {
    min-height: 48px;
    padding: 8px;
  }

  .feed-avatar {
    flex-basis: 28px;
    width: 28px;
    height: 28px;
    font-size: 10px;
  }

  .photo-stats {
    gap: 2px;
  }

  .photo-stats svg {
    width: 14px;
    height: 14px;
  }

  .like-button,
  .views-badge {
    padding: 4px 5px;
  }

  .stat-count {
    font-size: 11px;
  }
}

@media (max-width: 520px) {
  .search-panel,
  .results-panel,
  .gallery-panel,
  .search-drawer,
  .auth-card,
  .editor-panel,
  .editor-result-panel {
    padding: 16px;
  }

  .editor-options {
    grid-template-columns: 1fr;
  }

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

  .brand strong {
    font-size: 20px;
  }

  .upload-label strong {
    max-width: 180px;
  }

  .gallery-lightbox {
    padding: 12px;
  }

  .gallery-lightbox-frame {
    min-height: calc(100vh - 24px);
  }

  .gallery-lightbox-image {
    max-height: calc(100vh - 112px);
  }

  .gallery-lightbox-close {
    top: 0;
    right: 0;
  }

  .gallery-lightbox-nav {
    top: auto;
    bottom: 0;
    width: 82px;
    transform: none;
  }

  .gallery-lightbox-nav:active {
    transform: translateY(1px);
  }

  .gallery-lightbox-prev {
    left: 0;
  }

  .gallery-lightbox-next {
    right: 0;
  }
}

a.account-pill {
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease;
}

a.account-pill:hover,
a.account-pill:focus-visible {
  color: #ffffff;
  background: var(--accent);
  outline: none;
}

.feed-author-link {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-author-link:hover,
.feed-author-link:focus-visible {
  color: var(--accent);
  outline: none;
}

.feed-avatar {
  overflow: hidden;
  text-decoration: none;
}

.feed-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 22px;
  margin-top: 24px;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profile-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 96px;
  width: 96px;
  height: 96px;
  overflow: hidden;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent-warm);
  font-size: 30px;
  font-weight: 900;
}

.profile-avatar-official {
  background: var(--accent);
}

.profile-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-summary {
  min-width: 0;
  flex: 1;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-name-row h1 {
  margin: 0;
  font-size: 30px;
  overflow-wrap: anywhere;
}

.profile-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 10px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 800;
}

.profile-badge-early {
  gap: 5px;
  color: #6b4a00;
  background: linear-gradient(135deg, #ffe08a, #ffc24d);
}

.profile-badge-early svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.profile-bio {
  margin: 10px 0 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.profile-stats-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.profile-stats-row strong {
  color: var(--text);
  font-weight: 900;
}

.profile-owner-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.profile-follow-form {
  margin: 0;
}

.profile-error {
  margin-top: 16px;
}

.profile-panel {
  margin-top: 16px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profile-form {
  display: grid;
  gap: 14px;
  max-width: 560px;
}

.profile-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
  resize: vertical;
}

.profile-form textarea:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

.profile-feed {
  margin-top: 20px;
}

.profile-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.profile-tab span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.profile-tab:hover,
.profile-tab:focus-visible {
  color: var(--accent-dark);
  border-color: var(--accent);
  outline: none;
}

.profile-tab.active {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.profile-tab.active span {
  color: rgba(255, 255, 255, 0.85);
}

.profile-grid {
  margin-top: 18px;
  columns: 4;
  column-gap: 16px;
}

.profile-grid .feed-card {
  margin: 0 0 16px;
  break-inside: avoid;
}

.profile-card-image {
  cursor: zoom-in;
}

.profile-card-footer {
  min-height: 46px;
}

.profile-card-footer .feed-card-text {
  flex: 1;
}

.profile-card-footer .feed-card-text:empty {
  display: none;
}

.photo-delete-form {
  display: inline-flex;
}

.photo-delete-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease;
}

.photo-delete-button:hover,
.photo-delete-button:focus-visible {
  color: #ffffff;
  background: var(--accent);
  outline: none;
}

.profile-empty {
  margin-top: 18px;
}

.profile-empty a {
  color: var(--accent-dark);
}

.profile-not-found-note {
  margin: 0 0 18px;
  color: var(--muted);
}

.profile-not-found-link {
  display: inline-flex;
  text-decoration: none;
}

@media (max-width: 1120px) {
  .profile-grid {
    columns: 3;
  }
}

@media (max-width: 940px) {
  .profile-header {
    padding: 20px;
    gap: 16px;
  }

  .profile-avatar {
    flex-basis: 72px;
    width: 72px;
    height: 72px;
    font-size: 24px;
  }

  .profile-name-row h1 {
    font-size: 24px;
  }
}

@media (max-width: 640px) {
  .profile-grid {
    columns: 2;
    column-gap: 10px;
  }

  .profile-grid .feed-card {
    margin-bottom: 10px;
  }

  .profile-header {
    flex-direction: column;
  }
}

.app-shell {
  display: flex;
  flex-direction: column;
}

.comments-section {
  grid-column: 1;
  min-width: 0;
  margin: 0;
  padding: clamp(18px, 2.2vw, 28px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #fcfdfd 100%);
  box-shadow: 0 12px 32px rgba(22, 32, 38, 0.07);
}

.comments-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.comments-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.comments-title-row h2 {
  margin: 0;
  font-size: clamp(21px, 2.3vw, 26px);
  line-height: 1.15;
}

.comment-count-pill {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 850;
}

.comments-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.comment-form {
  min-width: 0;
  margin: 20px 0 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #f7f9f9;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.comment-form:focus-within {
  border-color: rgba(216, 59, 45, 0.64);
  background: #ffffff;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.comment-form textarea {
  width: 100%;
  min-width: 0;
  min-height: 74px;
  max-height: 180px;
  resize: none;
  padding: 15px 16px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
}

.comment-form textarea:focus {
  outline: none;
  box-shadow: none;
}

.comment-form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 10px 10px 15px;
  border-top: 1px solid rgba(223, 226, 231, 0.78);
}

.comment-form-feedback {
  display: grid;
  flex: 1 1 auto;
  gap: 2px;
  min-width: 0;
}

.comment-hint,
.comment-character-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.comment-character-count {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.comment-error {
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.comment-submit {
  flex: 0 0 auto;
  min-width: 116px;
  min-height: 42px;
  padding: 9px 17px;
  border-radius: 11px;
  font-size: 14px;
}

.comment-submit:disabled {
  cursor: default;
  opacity: 0.48;
}

.comment-login-note {
  margin: 18px 0 4px;
  padding: 14px 16px;
  border: 1px dashed #ccd7d4;
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 14px;
}

.comment-login-note a {
  color: var(--accent-dark);
  font-weight: 800;
}

.comment-list {
  display: grid;
  gap: 11px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.comment-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  padding: 0;
}

.comment-avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  font-size: 12px;
  text-decoration: none;
  box-shadow: 0 0 0 3px #ffffff, 0 3px 10px rgba(22, 32, 38, 0.13);
}

.comment-avatar-bot {
  color: #ffffff;
  background: linear-gradient(145deg, #e24a3d, #b52820);
}

.comment-content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #e4e7ea;
  border-radius: 4px 15px 15px 15px;
  background: #fafbfc;
}

.comment-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-width: 0;
}

.comment-author {
  color: var(--text);
  font-weight: 800;
  font-size: 14px;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.comment-author:hover {
  color: var(--accent-dark);
}

.comment-time {
  color: var(--muted);
  font-size: 12px;
}

.comment-delete {
  margin-left: auto;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.comment-delete:hover {
  background: var(--surface-muted);
  color: var(--danger);
}

.comment-delete:disabled {
  cursor: wait;
  opacity: 0.45;
}

.comment-delete:focus-visible {
  color: var(--danger);
  background: var(--surface-muted);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.comment-text {
  margin: 5px 0 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-source-content {
  border-color: rgba(0, 118, 111, 0.22);
  background: linear-gradient(145deg, #f2f8f6 0%, #f8fbfa 100%);
}

.comment-source-badge {
  padding: 3px 8px;
  border-radius: 999px;
  color: #006860;
  background: rgba(0, 118, 111, 0.1);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.comment-source-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: 8px;
  min-width: 0;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.comment-source-list li {
  min-width: 0;
  max-width: 100%;
}

.comment-source-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  min-height: 58px;
  padding: 10px 11px;
  overflow: hidden;
  border: 1px solid rgba(0, 118, 111, 0.17);
  border-radius: 11px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.comment-source-copy {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
}

.comment-source-copy strong,
.comment-source-copy > span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-source-copy strong {
  font-size: 12px;
  line-height: 1.35;
}

.comment-source-copy > span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.comment-source-link svg {
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  color: var(--accent-warm);
}

.comment-source-link:hover,
.comment-source-link:focus-visible {
  border-color: rgba(0, 118, 111, 0.55);
  box-shadow: 0 5px 14px rgba(0, 118, 111, 0.1);
  transform: translateY(-1px);
  outline: none;
}

.comment-empty {
  margin: 18px 0 0;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 13px;
  color: var(--muted);
  background: #fafbfc;
  font-size: 14px;
  text-align: center;
}

.site-footer {
  margin-top: auto;
  padding-top: 40px;
}

.site-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.site-footer-brand strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.site-footer-brand span {
  font-weight: 600;
}

.footer-mail {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--surface);
  font-weight: 800;
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.footer-mail:hover,
.footer-mail:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

@media (max-width: 720px) {
  .app-shell,
  .auth-shell {
    width: min(100% - 16px, 680px);
    padding-bottom: 28px;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 0;
    padding: 10px 0;
    border-bottom: 1px solid rgba(223, 226, 231, 0.78);
  }

  .brand-mark {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
  }

  .brand strong {
    font-size: 19px;
  }

  .brand span:not(.brand-mark) {
    font-size: 12px;
  }

  .topbar-actions {
    display: contents;
  }

  .top-action-button {
    grid-row: 2;
    grid-column: 1 / -1;
    width: 100%;
  }

  .auth-nav {
    grid-row: 3;
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    min-width: 0;
  }

  .auth-nav > .nav-button:not(.icon-nav),
  .auth-nav > .account-pill,
  .auth-nav > .logout-form {
    flex: 1 1 88px;
  }

  .auth-nav .icon-nav {
    flex: 0 0 auto;
    width: 46px;
    padding: 10px 0;
    justify-content: center;
  }

  .icon-nav .nav-txt {
    display: none;
  }

  .icon-nav .nav-ico {
    display: block;
  }

  .logout-form {
    display: grid;
  }

  .nav-button,
  .account-pill,
  .drawer-close-button {
    min-height: 44px;
  }

  .nav-button,
  .account-pill {
    min-width: 0;
    padding: 10px 11px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .lang-switch {
    grid-row: 1;
    grid-column: 2;
    justify-self: end;
    align-self: center;
    min-height: 28px;
    border-color: rgba(223, 226, 231, 0.74);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
  }

  .lang-option {
    min-height: 28px;
    padding: 5px 8px;
    font-size: 11px;
  }

  .search-drawer,
  .results-panel,
  .auth-card,
  .editor-panel,
  .editor-result-panel,
  .profile-header,
  .profile-panel {
    margin-top: 12px;
    padding: 16px;
  }

  .search-drawer {
    padding: 0;
  }

  .search-drawer-heading,
  .section-heading,
  .results-header {
    gap: 10px;
  }

  .search-drawer-heading {
    padding: 14px;
  }

  .drawer-close-button {
    flex-basis: 36px;
    width: 36px;
    min-height: 36px;
  }

  .search-form {
    gap: 12px;
    padding: 10px;
  }

  h1 {
    font-size: 30px;
    line-height: 1.05;
  }

  h2 {
    font-size: 22px;
  }

  .section-meta {
    min-height: 30px;
  }

  .upload-box {
    padding: 12px;
  }

  .search-upload-box {
    grid-template-columns: minmax(108px, 0.58fr) minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
  }

  .upload-label {
    min-height: 72px;
  }

  .search-upload-box .upload-label {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 190px;
    padding: 12px;
  }

  .search-upload-box .upload-mark {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
  }

  .upload-label strong {
    max-width: none;
    white-space: normal;
  }

  .file-preview {
    width: 100%;
    max-height: 260px;
  }

  .search-preview-frame {
    min-height: 190px;
  }

  .search-upload-box .file-preview {
    height: 190px;
  }

  .search-actions-panel {
    gap: 10px;
  }

  .search-actions-panel .check-option {
    padding: 11px;
    font-size: 12px;
  }

  .primary-button,
  #submit-button,
  .load-more-button,
  .download-button {
    width: 100%;
    min-height: 50px;
  }

  .result-layout {
    gap: 12px;
  }

  .uploaded-card {
    max-width: 320px;
  }

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

  .masonry-feed {
    gap: 9px;
  }

  .feed-column {
    gap: 9px;
  }

  .feed-card-footer,
  .profile-card-footer {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 8px;
  }

  .profile-card-footer {
    grid-template-columns: minmax(0, 1fr);
  }

  .feed-card-text {
    min-width: 0;
  }

  .photo-stats {
    grid-column: 1 / -1;
    justify-content: space-between;
    margin-left: 0;
    padding-top: 6px;
    border-top: 1px solid var(--border);
  }

  .like-button,
  .views-badge {
    min-height: 34px;
    padding: 6px 8px;
  }

  .gallery-lightbox {
    padding: 8px;
  }

  .gallery-lightbox-frame {
    width: 100%;
    min-height: calc(100vh - 16px);
  }

  .gallery-lightbox-image {
    max-height: calc(100vh - 126px);
  }

  .gallery-lightbox-close,
  .gallery-lightbox-nav {
    min-height: 46px;
  }

  .gallery-lightbox-caption {
    max-width: calc(100vw - 32px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .site-footer {
    padding-top: 28px;
  }

  .site-footer-inner {
    display: grid;
    grid-template-columns: 1fr;
    text-align: center;
  }

  .footer-mail {
    justify-content: center;
    width: 100%;
    border-radius: 8px;
  }
}

@media (max-width: 520px) {
  .topbar-actions {
    display: contents;
  }

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

  .auth-nav .account-pill {
    grid-column: 1 / -1;
  }

  .auth-nav > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .lang-switch {
    justify-self: end;
    width: auto;
  }

  .lang-option {
    flex: 0 0 auto;
  }

  .search-drawer-heading {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
  }

  .section-heading {
    display: grid;
    grid-template-columns: 1fr;
  }

  .section-meta,
  #gallery-status {
    justify-self: start;
  }

  .auth-card {
    margin-top: 18px;
  }

  .editor-layout,
  .profile-feed {
    margin-top: 12px;
  }

  .edited-preview-frame {
    min-height: 280px;
  }

  .editor-options,
  .result-actions {
    grid-template-columns: 1fr;
  }

  .profile-header {
    align-items: stretch;
    text-align: center;
  }

  .profile-avatar {
    align-self: center;
  }

  .profile-name-row {
    justify-content: center;
  }

  .profile-bio {
    margin-right: auto;
    margin-left: auto;
  }

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

  .profile-stats-row span {
    display: grid;
    gap: 2px;
    min-height: 54px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-muted);
  }

  .profile-owner-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .profile-owner-actions .nav-button,
  .profile-follow-form,
  .profile-follow-form .nav-button {
    width: 100%;
  }

  .profile-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .profile-tab {
    justify-content: center;
    border-radius: 8px;
  }

  .profile-tab:only-child {
    grid-column: 1 / -1;
  }

  .profile-panel {
    padding: 16px;
  }

  .profile-form {
    max-width: none;
  }
}

@media (max-width: 340px) {
  .app-shell,
  .auth-shell {
    width: min(100% - 12px, 680px);
  }

  .brand span:not(.brand-mark) {
    display: none;
  }

  .auth-nav {
    grid-template-columns: 1fr;
  }

  .search-upload-box {
    grid-template-columns: 1fr;
  }

  .search-upload-box .upload-label {
    min-height: 92px;
  }

  .masonry-feed,
  .profile-grid {
    gap: 8px;
  }

  .feed-card-footer,
  .profile-card-footer {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .feed-avatar {
    flex-basis: 24px;
    width: 24px;
    height: 24px;
  }

  .profile-stats-row {
    grid-template-columns: 1fr;
  }
}

.feed-title-link {
  color: inherit;
  text-decoration: none;
}

.feed-title-link:hover strong,
.feed-title-link:focus-visible strong {
  color: var(--accent-dark);
  text-decoration: underline;
}

.feed-title-link:focus-visible {
  outline: none;
}

.gallery-lightbox-page-link {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: #ffffff;
  background: rgba(16, 20, 24, 0.72);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  backdrop-filter: blur(10px);
  transition: background 160ms ease;
}

.gallery-lightbox-page-link:hover,
.gallery-lightbox-page-link:focus-visible {
  background: var(--accent);
  outline: none;
}

.photo-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.photo-page > *,
.photo-page-info {
  min-width: 0;
}

.photo-page-figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.photo-page-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 160px);
  object-fit: contain;
  background: #dde5e2;
}

.photo-page-info {
  position: sticky;
  top: 18px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.photo-page-title {
  margin-bottom: 16px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.photo-page-author {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  color: var(--text);
  text-decoration: none;
}

.photo-page-author small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.photo-page-author strong {
  font-size: 15px;
  font-weight: 850;
}

.photo-page-author:hover strong,
.photo-page-author:focus-visible strong {
  color: var(--accent-dark);
  text-decoration: underline;
}

.photo-page-author:focus-visible {
  outline: none;
}

.photo-page-stats {
  justify-content: flex-start;
  margin-left: 0;
  margin-bottom: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.photo-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 940px) {
  .photo-page {
    grid-template-columns: minmax(0, 1fr);
  }

  .photo-page-info {
    position: static;
  }
}

@media (max-width: 720px) {
  .comments-section {
    padding: 15px;
    border-radius: 14px;
  }

  .comment-form-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 10px;
  }

  .comment-form-feedback {
    padding-left: 4px;
  }

  .comment-character-count {
    justify-self: end;
  }

  .comment-form .comment-submit {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 44px;
  }

  .comment-avatar {
    width: 34px;
    height: 34px;
  }

  .comment-content {
    padding: 11px 12px;
  }

  .comment-source-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 420px) {
  .comments-section {
    padding: 13px;
  }

  .comment-item {
    gap: 8px;
  }

  .comment-avatar {
    width: 32px;
    height: 32px;
    font-size: 10px;
  }
}

/* Shared visual polish: keep every page in one calm, consistent design system. */
::selection {
  color: #ffffff;
  background: var(--accent);
}

.topbar {
  min-height: 70px;
  padding-right: 4px;
  padding-left: 4px;
  border-bottom: 1px solid rgba(216, 222, 227, 0.82);
  background: rgba(244, 246, 247, 0.9);
  box-shadow: 0 8px 24px rgba(22, 32, 38, 0.035);
}

.brand-mark {
  border-radius: 12px;
  background: linear-gradient(145deg, #e44738, #c92f24);
  box-shadow: 0 8px 18px rgba(216, 59, 45, 0.2);
}

.brand strong,
h1,
h2,
h3,
.photo-page-title,
.profile-name-row h1 {
  letter-spacing: -0.025em;
}

.brand-link:focus-visible {
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.055em;
}

.section-heading {
  margin-bottom: 19px;
}

.nav-button,
.account-pill,
.lang-switch {
  border-radius: 11px;
}

.nav-button,
.account-pill {
  box-shadow: 0 1px 2px rgba(22, 32, 38, 0.035);
}

.primary-action-button {
  background: linear-gradient(180deg, #ffffff, #fff8f7);
}

.primary-button,
#submit-button,
.load-more-button,
.text-search-button {
  border-radius: 11px;
  box-shadow: 0 7px 16px rgba(216, 59, 45, 0.16);
}

.search-panel,
.search-drawer,
.results-panel,
.gallery-panel,
.auth-card,
.editor-panel,
.editor-result-panel,
.profile-header,
.profile-panel,
.photo-page-figure,
.photo-page-info {
  border-color: rgba(216, 222, 227, 0.94);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

.comments-section {
  border-color: rgba(216, 222, 227, 0.94);
  border-radius: 16px;
}

.photo-page-info {
  top: 82px;
}

.upload-box {
  border-color: rgba(0, 118, 111, 0.34);
  border-radius: 13px;
}

.upload-label,
.search-preview-frame,
.edited-preview-frame,
.uploaded-card,
.match-card,
.rules-details,
.check-option {
  border-radius: 12px;
}

.upload-mark {
  border-radius: 11px;
  background: linear-gradient(145deg, #e44738, #c92f24);
}

.field-label input,
.field-label select,
.profile-form textarea {
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.94);
}

.text-search-form {
  border-color: rgba(216, 222, 227, 0.94);
  box-shadow: 0 9px 24px rgba(22, 32, 38, 0.07);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.text-search-form:focus-within {
  box-shadow: 0 0 0 4px var(--accent-soft), 0 9px 24px rgba(22, 32, 38, 0.07);
}

.text-search-button:focus-visible {
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

.feed-card {
  border-color: rgba(216, 222, 227, 0.94);
  border-radius: var(--radius-card);
  box-shadow: 0 7px 22px rgba(22, 32, 38, 0.065);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.feed-card-footer {
  border-top: 1px solid rgba(220, 226, 229, 0.62);
  background: linear-gradient(180deg, #ffffff, #fcfdfd);
}

.feed-avatar {
  box-shadow: 0 0 0 2px #ffffff, 0 3px 9px rgba(22, 32, 38, 0.12);
}

.profile-avatar {
  box-shadow: 0 0 0 4px var(--surface), 0 10px 24px rgba(22, 32, 38, 0.14);
}

.site-footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-mail {
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 7px rgba(22, 32, 38, 0.035);
}

.rules-details summary {
  cursor: pointer;
}

.rules-details summary:focus-visible {
  border-radius: 5px;
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.check-option {
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.check-option:hover,
.check-option:has(input:focus-visible) {
  border-color: rgba(216, 59, 45, 0.48);
  background: #fffafa;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.feed-author-link:focus-visible,
.feed-title-link:focus-visible,
.comments-badge:focus-visible,
.photo-page-author:focus-visible,
.comment-author:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.lang-option:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.text-search-clear:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

@media (hover: hover) {
  .feed-card:hover,
  .feed-card:focus-within {
    z-index: 1;
    border-color: rgba(216, 59, 45, 0.24);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
  }

  .feed-card:hover img,
  .feed-card:focus-within img {
    filter: brightness(0.98);
    transform: scale(1.012);
  }

  .nav-button:hover,
  .primary-button:hover,
  #submit-button:hover,
  .load-more-button:hover,
  .text-search-button:hover {
    transform: translateY(-1px);
  }
}

.nav-button:active,
.primary-button:active,
#submit-button:active,
.load-more-button:active,
.text-search-button:active {
  transform: translateY(1px);
}

@media (max-width: 720px) {
  .topbar {
    padding-right: 0;
    padding-left: 0;
  }

  .topbar:not(.topbar-home) .auth-nav {
    grid-row: 2;
  }

  .auth-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .auth-nav-two-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-nav-one-action {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-nav > .nav-button,
  .auth-nav > .account-pill,
  .auth-nav > .logout-form,
  .auth-nav .icon-nav,
  .logout-form .nav-button {
    width: 100%;
  }

  .auth-nav > .account-pill {
    grid-column: 1 / -1;
  }

  .auth-nav > :last-child:nth-child(odd) {
    grid-column: auto;
  }

  .auth-nav .icon-nav .nav-txt {
    display: inline;
  }

  .auth-nav .icon-nav .nav-ico {
    display: none;
  }

  .comments-badge {
    min-height: 34px;
    padding: 6px 8px;
  }

  .photo-delete-button,
  .comment-delete {
    width: 38px;
    height: 38px;
  }

  .photo-page-info {
    top: auto;
  }
}

@media (max-width: 520px) {
  .site-footer-links {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }
}

@media (max-width: 340px) {
  .auth-nav,
  .auth-nav-two-actions,
  .auth-nav-one-action {
    grid-template-columns: minmax(0, 1fr);
  }

  .profile-card-footer {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
