/* ------------------------------------------------------------------
   Qanater Transfer
   Design system: brand indigo #242452 as the single accent, cool
   neutrals, Geist for text, Geist Mono for file names and numbers.
   Corner radius rule: inputs and buttons 8px, panels 14px, checks 4px.
   Motion: hover and press feedback plus one entry transition on the
   login card; everything collapses under prefers-reduced-motion.
   ------------------------------------------------------------------ */

@font-face {
  font-family: 'Geist Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/geist-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Geist Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/geist-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Geist Mono Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/geist-mono-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light dark;

  --font-sans: 'Geist Variable', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Geist Mono Variable', ui-monospace, 'Cascadia Mono', 'SF Mono', Consolas, monospace;

  --brand: #242452;
  --brand-deep: #191938;
  --brand-tint: #e8e8f3;
  --brand-tint-strong: #d3d3e8;

  --bg: #f4f4f8;
  --surface: #fcfcfe;
  --surface-raised: #ffffff;
  --text: #16162b;
  --text-muted: #5c5c78;
  --text-faint: #8c8ca6;
  --border: #dcdce6;
  --border-strong: #c3c3d3;

  --btn-primary-bg: var(--brand);
  --btn-primary-text: #f6f6fb;
  --btn-primary-hover: #2f2f6b;
  --btn-secondary-bg: var(--brand-tint);
  --btn-secondary-text: var(--brand);
  --btn-secondary-hover: var(--brand-tint-strong);

  --success: #1d7a4b;
  --success-tint: #e3f3ea;
  --danger: #b2281f;
  --danger-tint: #fbe9e7;
  --danger-border: #efc3be;

  --focus: 0 0 0 3px rgba(36, 36, 82, 0.28);
  --shadow: 0 1px 2px rgba(36, 36, 82, 0.06), 0 12px 32px -16px rgba(36, 36, 82, 0.28);

  --radius-control: 8px;
  --radius-panel: 14px;
  --radius-check: 4px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand-tint: #26264f;
    --brand-tint-strong: #33336a;

    --bg: #0e0e1c;
    --surface: #151529;
    --surface-raised: #1b1b33;
    --text: #ececf5;
    --text-muted: #a5a5c1;
    --text-faint: #7a7a99;
    --border: #2a2a48;
    --border-strong: #3a3a60;

    --btn-primary-bg: #dcdcf5;
    --btn-primary-text: #16162b;
    --btn-primary-hover: #ececfb;
    --btn-secondary-bg: #26264f;
    --btn-secondary-text: #e4e4f7;
    --btn-secondary-hover: #33336a;

    --success: #5ccb8d;
    --success-tint: #12291d;
    --danger: #ff8a80;
    --danger-tint: #33191a;
    --danger-border: #5a2a2b;

    --focus: 0 0 0 3px rgba(220, 220, 245, 0.35);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.7);
  }
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
}

h1,
h2,
p {
  margin: 0;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

.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;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  fill: currentColor;
  flex: none;
}

/* ---------- Wordmark ---------- */

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.wordmark-mark {
  width: 18px;
  height: 26px;
  fill: var(--brand);
}

@media (prefers-color-scheme: dark) {
  .wordmark-mark {
    fill: #dcdcf5;
  }
}

.wordmark-inverse,
.wordmark-inverse .wordmark-mark {
  color: #f6f6fb;
  fill: #f6f6fb;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-weight: 560;
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.18s var(--ease),
    border-color 0.18s var(--ease),
    color 0.18s var(--ease),
    transform 0.12s var(--ease);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

.btn-primary:hover:not(:disabled) {
  background: var(--btn-primary-hover);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--btn-secondary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--brand-tint);
  color: var(--text);
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
}

.btn .btn-busy {
  display: none;
}

.btn.is-busy .btn-label {
  display: none;
}

.btn.is-busy .btn-busy {
  display: inline;
}

.btn.is-busy .btn-busy::after {
  content: '';
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: ellipsis 1.2s steps(4, end) infinite;
}

