:root {
  --bg: #0b1220;
  --bg-alt: #0e1528;
  --card: #121826;
  --card-border: #1f2937;
  --text: #e6eaf2;
  --muted: #9aa4b2;
  --primary: #6366f1;    /* indigo-500 */
  --primary-600: #4f46e5;/* indigo-600 */
  --accent: #22d3ee;     /* cyan-400 */
  --success: #22c55e;    /* green-500 */
  --danger: #ef4444;     /* red-500 */
  --warning: #f59e0b;    /* amber-500 */
  --ring: rgba(99, 102, 241, 0.6);
  --ring-weak: rgba(99, 102, 241, 0.25);
  --wood: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width=\"40\" height=\"40\" viewBox=\"0 0 40 40\"><rect width=\"40\" height=\"40\" fill=\"%230e1528\"/><path fill=\"%2311182a\" d=\"M0 20c10-4 10 4 20 0s10 4 20 0v20H0V20z\"/></svg>');
  --shadow: 0 10px 30px rgba(0,0,0,0.30), inset 0 1px 0 rgba(255,255,255,0.03);
  --shadow-soft: 0 8px 20px rgba(0,0,0,0.24);
  --gradient: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --focus: 0 0 0 3px var(--ring);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fc;
    --bg-alt: #eef2fb;
    --card: #ffffff;
    --card-border: #e6eaf2;
    --text: #0f172a;
    --muted: #64748b;
    --shadow: 0 10px 30px rgba(2,6,23,0.08), inset 0 1px 0 rgba(255,255,255,0.6);
    --shadow-soft: 0 8px 20px rgba(2,6,23,0.06);
    --wood: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width=\"40\" height=\"40\" viewBox=\"0 0 40 40\"><rect width=\"40\" height=\"40\" fill=\"%23eef2fb\"/><path fill=\"%23f7f9fe\" d=\"M0 20c10-4 10 4 20 0s10 4 20 0v20H0V20z\"/></svg>');
  }
}

/* Manual theme override via html[data-theme] */
html[data-theme="dark"] {
  --bg: #0b1220;
  --bg-alt: #0e1528;
  --card: #121826;
  --card-border: #1f2937;
  --text: #e6eaf2;
  --muted: #9aa4b2;
  --shadow: 0 10px 30px rgba(0,0,0,0.30), inset 0 1px 0 rgba(255,255,255,0.03);
  --shadow-soft: 0 8px 20px rgba(0,0,0,0.24);
  --wood: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width=\"40\" height=\"40\" viewBox=\"0 0 40 40\"><rect width=\"40\" height=\"40\" fill=\"%230e1528\"/><path fill=\"%2311182a\" d=\"M0 20c10-4 10 4 20 0s10 4 20 0v20H0V20z\"/></svg>');
}
html[data-theme="light"] {
  --bg: #f6f8fc;
  --bg-alt: #eef2fb;
  --card: #ffffff;
  --card-border: #e6eaf2;
  --text: #0f172a;
  --muted: #64748b;
  --shadow: 0 10px 30px rgba(2,6,23,0.08), inset 0 1px 0 rgba(255,255,255,0.6);
  --shadow-soft: 0 8px 20px rgba(2,6,23,0.06);
  --wood: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width=\"40\" height=\"40\" viewBox=\"0 0 40 40\"><rect width=\"40\" height=\"40\" fill=\"%23eef2fb\"/><path fill=\"%23f7f9fe\" d=\"M0 20c10-4 10 4 20 0s10 4 20 0v20H0V20z\"/></svg>');
}

/* Small spacing for the theme toggle in the nav */
#theme-toggle { margin-left: 8px; }
.btn.icon-btn { padding: 6px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; }
#theme-toggle-icon { width: 18px; height: 18px; display: inline-block; }

/* Base */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  margin: 0;
  position: relative; /* allow background overlay to sit behind content */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Animated gradient background overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1200px circle at 15% 10%, rgba(99,102,241,0.20), rgba(34,211,238,0.08) 40%, rgba(0,0,0,0) 60%),
    linear-gradient(120deg, #0ea5e9, #6366f1, #22d3ee, #a78bfa);
  background-size: 140% 140%, 400% 400%;
  animation: gradientDrift 28s ease infinite;
  will-change: background-position;
}

@keyframes gradientDrift {
  0%   { background-position: 0% 50%,   0% 50%; }
  50%  { background-position: 100% 50%, 100% 50%; }
  100% { background-position: 0% 50%,   0% 50%; }
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 16px; }

