:root {
  --bg: #eef2f5;
  --surface: #f8fafc;
  --panel: #ffffff;
  --ink: #17212f;
  --muted: #647184;
  --line: #d8e0e8;
  --line-strong: #c1ccd8;
  --brand: #1f6feb;
  --brand-dark: #1557bd;
  --success: #237a57;
  --danger: #9f2d2d;
  --shadow: 0 18px 45px rgba(23, 33, 47, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, var(--form-panel-width, 1fr)) 12px minmax(360px, 1fr);
  gap: 12px;
  height: 100vh;
  padding: 16px;
}

.panel-resizer {
  align-self: stretch;
  border-radius: 10px;
  cursor: col-resize;
  position: relative;
  touch-action: none;
  background: transparent;
  transition: background 120ms ease;
}

.panel-resizer::before {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 14px;
  left: 50%;
  width: 2px;
  border-radius: 999px;
  background: var(--line);
  transform: translateX(-50%);
  transition: background 120ms ease, width 120ms ease;
}

.panel-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background:
    linear-gradient(var(--muted), var(--muted)) center 12px / 2px 2px no-repeat,
    linear-gradient(var(--muted), var(--muted)) center 20px / 2px 2px no-repeat,
    linear-gradient(var(--muted), var(--muted)) center 28px / 2px 2px no-repeat,
    var(--panel);
  box-shadow: 0 6px 18px rgba(17, 38, 58, 0.08);
  transform: translate(-50%, -50%);
  transition: border-color 120ms ease, box-shadow 120ms ease, width 120ms ease;
}

.panel-resizer:hover::before,
.panel-resizer:focus-visible::before,
.app-shell.is-resizing .panel-resizer::before {
  width: 3px;
  background: var(--brand);
}

.panel-resizer:hover::after,
.panel-resizer:focus-visible::after,
.app-shell.is-resizing .panel-resizer::after {
  width: 8px;
  border-color: var(--brand);
  box-shadow: 0 8px 22px rgba(11, 107, 203, 0.18);
}

.panel-resizer:hover,
.app-shell.is-resizing .panel-resizer {
  background: rgba(11, 107, 203, 0.06);
}

.panel-resizer:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

