* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --ocean-primary: #0f172a;
  --ocean-secondary: #1e293b;
  --ocean-accent: #0ea5e9;
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --shadow-premium: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  background: radial-gradient(ellipse at bottom, var(--ocean-secondary) 0%, var(--ocean-primary) 100%);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  overflow: hidden;
  line-height: 1.5;
}

.ocean-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.depth-layer {
  position: absolute;
  width: 120%;
  height: 120%;
  border-radius: 50%;
  animation: float 20s ease-in-out infinite;
  opacity: 0.12;
  will-change: transform;
}

.depth-layer:nth-child(1) {
  background: radial-gradient(circle, #0ea5e9 0%, transparent 70%);
  top: 10%;
  left: -10%;
  animation-delay: 0s;
  animation-duration: 25s;
}

.depth-layer:nth-child(2) {
  background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
  bottom: 10%;
  right: -10%;
  animation-delay: -8s;
  animation-duration: 30s;
}

.depth-layer:nth-child(3) {
  background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
  top: 50%;
  left: 30%;
  animation-delay: -15s;
  animation-duration: 35s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
  25% { transform: translate(-20px, -30px) rotate(1deg) scale(1.05); }
  50% { transform: translate(30px, 20px) rotate(-1deg) scale(0.95); }
  75% { transform: translate(-10px, 40px) rotate(0.5deg) scale(1.02); }
}

.particle {
  position: absolute;
  width: 2px;
  height: 2px;
  background: #0ea5e9;
  border-radius: 50%;
  opacity: 0;
  animation: particle-float 15s linear infinite;
}

@keyframes particle-float {
  0% {
    opacity: 0;
    transform: translateY(100vh) translateX(0) scale(0);
  }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translateY(-100px) translateX(100px) scale(1);
  }
}

.login-container {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 38px 34px;
  background: var(--glass-bg);
  backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 32px;
  box-shadow: var(--shadow-premium), inset 0 1px 0 rgba(255,255,255,0.05);
  z-index: 100;
  position: relative;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  animation: containerEntrance 1.2s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes containerEntrance {
  0% {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
    filter: blur(10px);
  }
  100% {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

.login-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 32px;
  padding: 1px;
  background: linear-gradient(145deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02));
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: xor;
  -webkit-mask-composite: xor;
  pointer-events: none;
}

h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.3px;
  margin-top: 18px;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.glass-panel {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 16px 16px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: relative;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(14, 165, 233, 0.12);
  color: rgba(255,255,255,0.95);
  font-weight: 650;
  letter-spacing: 0.2px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin: 10px 0;
}

.kv > div { min-width: 220px; }

.row { margin: 12px 0; }
.muted { color: var(--text-secondary); }

code, pre {
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  color: var(--text-primary);
}

code {
  padding: 3px 10px;
  display: inline-block;
  backdrop-filter: blur(10px);
}

pre {
  padding: 14px;
  overflow-x: auto;
  margin-top: 10px;
}

a { color: #7dd3fc; text-decoration: none; }
a:hover { color: #38bdf8; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 32px rgba(14, 165, 233, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(14, 165, 233, 0.35);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 16px 48px rgba(14, 165, 233, 0.20);
}

.btn:active {
  transform: translateY(0);
  transition-duration: 0.1s;
}

.btn-cta {
  width: 100%;
  height: 54px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 14px 44px rgba(0,0,0,0.35);
  font-weight: 800;
  letter-spacing: 0.2px;
}

.btn-cta:hover {
  transform: translateY(-1px);
  border-color: rgba(14, 165, 233, 0.45);
  background: rgba(0, 0, 0, 0.45);
  box-shadow: 0 18px 54px rgba(14, 165, 233, 0.18);
}

select {
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.08) !important;
  color: var(--text-primary) !important;
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.mode-baseline {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.mode-baseline .mode-card {
  width: min(360px, 100%);
}

.mode-grid-tests {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

@media (max-width: 860px) {
  .mode-grid-tests {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

.mode-card {
  position: relative;
}

.mode-start {
  width: 100%;
}

.mode-info {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255,255,255,0.9);
  font-weight: 700;
  font-size: 14px;
  line-height: 26px;
  text-align: center;
  cursor: pointer;
}

.mode-info:hover {
  border-color: rgba(14, 165, 233, 0.45);
  background: rgba(0, 0, 0, 0.45);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.page-header h1 {
  margin-bottom: 0;
}

.page-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255,255,255,0.95);
  font-weight: 800;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: rgba(14, 165, 233, 0.45);
  background: rgba(0, 0, 0, 0.45);
}

.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  width: min(420px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: start;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 18px 60px rgba(0,0,0,0.45);
  transform: translateX(22px);
  opacity: 0;
  animation: toast-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.toast-out {
  animation: toast-out 240ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

@keyframes toast-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(22px); opacity: 0; }
}

.toast-icon {
  width: 28px;
  height: 28px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.toast-icon svg {
  width: 16px;
  height: 16px;
}

.toast-title {
  font-weight: 800;
  font-size: 14px;
  line-height: 1.2;
  margin-top: 2px;
}

.toast-msg {
  color: rgba(255,255,255,0.78);
  font-size: 13px;
  margin-top: 4px;
}

.toast-close {
  width: 28px;
  height: 28px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.86);
  cursor: pointer;
  line-height: 26px;
  font-size: 18px;
  font-weight: 700;
}

.toast-close:hover {
  border-color: rgba(14, 165, 233, 0.45);
  background: rgba(0, 0, 0, 0.45);
}

.toast-info { border-left: 3px solid rgba(14, 165, 233, 0.85); }
.toast-warn { border-left: 3px solid rgba(251, 191, 36, 0.85); }
.toast-success { border-left: 3px solid rgba(34, 197, 94, 0.85); }
.toast-error { border-left: 3px solid rgba(239, 68, 68, 0.85); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal {
  width: min(720px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  padding: 14px 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-title {
  font-weight: 750;
  letter-spacing: -0.2px;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  font-size: 18px;
}

.modal-close:hover {
  border-color: rgba(14, 165, 233, 0.45);
}

.modal-body {
  color: rgba(255,255,255,0.9);
}

.modal-figure {
  margin-bottom: 10px;
}

.mode-figure {
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  display: block;
}

table { border-collapse: collapse; width: 100%; overflow: hidden; border-radius: 14px; }
th, td { border-bottom: 1px solid rgba(255,255,255,0.08); padding: 10px 10px; text-align: left; }
th { color: var(--text-secondary); font-weight: 650; }

@media (max-width: 520px) {
  .login-container {
    padding: 26px 18px;
    border-radius: 26px;
  }
  h1 { font-size: 28px; }
  .btn { width: 100%; }
}

@media (max-height: 700px) {
  .login-container { padding: 26px 26px; }
}

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