 :root{
    --color-bg:            #0b1220;
    --color-surface:       rgba(238, 233, 223, 0.05);
    --color-border:        rgba(238, 233, 223, 0.12);
    --color-text:          #eee9df;
    --color-text-muted:    #9aa2b6;
    --color-brass:         #c9a24b;
    --color-brass-strong:  #e0b968;
    --color-teal:           #31584f;
    --font-display: 'Fraunces', Georgia, serif;
    --font-mono:    'IBM Plex Mono', 'Courier New', monospace;
    --radius-md: 16px;
    --radius-sm: 10px;
  }

  *{ box-sizing: border-box; }
  html, body{ height:100vh; }
  body{
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    background:
      radial-gradient(1000px 620px at 12% -10%, rgba(49,88,79,0.32), transparent 60%),
      radial-gradient(800px 560px at 100% 110%, rgba(201,162,75,0.12), transparent 55%),
      var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
  }

  .page{
    width: 100%;
    max-width: 650px;
  }

  .back-link{
    display: inline-flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 22px;
    color: var(--color-text-muted);
    text-decoration: none;
    margin-bottom: 5vh;
    transition: color 0.2s ease;
  }
    .back-link span{
    font-size: 14px;
    margin-left: 6px;
    margin-top: 4px;
    letter-spacing: 0.05em;
    text-transform: none;
  }
  .back-link:hover{ color: var(--color-brass); }

  .chat-card{
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: 0 20px 45px rgba(0,0,0,0.35);
  }

  .chat-header{
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
  }
  .chat-avatar{
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(201,162,75,0.22), rgba(49,88,79,0.28));
    color: var(--color-brass);
    font-family: var(--font-display);
    font-size: 18px;
    flex-shrink: 0;
  }
  .chat-title h1{
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 500;
    margin: 0;
  }
  .chat-title p{
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .status-dot{
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #4caf50;
    display: inline-block;
    animation: pulse 2.2s infinite;
  }
  @keyframes pulse{
    0%{ box-shadow: 0 0 0 0 rgba(76,175,80,0.55); }
    70%{ box-shadow: 0 0 0 6px rgba(76,175,80,0); }
    100%{ box-shadow: 0 0 0 0 rgba(76,175,80,0); }
  }

  #chat-box{
    height: 400px;
    overflow-y: auto;
    padding: 6px 4px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  #chat-box::-webkit-scrollbar{ width: 6px; }
  #chat-box::-webkit-scrollbar-thumb{ background: var(--color-border); border-radius: 4px; }

  .msg{
    max-width: 78%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
  }
  .msg strong{ color: var(--color-brass-strong); font-weight: 600; }
  .msg .sender{
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 4px;
    opacity: 0.7;
  }

  .msg.user{
    align-self: flex-end;
    background: rgba(201,162,75,0.16);
    border: 1px solid rgba(201,162,75,0.3);
    color: var(--color-text);
  }
  .msg.bot{
    align-self: flex-start;
    background: rgba(49,88,79,0.22);
    border: 1px solid rgba(49,88,79,0.4);
    color: var(--color-text);
  }
  .msg.error{
    align-self: flex-start;
    background: rgba(220,80,80,0.12);
    border: 1px solid rgba(220,80,80,0.4);
    color: #ffb4b4;
  }

  /* Typing indicator */
  .typing-dots{
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
  }
  .typing-dots span{
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--color-text-muted);
    animation: bounce 1.2s infinite ease-in-out;
  }
  .typing-dots span:nth-child(2){ animation-delay: 0.15s; }
  .typing-dots span:nth-child(3){ animation-delay: 0.3s; }
  @keyframes bounce{
    0%, 60%, 100%{ transform: translateY(0); opacity: 0.5; }
    30%{ transform: translateY(-4px); opacity: 1; }
  }

  .input-row{
    display: flex;
    gap: 10px;
  }
  #userInput{
    flex: 1;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: rgba(255,255,255,0.03);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
  }
  #userInput::placeholder{ color: var(--color-text-muted); }
  #userInput:focus{ border-color: var(--color-brass); }
  #userInput:disabled{ opacity: 0.6; }

  #sendBtn{
    padding: 12px 22px;
    background: linear-gradient(135deg, var(--color-brass) 0%, var(--color-brass-strong) 100%);
    color: #17110a;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  #sendBtn:hover:not(:disabled){ transform: translateY(-2px); }
  #sendBtn:disabled{ opacity: 0.55; cursor: not-allowed; transform: none; }

  a:focus-visible, button:focus-visible, input:focus-visible{
    outline: 2px solid var(--color-brass);
    outline-offset: 2px;
  }

  @media (max-width: 480px){
    .msg{ max-width: 88%; }
  }