:root {
  --navy: #152238;
  --navy-2: #1e334d;
  --gold: #c4a35a;
  --gold-2: #d4b56a;
  --paper: #f4efe6;
  --ink: #1b1b1b;
  --muted: #6e675c;
  --line: #e2d8c8;
  --white: #fffcf7;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
.bubble.pending { color: var(--muted); font-style: italic; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

.view { min-height: 100%; }

#login-view {
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 500px at 50% -10%, #2a4568 0%, transparent 55%),
    linear-gradient(180deg, #101b2b 0%, #152238 45%, #0e1622 100%);
}

.login-card {
  width: min(420px, calc(100% - 32px));
  background: var(--white);
  border-radius: 18px;
  padding: 40px 32px 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  text-align: center;
}

.mark {
  display: inline-block;
  letter-spacing: .28em;
  text-transform: lowercase;
  font-size: 12px;
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: 4px 10px 4px 14px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
}

.login-sub { margin: 0 0 28px; color: var(--muted); font-size: 14px; }

#login-form { display: grid; gap: 12px; }
input, textarea, button {
  font: inherit;
}

#login-form input, .composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}

#login-form input:focus, .composer textarea:focus {
  border-color: var(--gold);
}

#login-form button, .composer button, .ghost {
  cursor: pointer;
}

#login-form button, #send-btn {
  border: 0;
  background: var(--navy);
  color: #fff;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 600;
}

#login-form button:hover, #send-btn:hover { background: var(--navy-2); }
#login-form button:disabled, #send-btn:disabled { opacity: .55; cursor: not-allowed; }

.error { color: #b42318; font-size: 13px; margin: 10px 0 0; }

#chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 860px;
  margin: 0 auto;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.brand { font-weight: 700; color: var(--navy); }
.sub { font-size: 12px; letter-spacing: .22em; color: var(--gold); margin-top: 2px; }
.top-actions { display: flex; gap: 8px; }
.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}
.ghost:hover { border-color: var(--navy); color: var(--navy); }

.messages {
  flex: 1;
  overflow: auto;
  padding: 24px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bubble {
  max-width: 86%;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.65;
  word-break: break-word;
  font-size: 15px;
}
.msg-text { white-space: pre-wrap; }
.table-wrap { overflow-x: auto; max-width: 100%; }
.msg-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  margin: 8px 0 4px;
  background: #fff;
}
.msg-table th, .msg-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
}
.msg-table th {
  background: #f3efe6;
  color: var(--navy);
  font-weight: 600;
}
.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.download-chip {
  display: inline-flex;
  align-items: center;
  background: var(--navy);
  color: #fff !important;
  text-decoration: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
}
.download-chip:hover { background: var(--navy-2); }

.row { display: flex; }
.row.user { justify-content: flex-end; }
.row.assistant { justify-content: flex-start; }

.row.user .bubble {
  background: var(--navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.row.assistant .bubble {
  background: var(--white);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.welcome {
  text-align: center;
  color: var(--muted);
  margin: 48px 0 8px;
  font-size: 14px;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 20px 20px;
  background: var(--paper);
}

.composer-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.composer textarea {
  resize: none;
  min-height: 46px;
  max-height: 140px;
  flex: 1;
}

#send-btn { min-width: 84px; }
.attach-btn { min-width: 64px; height: 46px; border-radius: 12px; }

.attach-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.attach-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 8px 4px 4px;
  font-size: 12px;
  color: var(--muted);
  max-width: 220px;
}
.attach-chip img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
}
.attach-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.thumbs img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  background: #fff;
}
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.file-chip {
  display: inline-block;
  font-size: 12px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  padding: 2px 8px;
}
.row.assistant .file-chip {
  background: var(--paper);
  border-color: var(--line);
  color: var(--muted);
}
