:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #232020;
  --ink-soft: #6b635c;
  --accent: #b1543a;
  --accent-soft: #f0e3dd;
  --border: #e6ded3;
  --assistant-bg: #f7f3ec;
  --user-bg: #2f2a26;
  --user-ink: #f7f3ec;
  --error: #9b2c1e;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(35, 32, 32, 0.04), 0 8px 28px rgba(35, 32, 32, 0.06);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout shell ── */
.layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100dvh;
  gap: 0;
  max-width: 1100px;
  margin: 0 auto;
}

.app {
  width: 100%;
  max-width: 720px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow);
  flex: 0 0 auto;
}

/* ── Sidebar ── */
.sidebar {
  width: 310px;
  flex: 0 0 310px;
  height: 100dvh;
  overflow-y: auto;
  padding: 28px 0 28px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-inner {
  padding: 0 20px;
}

.sb-name {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 2px;
}

.sb-tagline {
  font-size: 11.5px;
  color: var(--ink-soft);
  letter-spacing: 0.3px;
  margin-bottom: 22px;
}

.sb-section {
  margin-bottom: 20px;
}

.sb-heading {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

/* Career & Education lists */
.sb-career,
.sb-edu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sb-career li,
.sb-edu li {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 9px;
  border-left: 2px solid var(--accent-soft);
  position: relative;
}

.sb-career li::before,
.sb-edu li::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--surface);
}

.sb-role {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}

.sb-org {
  font-size: 11px;
  color: var(--ink-soft);
}

.sb-period {
  font-size: 10.5px;
  color: var(--accent);
  font-weight: 500;
}

/* Skills tags */
.sb-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.sb-tag {
  font-size: 10.5px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #e7d3cb;
  white-space: nowrap;
}

/* Languages */
.sb-langs {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sb-langs li {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.sb-lang-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
}
.sb-lang-level {
  font-size: 10.5px;
  color: var(--ink-soft);
}

/* Projects */
.sb-projects {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sb-projects li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 9px;
  border-left: 2px solid var(--accent-soft);
  position: relative;
}
.sb-projects li::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--surface);
}
.sb-proj-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}
.sb-proj-desc {
  font-size: 10.5px;
  color: var(--ink-soft);
  line-height: 1.4;
}

/* Hide sidebar on narrow screens */
@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
}

/* Header */
.header {
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}
.avatar {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.5px;
}
.header-text h1 {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 21px;
  line-height: 1.2;
}
.header-text p {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.role-banner {
  font-size: 13px;
  color: var(--accent);
  margin-top: 5px;
}
.role-banner strong {
  font-weight: 600;
}

/* Language toggle */
.lang-toggle {
  flex: 0 0 auto;
  margin-left: auto;
  font-family: "Inter", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 5px 11px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.lang-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.lang-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Role-context gate */
.gate {
  padding: 14px 22px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
}
.gate-label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 9px;
  line-height: 1.5;
}
.gate-row {
  display: flex;
  gap: 8px;
}
#gateInput {
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 14px;
  border: 1px solid #e7d3cb;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
#gateInput:focus {
  border-color: var(--accent);
}
#gateBtn {
  flex: 0 0 auto;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 18px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
#gateBtn:hover {
  background: #9a4530;
}
#gateBtn:active {
  transform: scale(0.97);
}
.gate-msg {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 8px;
}

/* Chat area */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.message {
  display: flex;
  animation: rise 0.28s ease;
}
.message.user {
  justify-content: flex-end;
}
.bubble {
  max-width: 86%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
}
.message.assistant .bubble {
  background: var(--assistant-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  color: var(--ink);
}
.message.user .bubble {
  background: var(--user-bg);
  color: var(--user-ink);
  border-bottom-right-radius: 5px;
}
.message.error .bubble {
  background: #f6e3df;
  color: var(--error);
  border: 1px solid #e7c4bc;
}
.bubble p + p {
  margin-top: 9px;
}
.bubble ul {
  margin: 9px 0 0;
  padding-left: 18px;
}
.bubble p + ul,
.bubble ul + p {
  margin-top: 9px;
}
.bubble li {
  margin-top: 5px;
}
.bubble li:first-child {
  margin-top: 0;
}
.bubble strong {
  font-weight: 600;
}
.bubble a {
  color: inherit;
}

.cursor::after {
  content: "▍";
  color: var(--accent);
  animation: blink 1s steps(2) infinite;
  margin-left: 1px;
}

/* Suggestions */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 22px 4px;
}
.chip {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #e7d3cb;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  font-family: inherit;
}
.chip:hover {
  background: #e9d6cf;
}
.chip:active {
  transform: scale(0.97);
}

/* Composer */
.composer {
  display: flex;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}
#input {
  flex: 1;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
  resize: none;
  overflow-y: auto;
  max-height: 140px;
  transition: border-color 0.15s, background 0.15s;
}
#input:focus {
  border-color: var(--accent);
  background: var(--surface);
}
#send {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
#send:hover:not(:disabled) {
  background: #9a4530;
}
#send:active:not(:disabled) {
  transform: scale(0.94);
}
#send:disabled {
  background: #cdc4ba;
  cursor: not-allowed;
}

/* Footer */
.footer {
  padding: 12px 22px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  border-top: 1px solid var(--border);
}
.footer a {
  color: var(--accent);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@media (max-width: 600px) {
  .app {
    box-shadow: none;
  }
  .header-text h1 {
    font-size: 19px;
  }
  .bubble {
    max-width: 90%;
  }
}
