:root {
  color-scheme: dark;
  --bg: #070b16;
  --panel: rgba(15, 22, 42, 0.86);
  --panel-solid: #11182d;
  --panel-soft: #151e36;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f7f9ff;
  --muted: #9aa6c3;
  --primary: #7162ff;
  --primary-strong: #8d7fff;
  --cyan: #2dc6ff;
  --danger: #ff5e72;
  --success: #36d39a;
  --warning: #f6b94b;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(113, 98, 255, 0.18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(45, 198, 255, 0.12), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

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

.background-orb {
  position: fixed;
  z-index: -1;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  filter: blur(100px);
  opacity: 0.18;
  pointer-events: none;
}

.background-orb-one { top: -180px; left: -160px; background: var(--primary); }
.background-orb-two { right: -180px; bottom: -220px; background: var(--cyan); }

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 64px;
}

.center-card {
  width: min(560px, 100%);
  margin: 12vh auto 0;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.loading-card {
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.loading-card p { margin: 0; color: var(--muted); }

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.brand-row { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 17px;
  color: white;
  font-size: 28px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  box-shadow: 0 12px 32px rgba(87, 99, 255, 0.3);
}
.brand-mark-small { width: 44px; height: 44px; border-radius: 14px; font-size: 22px; }
.brand-subtitle { margin: 1px 0 0; color: var(--muted); font-size: 14px; }

.eyebrow {
  margin: 0 0 4px;
  color: #9ea6ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { margin-top: 0; line-height: 1.12; }
h1 { font-size: clamp(34px, 5vw, 58px); letter-spacing: -0.045em; }
h2 { font-size: clamp(24px, 3vw, 34px); letter-spacing: -0.03em; }
h3 { font-size: 18px; }
.muted { color: var(--muted); }

.setup-list {
  display: grid;
  gap: 10px;
  margin: 24px 0;
}
.setup-item {
  padding: 12px 14px;
  color: #ffd7dc;
  background: rgba(255, 94, 114, 0.08);
  border: 1px solid rgba(255, 94, 114, 0.18);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.login-layout {
  min-height: calc(100vh - 100px);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  align-items: center;
  gap: clamp(36px, 7vw, 100px);
}
.login-copy { max-width: 680px; }
.login-copy h1 { margin: 38px 0 22px; }
.login-copy > p { max-width: 600px; color: var(--muted); font-size: 18px; }
.feature-pills { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.feature-pills span {
  padding: 9px 13px;
  color: #d7dcff;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
}

.login-card {
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}
.form-heading { margin-bottom: 24px; }
.form-heading h2 { margin-bottom: 8px; }
.form-heading p:last-child { margin-bottom: 0; }
.field { display: grid; gap: 8px; margin: 16px 0; }
.field > span { color: #dce2f7; font-size: 14px; font-weight: 700; }
.field input,
.search-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(7, 11, 22, 0.75);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.field input:focus,
.search-field input:focus {
  border-color: rgba(113, 98, 255, 0.85);
  box-shadow: 0 0 0 4px rgba(113, 98, 255, 0.12);
  background: rgba(10, 15, 30, 0.95);
}
.password-field { position: relative; }
.password-field input { padding-right: 76px; }
.input-action { position: absolute; top: 6px; right: 7px; height: 36px; width: 58px; font-size: 12px; border-radius: 9px; }
.form-error {
  margin: 14px 0;
  padding: 11px 13px;
  color: #ffd3d9;
  background: rgba(255, 94, 114, 0.08);
  border: 1px solid rgba(255, 94, 114, 0.2);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.security-note { margin: 14px 0 0; color: var(--muted); text-align: center; font-size: 12px; }

.button,
.icon-button,
.text-button {
  border: 0;
  cursor: pointer;
  transition: transform 0.16s, opacity 0.16s, border-color 0.16s, background 0.16s;
}
.button:disabled,
.icon-button:disabled,
.text-button:disabled { cursor: not-allowed; opacity: 0.55; }
.button:not(:disabled):active,
.icon-button:not(:disabled):active { transform: translateY(1px); }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 45px;
  padding: 0 17px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
}
.button-primary {
  color: white;
  background: linear-gradient(135deg, var(--primary), #557dff 60%, var(--cyan));
  box-shadow: 0 12px 26px rgba(79, 95, 255, 0.22);
}
.button-primary:hover:not(:disabled) { filter: brightness(1.08); }
.button-secondary {
  color: #e7ebfb;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
}
.button-secondary:hover:not(:disabled) { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.09); }
.button-danger { color: white; background: linear-gradient(135deg, #ff4862, #d93c59); }
.button-full { width: 100%; }
.icon-button {
  display: inline-grid;
  place-items: center;
  color: #dce2f7;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}
.text-button { padding: 0; color: #aeb6ff; background: transparent; font-weight: 800; font-size: 13px; }

.dashboard { display: grid; gap: 22px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 10px 2px 16px;
}
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.account-area { display: flex; align-items: center; gap: 14px; }
.account-copy { display: grid; text-align: right; }
.account-copy strong { font-size: 14px; }
.account-copy span { color: var(--muted); font-size: 12px; }

.hero-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  min-height: 220px;
  padding: clamp(26px, 5vw, 48px);
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(120deg, rgba(113, 98, 255, 0.22), rgba(45, 198, 255, 0.08)),
    var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.hero-panel::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  right: -90px;
  top: -120px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(113, 98, 255, 0.7), rgba(45, 198, 255, 0.15));
  filter: blur(4px);
  opacity: 0.45;
}
.hero-panel > * { position: relative; z-index: 1; }
.hero-panel h2 { margin: 8px 0 12px; font-size: clamp(30px, 4vw, 48px); }
.hero-panel p:last-child { max-width: 700px; margin: 0; color: #b8c2df; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 14px;
}
.stat-card {
  min-width: 0;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.stat-card span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card strong { display: block; font-size: 23px; letter-spacing: -0.03em; }
.url-stat { overflow: hidden; color: #b9c4ff; font-size: 15px !important; text-overflow: ellipsis; white-space: nowrap; }

.upload-panel {
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
}
.drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 148px;
  padding: 24px;
  text-align: left;
  background: rgba(7, 11, 22, 0.38);
  border: 1px dashed rgba(147, 159, 201, 0.34);
  border-radius: var(--radius-lg);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.dragging {
  border-color: rgba(113, 98, 255, 0.9);
  background: rgba(113, 98, 255, 0.08);
}
.drop-zone.dragging { transform: scale(1.006); }
.drop-zone strong { display: block; margin-bottom: 5px; }
.drop-zone p { margin: 0; color: var(--muted); font-size: 13px; }
.upload-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 16px;
  color: #dce1ff;
  background: rgba(113, 98, 255, 0.16);
  border: 1px solid rgba(113, 98, 255, 0.25);
  font-size: 25px;
  font-weight: 900;
}
.selected-files { margin-top: 16px; padding: 16px; background: rgba(7, 11, 22, 0.38); border-radius: var(--radius-lg); }
.selected-files-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.selected-files-list { display: grid; gap: 8px; max-height: 240px; margin-bottom: 14px; overflow: auto; }
.selected-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 13px;
}
.selected-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-file-size { flex: 0 0 auto; color: var(--muted); }

.gallery-section {
  padding: clamp(20px, 4vw, 30px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
}
.gallery-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.gallery-toolbar h2 { margin: 4px 0 0; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }
.search-field input { width: min(300px, 42vw); }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.image-card {
  min-width: 0;
  overflow: hidden;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.image-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: 0 18px 36px rgba(0,0,0,0.2); }
.image-preview-button {
  display: block;
  width: 100%;
  height: 210px;
  padding: 0;
  overflow: hidden;
  background: #080d1a;
  border: 0;
  cursor: zoom-in;
}
.image-preview-button img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s; }
.image-card:hover .image-preview-button img { transform: scale(1.035); }
.image-body { padding: 14px; }
.image-name { margin: 0 0 5px; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.image-meta { display: flex; gap: 8px; color: var(--muted); font-size: 11px; }
.image-actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 13px; }
.image-actions .button { min-height: 38px; padding: 0 11px; font-size: 12px; }
.delete-icon-button { width: 38px; height: 38px; border-radius: 10px; color: #ffb7c1; background: rgba(255, 94, 114, 0.08); border-color: rgba(255, 94, 114, 0.16); }

.empty-state { padding: 70px 20px; text-align: center; }
.empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  color: #b8c0ff;
  background: rgba(113, 98, 255, 0.1);
  border: 1px solid rgba(113, 98, 255, 0.2);
  border-radius: 20px;
  font-size: 30px;
}
.empty-state h3 { margin-bottom: 8px; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }
.load-more { display: flex; margin: 22px auto 0; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 6, 14, 0.82); border: 0; backdrop-filter: blur(10px); cursor: default; }
.modal-card,
.confirm-card {
  position: relative;
  z-index: 1;
  width: min(900px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #10172b;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.modal-card { padding: 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 4px 4px 16px; }
.modal-head h2 { max-width: 720px; margin: 0; font-size: 22px; }
.modal-head .icon-button { width: 42px; height: 42px; border-radius: 12px; font-size: 25px; }
.modal-image-wrap { display: grid; place-items: center; min-height: 280px; max-height: 66vh; overflow: hidden; background: #070b15; border-radius: var(--radius-lg); }
.modal-image-wrap img { max-width: 100%; max-height: 66vh; object-fit: contain; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; }
.confirm-card { width: min(430px, 100%); padding: 30px; text-align: center; }
.danger-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 18px; color: #ffd2d9; background: rgba(255, 94, 114, 0.12); border: 1px solid rgba(255, 94, 114, 0.2); font-size: 25px; font-weight: 900; }
.confirm-card h2 { margin-bottom: 10px; }
.confirm-card p { margin: 0; color: var(--muted); }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 10px; width: min(380px, calc(100% - 36px)); }
.toast {
  padding: 14px 16px;
  background: #141c33;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--success);
  border-radius: 13px;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.34);
  animation: toast-in 0.22s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast strong { display: block; margin-bottom: 2px; font-size: 14px; }
.toast span { color: var(--muted); font-size: 13px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.skeleton-card { overflow: hidden; background: var(--panel-soft); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.skeleton-image, .skeleton-line { background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.09), rgba(255,255,255,0.04)); background-size: 200% 100%; animation: shimmer 1.1s infinite; }
.skeleton-image { height: 210px; }
.skeleton-body { padding: 15px; }
.skeleton-line { height: 12px; margin: 8px 0; border-radius: 999px; }
.skeleton-line.short { width: 62%; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 1000px) {
  .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card-wide { grid-column: 1 / -1; }
}

@media (max-width: 780px) {
  .app-shell { width: min(100% - 22px, 1240px); padding-top: 18px; }
  .login-layout { grid-template-columns: 1fr; gap: 34px; padding: 34px 0; }
  .login-copy { text-align: center; }
  .login-copy .brand-row { justify-content: center; }
  .feature-pills { justify-content: center; }
  .topbar { align-items: flex-start; }
  .account-copy { display: none; }
  .hero-panel { align-items: flex-start; flex-direction: column; }
  .hero-panel .button { width: 100%; }
  .gallery-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { width: 100%; }
  .search-field { flex: 1; }
  .search-field input { width: 100%; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 540px) {
  .center-card, .login-card, .gallery-section { padding: 20px; border-radius: 22px; }
  .login-copy h1 { margin-top: 28px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 15px; }
  .stat-card strong { font-size: 20px; }
  .hero-panel { min-height: auto; padding: 26px 20px; border-radius: 22px; }
  .upload-panel { padding: 12px; border-radius: 22px; }
  .drop-zone { align-items: center; flex-direction: column; text-align: center; }
  .gallery-grid { grid-template-columns: 1fr; }
  .image-preview-button { height: 240px; }
  .toolbar-actions { align-items: stretch; flex-direction: column; }
  .modal { padding: 10px; }
  .modal-card { padding: 12px; border-radius: 20px; }
  .modal-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .confirm-card { padding: 24px 18px; }
}