/* Header / Nav */
header .brand {
  display:flex; align-items:center; justify-content: space-between; padding: 8px 0;
}
.logo {
  font-weight: 800; font-size: 22px;
  color: #fff;
  letter-spacing: 0.2px;
  display: inline-block;
}
header .brand .nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
}
html[data-theme="light"] header .brand .nav {
  background: #ffffff;
}
.nav-link { margin: 0 4px; color: var(--text); opacity: .9; padding: 6px 10px; border-radius: 999px; }
.nav-link:hover { opacity: 1; background: rgba(255,255,255,0.08); text-decoration: none; }

/* Language switch - pill with globe + arrow icons, improved accessibility */
#lang-switch {
  -webkit-appearance: none;
  appearance: none;
  height: 38px;
  min-width: 96px;
  padding: 8px 40px 8px 38px; /* left for globe, right for arrow */
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background-color: rgba(255,255,255,0.10);
  color: inherit;
  line-height: 1.2;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: .01em;
  transition: box-shadow .2s, border-color .2s, background-color .2s, transform .06s;
  /* Globe (left) + Arrow (right) for dark theme/default */
  background-image:
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" stroke="%23E6EAF2" fill="none" viewBox="0 0 24 24" stroke-width="1.8"><circle cx="12" cy="12" r="9"/><path d="M12 3c2.5 3 2.5 15 0 18M3 12h18"/></svg>'),
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="%23E6EAF2" stroke-width="2" viewBox="0 0 24 24"><path d="M6 9l6 6 6-6"/></svg>');
  background-repeat: no-repeat, no-repeat;
  background-position: left 12px center, right 12px center;
  background-size: 16px 16px, 16px 16px;
}
#lang-switch:hover {
  background-color: rgba(255,255,255,0.14);
  border-color: var(--primary);
}
#lang-switch:active {
  transform: translateY(1px);
}
#lang-switch:focus,
#lang-switch:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-color: var(--primary);
  background-color: rgba(255,255,255,0.14);
}
/* Light theme variant: solid bg and darker icons */
html[data-theme="light"] #lang-switch {
  background-color: #ffffff;
  border-color: var(--card-border);
  color: var(--text);
  background-image:
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" stroke="%230F172A" fill="none" viewBox="0 0 24 24" stroke-width="1.8"><circle cx="12" cy="12" r="9"/><path d="M12 3c2.5 3 2.5 15 0 18M3 12h18"/></svg>'),
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="%230F172A" stroke-width="2" viewBox="0 0 24 24"><path d="M6 9l6 6 6-6"/></svg>');
}

/* Layout grid */
.grid { display: grid; grid-template-columns: 1fr; gap: 24px; align-items: start; }
@media (min-width: 960px) { .grid { grid-template-columns: 1.15fr 0.85fr; } }

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: none;
}
.card.small { max-width: 420px; margin: 40px auto; }

.hero-title { font-size: 32px; margin: 0 0 6px; line-height: 1.15; }
.hero-subtitle { color: var(--muted); margin: 0 0 16px; }

/* Forms */
.form label { display:block; margin: 10px 0; }
.form span { display: block; margin-bottom: 6px; font-size: 14px; color: var(--muted); }
.form input[type="email"], .form input[type="text"], .form input[type="password"], .form textarea, .form select {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.04); color: inherit; outline: none; transition: box-shadow .2s, border-color .2s, background .2s;
}

/* Enhanced select: custom arrow and improved hit target */
.form select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="%23E6EAF2" stroke-width="2" viewBox="0 0 24 24"><path d="M6 9l6 6 6-6"/></svg>');
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  padding-right: 38px;
  cursor: pointer;
}
.form select:focus {
  box-shadow: var(--focus);
  border-color: var(--primary);
  background: rgba(255,255,255,0.06);
}
.form input::placeholder, .form textarea::placeholder { color: var(--muted); opacity: .8; }
.form input:focus, .form textarea:focus, .form select:focus { box-shadow: var(--focus); border-color: var(--primary); background: rgba(255,255,255,0.06); }

/* Dropzone */
.dropzone {
  border: 2px dashed rgba(99,102,241,0.35);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 14px;
  background: rgba(255,255,255,0.03);
  transition: background .2s, border-color .2s, transform .08s;
}
.dropzone:hover { border-color: var(--primary); background: rgba(99,102,241,0.06); }
.dropzone.drag { border-color: var(--accent); background: rgba(34,211,238,0.08); transform: scale(1.01); }
.dropzone input[type="file"] { display:none; }
.dropzone .dz-icon {
  width: 42px; height: 42px; margin: 0 auto 6px; display:block; opacity: .9;
}
.dropzone p { margin: 6px 0 0; }

