:root {
  --bg: #0d1117; --panel: #161b22; --border: #30363d;
  --text: #e6edf3; --muted: #8b949e; --accent: #FF5C35;
  --user-bubble: #21262d; --ai-bubble: #0d2818;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.app { height: 100vh; display: flex; }

.sidebar { width: 280px; background: var(--panel); border-right: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.sidebar h2 { font-size: 15px; margin: 0 0 8px 0; color: var(--accent); }
label { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: block; }
input, select, textarea { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 8px; border-radius: 6px; font-size: 13px; margin-bottom: 10px; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.row2 { display: flex; gap: 8px; }
.row2 > div { flex: 1; }
button { background: var(--accent); color: #fff; border: none; padding: 9px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; margin-bottom: 8px; width: 100%; }
button:hover { opacity: 0.9; }
button.secondary { background: var(--border); }
.status { font-size: 11px; color: var(--muted); margin-top: 2px; }
.status.ok { color: #3fb950; }
.status.err { color: #f85149; }
hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; width: 100%; }

.history-list { flex: 1; overflow-y: auto; }
.history-item { padding: 8px; border-radius: 6px; cursor: pointer; font-size: 12.5px; margin-bottom: 4px; border: 1px solid transparent; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.history-item:hover { background: var(--user-bubble); }
.history-item.active { border-color: var(--accent); background: var(--user-bubble); }
.history-item .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .del { color: var(--muted); cursor: pointer; }
.history-item .del:hover { color: #f85149; }

.main { flex: 1; display: flex; flex-direction: column; }
.chat-window { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.msg { max-width: 720px; padding: 12px 16px; border-radius: 10px; line-height: 1.5; white-space: pre-wrap; font-size: 14.5px; }
.msg.user { align-self: flex-end; background: var(--user-bubble); }
.msg.ai { align-self: flex-start; background: var(--ai-bubble); border: 1px solid #1f6f43; }
.msg img { max-width: 260px; border-radius: 8px; display: block; margin-top: 8px; }
.file-chip-in-msg { display: inline-block; background: #1c2128; border: 1px solid var(--border); padding: 4px 8px; border-radius: 6px; font-size: 12px; margin-top: 6px; }

.input-bar { border-top: 1px solid var(--border); padding: 12px 24px 16px 24px; }
.attach-tray { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.attach-chip { background: var(--user-bubble); border: 1px solid var(--border); padding: 5px 10px; border-radius: 6px; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.attach-chip .remove { cursor: pointer; color: var(--muted); font-weight: bold; }
.input-row { display: flex; gap: 10px; align-items: flex-end; }
.input-row textarea { flex: 1; resize: none; min-height: 48px; max-height: 160px; margin-bottom: 0; }
.input-row button { padding: 0 20px; height: 48px; margin-bottom: 0; width: auto; }
.attach-btn { background: var(--border); color: var(--text); width: 48px; height: 48px; border-radius: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 18px; flex-shrink: 0; }
.attach-btn:hover { background: #3a4048; }
.empty-state { margin: auto; text-align: center; color: var(--muted); }
.empty-state h1 { color: var(--text); font-size: 22px; }
.hint { font-size: 10.5px; color: var(--muted); margin: -6px 0 10px 0; }
