:root{
    --bg: #0c0c0d;
    --bg-elevated: #17181a;
    --bg-input: #1f2023;
    --border: #2a2b2e;
    --gold: #c79c03;
    --gold-hover: #e0b108;
    --text: #f2f2f0;
    --text-secondary: #9aa4ad;
    --text-muted: #5e6c7b;
    --danger: #ff4d4d;
  }

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

  body{
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
  }

  .screen{
    display:none;
    height:100vh;
    width:100vw;
    animation: fadeIn .35s ease;
  }
  .screen.active{ display:flex; }

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

  /* ---------- LOGIN ---------- */
  #login-screen{
    align-items:center;
    justify-content:center;
    flex-direction:column;
    background:
      radial-gradient(circle at 50% -10%, rgba(199,156,3,0.08), transparent 45%),
      var(--bg);
  }

  .login-box{
    width: 100%;
    max-width: 380px;
    padding: 0 24px;
    text-align:center;
  }

  .brand-mark{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:56px; height:56px;
    margin-bottom:20px;
  }

  .brand-mark img{
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
  }

  .brand-mark-sm{
    display:inline-flex;
    align-items:center;
    width:18px; height:18px;
  }

  .brand-mark-sm img{
    width:100%;
    height:100%;
    object-fit:contain;
    filter: brightness(0) invert(1);
  }

  .login-box h1{
    font-size: 22px;
    font-weight:600;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
  }

  .login-box p.subtitle{
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 32px;
  }

  .field{
    text-align:left;
    margin-bottom: 14px;
  }

  .field label{
    display:block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
  }

  .field input{
    width:100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    outline:none;
    transition: border-color .15s ease, box-shadow .15s ease;
  }

  .field input:focus{
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(199,156,3,0.15);
  }

  .btn-primary{
    width:100%;
    padding: 12px;
    margin-top: 8px;
    background: var(--gold);
    color: #14140f;
    border:none;
    border-radius: 10px;
    font-size: 14px;
    font-weight:600;
    cursor:pointer;
    transition: background .15s ease, transform .1s ease;
  }
  .btn-primary:hover{ background: var(--gold-hover); }
  .btn-primary:active{ transform: scale(0.99); }

  .login-error{
    display:none;
    text-align:left;
    font-size: 12.5px;
    color: var(--danger);
    margin-top: 10px;
  }
  .login-error.show{ display:block; }

  .login-footer{
    margin-top: 22px;
    font-size: 12.5px;
    color: var(--text-muted);
  }

  /* ---------- BRIEFING ---------- */
  #briefing-screen{
    flex-direction:column;
    align-items:center;
    width:100%;
  }

  .briefing-topbar{
    width:100%;
    display:flex;
    align-items:center;
    gap:10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight:600;
    color: var(--text-secondary);
    flex-shrink:0;
  }

  .briefing-scroll{
    flex:1;
    width:100%;
    overflow-y:auto;
    display:flex;
    justify-content:center;
  }

  .briefing-box{
    width:100%;
    max-width: 560px;
    padding: 32px 24px 24px;
  }

  .briefing-box h1{
    font-size: 22px;
    font-weight:600;
    margin-bottom: 8px;
  }

  .briefing-box .subtitle{
    color: var(--text-muted);
    font-size: 13.5px;
    line-height:1.5;
    margin-bottom: 28px;
  }

  .b-field{
    margin-bottom: 20px;
  }

  .b-field label{
    display:block;
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height:1.4;
  }

  .b-field .req{ color: var(--gold); }

  .b-field input,
  .b-field textarea{
    width:100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline:none;
    resize: vertical;
    transition: border-color .15s ease, box-shadow .15s ease;
  }

  .b-field input:focus,
  .b-field textarea:focus{
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(199,156,3,0.15);
  }

  .b-field.field-missing input,
  .b-field.field-missing textarea{
    border-color: var(--danger);
  }

  .briefing-error{
    display:none;
    font-size: 13px;
    color: var(--danger);
    background: rgba(255,77,77,0.08);
    border: 1px solid rgba(255,77,77,0.25);
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: 8px;
  }
  .briefing-error.show{ display:block; }

  .briefing-footer{
    width:100%;
    display:flex;
    justify-content:center;
    padding: 16px 24px 22px;
    border-top: 1px solid var(--border);
    flex-shrink:0;
  }

  /* ---------- CHAT ---------- */
  #chat-screen{
    flex-direction:column;
    align-items:center;
    width:100%;
  }

  .chat-topbar{
    width:100%;
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
  }

  .chat-topbar .brand{
    display:flex;
    align-items:center;
    gap:10px;
    font-size: 14px;
    font-weight:600;
    color: var(--text-secondary);
  }

  .chat-topbar .brand .dot{
    width:8px; height:8px;
    border-radius:50%;
    background: var(--gold);
  }

  .logout-link{
    font-size: 13px;
    color: var(--text-muted);
    cursor:pointer;
    text-decoration:none;
    transition: color .15s ease;
  }
  .logout-link:hover{ color: var(--text-secondary); }

  .chat-body{
    flex:1;
    width:100%;
    max-width: 720px;
    display:flex;
    flex-direction:column;
    justify-content:center;
    padding: 20px;
    overflow-y:auto;
  }

  .chat-empty{
    text-align:center;
    margin-bottom: 28px;
  }

  .chat-empty h2{
    font-size: 24px;
    font-weight:600;
    margin-bottom:8px;
  }

  .chat-empty p{
    color: var(--text-muted);
    font-size: 14px;
  }

  .messages{
    display:flex;
    flex-direction:column;
    gap: 16px;
    width:100%;
  }

  .msg{
    max-width: 78%;
    padding: 11px 15px;
    border-radius: 14px;
    font-size: 14.5px;
    line-height:1.5;
  }

  .msg.user{
    align-self:flex-end;
    background: var(--gold);
    color: #14140f;
    border-bottom-right-radius: 4px;
  }

  .msg.ai{
    align-self:flex-start;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
  }

  .chat-inputbar{
    width:100%;
    max-width: 720px;
    padding: 16px 20px 24px;
  }

  .input-shell{
    display:flex;
    align-items:flex-end;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px 10px 10px 18px;
    transition: border-color .15s ease;
  }

  .input-shell:focus-within{
    border-color: var(--gold);
  }

  .input-shell textarea{
    flex:1;
    background:none;
    border:none;
    outline:none;
    resize:none;
    color: var(--text);
    font-size: 14.5px;
    font-family: inherit;
    max-height: 160px;
    line-height:1.5;
    padding: 6px 0;
  }

  .input-shell textarea::placeholder{
    color: var(--text-muted);
  }

  .send-btn{
    width:34px; height:34px;
    border-radius:10px;
    border:none;
    background: var(--gold);
    color:#14140f;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    flex-shrink:0;
    transition: background .15s ease;
  }
  .send-btn:hover{ background: var(--gold-hover); }
  .send-btn svg{ width:16px; height:16px; }

  .chat-hint{
    text-align:center;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 10px;
  }

  .attach-btn{
    width:34px; height:34px;
    border-radius:10px;
    border:none;
    background: transparent;
    color: var(--text-secondary);
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    flex-shrink:0;
    transition: background .15s ease, color .15s ease;
  }
  .attach-btn:hover{ background: var(--bg-elevated); color: var(--text); }
  .attach-btn svg{ width:18px; height:18px; }

  .attachments-row{
    display:flex;
    flex-wrap:wrap;
    gap: 8px;
    margin-bottom: 10px;
  }
  .attachments-row:empty{ display:none; margin:0; }

  .attachment-chip{
    display:flex;
    align-items:center;
    gap: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 10px 6px 6px;
    font-size: 12.5px;
    color: var(--text-secondary);
    max-width: 220px;
  }

  .attachment-chip .thumb{
    width: 26px; height:26px;
    border-radius:6px;
    object-fit:cover;
    flex-shrink:0;
    background: var(--bg-input);
  }

  .attachment-chip .icon-box{
    width:26px; height:26px;
    border-radius:6px;
    background: rgba(199,156,3,0.15);
    color: var(--gold);
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
  }
  .attachment-chip .icon-box svg{ width:14px; height:14px; }

  .attachment-chip .name{
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .attachment-chip .remove{
    background:none;
    border:none;
    color: var(--text-muted);
    cursor:pointer;
    font-size:15px;
    line-height:1;
    padding:2px;
    flex-shrink:0;
  }
  .attachment-chip .remove:hover{ color: var(--danger); }

  .msg-attachments{
    display:flex;
    flex-wrap:wrap;
    gap:6px;
    margin-top:8px;
  }
  .msg-attachments .tag{
    display:flex;
    align-items:center;
    gap:5px;
    background: rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 12px;
  }
  .msg.user .msg-attachments .tag{ background: rgba(0,0,0,0.12); }
  .msg-attachments .tag img{
    width:18px; height:18px;
    border-radius:4px;
    object-fit:cover;
  }

  ::-webkit-scrollbar{ width:6px; }
  ::-webkit-scrollbar-thumb{ background: var(--border); border-radius:3px; }