.app-shell.is-resizing,
.app-shell.is-resizing * {
  cursor: col-resize;
  user-select: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel {
  padding: 22px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.form-panel h1 {
  margin: 0 0 4px;
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.form-panel p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

label {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  font-size: 0.86rem;
  font-weight: 650;
  color: #2d3a49;
}

input,
textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  font-size: 0.94rem;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.4;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
  outline: 0;
}

input::placeholder,
textarea::placeholder {
  color: #8a97a6;
}

input[type="checkbox"] {
  accent-color: var(--brand);
}

h2 {
  margin-top: 20px;
  margin-bottom: 8px;
  font-size: 0.98rem;
  letter-spacing: 0;
}

.hint {
  margin: 2px 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.section-heading {
  margin: 22px 0 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.section-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.section-add {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
  flex: 0 0 auto;
}

.entry-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.entry-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(23, 33, 47, 0.04);
}

.entry-card-header {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.entry-field {
  margin: 0;
  display: grid;
  gap: 6px;
}

.entry-field span {
  font-size: 0.8rem;
  color: var(--muted);
}

.entry-input,
.point-input {
  width: 100%;
}

.point-input,
#skills {
  min-width: 0;
  overflow-wrap: anywhere;
}

textarea.point-input {
  min-height: 42px;
  resize: vertical;
}

.points-box {
  margin-top: 12px;
  border-top: 1px dashed var(--line-strong);
  padding-top: 10px;
}

.points-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.86rem;
  font-weight: 600;
}

.point-add {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.points-list {
  display: grid;
  gap: 8px;
}

.point-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

.row-remove,
.entry-remove {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.row-remove {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
}

.row-remove:hover,
.entry-remove:hover {
  border-color: #e2b8b8;
  background: #fff5f5;
  color: var(--danger);
}

.entry-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.entry-remove {
  padding: 7px 12px;
  font-size: 0.82rem;
}

.header-details-group {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  margin-bottom: 20px;
}

.contact-grid {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-strong);
  background: transparent;
}

.contact-field {
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 10px;
}

.contact-field span {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: var(--muted);
}

.contact-field input[type="text"],
.contact-field input[type="email"],
.contact-field input[type="url"] {
  grid-column: 1;
}

.contact-field input[type="checkbox"] {
  grid-column: 2;
  justify-self: end;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

button,
.button {
  border: 0;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  padding: 9px 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(23, 33, 47, 0.1);
  transition: background 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
/* Normalize font metrics so <button> and <a class="button"> match exactly */
.button,
button {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.section-add,
.point-add {
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-family: Arial, sans-serif;
  font-weight: 700;
  line-height: 1;
}

.section-add {
  font-size: 1.1rem;
}

.point-add {
  font-size: 1.05rem;
}

button:hover,
.button:hover {
  background: var(--brand-dark);
  box-shadow: 0 8px 20px rgba(31, 111, 235, 0.18);
}

.button.secondary {
  background: var(--success);
}

button:active,
.button:active {
  transform: translateY(1px);
}

.error {
  margin-top: 10px;
  white-space: pre-wrap;
  color: var(--danger);
  font-size: 0.86rem;
}

.preview-panel {
  padding: 12px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 2px 10px;
  padding: 2px 2px 10px;
  border-bottom: 1px solid var(--line);
}

.preview-header h2 {
  margin: 0;
}

#status {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.preview-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.preview-actions .button {
  padding: 6px 10px;
  font-size: 0.88rem;
  border-radius: 7px;
}

.preview-actions .button.secondary {
  padding: 6px 10px;
}

#pdf-frame {
  width: 100%;
  flex: 1 1 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f7fa;
  box-shadow: inset 0 1px 3px rgba(23, 33, 47, 0.06);
}

.assistant-chat {
  position: fixed;
  right: 18px;
  bottom: 82px;
  z-index: 20;
  width: min(380px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 112px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 60px rgba(23, 33, 47, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(0.98);
  transition: opacity 160ms ease, transform 160ms ease;
}

.assistant-chat.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.assistant-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.assistant-chat-header h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.assistant-chat-header span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.assistant-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
  background: #f7f9fc;
}

.assistant-message {
  max-width: 86%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
  background: #fff;
}

.assistant-message-agent {
  align-self: flex-start;
}

.assistant-chat-form {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.assistant-attach-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  box-shadow: none;
}

.assistant-attach-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.assistant-attach-button:hover {
  border-color: var(--brand);
  background: #f8fbff;
  color: var(--brand);
  box-shadow: none;
}

.assistant-chat-form textarea {
  min-height: 44px;
  max-height: 140px;
  resize: vertical;
}

.assistant-chat-form button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.assistant-upload-status {
  grid-column: 1 / -1;
  min-height: 16px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.assistant-message-user {
  align-self: flex-end;
  border-color: rgba(31, 111, 235, 0.25);
  background: #eaf2ff;
}

.assistant-chat-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 21;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--panel);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(23, 33, 47, 0.12);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.assistant-chat-toggle img {
  width: 52px;
  height: 52px;
}

.assistant-chat-toggle:hover {
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(23, 33, 47, 0.18);
  transform: scale(1.1);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .panel-resizer {
    display: none;
  }

  html, body {
    overflow: auto;
  }

  #pdf-frame {
    height: 70vh;
  }

  .assistant-chat {
    right: 12px;
    bottom: 76px;
    width: calc(100vw - 24px);
    height: min(560px, calc(100vh - 100px));
  }

  .assistant-chat-toggle {
    right: 12px;
    bottom: 12px;
  }
}

.assistant-message-typing {
  display: flex;
  align-items: center;
}

.assistant-message-typing .typing-dot {
  width: 8px;
  height: 8px;
  margin: 0 2px;
  background-color: #8a97a6;
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.assistant-message-typing .typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

.assistant-message-typing .typing-dot:nth-child(3) {
  animation-delay: -0.32s;
}

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}
