:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2f6df0;
  --accent-hover: #2256cf;
  --user-bubble: #2f6df0;
  --user-text: #ffffff;
  --assistant-bubble: #f0f2f6;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute must always win, even on elements whose class
   sets an explicit `display` (e.g. buttons, menu items). Without this, an
   author `display: ...` rule overrides the UA `[hidden] { display: none }`. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

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

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.app-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.app-header__intro { min-width: 0; }
.app-title {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.app-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* User avatar menu */
.user-menu {
  position: relative;
  flex: 0 0 auto;
}
.user-menu__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--assistant-bubble);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.user-menu__avatar:hover { border-color: var(--accent); }
.user-menu__avatar:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.user-menu__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.08);
  padding: 6px;
  z-index: 100;
}
.user-menu__dropdown[hidden] { display: none; }
.user-menu__identity {
  margin: 0;
  padding: 6px 10px 8px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  box-sizing: border-box;
  border: none;
  background: none;
  border-radius: 6px;
  padding: 9px 10px;
  margin-top: 2px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.user-menu__item:hover { background: var(--assistant-bubble); }
.user-menu__item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.user-menu__item--danger { color: #b42318; }
.user-menu__item--danger:hover { background: #fdecec; }
.user-menu__item--danger:focus-visible { outline-color: #b42318; }
.user-menu__divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 4px;
}
.user-menu__divider[hidden] { display: none; }

/* Branded sign-in screen */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #eef2fb 0%, var(--bg) 60%);
}
.login-screen[hidden] { display: none; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.12);
  padding: 40px 36px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.login-card__brand {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}
.login-card__tagline {
  margin: 10px 0 24px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
.login-card__btn {
  display: inline-block;
  text-decoration: none;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
}
.login-card__note {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Layout */
.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px;
  min-height: 0;
}

/* Chat column */
.chat {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 0;
}

.transcript {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.empty-state__title {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}
.empty-state__lead { margin: 0; }
.empty-state__btn {
  margin: 12px 0 4px;
  padding: 12px 24px;
  font-size: 15px;
}
.empty-state__hint { margin: 0; font-size: 12.5px; }
.empty-state__steps {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  text-align: left;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.empty-state__steps li {
  counter-increment: step;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.empty-state__steps li::before {
  content: counter(step);
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  line-height: 18px;
  text-align: center;
}

/* Drag-and-drop target */
.transcript--dragover {
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
  background: rgba(47, 109, 240, 0.04);
}

/* Stepper */
.stepper {
  flex: 0 0 auto;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin: 0;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.stepper[hidden] { display: none; }
.stepper__step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.stepper__step:not(:last-child)::after {
  content: "›";
  margin-left: 6px;
  color: var(--border);
}
.stepper__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 650;
}
.stepper__step--done { color: var(--muted); }
.stepper__step--done .stepper__num {
  background: var(--assistant-bubble);
  border-color: var(--border);
}
.stepper__step--current { color: var(--text); font-weight: 600; }
.stepper__step--current .stepper__num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Live status bar */
.status-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
  background: #fafbfc;
}
.status-bar[hidden] { display: none; }
.status-bar__spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Messages */
.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: normal;
  word-wrap: break-word;
}
.msg--user {
  align-self: flex-end;
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}
.msg--assistant {
  align-self: flex-start;
  background: var(--assistant-bubble);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg--error {
  align-self: flex-start;
  background: #fdecec;
  color: #b42318;
  border: 1px solid #f5c2c0;
}
.msg--chip {
  align-self: center;
  background: #eef6ee;
  color: #2e6b34;
  border: 1px solid #cfe6cf;
  font-size: 13px;
  border-radius: 999px;
  padding: 6px 14px;
}

.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul { margin: 4px 0 8px; padding-left: 20px; }
.msg li { margin: 2px 0; }
.msg strong { font-weight: 650; }
.msg code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}

/* Typing indicator */
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* Composer */
.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  padding: 12px;
}
.composer__row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.composer__textarea {
  flex: 1 1 auto;
  resize: none;
  max-height: 160px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  outline: none;
}
.composer__textarea:focus { border-color: var(--accent); }

.file-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
}
.file-upload:hover { border-color: var(--accent); color: var(--text); }

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--primary:disabled { background: #a9bdf0; cursor: not-allowed; }
.btn--secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  margin-top: 8px;
}
.btn--secondary:hover { border-color: var(--accent); }

/* Composer extras */
.composer__stop { padding: 10px 16px; }
.composer__hint {
  margin: 8px 2px 0;
  font-size: 12px;
  color: var(--muted);
}

/* Resume chip near the composer */
.resume-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #eef6ee;
  color: #2e6b34;
  border: 1px solid #cfe6cf;
  font-size: 12.5px;
  max-width: 100%;
}
.resume-chip[hidden] { display: none; }
.resume-chip__check { font-weight: 700; }
.resume-chip__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Docs sidebar */
.docs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  align-self: start;
  max-height: 100%;
  overflow-y: auto;
}
.docs__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 12px;
}
.docs__title {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.docs__reset {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  padding: 5px 10px;
  cursor: pointer;
}
.docs__reset:hover { border-color: var(--accent); color: var(--text); }
.docs__list { list-style: none; margin: 0; padding: 0; }
.docs__list li { margin-bottom: 8px; }
.docs__empty { font-size: 13px; color: var(--muted); margin: 0; }

/* Document groups (by company folder) */
.docs__group { margin-bottom: 16px; }
.docs__group:last-child { margin-bottom: 0; }
.docs__group-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.docs__group-list { list-style: none; margin: 0; padding: 0; }
.docs__group-list li { margin-bottom: 8px; }
.docs__group-list li:last-child { margin-bottom: 0; }

/* Document style picker */
.style-picker {
  margin: 0 0 14px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--border);
}
.style-picker__label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--muted);
}
.style-picker__select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  cursor: pointer;
}
.style-picker__select:focus { border-color: var(--accent); }
.style-picker__hint {
  margin: 6px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}
.style-picker__note {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: #2e6b34;
}
.style-picker__note:empty { display: none; }
.style-picker__note--error { color: #b42318; }

.doc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}
.doc-item:hover { border-color: var(--accent); background: var(--assistant-bubble); }
.doc-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.doc-item__iconwrap {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--accent);
}
.doc-item__name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-item__del {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 4px 7px;
  cursor: pointer;
}
.doc-item__del:hover { border-color: #f5c2c0; color: #b42318; }

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
    /* Let the chat own the viewport; the docs panel follows beneath it. */
    grid-template-rows: minmax(60vh, 1fr) auto;
  }
  .chat { order: 1; }
  .docs {
    order: 2;
    max-height: none;
  }
  .stepper { padding: 8px 14px; }
  .status-bar { padding: 8px 14px; }
}
