<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PRISM — Login</title>
<link rel="stylesheet" href="/css/prism.css">
<style>
  body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
  .login-box {
    text-align: center;
    max-width: 360px;
    width: 100%;
    padding: 0 24px;
  }
  .login-box svg { height: 40px; width: auto; margin-bottom: 32px; }
  .login-box h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: rgba(255,255,255,0.9);
  }
  .login-box p {
    font-size: 13px;
    color: rgba(255,255,255,0.4);
    margin-bottom: 28px;
  }
  .login-input {
    width: 100%;
    font-family: var(--font);
    font-size: 15px;
    color: var(--white);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 14px 20px;
    outline: none;
    text-align: center;
    letter-spacing: 2px;
    transition: all 0.2s;
    margin-bottom: 16px;
  }
  .login-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0,0,255,0.15);
  }
  .login-input::placeholder { letter-spacing: 0; }
  .login-btn {
    width: 100%;
    padding: 14px;
    background: var(--blue);
    color: white;
    border: none;
    border-radius: 10px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
  }
  .login-btn:hover { background: var(--blue-light); }
  .login-error {
    margin-top: 16px;
    font-size: 13px;
    color: var(--red);
    display: none;
  }
</style>
</head>
<body>
<div class="login-box">
  <svg viewBox="0 0 515.51 183.1" xmlns="http://www.w3.org/2000/svg"><g><path fill="#fff" d="M158.75,110.91l.05-45.79c0-.96.38-1.78,1.14-2.46.76-.69,1.69-1.03,2.79-1.03l32.19.04c17.02.02,25.52,6.86,25.5,20.53-.02,13.67-8.53,20.49-25.55,20.47l-20.21-.02v8.28c-.01.96-.4,1.77-1.17,2.44-.77.67-1.71,1.01-2.81,1.01h-7.93c-1.1-.01-2.04-.35-2.82-1.02-.79-.67-1.18-1.49-1.18-2.45ZM174.68,92.24l15.4.02c4.72,0,8.31-.68,10.76-2.07,2.45-1.38,3.68-4.05,3.68-8.01,0-3.96-1.22-6.63-3.66-8.02-2.44-1.39-6.03-2.08-10.76-2.09l-15.4-.02-.02,20.19Z"/><path fill="#fff" d="M290.97,112.93c0,1.05-.72,1.58-2.15,1.58h-10.13c-1.07-.01-2.24-.35-3.52-1.03-1.28-.68-2.26-1.49-2.93-2.45l-7.16-9.79c-2.95-4.02-6.52-6.04-10.71-6.04h-10.29s-.02,15.8-.02,15.8c0,.96-.39,1.77-1.16,2.44-.77.67-1.71,1.01-2.81,1.01h-7.93c-1.1-.01-2.04-.35-2.82-1.02-.79-.67-1.18-1.49-1.18-2.45l.05-45.79c0-.96.38-1.78,1.14-2.46.76-.69,1.69-1.03,2.79-1.03l34.81.04c6.44,0,11.72,1.52,15.84,4.54,4.12,3.02,6.17,7.09,6.17,12.22,0,7.13-5.32,11.6-15.92,13.41,1.69.54,3.25,1.47,4.68,2.78,1.43,1.31,3.08,3.22,4.93,5.72l7.67,10.64c.45.69.67,1.31.67,1.88ZM244.09,84.78l17.97.02c2.9,0,5.45-.5,7.66-1.5,2.21-1,3.31-2.61,3.32-4.81,0-2.21-1.1-3.82-3.31-4.82-2.21-1.01-4.76-1.51-7.66-1.52l-17.97-.02-.02,12.65Z"/><path fill="#fff" d="M297.98,111.14l.05-45.86c0-.96.39-1.78,1.18-2.46.79-.68,1.73-1.03,2.83-1.03h7.85c1.15.01,2.12.36,2.89,1.04.77.69,1.16,1.51,1.16,2.47l-.05,45.79c0,.96-.4,1.77-1.21,2.44-.8.67-1.75,1.01-2.85,1.01h-7.85c-1.1-.01-2.04-.34-2.82-.99-.79-.65-1.18-1.45-1.18-2.41Z"/><path fill="#fff" d="M322.55,101.06c0-1.45.49-2.48,1.48-3.11.98-.62,1.94-.94,2.87-.94h5.02c2.53,0,4.46,1.21,5.78,3.62,1.32,2.4,4.28,3.61,8.9,3.61l14.77.27c4.95,0,7.43-1.4,7.43-4.22,0-2.13-3.02-3.82-9.07-5.05-2.7-.57-5.68-1.13-8.94-1.68-3.26-.56-6.5-1.25-9.72-2.09-3.22-.84-6.18-1.82-8.88-2.95-2.7-1.13-4.89-2.68-6.56-4.66-1.67-1.97-2.5-4.3-2.5-6.97,0-4.93,2.02-8.72,6.05-11.38,4.03-2.66,10.95-3.98,20.76-3.97l10.72.23c5.77,0,10.96,1.31,15.58,3.9,4.62,2.59,6.93,5.83,6.93,9.7,0,1.45-.5,2.49-1.48,3.12-.99.64-1.93.95-2.83.95h-5.02c-2.53,0-4.46-1.22-5.78-3.63-1.32-2.42-4.28-3.63-8.9-3.63l-12.7-.23c-4.95,0-7.43,1.4-7.43,4.22,0,1.54,1.56,2.81,4.7,3.79,3.13.98,6.93,1.85,11.39,2.61,4.46.75,8.94,1.66,13.43,2.72,4.5,1.06,8.31,2.8,11.45,5.22,3.13,2.42,4.7,5.43,4.69,9.03,0,4.93-2.03,8.72-6.07,11.38-4.04,2.66-10.95,3.98-20.74,3.97l-12.78-.24c-5.77,0-10.97-1.3-15.61-3.9-4.64-2.59-6.95-5.83-6.95-9.7Z"/><path fill="#fff" d="M393.29,111.1l.05-45.64c0-1,.38-1.85,1.14-2.54.76-.69,1.69-1.03,2.79-1.03l17.17.02c1.1,0,2.14.35,3.12,1.03.98.69,1.64,1.51,1.98,2.47l12.41,31.42,12.48-31.4c.34-.96,1-1.78,1.98-2.46.99-.68,2.03-1.03,3.12-1.03l17.17.02c1.1,0,2.02.35,2.76,1.03.74.69,1.11,1.53,1.11,2.54l-.05,45.64c0,1.01-.39,1.85-1.16,2.52-.77.67-1.71,1.01-2.81,1.01h-7.59c-1.1-.01-2.03-.35-2.8-1.02-.77-.67-1.16-1.51-1.16-2.52l.04-35.93-14.94,36.14c-.39.91-1.08,1.69-2.07,2.33-.98.65-2.03.97-3.12.97h-6.03c-1.1,0-2.13-.33-3.1-.98-.97-.65-1.66-1.43-2.09-2.34l-14.81-36.17-.04,35.93c0,1.01-.39,1.85-1.16,2.52-.77.67-1.71,1.01-2.81,1.01h-7.59c-1.1-.01-2.04-.35-2.82-1.02-.79-.67-1.18-1.51-1.18-2.52Z"/></g><g><path fill="#fff" d="M76.84,58.26c-.65-8.78-8.29-15.38-17.08-14.73-.06,0-.11.02-.17.02-4.1.27-7.99,2.2-10.68,5.4-1.87,2.14-3.15,4.78-3.66,7.67,0,0,0,0,0,0-.15.82-.24,1.66-.26,2.51,0,.04,0,.08,0,.12,0,.45,0,.89.03,1.35.02.26.06.52.1.77.02.17.04.34.06.51.11.72.27,1.43.47,2.12.04.14.09.27.14.41.21.64.45,1.26.74,1.85.05.1.09.21.14.31.33.66.72,1.29,1.13,1.9.09.13.18.25.27.38.46.62.95,1.21,1.48,1.76,0,0,.02.02.03.03,1.22,1.22,2.28,2.59,3,4.16.42.92.78,1.9,1.04,2.97.94,3.81,1.08,16.7.16,20.45-.19.77-.4,1.44-.62,2.07,4.11-2.3,9.1-2.79,13.62-1.28l-.29-22.27c-.02-1.46,1.05-2.72,2.16-3.34.15-.09.29-.18.44-.27.23-.14.46-.27.68-.42,1.85-1.19,3.39-2.6,4.58-4.52.63-1.03,1.17-2.12,1.61-3.25.03-.07.02-.17.04-.25.7-2,1.01-4.17.85-6.42Z"/><path fill="#fff" d="M103.59,102.21c7.84,4.01,17.45.9,21.46-6.94.03-.05.04-.1.07-.15,1.9-3.64,2.27-7.96.93-11.93-.86-2.71-2.45-5.17-4.65-7.11,0,0,0,0,0,0-.62-.55-1.29-1.07-2.01-1.52-.04-.02-.07-.04-.11-.06-.38-.24-.76-.47-1.17-.67-.23-.12-.47-.21-.71-.32-.16-.07-.31-.14-.47-.21-.68-.28-1.36-.51-2.05-.7-.14-.04-.28-.06-.42-.09-.65-.15-1.31-.26-1.97-.33-.11-.01-.22-.03-.33-.04-.74-.06-1.48-.06-2.21-.02-.15,0-.31.02-.46.03-.77.07-1.53.18-2.27.35-.01,0-.03,0-.04,0-1.68.4-3.4.61-5.11.4-1.01-.12-2.03-.33-3.07-.65-3.74-1.17-14.83-7.75-17.56-10.49-.56-.56-1.02-1.09-1.45-1.61-.17,4.7-2.34,9.22-5.98,12.3l19.18,11.32c1.26.74,1.78,2.31,1.73,3.58,0,.17,0,.34,0,.51,0,.27,0,.53,0,.8.05,2.2.46,4.25,1.49,6.26.55,1.08,1.2,2.1,1.94,3.06.05.06.14.11.19.17,1.35,1.64,3.04,3.04,5.05,4.06Z"/><path fill="#fff" d="M52.13,103.9c-7.34,4.87-9.34,14.76-4.47,22.1.03.05.07.09.1.14,2.24,3.44,5.83,5.88,9.94,6.66,2.78.58,5.71.4,8.48-.56,0,0,0,0,0,0,.79-.27,1.56-.6,2.31-1.01.04-.02.07-.04.11-.06.39-.21.78-.44,1.16-.69.22-.15.42-.31.63-.46.14-.1.28-.2.41-.3.58-.45,1.12-.93,1.61-1.45.1-.1.19-.21.29-.32.45-.49.87-1.01,1.25-1.55.06-.09.14-.18.2-.27.41-.61.77-1.26,1.1-1.92.07-.14.13-.28.2-.42.32-.7.59-1.42.8-2.15,0-.01.01-.02.01-.04.47-1.66,1.14-3.26,2.16-4.65.6-.82,1.28-1.61,2.08-2.36,2.86-2.68,14.03-9.12,17.75-10.16.76-.21,1.45-.36,2.11-.47-4.01-2.46-6.89-6.56-7.79-11.25l-19.27,11.16c-1.26.73-2.88.42-3.97-.25-.15-.09-.3-.16-.45-.25-.23-.13-.46-.27-.7-.39-1.94-1.03-3.93-1.69-6.19-1.77-1.21-.05-2.42.02-3.62.19-.07.01-.16.07-.24.08-2.09.37-4.14,1.16-6.02,2.41Z"/></g></svg>
  <h2>Welcome to PRISM</h2>
  <p>Enter the access password to continue</p>
  <form id="loginForm">
    <input type="password" class="login-input" id="password" placeholder="Password" autofocus>
    <button type="submit" class="login-btn">Enter</button>
  </form>
  <div class="login-error" id="error">Invalid password. Try again.</div>
</div>

<script>
document.getElementById('loginForm').addEventListener('submit', async (e) => {
  e.preventDefault();
  const password = document.getElementById('password').value;
  const errorEl = document.getElementById('error');
  errorEl.style.display = 'none';

  try {
    const res = await fetch('/api/login', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ password })
    });

    if (res.ok) {
      window.location.href = '/';
    } else {
      errorEl.style.display = 'block';
      document.getElementById('password').value = '';
      document.getElementById('password').focus();
    }
  } catch (err) {
    errorEl.textContent = 'Connection error. Try again.';
    errorEl.style.display = 'block';
  }
});
</script>
</body>
</html>
