/* ============================================================
   Siraty — styles
   Logical properties are used throughout so the interface works
   in both Arabic (RTL) and English (LTR).
   ============================================================ */

:root {
  --accent: #246c60;
  --accent-deep: #1b564c;
  --ink: #1f332d;
  --muted: #566860;        /* ≥ 5.5:1 on white */
  --faint: #586861;        /* ≥ 5:1 on every background used */
  --line: #dde4dc;
  --bg: #f6f7f2;
  --focus: #8a6d1f;
  --danger: #9a4a39;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans Arabic', Tahoma, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: 0; transition: background-color .15s, filter .15s; -webkit-tap-highlight-color: transparent; }
button:hover:not(:disabled) { filter: brightness(.96); }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

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

.skip-link {
  position: absolute; inset-inline-start: 12px; top: -60px; z-index: 10;
  background: #fff; color: var(--accent-deep); padding: 10px 16px; border-radius: 8px;
  box-shadow: 0 4px 16px #0003;
}
.skip-link:focus { top: 10px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ───────── top bar ───────── */
.topbar {
  min-height: 80px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 4%; border-bottom: 1px solid var(--line); background: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 28px; font-weight: 700; }
.brand-icon {
  display: grid; place-items: center; width: 39px; height: 43px;
  background: var(--accent); color: #fff; border-radius: 12px 3px 12px 3px; font-size: 26px;
}
html[dir=ltr] .brand-icon { border-radius: 3px 12px 3px 12px; }
.brand-tag {
  font-size: 13px; font-weight: 400; color: var(--muted);
  margin-inline-start: 14px; padding-inline-start: 18px; border-inline-start: 1px solid var(--line);
}
.top-actions { display: flex; gap: 16px; align-items: center; }
#saved { font-size: 13px; color: #4d6a5e; }
.primary { background: var(--accent); color: #fff; padding: 11px 22px; border-radius: 8px; font-weight: 500; }
.primary .arrow { margin-inline-start: 10px; font-size: 18px; }
.ghost { background: none; border: 1px solid var(--line); color: var(--muted); padding: 8px 14px; border-radius: 8px; font-size: 13px; }

/* ───────── intro ───────── */
main { max-width: 1600px; margin: auto; padding: 32px 4% 0; }
.intro { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { color: #4f6d62; font-size: 13px; }
h1 { font-size: 31px; font-weight: 500; line-height: 1.6; margin: 4px 0; }
h1 em { font-style: normal; color: var(--accent); }
.intro p { margin: 0; color: var(--muted); }
.intro-note { display: flex; align-items: center; gap: 13px; color: #5d6a52; padding: 16px 24px; border: 1px solid #dfe4d5; border-radius: 12px; }
.intro-note > span { font-size: 32px; color: #a39468; }
.intro-note small { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; }

/* ───────── workspace grid ───────── */
.workspace { display: grid; grid-template-columns: minmax(330px, 1fr) minmax(380px, 1.24fr) 200px; gap: 22px; align-items: start; }

.editor { background: #fff; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }

.resume-switch { padding: 16px 24px 14px; background: #fafbf7; border-bottom: 1px solid var(--line); }
.resume-switch > label { font-size: 12px; color: var(--muted); }
.switch-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.switch-row select { margin: 0; flex: 1; min-width: 0; }
.chip-btn { background: #edf3ee; color: var(--accent-deep); border-radius: 7px; padding: 8px 12px; font-size: 13px; white-space: nowrap; }
.danger-btn { color: var(--danger); background: #f7ece8; }

.editor-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 10px; }
h2 { font-size: 18px; margin: 0; font-weight: 600; }
.editor-head > span { font-size: 13px; color: var(--muted); }
.progress { height: 3px; background: #edf1eb; margin: 0 24px 16px; }
.progress i { display: block; height: 3px; background: #5f9078; transition: width .2s; }

.tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { flex: 1; min-width: max-content; color: var(--muted); background: none; padding: 10px 8px 13px; border-bottom: 2px solid transparent; font-size: 14px; }
.tabs .active { color: var(--accent-deep); border-bottom-color: var(--accent); font-weight: 600; }

#editorForm { padding: 22px 24px; }
.section-title { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.section-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; background: #eef3ed; border-radius: 9px; color: #476654; font-size: 13px; }
h3 { font-size: 16px; font-weight: 600; margin: 0; }
.section-title p { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.group { margin-bottom: 26px; }
.group h4 { margin: 0 0 12px; font-size: 14px; color: var(--accent-deep); padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.fields { display: grid; gap: 16px; }

label, .field-label { display: block; font-size: 13px; font-weight: 500; color: #3f544b; }
input, textarea, select {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid #cfd8cd; border-radius: 7px; background: #fff; color: var(--ink); font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { outline: 0; border-color: #4f8a75; box-shadow: 0 0 0 3px #246c6024; }
input::placeholder, textarea::placeholder { color: #6e7a73; }
input[type=checkbox] { display: inline-block; width: auto; margin: 0; }
textarea { resize: vertical; line-height: 1.8; min-height: 70px; }
label small, .photo-field small { display: block; color: var(--faint); font-size: 12px; font-weight: 400; margin-top: 6px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.photo-row { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.photo-thumb { width: 64px; height: 64px; border-radius: 50%; background: #eef3ed center / cover no-repeat; border: 1px dashed #b5c4b8; flex: none; }
.photo-thumb.has-photo { border-style: solid; }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.repeat-card { display: grid; gap: 12px; padding: 14px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 8px; }
.remove { background: none; color: var(--danger); font-size: 13px; justify-self: start; padding: 4px 0; }
.add { width: 100%; padding: 10px; background: #edf3ee; color: var(--accent-deep); border-radius: 7px; font-size: 14px; }

.editor-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 24px 20px; }
.text-button { background: none; color: #4f6a5c; font-size: 13px; padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }
.next { background: #edf3ee; color: var(--accent-deep); border-radius: 6px; padding: 9px 14px; font-size: 14px; }
.privacy { text-align: center; color: var(--faint); font-size: 12px; background: #fafbf7; padding: 12px; border-top: 1px solid #eff1ea; }

/* ───────── preview area ───────── */
.preview-area { background: #e8ece4; border: 1px solid #dde3d8; border-radius: 13px; padding: 0 20px 16px; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; min-height: 60px; font-size: 13px; }
.preview-toolbar strong { font-weight: 500; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #4f8f74; margin-inline-end: 8px; }
.paper-label { color: var(--faint); font-size: 11px; margin-inline-start: 10px; }
.direction-control { display: flex; align-items: center; gap: 8px; }
.direction-control label { font-size: 12px; color: var(--muted); }
.direction-control select { width: auto; padding: 4px 8px; margin: 0; background: transparent; font-size: 13px; border-color: transparent; }
.paper-wrap { filter: drop-shadow(0 5px 8px #233c3614); }
.preview-hint { text-align: center; color: var(--muted); font-size: 12px; padding-top: 14px; }

/* ───────── design panel ───────── */
.design-heading { display: flex; justify-content: space-between; padding: 14px 0; font-size: 15px; font-weight: 600; }
.design-heading .spark { color: #8fa584; font-size: 19px; }
.panel-label { margin: 18px 0 10px; color: var(--muted); font-size: 13px; }
.templates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.template { position: relative; width: 100%; padding: 8px 6px 10px; text-align: center; border: 1px solid #dbe2d5; border-radius: 9px; background: transparent; color: var(--muted); }
.template.selected { border-color: #3f7d67; background: #eaf1e8; }
.template.selected::after { content: '✓'; position: absolute; top: 8px; inset-inline-end: 8px; width: 17px; height: 17px; border-radius: 50%; background: #3f7d67; color: #fff; text-align: center; font-size: 11px; line-height: 17px; }
.template strong { display: block; margin-top: 7px; font-size: 13px; font-weight: 500; color: var(--ink); }
.template small { font-size: 12px; color: var(--faint); }
@media (min-width: 1151px) { .template small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } }

.mini { display: block; margin-inline: auto; width: 67px; height: 77px; padding: 11px 9px; background: #fff; box-shadow: 0 1px 5px #324c3418; }
.mini i { display: block; width: 32px; height: 8px; margin-bottom: 8px; background: #7b9d8b; }
.mini b { display: block; height: 3px; margin-top: 5px; background: #d9e0d8; }
.mini b:last-child { width: 70%; }
.modern-mini { border-top: 3px solid #7b9d8b; }
.classic-mini { border-bottom: 2px solid #81929b; }
.classic-mini i { margin-inline: auto; background: #81929b; }
.minimal-mini i { background: #888f89; width: 24px; }
.compact-mini { padding: 8px 8px; }
.compact-mini i { width: 40px; height: 6px; margin-bottom: 5px; }
.compact-mini b { height: 2px; margin-top: 3px; border-inline-start: 3px solid #7b9d8b; }

.banner-mini { padding: 0 0 0; }
.banner-mini i { width: 100%; height: 22px; margin: 0 0 8px; background: #5f8f7d; }
.banner-mini b { margin-inline: 9px; }
.sidebar-mini { position: relative; padding: 11px 8px 0; }
.sidebar-mini i { position: absolute; top: 0; bottom: 0; inset-inline-start: 0; width: 22px; height: auto; margin: 0; background: #5f8f7d; }
.sidebar-mini b { margin-inline-start: 26px; }
.ribbon-mini b:first-of-type { height: 6px; background: #7b9d8b; }
.ribbon-mini i { width: 24px; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; background: var(--swatch); color: #fff; font-size: 13px; }
.swatches button[aria-pressed=true] { outline: 2px solid var(--swatch); outline-offset: 3px; }

.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.order-list li { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 3px 4px 3px 4px; border-radius: 6px; font-size: 13px; }
.order-list li:hover { background: #eef3ed; }
.order-btns { display: flex; gap: 2px; }
.order-btns button { width: 26px; height: 26px; border-radius: 5px; background: #e8efe7; color: var(--accent-deep); font-size: 10px; }

.design-tip { margin: 24px 0 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.design-tip > span { color: #a99a6c; font-size: 22px; }
.design-tip h3 { margin-top: 6px; font-size: 13px; }
.design-tip p { margin: 6px 0; font-size: 12px; line-height: 1.9; color: var(--muted); }
.utility { display: block; width: 100%; padding: 7px 0; background: none; color: #4a6a58; font-size: 12px; text-align: start; }
.danger { color: var(--danger); margin-top: 8px; }

.site-footer { display: flex; justify-content: space-between; gap: 12px; padding: 26px 0; font-size: 12px; color: var(--faint); }
.footer-brand { font-size: 15px; color: #476654; }

.toast {
  position: fixed; bottom: 24px; left: 50%; z-index: 30; max-width: min(92vw, 560px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #234b3e; color: #fff; padding: 12px 22px; border-radius: 9px; box-shadow: 0 5px 20px #0003; font-size: 14px;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast:empty { display: none; }

/* print-tips dialog */
dialog { width: min(92vw, 460px); padding: 24px 26px; border: 0; border-radius: 14px; color: var(--ink); box-shadow: 0 20px 60px #0004; }
dialog::backdrop { background: #1d2a2599; }
dialog h2 { margin-bottom: 12px; }
dialog ol { margin: 0 0 14px; padding-inline-start: 22px; line-height: 1.9; font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 18px; margin-top: 18px; }

/* ============================================================
   Resume paper. Everything inside uses `em` so the same rules
   scale for the screen preview and for print.
   ============================================================ */
.paper {
  --cv-accent: #246c60;
  --cv-font: 'IBM Plex Sans Arabic', Tahoma, Arial, sans-serif;
  min-height: 640px; padding: 3.2em 2.8em;
  background: #fff; color: #2c3833;
  font-family: var(--cv-font); font-size: 11px; line-height: 1.7;
  overflow-wrap: anywhere;
}
.paper a { color: inherit; }
.placeholder { color: #6b7871 !important; }

.cv-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.6em; }
.cv-id { flex: 1; min-width: 0; }
.cv-name { margin: 0; font-size: 2.6em; font-weight: 600; line-height: 1.35; color: var(--cv-accent); }
.cv-title { margin: .5em 0 1em; font-size: 1.2em; color: #50635a; }
.contacts { display: flex; flex-wrap: wrap; gap: .3em 1.2em; padding-bottom: 1.5em; border-bottom: 1px solid #e6eae4; color: #5f6d65; font-size: .9em; }
.cv-photo { flex: none; width: 7.6em; height: 7.6em; object-fit: cover; border-radius: 50%; }

.cv-section { margin-top: 1.9em; }
.cv-section > h3 { display: flex; align-items: center; gap: .8em; margin: 0 0 .8em; font-size: 1.2em; color: var(--cv-accent); }
.cv-section > h3::after { content: ''; flex: 1; height: 1px; background: #dfe5dc; }
.cv-section p { margin: .3em 0; color: #4d5a53; }
.cv-section ul { margin: .3em 0; padding-inline-start: 1.4em; color: #4d5a53; }
.cv-section li { margin: .15em 0; }
.cv-entry { margin: 0 0 1.2em; break-inside: avoid; }
.entry-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 1em; font-weight: 600; }
.entry-heading time { flex: none; font-weight: 500; font-size: .95em; color: #44524b; }
.entry-place { margin-top: .2em; font-size: .95em; color: #5a6e63; }
.entry-text { margin-top: .3em; }
.skill-list { display: flex; flex-wrap: wrap; gap: .5em; list-style: none; padding: 0 !important; }
.skill-list li { margin: 0; padding: .35em .8em; background: #eef3ed; border-radius: 3px; font-size: .95em; }
.lang-list p, .lang-list ul { margin: .15em 0; }

/* layout-only wrapper (see render()): invisible on screen, page margins when printing */
.frame, .frame tbody, .frame tr, .frame td { display: block; width: 100%; padding: 0; border: 0; }
.frame thead, .frame tfoot { display: none; }

/* tint of the chosen accent colour, used by the coloured templates */
.paper { --cv-tint: #eaf1ed; }
@supports (color: color-mix(in srgb, red 10%, white)) {
  .paper { --cv-tint: color-mix(in srgb, var(--cv-accent) 11%, #fff); }
}

/* modern — accent bar on top, chips */
.paper.modern .cv-header { padding-top: 1.9em; border-top: .45em solid var(--cv-accent); }

/* classic — serif, centred, ruled headings */
.paper.classic { --cv-font: 'Noto Naskh Arabic', 'Times New Roman', Georgia, serif; font-size: 11.5px; line-height: 1.75; }
.paper.classic .cv-header { flex-direction: column; align-items: center; text-align: center; gap: .8em; padding-bottom: 1.2em; border-bottom: .18em double var(--cv-accent); }
.paper.classic .cv-photo { border-radius: 50%; width: 7em; height: 7em; }
.paper.classic .cv-name { color: #1d2a25; font-weight: 700; }
.paper.classic .contacts { justify-content: center; border: 0; padding-bottom: 0; }
.paper.classic .cv-section > h3 { display: block; padding-bottom: .3em; border-bottom: 1px solid var(--cv-accent); font-weight: 700; }
.paper.classic .cv-section > h3::after { display: none; }
.paper.classic .entry-heading time { font-style: italic; }
.paper.classic .skill-list li { background: none; padding: 0; border-radius: 0; }
.paper.classic .skill-list li:not(:last-child)::after { content: '،'; }
html .paper.classic[lang=en] .skill-list li:not(:last-child)::after { content: ','; }

/* minimal — airy, quiet headings, plain skills */
.paper.minimal { line-height: 1.85; }
.paper.minimal .cv-header { padding-top: 0; }
.paper.minimal .cv-name { color: #25312c; font-weight: 500; font-size: 2.4em; }
.paper.minimal .cv-photo { border-radius: .5em; width: 6em; height: 6em; }
.paper.minimal .contacts { border-bottom-color: transparent; }
.paper.minimal .cv-section { margin-top: 2.3em; }
.paper.minimal .cv-section > h3 { font-size: 1.05em; font-weight: 600; letter-spacing: 0; }
.paper.minimal .cv-section > h3::after { display: none; }
.paper.minimal .skill-list { gap: .2em 1.1em; }
.paper.minimal .skill-list li { padding: 0; background: none; border-radius: 0; }
.paper.minimal .skill-list li:not(:last-child)::after { content: '/'; margin-inline-start: 1.1em; color: #a2aca6; }

/* compact — dense, fits more on one page */
.paper.compact { font-size: 10px; line-height: 1.55; padding: 2.6em 2.4em; }
.paper.compact .cv-header { align-items: center; padding-bottom: 1.1em; border-bottom: .22em solid var(--cv-accent); }
.paper.compact .cv-name { font-size: 2.3em; }
.paper.compact .cv-title { margin: .2em 0 .6em; }
.paper.compact .contacts { padding-bottom: 0; border: 0; gap: .2em 1em; }
.paper.compact .cv-photo { width: 5.8em; height: 5.8em; border-radius: .4em; }
.paper.compact .cv-section { margin-top: 1.3em; }
.paper.compact .cv-section > h3 { margin-bottom: .5em; padding-inline-start: .6em; border-inline-start: .3em solid var(--cv-accent); font-size: 1.1em; line-height: 1.3; }
.paper.compact .cv-section > h3::after { display: none; }
.paper.compact .cv-entry { margin-bottom: .8em; }
.paper.compact .skill-list { gap: .2em 1.5em; }
.paper.compact .skill-list li { padding: 0; background: none; border-radius: 0; }
.paper.compact .skill-list li::before { content: '▪'; margin-inline-end: .5em; color: var(--cv-accent); }

/* banner — solid colour header band, tinted section headings */
.paper.banner .cv-header { align-items: center; padding: 1.8em 2em; background: var(--cv-accent); color: #fff; border-radius: .5em; }
.paper.banner .cv-name { color: #fff; font-size: 2.5em; }
.paper.banner .cv-title { margin-bottom: .8em; color: #ffffffe0; }
.paper.banner .contacts { padding-bottom: 0; border: 0; color: #fff; }
.paper.banner .cv-photo { border: .22em solid #fff; }
.paper.banner .cv-section > h3 { padding: .35em .8em; background: var(--cv-tint); border-inline-start: .3em solid var(--cv-accent); border-radius: .15em; }
.paper.banner .cv-section > h3::after { display: none; }
.paper.banner .skill-list li { background: var(--cv-tint); color: #26332d; }

/* sidebar — coloured band holding photo, contacts, skills and languages.
   The band is painted as the background of the whole layout (not of the column), so when the
   resume runs onto a second page the band continues down that page too. */
.paper.sidebar .cv-layout { display: grid; grid-template-columns: 31% 1fr; gap: 2em; align-items: start; }
.paper.sidebar .cv-layout { background-image: linear-gradient(var(--cv-accent), var(--cv-accent)); background-size: 31% 100%; background-repeat: no-repeat; }
.paper.sidebar[dir=rtl] .cv-layout { background-position: right top; }
.paper.sidebar[dir=ltr] .cv-layout { background-position: left top; }
.paper.sidebar .cv-side { padding: 1.8em 1.3em; color: #fff; }
.paper.sidebar .cv-side .cv-photo { display: block; width: 100%; height: auto; aspect-ratio: 1; margin-bottom: 1.3em; border: .2em solid #ffffff88; }
.paper.sidebar .cv-side .contacts { flex-direction: column; gap: .5em; padding: 0 0 .6em; border: 0; color: #fff; font-size: .95em; }
.paper.sidebar[dir=rtl] .cv-side .contacts > * { text-align: right; }
.paper.sidebar[dir=ltr] .cv-side .contacts > * { text-align: left; }
.paper.sidebar .cv-side .cv-section { margin-top: 1.5em; }
.paper.sidebar .cv-side .cv-section > h3 { padding-bottom: .35em; border-bottom: 1px solid #ffffff66; color: #fff; font-size: 1.1em; }
.paper.sidebar .cv-side .cv-section > h3::after { display: none; }
.paper.sidebar .cv-side p, .paper.sidebar .cv-side li { color: #fff; }
.paper.sidebar .cv-side .skill-list { flex-direction: column; gap: .35em; }
.paper.sidebar .cv-side .skill-list li { padding: 0; background: none; border-radius: 0; }
.paper.sidebar .cv-main { padding-top: 1.8em; }
.paper.sidebar .cv-main .cv-header { display: block; }
.paper.sidebar .cv-main .cv-title { margin-bottom: .2em; }

/* ribbon — filled colour bars for headings, outlined skill pills */
.paper.ribbon .cv-header { padding-bottom: 1.1em; border-bottom: .3em solid var(--cv-accent); }
.paper.ribbon .contacts { padding-bottom: 0; border: 0; }
.paper.ribbon .cv-section > h3 { padding: .4em .9em; background: var(--cv-accent); color: #fff; border-radius: .25em; }
.paper.ribbon .cv-section > h3::after { display: none; }
.paper.ribbon .entry-heading time { color: var(--cv-accent); font-weight: 600; }
.paper.ribbon .skill-list li { background: none; border: .1em solid var(--cv-accent); border-radius: 99px; color: var(--cv-accent); }

.empty-preview { padding: 85px 0; text-align: center; color: #62716a; font-size: 1.1em; }
.empty-preview span { display: block; margin-bottom: 15px; font-size: 3.4em; color: #c3d1c6; }

/* ============================================================
   Responsive
   ============================================================ */
@media (min-width: 1450px) {
  .paper { min-height: 735px; padding: 3.4em 3em; font-size: 12px; }
  .paper.classic { font-size: 12.5px; }
  .paper.compact { font-size: 11px; }
}

@media (max-width: 1150px) {
  .workspace { grid-template-columns: minmax(300px, 1fr) minmax(340px, 1.15fr); }
  .design-panel { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-start; }
  .design-heading { width: 100%; }
  .panel-label { margin: 0; width: 100%; }
  .templates { display: flex; flex-wrap: wrap; width: 100%; }
  .template { display: grid; text-align: start; grid-template-columns: 54px 1fr; gap: 0 10px; width: auto; min-width: 150px; flex: 1; align-items: center; }
  .mini { grid-row: 1 / 3; transform: scale(.65); transform-origin: top; width: 67px; margin-bottom: -25px; }
  .template strong, .template small { grid-column: 2; margin: 0; }
  .order-list { width: 100%; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .design-tip { display: none; }
  .intro-note { display: none; }
}

@media (max-width: 740px) {
  .topbar { padding: 10px 5%; }
  .brand { font-size: 24px; }
  .brand-tag, #saved, .primary .arrow { display: none; }
  .primary { padding: 9px 14px; font-size: 14px; }
  .ghost { padding: 8px 10px; }
  main { padding: 22px 5% 0; }
  h1 { font-size: 25px; }
  .workspace { display: flex; flex-direction: column; gap: 20px; }
  .editor, .preview-area, .design-panel { width: 100%; }
  .editor { order: 0; }
  .design-panel { order: 1; }
  .preview-area { order: 2; padding: 0 12px 12px; }
  .template { min-width: 130px; }
  .paper { min-height: 560px; padding: 2.4em 1.8em; font-size: 10px; }
  .paper.classic { font-size: 10.5px; }
  .paper.compact { font-size: 9px; }
  .cv-name { font-size: 2.2em; }
  .site-footer > span:last-child { display: none; }
  .direction-control label { display: none; }
  .pair { gap: 9px; }
  .switch-row { flex-wrap: wrap; }
  .switch-row select { flex-basis: 100%; }
}

@media (max-width: 480px) { .pair { grid-template-columns: 1fr; } }

/* iOS zooms into any field below 16px — keep touch inputs at 16px */
@media (pointer: coarse) {
  input, textarea, select { font-size: 16px; }
  .order-btns button { width: 36px; height: 36px; }
  .chip-btn, .add, .next, .remove { min-height: 40px; }
}

/* ============================================================
   Print — only the resume is printed
   ============================================================ */
/* Margin 0 is deliberate: browsers print their own header/footer (date, title, file path)
   only inside the page margin, so with no margin there is nowhere to print them.
   The page margins are rebuilt with the repeating header/footer rows of .frame below. */
@page { size: A4; margin: 0; }

@media print {
  html, body, main, .workspace, .preview-area, .paper-wrap {
    display: block !important; width: auto !important; max-width: none !important;
    margin: 0 !important; padding: 0 !important; border: 0 !important;
    background: #fff !important; filter: none !important; box-shadow: none !important;
  }
  .topbar, .intro, .editor, .design-panel, .preview-toolbar, .preview-hint,
  .site-footer, .toast, dialog, .skip-link { display: none !important; }

  .paper { min-height: 0 !important; padding: 0 !important; font-size: 10.5pt;
    print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .paper.classic { font-size: 11pt; }
  .paper.compact { font-size: 9.5pt; }
  .paper a { text-decoration: none; }
  .frame { display: table !important; width: 100% !important; border-collapse: collapse; }
  .frame thead { display: table-header-group !important; }
  .frame tfoot { display: table-footer-group !important; }
  .frame tbody { display: table-row-group !important; }
  .frame tr { display: table-row !important; }
  .frame td { display: table-cell !important; }
  .frame thead td, .frame tfoot td { height: 14mm; }
  .frame .frame-body { padding: 0 15mm !important; }
  .cv-header { break-inside: avoid; }
  .cv-section > h3 { break-after: avoid; }
  .cv-entry, .cv-section li { break-inside: avoid; }
}
