:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7fb;
  color: #172033;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top, #eef2ff 0, #f7f8fb 38%, #f5f7fb 100%); }
button, input { font: inherit; }
button { cursor: pointer; }
label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 700; }
input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid #ccd3e0;
  border-radius: 12px;
  background: #fff;
  color: #172033;
  outline: none;
}
input:focus { border-color: #5965e8; box-shadow: 0 0 0 4px rgba(89, 101, 232, .12); }

.auth-page { display: grid; place-items: center; padding: 24px; }
.auth-card, .hero-card {
  width: min(100%, 720px);
  padding: 36px;
  border: 1px solid rgba(210, 216, 228, .9);
  border-radius: 24px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 24px 70px rgba(30, 39, 73, .12);
  backdrop-filter: blur(12px);
}
.auth-card { max-width: 430px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 20px;
  border-radius: 15px;
  background: #172033;
  color: #fff;
  font-weight: 800;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 5vw, 42px); line-height: 1.1; }
h2 { margin-bottom: 8px; }
.muted { color: #68738a; line-height: 1.65; }
.stack { display: grid; gap: 14px; margin-top: 24px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 11px;
  font-weight: 750;
  text-decoration: none;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.primary { background: #5360e8; color: #fff; }
.primary:hover { background: #4652d7; }
.ghost { background: transparent; color: #384157; }
.ghost:hover { background: #eef0f6; }
.danger { background: #fff0f1; color: #b4232e; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 12px clamp(18px, 5vw, 64px);
  border-bottom: 1px solid rgba(216, 221, 231, .85);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(14px);
}
.brand { color: #172033; font-weight: 850; text-decoration: none; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.top-actions form { margin: 0; }
.status-dot { width: 8px; height: 8px; margin-left: 8px; border-radius: 50%; }
.status-dot.ok { background: #16a36a; }
.status-dot.warn { background: #e29822; }

.page-shell { padding: clamp(44px, 9vw, 100px) 20px 32px; }
.hero-card { margin: 0 auto; }
.eyebrow { margin-bottom: 12px; color: #5360e8; font-size: 13px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.resolve-form { margin-top: 30px; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.input-row .button { min-width: 150px; }

.alert, .result {
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid #dbe1ec;
  border-radius: 12px;
  background: #f7f9fc;
  line-height: 1.55;
}
.alert-error, .result.error { border-color: #ffc6cb; background: #fff2f3; color: #9d1c28; }
.alert-warning, .result.warning { border-color: #f4d6a2; background: #fff8e9; color: #815710; }
.result.success { border-color: #bce6d4; background: #effbf5; color: #116443; }
.result.loading { color: #5360e8; }
.download-link { display: inline-flex; margin-top: 14px; color: #4652d7; font-weight: 800; }
.copy-button { margin-left: 12px; border: 0; background: transparent; color: #526078; font-weight: 700; }
.footer-note { margin: 22px auto 0; text-align: center; color: #7c8699; font-size: 13px; }

dialog {
  width: min(calc(100% - 30px), 560px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 30px 90px rgba(20, 28, 52, .28);
}
dialog::backdrop { background: rgba(18, 25, 43, .52); backdrop-filter: blur(4px); }
.dialog-card { display: grid; gap: 12px; padding: 28px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.icon-button { border: 0; background: transparent; color: #626d83; font-size: 30px; line-height: 1; }
.credential-state { padding: 12px 14px; border-radius: 10px; background: #f2f4f8; color: #526078; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }

@media (max-width: 650px) {
  .auth-card, .hero-card { padding: 25px; border-radius: 19px; }
  .topbar { align-items: flex-start; }
  .brand { padding-top: 10px; }
  .input-row { grid-template-columns: 1fr; }
  .input-row .button { width: 100%; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
}

.history-card {
  width: min(100%, 980px);
  margin: 28px auto 0;
  padding: 30px;
  border: 1px solid rgba(210, 216, 228, .9);
  border-radius: 24px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 18px 55px rgba(30, 39, 73, .08);
}
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
.section-heading h2 { font-size: clamp(22px, 4vw, 30px); }
.browser-identity { margin-bottom: 0; }
.browser-identity code {
  padding: 3px 7px;
  border-radius: 6px;
  background: #eef0f6;
  color: #384157;
}
.history-list { display: grid; gap: 12px; }
.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  padding: 18px;
  border: 1px solid #dfe4ed;
  border-radius: 14px;
  background: #fbfcfe;
}
.history-item.new-item { animation: history-in .35s ease both; }
@keyframes history-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.history-main { min-width: 0; }
.history-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 8px;
  color: #68738a;
  font-size: 13px;
}
.source-link {
  display: block;
  overflow: hidden;
  color: #4652d7;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-status { margin-top: 7px; color: #526078; font-size: 14px; }
.history-actions { display: flex; align-items: center; gap: 6px; }
.secondary { background: #eef0ff; color: #4652d7; }
.secondary:hover { background: #e2e5ff; }
.empty-state {
  padding: 28px;
  border: 1px dashed #cdd4e1;
  border-radius: 14px;
  color: #7c8699;
  text-align: center;
}
.history-limit-note, .settings-warning {
  margin: 14px 0 0;
  color: #7c8699;
  font-size: 13px;
  line-height: 1.55;
}
.clear-history-form { flex: 0 0 auto; }

@media (max-width: 760px) {
  .history-card { padding: 22px; border-radius: 19px; }
  .section-heading, .history-item { grid-template-columns: 1fr; display: grid; }
  .history-actions { flex-wrap: wrap; }
  .history-actions .button { flex: 1 1 auto; }
  .clear-history-form .button { width: 100%; }
}

.history-title {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
  color: #172033;
  font-size: 17px;
  font-weight: 850;
}
.result > div + div { margin-top: 6px; }

/* Multi-platform navigation and controls */
.site-rail {
  position: fixed;
  top: 50%;
  left: 18px;
  z-index: 20;
  display: grid;
  gap: 12px;
  transform: translateY(-50%);
  animation: rail-fade-in .7s ease both;
}
.site-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(210, 216, 228, .92);
  border-radius: 17px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 13px 34px rgba(30, 39, 73, .12);
  text-decoration: none;
  opacity: 1;
  transform: translateX(0) scale(1);
  animation: site-icon-in .5s ease backwards;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.site-icon:nth-child(1) { animation-delay: .12s; }
.site-icon:nth-child(2) { animation-delay: .24s; }
.site-icon:nth-child(3) { animation-delay: .36s; }
.site-icon:hover {
  transform: translateX(3px) scale(1.04);
  border-color: #b8c0d4;
  box-shadow: 0 17px 42px rgba(30, 39, 73, .17);
}
.site-icon svg { width: 42px; height: 42px; }
.site-icon svg rect { fill: #172033; }
.site-icon svg path { fill: #fff; }
.shutterstock-icon svg rect { fill: #e83037; }
.vecteezy-icon svg rect { fill: #126c60; }
.site-icon span {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  padding: 6px 9px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-4px, -50%);
  transition: opacity .16s ease, transform .16s ease;
}
.site-icon:hover span,
.site-icon:focus-visible span { opacity: 1; transform: translate(0, -50%); }

@keyframes rail-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes site-icon-in {
  from { opacity: 0; transform: translateX(-18px) scale(.96); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.supported-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
}
.supported-platforms span,
.platform-badge,
.quality-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef0ff;
  color: #4652d7;
  font-size: 12px;
  font-weight: 800;
}
.quality-badge { background: #eaf8f1; color: #116443; }

.quality-field {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  border: 0;
}
.quality-field[hidden] { display: none; }
.quality-field legend {
  width: 100%;
  margin-bottom: 3px;
  color: #384157;
  font-size: 14px;
  font-weight: 800;
}
.quality-option {
  display: block;
  margin: 0;
  cursor: pointer;
}
.quality-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  opacity: 0;
}
.quality-option span {
  display: grid;
  min-width: 112px;
  padding: 10px 14px;
  border: 1px solid #d5dbe7;
  border-radius: 12px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.quality-option small { margin-top: 2px; color: #7c8699; }
.quality-option input:checked + span {
  border-color: #5965e8;
  background: #f2f3ff;
  box-shadow: 0 0 0 3px rgba(89, 101, 232, .11);
}
.quality-option input:focus-visible + span { outline: 3px solid rgba(89, 101, 232, .25); }
.platform-hint {
  margin: 11px 0 0;
  color: #7c8699;
  font-size: 13px;
}
.platform-hint.detected { color: #116443; }
.platform-hint.warning { color: #9d1c28; }
.history-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
}
.history-title-row .history-title { margin-bottom: 0; }

@media (min-width: 1100px) {
  .page-shell { padding-left: 92px; }
}

@media (max-width: 780px) {
  body { padding-bottom: 82px; }
  .site-rail {
    top: auto;
    bottom: 12px;
    left: 50%;
    display: flex;
    padding: 7px;
    border: 1px solid rgba(210, 216, 228, .9);
    border-radius: 20px;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 18px 50px rgba(30, 39, 73, .18);
    backdrop-filter: blur(14px);
    transform: translateX(-50%);
  }
  .site-icon { width: 48px; height: 48px; box-shadow: none; }
  .site-icon svg { width: 38px; height: 38px; }
  .site-icon span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .site-rail, .site-icon, .history-item.new-item { animation: none; opacity: 1; transform: none; }
  .site-icon, .button { transition: none; }
}
