:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #b91c1c;      /* Vatan kırmızısı tonu */
  --accent-dark: #991b1b;
  --bot-bg: #f4f4f5;
  --user-bg: #b91c1c;
  --user-fg: #ffffff;
  --radius: 12px;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- AUTH ---------- */
.auth-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #fafafa 0%, #f0f0f0 100%);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
}
.auth-title { margin: 0; font-size: 28px; text-align: center; color: var(--accent); letter-spacing: -.5px; }
.auth-sub { margin: 6px 0 22px; text-align: center; color: var(--muted); font-size: 13px; }
.auth-tabs { display: flex; gap: 4px; background: #f3f4f6; border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tab {
  flex: 1; padding: 8px; border: none; background: transparent; border-radius: 8px;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; transition: all .15s;
}
.auth-tab.active { background: var(--bg); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; outline: none; transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }
#pw-hint { color: var(--muted); font-weight: 400; }

.consents { margin: 4px 0 18px; padding: 14px; background: #fafafa; border: 1px solid var(--line); border-radius: 10px; }
.consents-title { margin: 0 0 10px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 1.4; margin-bottom: 9px; color: #374151; cursor: pointer; }
.consent:last-child { margin-bottom: 0; }
.consent input { margin-top: 2px; flex-shrink: 0; }

.btn-primary {
  width: 100%; padding: 12px; border: none; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.auth-error { margin: 12px 0 0; padding: 10px 12px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; color: var(--accent-dark); font-size: 13px; }

/* ---------- CHAT ---------- */
.chat-view { display: flex; height: 100%; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; background: #fafafa;
}
.btn-new {
  margin: 14px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-new:hover { border-color: var(--accent); color: var(--accent); }
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px; }
.conv-item {
  padding: 10px 12px; margin-bottom: 4px; border-radius: 8px; cursor: pointer; font-size: 13.5px;
  color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .12s;
}
.conv-item:hover { background: #eef0f2; }
.conv-item.active { background: #e5e7eb; font-weight: 600; }
.conv-warn { padding: 8px 12px; margin: 4px 8px; font-size: 11.5px; color: var(--accent-dark); background: #fef2f2; border-radius: 8px; line-height: 1.4; }

.sidebar-footer { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-email { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-ghost { border: none; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; flex-shrink: 0; }
.btn-ghost:hover { color: var(--accent); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.empty-hint { margin: auto; color: var(--muted); font-size: 14px; text-align: center; max-width: 340px; line-height: 1.5; }

.msg { max-width: 760px; width: fit-content; }
.msg.user { align-self: flex-end; }
.msg.bot { align-self: flex-start; }
.bubble { padding: 12px 15px; border-radius: var(--radius); font-size: 15px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.msg.user .bubble { background: var(--user-bg); color: var(--user-fg); border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: var(--bot-bg); color: var(--fg); border-bottom-left-radius: 4px; }
.msg.bot .bubble.streaming::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--muted); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* Kaynaklar */
.sources { margin-top: 8px; }
.sources-toggle {
  border: none; background: transparent; color: var(--accent); font-size: 12.5px; font-weight: 600;
  cursor: pointer; padding: 4px 0; display: inline-flex; align-items: center; gap: 4px;
}
.sources-toggle:hover { text-decoration: underline; }
.sources-body { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.source-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.source-doc { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .4px; }
.source-title { font-size: 13px; font-weight: 600; margin: 3px 0 6px; }
.source-text { font-size: 12.5px; color: #4b5563; line-height: 1.5; white-space: pre-wrap; max-height: 220px; overflow-y: auto; }

.chat-form { border-top: 1px solid var(--line); padding: 14px 20px; display: flex; gap: 10px; align-items: flex-end; }
#chat-input {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px;
  font-size: 15px; font-family: inherit; outline: none; max-height: 160px; line-height: 1.4;
}
#chat-input:focus { border-color: var(--accent); }
.btn-send {
  width: 44px; height: 44px; flex-shrink: 0; border: none; border-radius: 12px; background: var(--accent);
  color: #fff; font-size: 18px; cursor: pointer; transition: background .15s;
}
.btn-send:hover { background: var(--accent-dark); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- MOBİL ---------- */
/* Üst mobil bar + hamburger + backdrop: yalnız dar ekranda görünür. */
.mobile-bar { display: none; }
.menu-btn {
  width: 40px; height: 40px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); font-size: 19px; line-height: 1; cursor: pointer;
  align-items: center; justify-content: center; color: var(--fg);
}
.menu-btn:active { background: #f3f4f6; }
.sidebar-backdrop { display: none; }

@media (max-width: 640px) {
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg);
    position: sticky; top: 0; z-index: 12;
  }
  .mobile-title { font-weight: 700; color: var(--accent); font-size: 16px; }

  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 20; width: 82%; max-width: 300px; height: 100%;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: 2px 0 16px rgba(0,0,0,.18);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop.show {
    display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.4);
  }

  .messages { padding: 16px; }
  .msg { max-width: 100%; }
  .chat-form { padding: 10px 12px; }
}
