:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --ink: #122033;
  --muted: #5f6b7a;
  --primary: #1f5f93;
  --primary-2: #163f64;
  --success: #e9f8ef;
  --success-border: #97d9ad;
  --error: #fff0f0;
  --error-border: #f2a8a8;
  --line: #d9e3ee;
  --shadow: 0 18px 45px rgba(24, 48, 79, 0.12);
}
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; overflow: hidden; font-family: "Segoe UI", "Noto Sans Hebrew", Arial, Helvetica, sans-serif; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; background: radial-gradient(circle at top left, #dcebf8, var(--bg) 45%); color: var(--ink); }
.app-shell { width: min(1240px, calc(100% - 12px)); height: 100dvh; margin: 0 auto; padding: 6px 0; display: flex; flex-direction: column; gap: 7px; overflow: hidden; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: white; border-radius: 16px; padding: 7px 14px; box-shadow: var(--shadow); flex: 0 0 auto; }
.eyebrow { margin: 0 0 2px; letter-spacing: .08em; text-transform: uppercase; opacity: .8; font-size: 10px; }
h1 { margin: 0; font-size: clamp(17px, 1.8vw, 23px); line-height: 1.05; }
.subtitle { margin: 1px 0 0; opacity: .88; max-width: 760px; line-height: 1.16; font-size: 12.5px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.global-help-link {
  width: auto;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 999px;
  background: rgba(255,255,255,.96);
  color: var(--primary-2);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(0,0,0,.16);
}
.global-help-link span {
  width: 21px;
  height: 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(31,95,147,.22);
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.global-help-link:hover { background: white; color: var(--primary); box-shadow: 0 12px 26px rgba(0,0,0,.20); }
.global-help-link:hover span { border-color: var(--primary); background: var(--primary-2); }
.status-card { min-width: 104px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); border-radius: 12px; padding: 8px 10px; text-align: center; }
.status-card span { display: block; opacity: .75; font-size: 11px; }
.status-card strong { display: block; margin-top: 3px; font-size: 15px; }
.grid-form { flex: 1 1 auto; min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, 380px); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "job side" "actions actions"; gap: 8px; margin-top: 0; align-items: stretch; overflow: hidden; }
.panel, .alert { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px; box-shadow: 0 10px 30px rgba(24,48,79,.07); }
.job-panel { grid-area: job; min-width: 0; }
.side-panels { grid-area: side; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; overflow: auto; padding-inline-start: 2px; }
.files-panel { grid-area: files; }
.ai-panel { grid-area: ai; }
.personal-panel { grid-area: personal; }
.wide { grid-area: actions; }
.section-title { display: flex; align-items: flex-start; gap: 7px; margin-bottom: 5px; }
.section-title.compact { margin-bottom: 5px; }
.section-title-content { min-width: 0; flex: 1; }
.step { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: white; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; font-size: 13px; }
h2 { margin: 0; font-size: 15px; }
.section-title p, .hint, .actions p { margin: 2px 0 0; color: var(--muted); line-height: 1.2; font-size: 11px; }
label { display: block; margin-top: 6px; font-weight: 700; font-size: 13px; }
input, textarea, select { width: 100%; margin-top: 3px; border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; font: inherit; color: var(--ink); background: #fbfdff; outline: none; font-size: 12.5px; }
textarea { min-height: 0; height: auto; resize: none; direction: ltr; text-align: left; line-height: 1.28; overflow: auto; }
.job-panel label:has(textarea[name="job_text"]) { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.job-panel textarea[name="job_text"] { flex: 1 1 auto; min-height: 180px; }
.focus-textarea { flex: 0 0 auto; min-height: 50px; height: 56px; max-height: 56px; direction: rtl; text-align: right; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,95,147,.12); }
.checkbox-row { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.checkbox-row input { width: auto; margin: 0; }
.ai-panel { gap: 5px; overflow: auto; }
.ai-panel label { margin-top: 5px; }
.ai-panel input, .ai-panel select { min-height: 34px; }
.ai-panel .checkbox-row { min-height: 28px; }
.api-key-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.field-note { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.25; }
.api-key-row .field-note { margin-top: 0; }
.api-key-row .mini-button { flex: 0 0 auto; white-space: nowrap; }
.usage-note { display: grid; gap: 2px; margin: 5px 0 6px; padding: 7px 9px; border: 1px solid #cfe0ef; border-radius: 10px; background: #f5faff; color: var(--ink); font-size: 11.5px; line-height: 1.25; }
.usage-note strong { font-size: 13px; color: var(--primary-2); }
.ai-panel .section-title .step { font-size: 0; }
.ai-panel .section-title .step::after { content: "3"; font-size: 13px; }
.files-panel .upload-button { display: none; }
.files-panel .section-title .step { font-size: 0; }
.files-panel .section-title .step::after { content: "2"; font-size: 13px; }
.files-panel .file-picker-control { min-height: 38px; border-style: dashed; font-size: 13px; }
.template-field { margin-top: 7px; }
.field-label { display: block; font-weight: 700; font-size: 13px; }
.template-options { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; margin-top: 4px; }
.template-option {
  position: relative;
  min-height: 32px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfdff;
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 750;
  line-height: 1.15;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(31,95,147,.03);
}
.template-option input { position: absolute; opacity: 0; pointer-events: none; }
.template-option:hover { border-color: rgba(31,95,147,.42); background: #f6faff; }
.template-option:focus-within { border-color: rgba(31,95,147,.62); box-shadow: 0 0 0 2px rgba(31,95,147,.12); }
.template-option:has(input:checked) { border-color: var(--primary); background: #eef7ff; box-shadow: 0 0 0 2px rgba(31,95,147,.11); }
.template-swatch { width: 18px; height: 22px; border-radius: 4px; border: 1px solid rgba(18,32,51,.16); background: linear-gradient(90deg, #f3f7fb 0 32%, #0f355c 32%); box-shadow: 0 3px 8px rgba(18,32,51,.12); }
.template-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-preview {
  position: fixed;
  z-index: 90;
  top: 50%;
  left: 50%;
  width: min(330px, calc(100vw - 32px));
  padding: 10px;
  border: 1px solid rgba(18,32,51,.18);
  border-radius: 12px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 24px 70px rgba(18,32,51,.30);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.96);
  transform-origin: center;
  transition: opacity .14s ease, transform .14s ease;
}
.template-option:hover .template-preview,
.template-option:focus-within .template-preview { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.preview-page {
  width: 100%;
  aspect-ratio: 1 / 1.414;
  display: block;
  overflow: hidden;
  border: 1px solid #d8dee8;
  border-radius: 5px;
  background: white;
}
.preview-header { display: block; height: 18%; background: #0f355c; }
.preview-body { display: grid; grid-template-columns: 34% 1fr; height: 82%; }
.preview-side { display: grid; align-content: start; gap: 5px; padding: 10px 7px; background: #f3f7fb; }
.preview-main { display: grid; align-content: start; gap: 6px; padding: 11px 9px; }
.preview-side span,
.preview-main span { display: block; height: 4px; border-radius: 999px; background: #c6d1dd; }
.preview-main span:nth-child(1),
.preview-main span:nth-child(4) { width: 64%; height: 5px; background: #0f355c; }
.preview-main span:nth-child(2),
.preview-main span:nth-child(5) { width: 92%; }
.preview-main span:nth-child(3),
.preview-main span:nth-child(6) { width: 78%; }
.template-executive .template-swatch { background: linear-gradient(90deg, #f8f6f0 0 32%, #14213d 32% 82%, #c89b3c 82%); }
.template-clean .template-swatch { background: linear-gradient(90deg, #f2faf9 0 30%, #0f3d3e 30% 82%, #2c7a7b 82%); }
.template-bold .template-swatch { background: linear-gradient(90deg, #f7f4f2 0 36%, #20242c 36% 82%, #b8563b 82%); }
.template-minimal .template-swatch { background: linear-gradient(90deg, #f7f8fa 0 28%, #fff 28% 80%, #111827 80%); }
.template-slate .template-swatch { background: linear-gradient(90deg, #f1f4f7 0 38%, #2f3a4a 38% 82%, #8fa3b8 82%); }
.template-emerald .template-swatch { background: linear-gradient(90deg, #f0faf5 0 33%, #064e3b 33% 82%, #10b981 82%); }
.template-maroon .template-swatch { background: linear-gradient(90deg, #fbf5f6 0 31%, #5b1f2e 31% 82%, #d6a24a 82%); }
.template-executive .preview-header { background: linear-gradient(90deg, #14213d 0 82%, #c89b3c 82%); }
.template-executive .preview-body { grid-template-columns: 32% 1fr; }
.template-executive .preview-side { background: #f8f6f0; }
.template-executive .preview-main span:nth-child(1),
.template-executive .preview-main span:nth-child(4) { background: #14213d; }
.template-clean .preview-header { background: linear-gradient(90deg, #0f3d3e 0 82%, #2c7a7b 82%); }
.template-clean .preview-body { grid-template-columns: 30% 1fr; }
.template-clean .preview-side { background: #f2faf9; }
.template-clean .preview-main span:nth-child(1),
.template-clean .preview-main span:nth-child(4) { background: #0f3d3e; }
.template-bold .preview-header { background: linear-gradient(90deg, #20242c 0 82%, #b8563b 82%); }
.template-bold .preview-body { grid-template-columns: 36% 1fr; }
.template-bold .preview-side { background: #f7f4f2; }
.template-bold .preview-main span:nth-child(1),
.template-bold .preview-main span:nth-child(4) { background: #20242c; }
.template-minimal .preview-header { height: 15%; background: white; border-bottom: 3px solid #111827; }
.template-minimal .preview-body { grid-template-columns: 28% 1fr; }
.template-minimal .preview-side { background: #f7f8fa; }
.template-minimal .preview-main span:nth-child(1),
.template-minimal .preview-main span:nth-child(4) { background: #111827; }
.template-slate .preview-header { background: linear-gradient(90deg, #2f3a4a 0 82%, #8fa3b8 82%); }
.template-slate .preview-body { grid-template-columns: 38% 1fr; }
.template-slate .preview-side { background: #f1f4f7; }
.template-slate .preview-main span:nth-child(1),
.template-slate .preview-main span:nth-child(4) { background: #2f3a4a; }
.template-emerald .preview-header { background: linear-gradient(90deg, #064e3b 0 82%, #10b981 82%); }
.template-emerald .preview-body { grid-template-columns: 33% 1fr; }
.template-emerald .preview-side { background: #f0faf5; }
.template-emerald .preview-main span:nth-child(1),
.template-emerald .preview-main span:nth-child(4) { background: #065f46; }
.template-maroon .preview-header { background: linear-gradient(90deg, #5b1f2e 0 82%, #d6a24a 82%); }
.template-maroon .preview-body { grid-template-columns: 31% 1fr; }
.template-maroon .preview-side { background: #fbf5f6; }
.template-maroon .preview-main span:nth-child(1),
.template-maroon .preview-main span:nth-child(4) { background: #5b1f2e; }
input[type="file"] { padding: 9px 10px; cursor: pointer; }
.file-picker { display: block; }
.file-picker > span:first-child { display: block; }
.file-picker input[type="file"] { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
.file-picker-control { display: flex; align-items: center; justify-content: center; min-height: 31px; margin-top: 4px; border: 1px solid var(--line); border-radius: 10px; background: #fbfdff; color: var(--ink); font-weight: 700; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(31,95,147,.04); font-size: 12.5px; line-height: 1.25; }
.file-picker-control:hover { border-color: var(--primary); background: #f5f9fc; }
.actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: transparent; padding: 0 2px; min-height: 36px; }
button { appearance: none; border: 0; border-radius: 12px; background: var(--primary); color: white; font: 700 13.5px/1.25 "Segoe UI", "Noto Sans Hebrew", Arial, Helvetica, sans-serif; letter-spacing: 0; padding: 9px 16px; cursor: pointer; box-shadow: 0 12px 25px rgba(31,95,147,.28); }
button:hover { background: var(--primary-2); }
button:disabled { cursor: wait; opacity: .78; }
.alert { margin-top: 18px; }
.alert pre { white-space: pre-wrap; direction: ltr; text-align: left; }
.success { background: var(--success); border-color: var(--success-border); }
.error { background: var(--error); border-color: var(--error-border); }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.links a { display: inline-block; padding: 10px 14px; border-radius: 999px; background: white; color: var(--primary); text-decoration: none; border: 1px solid var(--line); font-weight: 700; }
.result-panel { padding: 16px; }
.result-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.result-header p { margin: 5px 0 0; }
.primary-link { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 10px 16px; border-radius: 12px; background: var(--primary); color: white; text-decoration: none; font-weight: 700; line-height: 1.25; white-space: nowrap; box-shadow: 0 10px 20px rgba(31,95,147,.22); }
.primary-link:hover { background: var(--primary-2); }
.pdf-window { height: min(76vh, 760px); min-height: 520px; margin-top: 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #eef3f8; }
.pdf-window iframe { display: block; width: 100%; height: 100%; border: 0; background: white; }
.selected-files { margin-top: 8px; }
.selected-files strong, .file-list-title { display: block; margin: 0 0 5px; font-size: 12px; color: var(--muted); }
.file-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; max-height: 120px; overflow: auto; }
.file-list.compact { max-height: 58px; margin-bottom: 8px; }
.file-list li { direction: ltr; text-align: left; padding: 5px 7px; background: #f5f8fb; border: 1px solid var(--line); border-radius: 8px; font-size: 11px; }
.managed-file-list { margin: 0; padding: 0 2px 2px; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; max-height: 150px; overflow: auto; scrollbar-gutter: stable; }
.managed-file-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 3px; min-height: 24px; padding: 2px 4px; background: #f5f8fb; border: 1px solid var(--line); border-radius: 7px; }
.managed-file-list li::before { content: attr(data-filename); display: block; min-width: 0; direction: ltr; unicode-bidi: plaintext; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9.5px; line-height: 1.15; color: var(--ink); font-weight: 700; }
.managed-file-name { display: none; }
.file-actions { display: flex; gap: 3px; }
.mini-button { min-height: 22px; padding: 3px 6px; border-radius: 6px; box-shadow: none; font-size: 10.5px; font-weight: 700; line-height: 1.15; }
.mini-button.danger { background: #b42318; }
.mini-button.danger:hover { background: #861b13; }
.mini-link { display: inline-flex; align-items: center; justify-content: center; min-height: 22px; padding: 3px 6px; border-radius: 6px; background: #eef3f8; color: var(--ink); text-decoration: none; font-size: 10.5px; font-weight: 700; line-height: 1.15; }
.mini-link:hover { background: #d9e3ee; }
code { direction: ltr; unicode-bidi: isolate; }
.loading-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: rgba(18,32,51,.58); backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
.loading-overlay.is-visible { opacity: 1; pointer-events: auto; }
.loading-box { width: min(440px, 100%); border: 1px solid rgba(255,255,255,.58); border-radius: 24px; padding: 28px; background: rgba(255,255,255,.95); box-shadow: 0 24px 70px rgba(0,0,0,.24); text-align: center; }
.loading-box h2 { margin-top: 18px; font-size: 22px; }
.loading-box p { margin: 10px auto 0; color: var(--muted); line-height: 1.6; max-width: 340px; }
.loader { display: flex; justify-content: center; align-items: center; gap: 10px; height: 54px; }
.loader span { width: 14px; height: 14px; border-radius: 50%; background: var(--primary); animation: loader-bounce .8s infinite ease-in-out both; }
.loader span:nth-child(2) { animation-delay: .12s; background: #2f8c77; }
.loader span:nth-child(3) { animation-delay: .24s; background: #d78b32; }
.loading-bar { height: 8px; margin-top: 22px; overflow: hidden; border-radius: 999px; background: #d9e3ee; }
.loading-bar span { display: block; width: 42%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #2f8c77, #d78b32); animation: loading-sweep 1.35s infinite ease-in-out; }
.has-result-modal { overflow: hidden; }
.result-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; background: rgba(18,32,51,.62); backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
.result-overlay.is-visible { opacity: 1; pointer-events: auto; }
.result-modal { width: min(1120px, 100%); max-height: calc(100vh - 36px); display: flex; flex-direction: column; gap: 12px; border: 1px solid rgba(255,255,255,.58); border-radius: 22px; padding: 16px; background: rgba(255,255,255,.97); box-shadow: 0 24px 80px rgba(0,0,0,.28); }
.result-modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.result-modal-header .eyebrow { color: var(--primary); }
.result-modal-header h2 { margin: 0; font-size: 24px; }
.result-modal-header p { margin: 5px 0 0; color: var(--muted); }
.close-button { width: 42px; height: 42px; flex: 0 0 auto; padding: 0; border-radius: 50%; box-shadow: none; font-size: 26px; line-height: 1; background: #eef3f8; color: var(--ink); }
.close-button:hover { background: #d9e3ee; }
.modal-pdf-window { min-height: 0; height: min(68vh, 720px); overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #eef3f8; }
.modal-pdf-window object, .modal-pdf-window iframe { display: block; width: 100%; height: 100%; border: 0; background: white; }
.pdf-missing { margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff8e8; color: #7a4b00; }
.modal-downloads { display: flex; flex-wrap: wrap; gap: 10px; }
.modal-downloads a { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 14px; border-radius: 999px; background: var(--primary); color: white; text-decoration: none; border: 1px solid var(--primary); font-weight: 700; line-height: 1.25; }
.modal-downloads a:hover { background: var(--primary-2); }
.modal-log { max-height: 130px; overflow: auto; border-top: 1px solid var(--line); padding-top: 8px; }
.modal-log pre { white-space: pre-wrap; direction: ltr; text-align: left; margin-bottom: 0; }
.file-editor-overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 18px; background: rgba(18,32,51,.62); backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
.file-editor-overlay.is-visible { opacity: 1; pointer-events: auto; }
.file-editor-box { width: min(920px, 100%); max-height: calc(100vh - 36px); display: flex; flex-direction: column; gap: 12px; border: 1px solid rgba(255,255,255,.58); border-radius: 22px; padding: 16px; background: rgba(255,255,255,.97); box-shadow: 0 24px 80px rgba(0,0,0,.28); }
.file-editor-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.file-editor-header .eyebrow { color: var(--primary); }
#file-editor-content { min-height: 52vh; max-height: 62vh; resize: vertical; direction: ltr; text-align: left; font-family: Consolas, "Courier New", monospace; }
.editor-actions { display: flex; justify-content: flex-start; gap: 10px; }
.secondary-button { background: #eef3f8; color: var(--ink); box-shadow: none; }
.secondary-button:hover { background: #d9e3ee; }
.upload-button { width: 100%; min-height: 32px; margin-top: 5px; padding: 7px 10px; font-size: 12.5px; }
.help-button { width: 100%; margin-top: 8px; background: #f7fbff; color: var(--primary); border: 1px solid var(--line); box-shadow: none; }
.help-button:hover { background: #edf6ff; }
.prominent-help { min-height: 40px; margin-top: 10px; background: #fff8e8; color: #7a4b00; border: 1px solid #efc36d; box-shadow: 0 8px 18px rgba(122,75,0,.12); }
.prominent-help:hover { background: #ffefd0; }
.panel { min-width: 0; min-height: 0; overflow: hidden; }
.job-panel, .ai-panel, .files-panel, .personal-panel { display: flex; flex-direction: column; }
.job-panel { overflow: hidden; }
.files-panel { order: 1; flex: 0 0 auto; max-height: 32dvh; }
.ai-panel { order: 2; overflow: auto; }
.personal-panel { order: 3; }
.personal-panel { overflow: auto; }
.files-panel .section-title p { display: none; }
.files-panel .managed-file-list { flex: 0 1 auto; min-height: 52px; }
.file-list-title { margin-top: 5px; }
.help-overlay { position: fixed; inset: 0; z-index: 65; display: grid; place-items: center; padding: 18px; background: rgba(18,32,51,.62); backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
.help-overlay.is-visible { opacity: 1; pointer-events: auto; }
.help-box { width: min(720px, 100%); max-height: calc(100vh - 36px); overflow: auto; border: 1px solid rgba(255,255,255,.58); border-radius: 22px; padding: 18px; background: rgba(255,255,255,.98); box-shadow: 0 24px 80px rgba(0,0,0,.28); }
.help-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.help-box h2 { font-size: 22px; }
.help-box h3 { margin: 14px 0 6px; font-size: 16px; }
.help-box p, .help-box li { color: var(--muted); line-height: 1.45; }
.help-box ul { margin: 6px 0 0; padding-inline-start: 20px; }
.sample-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sample-links a { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 8px 12px; border-radius: 999px; background: var(--primary); color: white; text-decoration: none; font-weight: 700; line-height: 1.25; }
@keyframes loader-bounce { 0%, 80%, 100% { transform: scale(.65); opacity: .45; } 40% { transform: scale(1.15); opacity: 1; } }
@keyframes loading-sweep { 0% { transform: translateX(150%); } 100% { transform: translateX(-250%); } }
@media (max-height: 760px) and (min-width: 861px) {
  .hero { padding-block: 6px; }
  .subtitle, .usage-note span, .section-title p { display: none; }
  .usage-note { padding: 5px 8px; }
  .grid-form { gap: 6px; }
  .side-panels { gap: 6px; }
  .panel, .alert { padding: 7px; }
  .job-panel textarea[name="job_text"] { min-height: 140px; }
  .focus-textarea { height: 48px; max-height: 48px; }
  .managed-file-list { max-height: 58px; }
  .template-option { min-height: 29px; padding: 4px; }
}
@media (max-width: 1180px) and (min-width: 1101px) {
  .grid-form { grid-template-columns: minmax(0, 1fr) minmax(310px, 350px); grid-template-areas: "job side" "actions actions"; }
  .managed-file-list { grid-template-columns: 1fr; max-height: 130px; }
  .template-options { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1100px) {
  .app-shell { width: min(100% - 10px, 1180px); height: 100dvh; }
  .hero { flex-direction: column; align-items: stretch; padding: 7px 10px; }
  .hero-actions { margin-top: 4px; }
  .grid-form {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) auto;
    grid-template-areas: "job" "side" "actions";
    gap: 7px;
    overflow: hidden;
  }
  .side-panels { overflow: auto; padding-inline-start: 0; }
  .job-panel { grid-row: auto; }
  .job-panel textarea[name="job_text"] { min-height: 110px; }
  .focus-textarea { height: 46px; max-height: 46px; }
  .managed-file-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 120px; }
  .actions, .result-header { flex-direction: column; align-items: stretch; gap: 6px; }
  .actions p { display: none; }
  button:not(.mini-button), .primary-link { width: 100%; }
  .pdf-window { min-height: 460px; height: 68vh; }
  .result-overlay { padding: 10px; }
  .result-modal { max-height: calc(100vh - 20px); padding: 12px; }
  .modal-pdf-window { height: 58vh; }
  .modal-downloads a { flex: 1 1 140px; }
}
@media (max-width: 640px), (max-height: 640px) {
  .eyebrow, .subtitle, .usage-note, .section-title p, .api-key-row .field-note { display: none; }
  h1 { font-size: 17px; }
  .section-title { margin-bottom: 3px; }
  label { margin-top: 4px; font-size: 12.5px; }
  input, textarea, select { min-height: 30px; padding: 5px 7px; }
  .hero-actions button { min-height: 30px; padding-block: 6px; }
  .managed-file-list { max-height: 110px; }
  .template-options { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .template-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .hero { padding: 6px 9px; border-radius: 12px; }
  .eyebrow, .subtitle { display: none; }
  h1 { font-size: 17px; }
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
  .global-help-link, .hero-actions button { min-height: 30px; padding: 6px 8px; font-size: 12px; }
  .grid-form { grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .panel, .alert { padding: 7px; border-radius: 12px; }
  .template-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .app-shell { width: min(100% - 8px, 1180px); padding-block: 4px; gap: 5px; }
  .hero { min-height: 0; }
  .hero-actions { display: none; }
  h1 { font-size: 16px; }
  .grid-form {
    grid-template-rows: minmax(0, .92fr) minmax(0, 1.08fr) auto;
    gap: 5px;
  }
  .side-panels {
    display: grid;
    grid-template-rows: auto minmax(0, .86fr) minmax(0, 1.14fr);
    gap: 5px;
    overflow: hidden;
  }
  .panel, .alert { padding: 6px; border-radius: 11px; }
  .section-title { gap: 5px; margin-bottom: 2px; }
  .step { width: 21px; height: 21px; font-size: 12px; }
  h2 { font-size: 14px; }
  label { margin-top: 3px; font-size: 12px; }
  input, textarea, select { min-height: 28px; padding: 4px 7px; font-size: 12px; }
  .job-panel textarea[name="job_text"] { min-height: 88px; }
  .focus-textarea { height: 38px; max-height: 38px; }
  .file-picker > span:first-child,
  .file-list-title,
  .field-note,
  .api-key-row,
  .checkbox-row:last-child { display: none; }
  .files-panel .file-picker-control { min-height: 30px; margin-top: 0; }
  .files-panel { max-height: 38dvh; }
  .managed-file-list { grid-template-columns: 1fr; max-height: 96px; }
  .managed-file-list li { min-height: 21px; padding: 1px 3px; }
  .ai-panel input, .ai-panel select { min-height: 28px; }
  .ai-panel,
  .personal-panel { min-height: 0; overflow: auto; }
  .personal-panel { display: flex; }
  .template-field { flex: 1 1 auto; min-height: 0; margin-top: 4px; display: flex; flex-direction: column; overflow: hidden; }
  .template-options { flex: 1 1 auto; min-height: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; overflow: auto; padding: 1px 1px 4px; }
  .template-option { min-height: 27px; grid-template-columns: 16px minmax(0, 1fr); gap: 4px; padding: 3px 4px; font-size: 9.8px; }
  .template-swatch { width: 16px; height: 20px; }
  .actions { min-height: 31px; }
  .actions button { min-height: 31px; padding-block: 6px; }
}
@media (max-width: 480px) {
  body { height: auto; min-height: 100vh; overflow: auto; }
  .app-shell { width: min(100% - 10px, 1180px); height: auto; min-height: 100dvh; overflow: visible; padding-block: 5px; }
  .hero { position: static; border-radius: 12px; }
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .grid-form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: visible;
    gap: 7px;
  }
  .side-panels {
    display: flex;
    flex-direction: column;
    overflow: visible;
    gap: 7px;
  }
  .panel, .alert { overflow: visible; }
  .job-panel { overflow: visible; }
  .job-panel textarea[name="job_text"] {
    height: 34vh;
    min-height: 190px;
    max-height: 360px;
    overflow: auto;
    resize: vertical;
  }
  .focus-textarea {
    height: 82px;
    max-height: none;
    resize: vertical;
  }
  .files-panel,
  .ai-panel,
  .personal-panel {
    overflow: visible;
  }
  .file-picker > span:first-child,
  .file-list-title,
  .field-note,
  .api-key-row,
  .checkbox-row:last-child {
    display: revert;
  }
  .api-key-row { display: flex; }
  .managed-file-list {
    grid-template-columns: 1fr;
    max-height: 160px;
    overflow: auto;
  }
  .template-field {
    display: block;
    overflow: visible;
  }
  .template-options {
    display: grid;
    grid-template-columns: 1fr;
    max-height: none;
    overflow: visible;
    gap: 5px;
    padding: 0;
  }
  .template-option {
    min-height: 36px;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 7px;
    padding: 6px;
    font-size: 11.5px;
  }
  .template-swatch { width: 22px; height: 26px; }
  .actions {
    position: sticky;
    bottom: 0;
    z-index: 20;
    padding: 6px 0 0;
    background: linear-gradient(180deg, rgba(238,243,248,0), var(--bg) 35%);
  }
  .actions button { min-height: 42px; }
}
@media (max-width: 860px) { .template-preview { display: none; } }