@keyframes ellipsis {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* ---------- Forms ---------- */

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 14px;
  font-weight: 560;
  color: var(--text);
}

.field input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface-raised);
  color: var(--text);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.field input::placeholder {
  color: var(--text-faint);
}

.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus);
}

@media (prefers-color-scheme: dark) {
  .field input:focus {
    border-color: #dcdcf5;
  }
}

.field.has-error input {
  border-color: var(--danger);
}

.field-error {
  font-size: 13px;
  color: var(--danger);
}

.input-with-action {
  position: relative;
}

.input-with-action input {
  padding-right: 48px;
}

.input-action {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.input-action:hover {
  background: var(--brand-tint);
  color: var(--text);
}

.input-action:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.input-action .icon-hide {
  display: none;
}

.input-action[aria-pressed='true'] .icon-show {
  display: none;
}

.input-action[aria-pressed='true'] .icon-hide {
  display: block;
}

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  font-size: 14px;
}

.alert-error {
  background: var(--danger-tint);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.alert .btn {
  margin-left: auto;
}

/* ---------- Login ---------- */

.login {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  min-height: 100dvh;
}

.login-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 48px;
  background: var(--brand);
  color: #f6f6fb;
  isolation: isolate;
}

.login-brand::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 80% at 100% 100%, rgba(255, 255, 255, 0.08), transparent 60%);
  pointer-events: none;
  z-index: -1;
}

.login-brand-copy {
  max-width: 34ch;
  margin-bottom: 40px;
}

