:root {
  color-scheme: dark;
  --bg: #050a12;
  --bg-soft: #08111e;
  --surface: rgba(10, 20, 34, 0.92);
  --surface-strong: #0d1828;
  --surface-muted: #0a1422;
  --border: rgba(125, 164, 205, 0.16);
  --border-strong: rgba(54, 211, 255, 0.3);
  --text: #f5f9ff;
  --muted: #8ca1bb;
  --muted-strong: #b5c5d8;
  --cyan: #21d4fd;
  --blue: #316cf4;
  --green: #31e6a1;
  --red: #ff6d7a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    var(--bg);
  background-size: 42px 42px;
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
label,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.drop-zone:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(110px);
  pointer-events: none;
}

.ambient-one {
  width: 420px;
  height: 420px;
  top: -180px;
  right: 8%;
  background: rgba(32, 185, 255, 0.13);
}

.ambient-two {
  width: 360px;
  height: 360px;
  bottom: -180px;
  left: 4%;
  background: rgba(49, 108, 244, 0.12);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-card {
  width: min(460px, 100%);
  padding: 42px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(14, 29, 48, 0.97), rgba(6, 13, 24, 0.97));
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  gap: 4px;
  padding: 12px;
  margin-bottom: 28px;
  border: 1px solid rgba(33, 212, 253, 0.3);
  border-radius: 16px;
  background: rgba(33, 212, 253, 0.08);
}

.brand-mark span {
  display: block;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--cyan), var(--blue));
}

.brand-mark span:nth-child(1) { height: 18px; }
.brand-mark span:nth-child(2) { height: 30px; }
.brand-mark span:nth-child(3) { height: 23px; }

.brand-mark-small {
  width: 42px;
  height: 42px;
  padding: 9px;
  margin: 0;
  border-radius: 13px;
}

.brand-mark-small span:nth-child(1) { height: 14px; }
.brand-mark-small span:nth-child(2) { height: 23px; }
.brand-mark-small span:nth-child(3) { height: 18px; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

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

h1 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 5vw, 3.35rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.18rem;
  letter-spacing: -0.025em;
}