/* Queue */
.queue .item {
  display:flex; align-items:center; gap: 12px; padding: 10px;
  border-bottom: 1px dashed var(--card-border);
}
.queue .item .name { flex:1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .item .pct { min-width: 42px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.queue .item .file-icn { width: 18px; height: 18px; display:inline-block; opacity: .9; }

/* Progress bars */
.progress { height: 8px; background: rgba(255,255,255,0.07); border-radius: 999px; overflow: hidden; flex:1; position: relative; }
.progress .bar { height: 100%; background: var(--gradient); width: 0%; transition: width .2s; }

.overall-wrap {
  margin-top: 8px; display:none; align-items:center; gap: 10px;
}
.overall-wrap.show { display: flex; }
.overall-wrap .label { color: var(--muted); font-size: 13px; width: 110px; }
.overall-wrap .pct { min-width: 42px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Rows and mode */
.row { display:flex; gap: 10px; }
@media (max-width: 640px) { .row { flex-direction: column; } }
.mode { border: 1px dashed var(--card-border); border-radius: var(--radius-sm); padding: 10px; margin-top: 8px; }
.mode legend { font-size: 13px; color: var(--muted); }
.mode label { margin-right: 14px; }

.actions { margin-top: 12px; display:flex; gap:10px; flex-wrap: wrap; }

/* Buttons */
.btn {
  border: none; border-radius: 999px; padding: 10px 16px;
  background: rgba(255,255,255,0.08); color:#fff; cursor: pointer;
  transition: transform .06s ease-out, box-shadow .2s, background .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--gradient); color: #fff; }
.btn.primary:hover { box-shadow: 0 8px 24px rgba(99,102,241,0.35); }
.btn.small { padding: 6px 10px; }
.btn.ghost { background: transparent; border: 1px solid var(--card-border); }
.btn.success { background: linear-gradient(135deg, var(--success), #16a34a); }
.btn.danger  { background: linear-gradient(135deg, var(--danger), #dc2626); }

/* Side graphic */
.side-graphic img { width: 100%; border-radius: var(--radius); display:block; box-shadow: var(--shadow-soft); }

/* Footer */
.footer { margin-top: 28px; padding: 20px 0; color: var(--muted); font-size: 14px; }

/* Tables (admin) */
.table { width: 100%; border-collapse: collapse; background: transparent; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--card-border); text-align: left; }
.table th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 12px; letter-spacing: .02em; }

/* Badges */
.badge {
  display:inline-block; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--card-border); color: var(--muted); background: rgba(255,255,255,0.04);
}
.badge.status-active { color: #10b981; border-color: rgba(16,185,129,0.35); background: rgba(16,185,129,0.08); }
.badge.status-pending { color: #f59e0b; border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.08); }
.badge.status-expired { color: #a78bfa; border-color: rgba(167,139,250,0.35); background: rgba(167,139,250,0.08); }
.badge.status-deleted { color: #ef4444; border-color: rgba(239,68,68,0.35); background: rgba(239,68,68,0.08); }
.badge.status-failed  { color: #ef4444; border-color: rgba(239,68,68,0.35); background: rgba(239,68,68,0.08); }

/* Utilities */
.right { float: right; }
.muted { color: var(--muted); }
.small { width: 64px; }

/* Focus ring for keyboard users */
:focus-visible { outline: none; box-shadow: var(--focus) !important; }

/* Toasts */
#toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--card); border: 1px solid var(--card-border); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 12px; box-shadow: var(--shadow-soft); display: flex; align-items: center; gap: 10px;
  animation: toast-in .18s ease-out;
}
.toast.success { border-color: rgba(34,197,94,0.35); }
.toast.error   { border-color: rgba(239, 68, 68, 0.35); }
.toast.info    { border-color: rgba(99,102,241,0.35); }
.toast .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.toast.success .dot { background: var(--success); }
.toast.error .dot { background: var(--danger); }
.toast.info .dot { background: var(--primary); }
@keyframes toast-in { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Transfer page specifics */
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 16px 0; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; }

.password-gate { background: rgba(239,68,68,0.08); border: 1px dashed rgba(239,68,68,0.35); padding: 12px; border-radius: var(--radius-sm); margin: 8px 0 12px; }

.error { color: #fca5a5; margin: 8px 0; }

/* Accessibility helpers */
.visually-hidden { position: absolute !important; clip: rect(1px,1px,1px,1px); clip-path: inset(50%); height: 1px; width: 1px; overflow: hidden; white-space: nowrap; }