:root {
  color-scheme: light;
  --primary-blue: #0056a4;
  --deep-navy: #003b71;
  --cyan-blue: #00aeef;
  --green-accent: #00a651;
  --bg: #f5f9fc;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #657284;
  --line: #d9e7f2;
  --accent: #0056a4;
  --accent-strong: #003b71;
  --user: #0056a4;
  --bot: #eef7fd;
  --shadow: 0 22px 70px rgba(0, 59, 113, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(0, 174, 239, 0.15), transparent 34%),
    linear-gradient(315deg, rgba(0, 86, 164, 0.12), transparent 36%),
    var(--bg);
  color: var(--ink);
}

.shell {
  width: min(980px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.chat-panel {
  width: min(760px, 100%);
  height: min(820px, calc(100vh - 56px));
  min-height: 560px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(217, 231, 242, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.manage-panel {
  width: min(860px, 100%);
  min-height: min(820px, calc(100vh - 56px));
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(217, 231, 242, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-panel {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(217, 231, 242, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  min-height: 92px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--deep-navy);
}

.brand-logo {
  display: block;
  width: 190px;
  height: 72px;
  object-fit: contain;
}

.header-link {
  flex: 0 0 auto;
  color: var(--panel);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.header-link:hover {
  color: var(--cyan-blue);
  text-decoration: underline;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.session-label {
  color: var(--panel);
  font-size: 13px;
  font-weight: 700;
}

.header-button {
  min-width: 0;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  background: transparent;
  color: var(--panel);
  font-size: 14px;
}

.header-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #b8d8ef;
  border-radius: 999px;
  color: var(--deep-navy);
  font-size: 14px;
  font-weight: 700;
}

.messages {
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #ffffff, #f5f9fc);
}

.message {
  display: flex;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(78%, 580px);
  padding: 13px 15px;
  border-radius: 8px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.bot .bubble {
  background: var(--bot);
  color: var(--ink);
  border: 1px solid #cfe7f7;
}

.user .bubble {
  background: var(--user);
  color: #fff;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

textarea {
  width: 100%;
  max-height: 160px;
  resize: none;
  border: 1px solid #bfd4e6;
  border-radius: 8px;
  padding: 13px 14px;
  font: inherit;
  line-height: 1.45;
  color: var(--ink);
  outline: none;
}

textarea:focus {
  border-color: var(--cyan-blue);
  box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.18);
}

button {
  min-width: 78px;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--panel);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:focus-visible {
  outline: 3px solid rgba(0, 166, 81, 0.32);
  outline-offset: 2px;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.upload-panel {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: #f5f9fc;
}

.login-form {
  display: grid;
  gap: 16px;
  padding: 28px 24px 24px;
}

.login-form h1 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 24px;
  letter-spacing: 0;
}

.upload-form {
  display: grid;
  grid-template-columns: 190px 1fr auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input[type="file"],
input[type="password"],
input[type="text"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid #bfd4e6;
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--panel);
}

input[type="file"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  border-color: var(--cyan-blue);
  box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.18);
  outline: none;
}

.summary {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.file-list {
  display: grid;
  gap: 0;
}

.file-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
}

.file-row h2 {
  margin: 0 0 5px;
  font-size: 16px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.file-row p,
.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.empty-state {
  padding: 24px;
}

.danger-button {
  background: var(--deep-navy);
}

.danger-button:hover {
  background: #002c55;
}

@media (max-width: 620px) {
  .shell {
    width: 100%;
    padding: 0;
  }

  .chat-panel {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .manage-panel {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
  }

  .login-panel {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
  }

  .chat-header {
    min-height: 82px;
    padding: 8px 18px;
  }

  .brand-logo {
    width: 148px;
    height: 56px;
  }

  .upload-form,
  .file-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .header-actions {
    gap: 10px;
  }

  .messages {
    padding: 18px;
  }

  .bubble {
    max-width: 92%;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }
}