.login-copy,
.page-heading p,
.panel-heading + p {
  color: var(--muted-strong);
  line-height: 1.65;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.login-form label,
.field {
  display: grid;
  gap: 8px;
}

.login-form label > span,
.field > span {
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(3, 9, 16, 0.72);
  color: var(--text);
  padding: 12px 14px;
  transition: border-color 160ms ease, background 160ms ease;
}

input:hover,
select:hover,
input:focus,
select:focus {
  border-color: var(--border-strong);
  background: rgba(6, 16, 27, 0.9);
}

.form-error {
  margin: 0;
  padding: 11px 12px;
  border: 1px solid rgba(255, 109, 122, 0.3);
  border-radius: 10px;
  background: rgba(255, 109, 122, 0.08);
  color: #ffb8bf;
  font-size: 0.86rem;
}

.security-note,
.service-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.security-note {
  justify-content: center;
  margin-top: 24px;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 14px rgba(49, 230, 161, 0.75);
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 18px;
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, filter 150ms ease, background 150ms ease;
}

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

.button:disabled {
  opacity: 0.58;
  cursor: wait;
  transform: none;
}

.button-primary {
  background: linear-gradient(115deg, var(--blue), #246bff 45%, #10bfe8);
  box-shadow: 0 12px 32px rgba(37, 107, 255, 0.2);
}

.button-primary:hover {
  filter: brightness(1.08);
}

.button-secondary,
.button-ghost {
  border-color: var(--border);
  background: rgba(12, 24, 40, 0.72);
}

.button-secondary:hover,
.button-ghost:hover {
  border-color: var(--border-strong);
  background: rgba(17, 34, 55, 0.9);
}

.button-compact {
  min-height: 36px;
  padding-inline: 13px;
  font-size: 0.78rem;
}

.button-danger {
  border-color: rgba(255, 109, 122, 0.22);
  background: rgba(255, 109, 122, 0.08);
  color: #ffabb4;
}

.button-danger:hover {
  border-color: rgba(255, 109, 122, 0.46);
  background: rgba(255, 109, 122, 0.14);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 clamp(20px, 5vw, 64px);
  border-bottom: 1px solid var(--border);
  background: rgba(5, 10, 18, 0.84);
  backdrop-filter: blur(18px);
}

.brand,
.topbar-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

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

.brand strong {
  font-size: 0.96rem;
}

.brand small,
.current-user {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.topbar-actions {
  gap: 16px;
}

.content {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto;
  padding: 56px 0 80px;
}

.page-heading,
.library-heading,
.panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.page-heading {
  margin-bottom: 32px;
}

.page-heading h1 {
  max-width: 760px;
  margin-bottom: 12px;
}

.page-heading p {
  max-width: 720px;
  margin-bottom: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card,
.panel {
  border: 1px solid var(--border);
  background: linear-gradient(145deg, rgba(13, 25, 42, 0.92), rgba(7, 15, 26, 0.92));
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.16);
}

.stat-card {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 22px;
  border-radius: 16px;
}

.stat-card-accent {
  border-color: rgba(33, 212, 253, 0.24);
  background: linear-gradient(145deg, rgba(10, 45, 63, 0.72), rgba(7, 18, 32, 0.92));
}

.stat-card strong {
  margin: 11px 0 3px;
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -0.04em;
}

.stat-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.stat-card small,
.field small,
.steps small {
  color: var(--muted);
  font-size: 0.74rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 20px;
  margin-bottom: 44px;
}

.panel {
  border-radius: var(--radius);
  padding: 26px;
}

.panel-heading {
  align-items: flex-start;
  margin-bottom: 20px;
}

.panel-heading h2 {
  margin: 0;
}

.limit-badge {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 0.68rem;
  font-weight: 700;
}

.upload-panel form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.55fr);
  gap: 18px;
}

.drop-zone {
  grid-row: span 3;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed rgba(33, 212, 253, 0.38);
  border-radius: 16px;
  background: rgba(19, 173, 218, 0.035);
  color: var(--muted-strong);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--cyan);
  background: rgba(33, 212, 253, 0.075);
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-symbol,
.empty-symbol {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
  border: 1px solid rgba(33, 212, 253, 0.28);
  border-radius: 14px;
  background: rgba(33, 212, 253, 0.08);
  color: var(--cyan);
  font-size: 1.7rem;
}

.drop-zone strong {
  color: var(--text);
}

.drop-zone > span:not(.upload-symbol),
.drop-zone small {
  color: var(--muted);
  font-size: 0.78rem;
}

.drop-zone small {
  max-width: 82%;
  margin-top: 10px;
  overflow-wrap: anywhere;
}

.field small {
  line-height: 1.4;
}

.upload-feedback {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: rgba(33, 212, 253, 0.06);
  color: var(--muted-strong);
  font-size: 0.78rem;
}

.guide-panel {
  position: relative;
  overflow: hidden;
}

.guide-panel::after {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  right: -70px;
  top: -70px;
  border-radius: 50%;
  background: rgba(33, 212, 253, 0.08);
  filter: blur(12px);
}

.steps {
  display: grid;
  gap: 18px;
  padding: 0;
  margin: 24px 0;
  list-style: none;
}

.steps li {
  display: flex;
  gap: 13px;
  align-items: flex-start;
}

.steps li > span {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(33, 212, 253, 0.3);
  border-radius: 9px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 800;
}

.steps strong,
.steps small {
  display: block;
}

.steps strong {
  margin-bottom: 4px;
  font-size: 0.87rem;
}

.guide-alert {
  padding: 13px 14px;
  border: 1px solid rgba(49, 230, 161, 0.18);
  border-radius: 12px;
  background: rgba(49, 230, 161, 0.055);
  color: #a9d8c9;
  font-size: 0.76rem;
  line-height: 1.5;
}

.library-heading {
  margin-bottom: 18px;
}

.library-heading h2 {
  margin: 0;
  font-size: 1.5rem;
}

.filters {
  display: flex;
  gap: 10px;
}

.search-field input {
  min-width: 280px;
}

.filters select {
  min-width: 170px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.image-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(8, 17, 29, 0.88);
  transition: transform 160ms ease, border-color 160ms ease;
}

.image-card:hover {
  transform: translateY(-2px);
  border-color: rgba(33, 212, 253, 0.26);
}

.image-preview {
  aspect-ratio: 4 / 3;
  display: block;
  width: 100%;
  object-fit: cover;
  background:
    linear-gradient(45deg, #101d2d 25%, transparent 25%),
    linear-gradient(-45deg, #101d2d 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #101d2d 75%),
    linear-gradient(-45deg, transparent 75%, #101d2d 75%),
    #091421;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.image-details {
  padding: 15px;
}

.image-details h3 {
  margin: 0 0 7px;
  overflow: hidden;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 13px;
}

.image-meta span {
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.64rem;
}

.image-url {
  display: block;
  width: 100%;
  margin-bottom: 12px;
  overflow: hidden;
  color: #6faefc;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.67rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 7px;
}

.card-actions .button {
  min-height: 36px;
  padding-inline: 10px;
  font-size: 0.7rem;
}

.state-card {
  min-height: 210px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.state-card p {
  margin: 0;
  font-size: 0.82rem;
}

.toast-region {
  position: fixed;
  z-index: 30;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 10px;
}

.toast {
  width: min(380px, calc(100vw - 44px));
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #0b1928;
  box-shadow: var(--shadow);
  color: var(--muted-strong);
  font-size: 0.82rem;
  animation: toast-in 180ms ease-out;
}

.toast.is-error {
  border-color: rgba(255, 109, 122, 0.38);
  color: #ffc0c6;
}

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

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1100px) {
  .stats-grid,
  .image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .topbar {
    height: auto;
    padding: 14px 18px;
  }

  .service-status,
  .current-user {
    display: none;
  }

  .content {
    width: min(100% - 28px, 1380px);
    padding-top: 36px;
  }

  .page-heading,
  .library-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .stat-card {
    min-height: 128px;
    padding: 17px;
  }

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

  .drop-zone {
    grid-row: auto;
    min-height: 220px;
  }

  .filters {
    flex-direction: column;
  }

  .search-field input,
  .filters select {
    min-width: 0;
  }

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

@media (max-width: 480px) {
  .login-shell {
    padding: 16px;
  }

  .login-card,
  .panel {
    padding: 22px;
  }

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

  .page-heading .button,
  .upload-panel .button-primary {
    width: 100%;
  }
}

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