:root {
  --navy: #15294B; --navy-dark: #0C2742; --teal: #0F6E66;
  --teal-bright: #13A89E; --gold: #C2A14E; --text: #EAF0F7;
  --dim: #9FB0C7; --card: #102138; --bubble-user: #1E3A66;
  --bubble-bot: #102138; --danger: #E06C6C; --line: rgba(159,176,199,.15);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--navy-dark); color: var(--text);
  display: flex; flex-direction: column;
}
.spacer { flex: 1; }
button { font-family: inherit; cursor: pointer; }
.icon-btn {
  background: none; border: 1px solid var(--dim); color: var(--dim);
  border-radius: 7px; width: 30px; height: 28px; font-size: 15px;
  line-height: 1;
}
.icon-btn.sm { width: 24px; height: 22px; font-size: 13px; }
.icon-btn:hover { border-color: var(--gold); color: var(--gold); }

/* top bar */
#topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: rgba(12,39,66,.95); border-bottom: 2px solid var(--gold);
  flex: none;
}
#topbar .logo { width: 26px; height: 26px; border-radius: 6px; }
#topbar .title { font-weight: 600; font-size: 15px; }
.mode-badge { font-size: 11px; color: var(--navy-dark); background: var(--teal-bright);
  padding: 2px 9px; border-radius: 10px; font-weight: 700; }
.pill-btn { background: rgba(19,168,158,.12); border: 1px solid var(--teal-bright);
  color: var(--teal-bright); border-radius: 8px; padding: 5px 13px; font-size: 13px; }
.pill-btn:hover { background: rgba(19,168,158,.22); }
.folder-name { font-size: 13px; color: var(--text); }
.welcome { flex: 1; display: flex; align-items: center; justify-content: center; }
.wc-inner { text-align: center; }
.wc-logo { width: 72px; height: 72px; border-radius: 16px; margin-bottom: 14px; }
.wc-inner h2 { font-size: 20px; margin-bottom: 6px; }
.wc-inner p { color: var(--dim); font-size: 14px; margin-bottom: 20px; }
.tree-empty { padding: 16px 14px; font-size: 12.5px; color: var(--dim); line-height: 1.6; }
.hint-msg { color: var(--dim); font-size: 13px; line-height: 1.7; padding: 6px 2px; }
.hint-msg em { color: var(--teal-bright); font-style: normal; }
#project-select {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 10px; font-size: 13px; min-width: 160px;
}
.quota { font-size: 11.5px; color: var(--dim); }

/* three-pane layout */
#workspace {
  flex: 1; display: grid; grid-template-columns: 230px 1fr 380px;
  min-height: 0;
}
#tree-pane, #chat-pane {
  display: flex; flex-direction: column; min-height: 0;
  background: rgba(12,39,66,.6);
}
#tree-pane { border-inline-end: 1px solid var(--line); }
#chat-pane { border-inline-start: 1px solid var(--line); }
.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; font-size: 12.5px; color: var(--dim);
  border-bottom: 1px solid var(--line); flex: none;
}
#file-tree { list-style: none; overflow-y: auto; flex: 1; padding: 6px 0; }
#file-tree li {
  padding: 5px 14px; font-size: 13px; cursor: pointer; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
}
#file-tree li:hover { background: rgba(19,168,158,.1); }
#file-tree li.active { background: rgba(19,168,158,.18); color: var(--teal-bright); }
#file-tree li .del {
  margin-inline-start: auto; opacity: 0; color: var(--danger); font-size: 12px;
}
#file-tree li:hover .del { opacity: 1; }

/* center */
#center-pane { display: flex; flex-direction: column; min-width: 0; }
.tabbar {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  background: rgba(12,39,66,.9); border-bottom: 1px solid var(--line);
  flex: none;
}
.tab {
  background: none; border: none; color: var(--dim); font-size: 13px;
  padding: 5px 12px; border-radius: 7px 7px 0 0;
}
.tab.active { color: var(--teal-bright); background: var(--navy-dark);
  border-bottom: 2px solid var(--teal-bright); }
.active-file { font-size: 12px; color: var(--dim); margin-inline-start: 8px; }
.ghost-btn {
  background: none; border: 1px solid var(--dim); color: var(--dim);
  border-radius: 7px; padding: 5px 12px; font-size: 12.5px;
}
.ghost-btn:hover { border-color: var(--teal-bright); color: var(--teal-bright); }
.run-btn {
  background: linear-gradient(135deg, var(--gold), #d8b968); color: var(--navy-dark);
  border: none; border-radius: 7px; padding: 6px 16px; font-weight: 700;
  font-size: 13px;
}
#editor-host { flex: 1; min-height: 0; }
#preview-frame { flex: 1; border: 0; background: #fff; }

/* chat */
#chat-log {
  flex: 1; overflow-y: auto; padding: 14px; display: flex;
  flex-direction: column; gap: 10px;
}
.msg {
  max-width: 92%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px;
  line-height: 1.6; white-space: pre-wrap; word-wrap: break-word;
}
.msg.user { align-self: flex-end; background: var(--bubble-user);
  border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--bubble-bot);
  border: 1px solid rgba(194,161,78,.25); border-bottom-left-radius: 4px; }
.msg.bot.error { border-color: var(--danger); color: #F3C6C6; }
.msg[dir="rtl"] { text-align: right; }
.msg .prov { font-size: 10px; color: var(--gold); margin-top: 5px; }
.typing { align-self: flex-start; color: var(--dim); font-size: 12.5px;
  padding: 4px 8px; }
#chat-files {
  padding: 0 12px; display: flex; flex-wrap: wrap; gap: 5px; flex: none;
}
#chat-files .fc {
  font-size: 11px; background: rgba(19,168,158,.15);
  border: 1px solid rgba(19,168,158,.4); color: var(--teal-bright);
  border-radius: 9px; padding: 2px 9px; cursor: pointer;
}
.chat-input {
  display: flex; gap: 7px; padding: 10px 12px; border-top: 1px solid var(--line);
  flex: none;
}
#chat-box {
  flex: 1; resize: none; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px;
  font-size: 13.5px; font-family: inherit; max-height: 120px;
}
#chat-box:focus { outline: none; border-color: var(--teal-bright); }
#chat-send {
  background: linear-gradient(135deg, var(--teal), var(--teal-bright));
  border: none; color: #fff; border-radius: 10px; width: 42px; font-size: 17px;
  font-weight: 700;
}
#chat-send:disabled { opacity: .5; }

/* login */
#login {
  position: fixed; inset: 0; background: rgba(12,39,66,.97); z-index: 20;
  display: flex; align-items: center; justify-content: center;
}
.card {
  background: var(--navy); border: 1px solid rgba(194,161,78,.4);
  border-radius: 16px; padding: 34px 30px; width: min(400px, 92vw);
  text-align: center; box-shadow: 0 18px 60px rgba(0,0,0,.5);
}
.card .brand { width: 60px; height: 60px; border-radius: 14px; margin-bottom: 14px; }
.card h2 { font-size: 19px; margin-bottom: 6px; }
.card p { font-size: 13px; color: var(--dim); margin-bottom: 18px; }
.card input {
  width: 100%; padding: 11px 14px; border-radius: 10px; font-size: 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  margin-bottom: 12px; text-align: center; direction: ltr;
}
.card input:focus { outline: none; border-color: var(--teal-bright); }
.card button {
  width: 100%; padding: 11px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--teal), var(--teal-bright));
  color: #fff; font-size: 15px; font-weight: 600;
}
#login-err { color: var(--danger); font-size: 12.5px; margin-top: 10px; min-height: 15px; }