.login-brand-copy h1 {
  font-size: clamp(30px, 3.4vw, 42px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin-bottom: 14px;
}

.login-brand-copy p {
  font-size: 16px;
  line-height: 1.55;
  color: rgba(246, 246, 251, 0.78);
}

.login-brand-mark {
  position: absolute;
  right: -6%;
  bottom: -8%;
  width: min(46%, 340px);
  height: auto;
  aspect-ratio: 408 / 604;
  fill: rgba(246, 246, 251, 0.1);
  z-index: -1;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.login-form {
  width: 100%;
  max-width: 400px;
  display: grid;
  gap: 20px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow);
}

@media (prefers-reduced-motion: no-preference) {
  .login-form {
    animation: rise 0.55s var(--ease) both;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-form-head h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.login-form-head p,
.login-help {
  color: var(--text-muted);
  font-size: 14px;
}

.login-help {
  text-align: center;
}

@media (max-width: 860px) {
  .login {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .login-brand {
    padding: 22px 20px;
    gap: 16px;
  }

  .login-brand-copy {
    margin-bottom: 0;
  }

  .login-brand-copy h1 {
    font-size: 24px;
    margin-bottom: 6px;
  }

  .login-brand-copy p {
    font-size: 14px;
  }

  .login-brand-mark {
    width: 110px;
    right: -10px;
    bottom: -30px;
  }

  .login-panel {
    align-items: flex-start;
    padding: 24px 16px 40px;
  }

  .login-form {
    padding: 24px 20px;
    box-shadow: none;
  }
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 64px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1040px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.topbar-name {
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Files page ---------- */

.files {
  max-width: 1040px;
  margin: 0 auto;
  padding: 40px 24px 96px;
  display: grid;
  gap: 20px;
}

.files-head h1 {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-bottom: 6px;
}

.files-summary {
  color: var(--text-muted);
  font-size: 15px;
}

.toolbar {
  position: sticky;
  top: 72px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow);
}

.toolbar-select {
  font-size: 14px;
  color: var(--text-muted);
}

/* Custom checkbox */

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.check-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-check);
  background: var(--surface-raised);
  color: var(--btn-primary-text);
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.check-box .icon {
  width: 12px;
  height: 12px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}

.check input:checked + .check-box {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
}

.check input:indeterminate + .check-box {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
}

.check input:indeterminate + .check-box .icon {
  opacity: 0;
}

.check input:indeterminate + .check-box::after {
  content: '';
  width: 8px;
  height: 2px;
  background: var(--btn-primary-text);
  border-radius: 1px;
}

.check input:checked + .check-box .icon {
  opacity: 1;
  transform: scale(1);
}

.check input:focus-visible + .check-box {
  box-shadow: var(--focus);
}

/* File list */

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  overflow: hidden;
}

.file-row {
  display: grid;
  grid-template-columns: auto 40px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s var(--ease);
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row:hover {
  background: color-mix(in srgb, var(--brand-tint) 45%, transparent);
}

.file-row.is-selected {
  background: color-mix(in srgb, var(--brand-tint) 70%, transparent);
}

.file-row.is-done .file-name::after {
  content: 'saved';
  margin-left: 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 560;
  color: var(--success);
}

.file-row.is-active .file-name::after {
  content: 'downloading';
  margin-left: 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 560;
  color: var(--text-muted);
}

.file-row.is-failed .file-name::after {
  content: 'failed';
  margin-left: 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 560;
  color: var(--danger);
}

.file-position {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.file-name {
  font-family: var(--font-mono);
  font-size: 14px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.file-size {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Skeleton loading */

.file-row.is-skeleton {
  display: block;
  padding: 16px 14px;
}

.skeleton {
  display: block;
  height: 14px;
  width: 62%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--border) 0%, var(--brand-tint) 50%, var(--border) 100%);
  background-size: 200% 100%;
}

.file-row.is-skeleton:nth-child(2n) .skeleton {
  width: 48%;
}

.file-row.is-skeleton:nth-child(3n) .skeleton {
  width: 70%;
}

@media (prefers-reduced-motion: no-preference) {
  .skeleton {
    animation: shimmer 1.4s linear infinite;
  }
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Empty state */

.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 8px;
  padding: 64px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-panel);
}

.empty-icon {
  width: 40px;
  height: 40px;
  fill: var(--text-faint);
  margin-bottom: 8px;
}

.empty h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.empty p {
  color: var(--text-muted);
  max-width: 40ch;
}

/* Note */

.note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--brand-tint);
  color: var(--text-muted);
  font-size: 14px;
}

.note .icon {
  margin-top: 2px;
  color: var(--text-muted);
}

/* Download queue */

.queue {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow);
}

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

.queue-title {
  font-weight: 600;
}

.queue-subtitle {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--btn-primary-bg);
  transition: width 0.25s linear;
}

.queue-meta {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.queue-note {
  font-size: 13px;
  color: var(--text-muted);
}

.queue.is-done .progress-fill {
  background: var(--success);
}

.queue.is-failed .progress-fill {
  background: var(--danger);
}

/* ---------- Error page ---------- */

.error-page {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
  padding: 48px 24px;
}

.error-status {
  font-family: var(--font-mono);
  color: var(--text-faint);
}

.error-page h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

/* ---------- Responsive: files page ---------- */

@media (max-width: 720px) {
  .files {
    padding: 24px 14px 80px;
    gap: 16px;
  }

  .files-head h1 {
    font-size: 26px;
  }

  .toolbar {
    top: 68px;
    flex-wrap: wrap;
    padding: 10px 12px 12px;
  }

  .toolbar-select {
    flex: 1 1 100%;
  }

  .toolbar .btn {
    flex: 1 1 100%;
    padding: 0 12px;
  }

  .topbar-inner {
    padding: 0 14px;
  }

  .topbar-name {
    display: none;
  }

  .file-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      'check name download'
      'check size download';
    row-gap: 2px;
  }

  .file-row .check { grid-area: check; }
  .file-row .file-name { grid-area: name; }
  .file-row .file-size { grid-area: size; text-align: left; }
  .file-row .file-download { grid-area: download; }
  .file-position { display: none; }

  .file-download-label {
    display: none;
  }

  .file-download {
    padding: 0 10px;
  }
}

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