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

:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --border: #1e1e2e;
  --text: #e0e0e8;
  --text-dim: #6b6b80;
  --accent: #7c5cfc;
  --accent-dim: #5a3fd4;
  --tool-bg: #161622;
  --font: "SF Mono", "Cascadia Code", "Fira Code", monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.view {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.view[hidden] {
  display: none;
}

/* Login */
#login-view {
  justify-content: center;
  align-items: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 40px;
  width: 380px;
  text-align: center;
}

.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin: 4px 0 32px;
}

.login-card input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}

.login-card input:focus {
  border-color: var(--accent);
}

.login-card button {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

.login-card button:hover {
  background: var(--accent-dim);
}

.error {
  color: #e55;
  font-size: 13px;
  margin-top: 12px;
}

/* Chat */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

header h1 {
  font-size: 16px;
  font-weight: 700;
}

.user-badge {
  background: var(--accent);
  color: #fff;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot.online {
  background: #4caf50;
}

.dot.offline {
  background: #666;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 12px;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

/* Messages */
main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.msg {
  max-width: 720px;
  margin: 0 auto 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  background: var(--accent);
  color: #fff;
  margin-left: auto;
  margin-right: 0;
  max-width: 500px;
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  background: var(--surface);
  border: 1px solid var(--border);
}

.msg.tool {
  background: var(--tool-bg);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  border-left: 3px solid var(--accent);
}

.msg.tool .tool-name {
  color: var(--accent);
  font-weight: 600;
}

/* Footer */
footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

#chat-form {
  display: flex;
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
}

#chat-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}

#chat-input:focus {
  border-color: var(--accent);
}

#chat-form button {
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

#chat-form button:hover {
  background: var(--accent-dim);
}

/* File panel */
#file-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#file-panel[hidden] {
  display: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 700;
}

#drop-zone {
  margin: 16px;
  padding: 32px 16px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

#drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(124, 92, 252, 0.05);
}

#drop-zone p {
  font-size: 13px;
  color: var(--text-dim);
  margin: 4px 0;
}

.upload-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
}

.upload-btn:hover {
  background: var(--accent-dim);
}

#file-list {
  padding: 0 16px 16px;
}

.file-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 4px;
}

.file-entry:hover {
  background: var(--bg);
}

.file-name {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-icon {
  color: var(--text-dim);
  flex-shrink: 0;
}

.file-size {
  color: var(--text-dim);
  font-size: 11px;
  flex-shrink: 0;
}

.file-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
}

.file-delete:hover {
  color: #e55;
  background: rgba(238, 85, 85, 0.1);
}

#upload-status {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--accent);
}

.text-dim {
  color: var(--text-dim);
}

/* PDF preview */
.msg.pdf-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0;
  overflow: hidden;
  max-width: 720px;
}

.pdf-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: var(--tool-bg);
}

.highlight-badge {
  background: rgba(255, 230, 0, 0.15);
  color: #ffe600;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.pdf-image {
  width: 100%;
  display: block;
  cursor: zoom-in;
  border-radius: 0 0 10px 10px;
}

/* PDF fullscreen overlay */
.pdf-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: zoom-out;
  padding: 20px;
}

.pdf-overlay img {
  max-width: 95vw;
  max-height: 95vh;
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(124, 92, 252, 0.3);
}

/* Scrollbar */
main::-webkit-scrollbar {
  width: 6px;
}

main::-webkit-scrollbar-track {
  background: transparent;
}

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