/* CodeForge — Claude-inspired light, clean, conversational UI */

:root {
  --bg: #f7f6f3;             /* warm off-white */
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f2f1ed;
  --border: #e6e4de;
  --border-strong: #d5d2ca;
  --text: #1f1e1c;
  --text-dim: #6f6b63;
  --text-faint: #9c978d;
  --accent: #d97757;         /* terracotta / coral — our distinct accent */
  --accent-soft: #fae9e2;
  --accent-text: #b4532f;
  --code-bg: #fbfaf7;
  --code-head: #f1efe9;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
  --radius: 10px;
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; background: none; border: none; color: inherit; }

/* ===== Top bar ===== */
.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand { display: flex; align-items: center; gap: 8px; margin-right: auto; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #e2a03b);
  color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.conn-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-dim);
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.conn-pill.online .conn-dot { background: #52a46c; }
.conn-pill.online { color: #2f6b45; border-color: #cfe6d6; background: #f0f7f2; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
  color: var(--text-dim); font-size: 16px; transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

.ghost-btn {
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-weight: 500; transition: all 0.15s;
}
.ghost-btn:hover { border-color: var(--border-strong); background: var(--surface-hover); }

/* ===== Layout ===== */
.layout { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; z-index: 1; }
.convo { flex: 1; overflow-y: auto; }
.convo-inner { max-width: 720px; margin: 0 auto; padding: 24px 20px 32px; }

/* ===== Welcome ===== */
.welcome { text-align: center; padding: 56px 0 30px; animation: fade .4s ease; }
.welcome-mark {
  width: 52px; height: 52px; margin: 0 auto; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #e2a03b); color: #fff;
  display: grid; place-items: center; font-size: 26px;
}
.welcome h1 { margin-top: 22px; font-size: 24px; font-weight: 650; letter-spacing: -0.3px; }
.welcome p { margin-top: 8px; color: var(--text-dim); font-size: 14.5px; }
.suggestions { margin-top: 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chip {
  text-align: left; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); font-size: 13.5px;
  transition: all 0.15s; color: var(--text);
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== Messages ===== */
.messages { display: flex; flex-direction: column; }
.msg { display: flex; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--border); animation: fade .3s ease; }
.msg:last-child { border-bottom: none; }
.msg-avatar { width: 28px; height: 28px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center; font-size: 13px; }
.msg.user .msg-avatar { background: var(--bg-soft); border: 1px solid var(--border); }
.msg.assistant .msg-avatar { background: var(--accent-soft); color: var(--accent-text); }
.msg-content {
  flex: 1; min-width: 0; font-size: 15px; line-height: 1.65; padding-top: 2px;
}
.msg.user .msg-content { white-space: pre-wrap; color: var(--text); }
.msg.assistant .msg-content { color: #302e2a; }

.msg-content p { margin: 0 0 12px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content ul, .msg-content ol { margin: 0 0 12px; padding-left: 22px; }
.msg-content li { margin: 4px 0; }
.msg-content h3, .msg-content h4 { font-size: 16px; font-weight: 650; margin: 16px 0 8px; }
.msg-content strong { font-weight: 600; color: var(--text); }
.msg-content code:not(pre code) {
  background: var(--accent-soft); color: var(--accent-text); padding: 2px 6px;
  border-radius: 5px; font-family: var(--mono); font-size: 13px;
}

/* Code blocks */
.code-block { margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--code-bg); }
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; background: var(--code-head); border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-faint); font-family: var(--mono);
}
.code-head button { font-size: 12px; color: var(--text-dim); padding: 2px 8px; border-radius: 6px; font-family: var(--mono); }
.code-head button:hover { color: var(--text); background: var(--surface-hover); }
.code-block pre { overflow-x: auto; padding: 14px 16px; }
.code-block code { font-family: var(--mono); font-size: 13px; line-height: 1.6; }

.cursor-blink { display: inline-block; width: 7px; height: 15px; background: var(--accent); vertical-align: text-bottom; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.thinking { color: var(--text-faint); font-style: italic; font-size: 14px; }

/* ===== Composer ===== */
.composer-wrap { border-top: 1px solid var(--border); background: rgba(255,255,255,0.75); backdrop-filter: blur(10px); padding: 12px 20px 14px; }
.composer-inner { max-width: 720px; margin: 0 auto; }
.model-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.composer-attach { display: flex; align-items: center; gap: 8px; }
.attach-btn {
  width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); font-size: 18px;
}
.attach-btn:hover { color: var(--accent); border-color: var(--accent); }
.attach-hint { font-size: 12.5px; color: var(--text-faint); }
.model-select-wrap { display: flex; align-items: center; gap: 8px; }
.model-label { font-size: 12px; color: var(--text-faint); }
#modelSelect {
  padding: 6px 26px 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500;
  appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236f6b63' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center;
}
#modelSelect:focus { outline: none; border-color: var(--accent); }

.composer {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px;
  padding: 12px 12px 12px 16px; box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#promptInput {
  flex: 1; border: none; outline: none; resize: none; background: transparent;
  font-family: inherit; font-size: 15px; color: var(--text); line-height: 1.55;
  max-height: 180px; padding: 2px 0;
}
#promptInput::placeholder { color: var(--text-faint); }
.send-btn {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 16px; transition: all 0.15s;
  opacity: 0.55;
}
.send-btn:not(:disabled):hover { background: var(--accent-text); transform: translateY(-1px); }
.send-btn:disabled { cursor: not-allowed; }

.attached { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; } 
.attached-file {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px;
}
.attached-file .rm { color: var(--text-faint); font-size: 14px; }
.attached-file .rm:hover { color: var(--accent-text); }
.hint-line { text-align: center; font-size: 11.5px; color: var(--text-faint); margin-top: 10px; }

/* ===== Drawer ===== */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.25); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 340px; max-width: 90vw;
  background: var(--bg-soft); z-index: 70; box-shadow: -10px 0 40px rgba(0,0,0,0.12);
  padding: 20px; overflow-y: auto; animation: slideIn .25s ease;
}
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.drawer-head h2 { font-size: 18px; font-weight: 650; }
.drawer-section { padding: 16px 0; border-top: 1px solid var(--border); }
.drawer-section h3 { font-size: 13px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-dim); font-weight: 600; }
.drawer-note { font-size: 13px; color: var(--text-dim); line-height: 1.6; margin: 8px 0 12px; }
.key-row { display: flex; gap: 8px; }
.key-row input {
  flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border-strong);
  font-family: var(--mono); font-size: 13px; background: var(--surface);
}
.key-row input:focus { outline: none; border-color: var(--accent); }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.primary-btn { padding: 10px 18px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; transition: all 0.15s; }
.primary-btn:hover { background: var(--accent-text); }
.key-status { margin-top: 10px; font-size: 13px; }
.key-status.ok { color: #2f6b45; }
.key-status.err { color: #c7443a; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; padding: 8px 0; cursor: pointer; }
.switch-row input { display: none; }
.switch { width: 40px; height: 22px; border-radius: 999px; background: #dcd9d1; position: relative; flex-shrink: 0; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(16px); z-index: 100;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  padding: 11px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: all 0.25s; max-width: 80%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: #e5b3ae; color: #c7443a; }

/* Responsive */
@media (max-width: 640px) {
  .suggestions { grid-template-columns: 1fr; }
  .attach-hint, .model-label { display: none; }
  .convo-inner { padding: 16px 14px 24px; }
  .topbar-inner { padding: 8px 12px; }
  .conn-pill span#connText { display: none; }
}
