/*
 * CertificateMaker: the tool's own components, styled in the site's design language (6 Oct 2026, on the
 * UltraCompress Pro template, after QUOTIFY). Base: /libs/site-pages.css (tokens, Inter and Space Grotesk, buttons,
 * theme toggle, focus rings) and /libs/shared-nav.css (the site's header and footer). This file holds only what the tool
 * itself needs: the toolbar, the collapsible editor sections beside the sticky preview, the template list, the border
 * picker, the colour pickers, the logo and signature drop zones, the signature pad, the windows (bulk, shortcuts, save
 * and load template), the history panel and the toasts. Light is the default; dark applies when <html> has no data-theme.
 * Every class and id the script touches keeps its name.
 *
 * The certificate itself (.certificate-canvas) keeps fixed paper colours on purpose: it is the page the PDF, the PNG and
 * the print are made from and must look the same in both page themes.
 */

/* ----- Tokens the tool adds ----- */
:root {
    --surface: #ffffff;                 /* cards are true white in the light theme */
    --surface-2: #f3f4f8;               /* a quiet inset inside a card */
    --ring: rgba(139, 92, 246, 0.18);
    --app-max: 1600px;
    --warning: #d97706;
    --error: #dc2626;
    --radius-sm: 8px;
    --radius-lg: 16px;
}
:root:not([data-theme="light"]) {
    --surface: #14141f;
    --surface-2: rgba(255, 255, 255, 0.05);
    --warning: #fbbf24;
    --error: #f87171;
}

/* ----- Page: full width, the page provides the side space ----- */
.container.app-container {
    max-width: calc(var(--app-max) + 2 * var(--content-gutter));
    margin-top: 16px;
}
@media (min-width: 640px) { .container.app-container { margin-top: 24px; } }

/* ----- Tools back link above the header, as on every other tool: the bar scrolls away under the sticky header ----- */
body { padding-top: 0; }
.back-bar { height: 48px; display: flex; align-items: center; padding: 0 var(--zdu-gutter, 24px); }
body > header { position: sticky; top: 0; z-index: 50; }
header .site-nav { position: relative; top: auto; }
.theme-toggle { top: calc(90px + var(--bar-offset, 48px)); }
@media (max-width: 768px) { .theme-toggle { top: calc(75px + var(--bar-offset, 48px)); } }

/* ----- Hero: brand row, headline, tagline ----- */
.app-hero { margin: 0 0 2rem; text-align: center; }
.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.25rem;
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-strong);
}
.app-brand img { width: 44px; height: 44px; border-radius: 12px; display: block; }
.app-hero h1 { margin-bottom: 0.75rem; }
.app-tagline { color: var(--text-2); font-size: 1.125rem; line-height: 1.6; max-width: 46rem; margin: 0 auto; }

/* ----- Buttons: the site's pills in the tool's sizes ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 9999px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    padding: 12px 24px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-strong); border: 1px solid var(--surface-border); padding: 11px 23px; }
.btn-secondary:hover:not(:disabled) { border-color: var(--brand); color: var(--link); transform: translateY(-2px); }
.btn-sm { font-size: 0.85rem; padding: 9px 16px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-secondary.btn-sm { padding: 8px 15px; }

/* ----- The app: the toolbar above the two panels ----- */
.app-shell { margin: 0 0 3rem; scroll-margin-top: 90px; }
.app-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; margin: 0 0 1.25rem; }
.app-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ----- The two panels: the editor and the preview ----- */
.main-content { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--surface-shadow);
    overflow: hidden;
}
.panel-header { padding: 14px 20px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-title { margin: 0; font-size: 1.05rem; font-weight: 700; }
.preview-note { font-size: 0.8125rem; color: var(--text-3); }
.preview-panel { position: sticky; top: 100px; max-height: calc(100vh - 120px); display: flex; flex-direction: column; }
.preview-wrapper { flex: 1; overflow: auto; padding: 32px; background: var(--surface-2); }
.certificate-stage { margin: 0 auto; position: relative; }

/* Editor sections (collapsible) */
.editor-section { border-bottom: 1px solid var(--surface-border); }
.editor-section:last-child { border-bottom: none; }
.editor-section-header {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}
.editor-section-header:hover { background: var(--surface-2); }
.editor-section-header:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.editor-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
}
.editor-section-title svg { width: 18px; height: 18px; color: var(--link); flex-shrink: 0; }
.editor-section-toggle { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; color: var(--text-3); transition: transform 0.2s ease; }
.editor-section.collapsed .editor-section-toggle { transform: rotate(-90deg); }
.editor-section-content { padding: 4px 20px 20px; display: grid; gap: 14px; }
.editor-section.collapsed .editor-section-content { display: none; }
.section-hint { margin: 0; font-size: 0.85rem; color: var(--text-3); }

/* Form fields */
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--text-strong); }
.form-hint { font-size: 0.78rem; color: var(--text-3); font-weight: 400; }
.editor-panel input:not([type="checkbox"]):not([type="color"]):not([type="file"]), .editor-panel select, .editor-panel textarea, .modal input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--field);
    border: 1px solid var(--field-border);
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.925rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.editor-panel input::placeholder, .editor-panel textarea::placeholder, .modal input::placeholder { color: var(--placeholder); }
.editor-panel input:focus, .editor-panel select:focus, .editor-panel textarea:focus, .modal input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.editor-panel textarea { resize: vertical; min-height: 84px; }
.editor-panel select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b93a1' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.editor-panel select option { color: #0a0a14; background: #fff; }
.editor-panel input[type="date"] { color-scheme: light; }
:root:not([data-theme="light"]) .editor-panel input[type="date"] { color-scheme: dark; }
.color-picker-wrapper { display: flex; align-items: center; gap: 8px; }
.color-picker-wrapper input[type="color"] { width: 42px; height: 42px; flex-shrink: 0; padding: 2px; border: 1px solid var(--surface-border); border-radius: 10px; cursor: pointer; background: var(--surface); }
.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker-wrapper input[type="color"]::-webkit-color-swatch { border: none; border-radius: 7px; }
.color-picker-wrapper input[type="text"] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Template list: five rows, a swatch and a name each, so every row is full */
.template-list { display: grid; gap: 8px; }
.template-card {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 10px;
    border: 2px solid var(--surface-border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text-strong);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.template-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--surface-hover-shadow); }
.template-card.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.template-preview {
    width: 56px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: Georgia, serif;
    font-weight: 700;
    font-size: 0.95rem;
}
.template-preview--achievement { background: linear-gradient(180deg, #fff9e6 0%, #fff 100%); color: #1a1a2e; border: 3px double #c9a227; }
.template-preview--course { background: linear-gradient(135deg, #f0f9ff 0%, #fff 100%); color: #1e40af; border: 2px solid #2563eb; }
.template-preview--award { background: linear-gradient(180deg, #fef3c7 0%, #fff 100%); color: #7c2d12; border: 4px ridge #c9a227; }
.template-preview--participation { background: linear-gradient(135deg, #ecfdf5 0%, #fff 100%); color: #065f46; border: 2px solid #065f46; }
.template-preview--appreciation { background: linear-gradient(180deg, #faf5ff 0%, #fff 100%); color: #581c87; border: 3px solid #7c3aed; }
.template-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.template-name { font-weight: 600; font-size: 0.9rem; }
.template-desc { font-size: 0.78rem; color: var(--text-3); }

/* Border picker: six options in two rows of three */
.border-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.border-option {
    height: 56px;
    border: 2px solid var(--surface-border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-2);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.border-option::before { content: ''; position: absolute; inset: 6px; border-radius: 4px; pointer-events: none; }
.border-option--classic::before { border: 3px double #c9a227; box-shadow: inset 0 0 0 1px #1a1a2e; }
.border-option--modern::before { border: 2px solid #2563eb; }
.border-option--elegant::before { border: 2px solid #1a1a2e; box-shadow: inset 0 0 0 1px #c9a227; }
.border-option--minimal::before { border: 1px solid #334155; }
.border-option--ornate::before { border: 4px ridge #c9a227; }
.border-option:hover { border-color: var(--brand); color: var(--link); transform: translateY(-2px); }
.border-option.active { border-color: var(--brand); color: var(--link); box-shadow: 0 0 0 3px var(--ring); }

/* Drop zones: the site's drop zone in miniature (tint, lift, the icon grows) */
.file-upload {
    border: 2px dashed rgba(139, 92, 246, 0.45);
    border-radius: 14px;
    padding: 18px 16px;
    text-align: center;
    cursor: pointer;
    background: var(--surface-2);
    transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}
.file-upload input[type="file"] { display: none; }
.file-upload:hover, .file-upload.dragover { border-color: var(--brand); background: var(--tint-brand); transform: translateY(-2px); box-shadow: var(--surface-hover-shadow); }
.file-upload:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.file-upload-icon {
    width: 48px;
    height: 48px;
    padding: 12px;
    margin: 0 auto 8px;
    border-radius: 50%;
    background: var(--gradient-brand);
    color: #fff;
    display: block;
    transition: transform 0.25s ease;
}
.file-upload:hover .file-upload-icon, .file-upload.dragover .file-upload-icon { transform: scale(1.1); }
.file-upload-text { font-size: 0.9rem; color: var(--text-2); }
.file-upload-text span { color: var(--link); font-weight: 600; }
.file-upload-hint { font-size: 0.78rem; color: var(--text-3); margin-top: 4px; }
.uploaded-preview { max-width: 180px; max-height: 80px; margin: 12px auto 0; display: block; border-radius: 8px; background: #fff; padding: 4px; border: 1px solid var(--surface-border); }
.uploaded-preview.hidden { display: none; }

/* Tabs and the signature pad */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
    padding: 8px 16px;
    border-radius: 9999px;
    border: 1px solid var(--chip-border);
    background: var(--chip);
    color: var(--text-2);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}
.tab:hover { border-color: var(--brand); color: var(--link); }
.tab.active { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.signature-pad-container { border: 1px solid var(--surface-border); border-radius: 12px; overflow: hidden; }
.signature-pad { display: block; width: 100%; height: 120px; background: #fff; cursor: crosshair; touch-action: none; }
.signature-pad-actions { padding: 10px 12px; background: var(--surface-2); border-top: 1px solid var(--surface-border); display: flex; justify-content: flex-end; gap: 8px; }

/* ===== The certificate: fixed colours, the same in both page themes (this is the PDF, the PNG and the print) ===== */
.certificate-canvas {
    --cert-bg: #ffffff;
    --cert-title: #1a1a2e;
    --cert-accent: #c9a227;
    background: #fff;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 10px 10px -5px rgba(0, 0, 0, 0.05);
    position: relative;
    transform-origin: top left;
    flex-shrink: 0;
    font-family: Georgia, serif;
    line-height: 1.6;
}
.certificate-canvas.a4-portrait { width: 595px; height: 842px; }
.certificate-canvas.a4-landscape { width: 842px; height: 595px; }
.certificate-canvas.letter-portrait { width: 612px; height: 792px; }
.certificate-canvas.letter-landscape { width: 792px; height: 612px; }
.certificate-inner {
    width: 100%;
    height: 100%;
    position: relative;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    background: var(--cert-bg);
}
/* Template tints: a light gradient into the background colour while it is white; a chosen colour replaces it */
.certificate-inner.template-achievement { background: linear-gradient(180deg, #fff9e6 0%, var(--cert-bg) 100%); }
.certificate-inner.template-course { background: linear-gradient(135deg, #f0f9ff 0%, var(--cert-bg) 100%); }
.certificate-inner.template-award { background: linear-gradient(180deg, #fef3c7 0%, var(--cert-bg) 100%); }
.certificate-inner.template-participation { background: linear-gradient(135deg, #ecfdf5 0%, var(--cert-bg) 100%); }
.certificate-inner.template-appreciation { background: linear-gradient(180deg, #faf5ff 0%, var(--cert-bg) 100%); }
.certificate-inner.custom-bg { background: var(--cert-bg); }
/* Border styles, drawn in the accent colour (the inner rings in the title colour) */
.border-classic { border: 12px double var(--cert-accent); box-shadow: inset 0 0 0 4px var(--cert-title); }
.border-modern { border: 4px solid var(--cert-accent); box-shadow: inset 0 0 0 2px #e2e8f0; }
.border-elegant { border: 8px solid var(--cert-title); box-shadow: inset 0 0 0 3px var(--cert-accent), inset 0 0 0 6px var(--cert-title); }
.border-minimal { border: 2px solid var(--cert-accent); }
.border-ornate { border: 16px ridge var(--cert-accent); box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.12); }
.border-none { border: none; }
/* Certificate content */
.cert-logo { max-width: 120px; max-height: 80px; object-fit: contain; }
.cert-header { text-align: center; margin-bottom: 10px; }
.cert-title { font-size: 36px; font-weight: 700; letter-spacing: 4px; text-transform: uppercase; margin-bottom: 5px; line-height: 1.2; }
.cert-subtitle { font-size: 16px; letter-spacing: 2px; text-transform: uppercase; opacity: 0.8; margin: 0; }
.cert-body { text-align: center; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 15px; max-width: 80%; }
.cert-recipient { font-size: 42px; font-weight: 600; border-bottom: 2px solid currentColor; padding-bottom: 5px; margin: 10px 0; line-height: 1.2; overflow-wrap: anywhere; }
.cert-description { font-size: 14px; line-height: 1.8; margin: 0; overflow-wrap: anywhere; }
.cert-footer { width: 100%; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-top: 20px; }
.cert-signature-block { text-align: center; min-width: 150px; }
.cert-signature-img { max-width: 120px; max-height: 50px; margin-bottom: 5px; display: inline-block; }
.cert-signature-typed { font-size: 24px; line-height: 1.3; margin-bottom: 5px; }
.cert-signature-line { width: 150px; border-bottom: 1px solid currentColor; margin: 0 auto 5px; }
.cert-signature-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin: 0; }
.cert-date-block { text-align: center; }
.cert-date { font-size: 14px; margin: 0 0 5px; }
.cert-date-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin: 0; }
/* Text alignment: the script sets align-left, align-center or align-right on the inner */
.certificate-inner.align-left .cert-header, .certificate-inner.align-left .cert-body { text-align: left; align-self: flex-start; }
.certificate-inner.align-right .cert-header, .certificate-inner.align-right .cert-body { text-align: right; align-self: flex-end; }
.hidden { display: none !important; }

/* ----- Windows (bulk, shortcuts, save and load template) ----- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 20, 0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(12px);
    transition: transform 0.25s ease;
}
.modal--narrow { max-width: 420px; }
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header, .sidebar-header { padding: 18px 20px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-title, .sidebar-title { margin: 0; font-size: 1.15rem; }
.modal-close {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid var(--chip-border);
    background: var(--chip);
    color: var(--text-strong);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, color 0.2s ease;
}
.modal-close:hover { border-color: var(--brand); color: var(--link); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; display: grid; gap: 14px; align-content: start; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--surface-border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-hint { display: block; margin: 0; }
.csv-preview { max-height: 220px; overflow: auto; border: 1px solid var(--surface-border); border-radius: 12px; }
.csv-preview table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 0; }
.csv-preview th, .csv-preview td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--surface-border); color: var(--text); }
.csv-preview th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; color: var(--text-strong); }
.progress-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--gradient-brand); transition: width 0.15s ease; }
.progress-text { font-size: 0.85rem; color: var(--text-2); margin: 8px 0 0; text-align: center; }
.shortcuts-list { display: grid; gap: 10px; }
.shortcut-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.shortcut-keys { display: flex; gap: 4px; }
.shortcut-key {
    background: var(--surface-2);
    border: 1px solid var(--surface-border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    color: var(--text-2);
}
.shortcut-description { font-size: 0.875rem; color: var(--text-2); }

/* Saved templates and history entries */
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    background: var(--surface-2);
    transition: border-color 0.2s ease, transform 0.2s ease;
}
.list-item + .list-item { margin-top: 8px; }
.list-item:hover { border-color: var(--brand); transform: translateY(-2px); }
.list-item--button { width: 100%; cursor: pointer; font-family: inherit; text-align: left; color: inherit; }
.list-item-info { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; color: var(--text-strong); overflow-wrap: anywhere; }
.list-item-subtitle { font-size: 0.8125rem; color: var(--text-3); overflow-wrap: anywhere; }
.list-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.list-item-actions .btn-sm { padding: 7px 14px; }
.btn-danger-ghost { color: var(--danger); border-color: rgba(185, 28, 28, 0.3); }
.btn-danger-ghost:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }

/* History panel (slides in from the right) */
.sidebar {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--surface-border);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.25);
    z-index: 1001;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}
.sidebar.active { right: 0; }
.sidebar-body { padding: 20px; overflow-y: auto; flex: 1; }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(10, 10, 20, 0.5); z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.25s ease, visibility 0.25s ease; }
.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* ----- Toasts ----- */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 32px); }
.toast {
    background: #0a0a14;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-left: 4px solid var(--brand);
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
    min-width: 260px;
    max-width: 400px;
    font-size: 0.875rem;
    font-weight: 500;
    overflow-wrap: anywhere;
    animation: slideIn 0.3s ease;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-success { border-left-color: #4ade80; }
.toast-error { border-left-color: #f87171; }
.toast-info { border-left-color: #38bdf8; }

/* ----- Information sections below the tool ----- */
.info-section { margin: 0 0 2.5rem; }
.info-section h2 { font-size: 1.75rem; margin: 0 0 1.25rem; }
.info-section > p { max-width: 70ch; }
/* Three columns on desktops, two on tablets, one on phones: six cards fill two rows without a gap. */
.info-section .info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.info-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 1rem 0 1.5rem; }
.info-stack { display: grid; gap: 12px; }
.info-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    box-shadow: var(--surface-shadow);
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.info-card:hover { transform: translateY(-4px); box-shadow: var(--surface-hover-shadow); }
.info-card--small { padding: 16px; box-shadow: none; }
.info-card h3 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.info-card p { color: var(--text-2); margin-bottom: 0.75rem; }
.info-card p:last-child { margin-bottom: 0; }
.info-section article:not(.info-card) p { color: var(--text-2); max-width: 70ch; }
.step-card { position: relative; padding-top: 24px; }
.step-num {
    position: absolute;
    top: -16px;
    left: 20px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gradient-brand);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 0.75rem; }
.step-head h3 { margin: 0; }
.step-emoji { font-size: 1.6rem; line-height: 1; }
.info-section details.info-card { padding: 0; }
.info-section details.info-card summary {
    cursor: pointer;
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-strong);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.info-section details.info-card summary::-webkit-details-marker { display: none; }
.info-section details.info-card summary::after { content: '+'; color: var(--link); font-weight: 700; font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.info-section details.info-card[open] summary::after { content: '\2212'; }
.info-section details.info-card p { padding: 0 20px 16px; margin: 0; color: var(--text-2); }

/* ----- Tablets ----- */
@media (max-width: 1023px) {
    .main-content { grid-template-columns: 1fr; }
    .preview-panel { position: static; max-height: none; order: -1; }
    .info-section .info-grid, .info-three { grid-template-columns: repeat(2, 1fr); }
}

/* ----- Phones ----- */
@media (max-width: 639px) {
    .app-hero { margin-bottom: 1.5rem; }
    .app-tagline { font-size: 1rem; }
    .app-toolbar { gap: 10px; }
    .app-actions { width: 100%; }
    .app-actions .btn { flex: 1 1 auto; padding-left: 12px; padding-right: 12px; }
    .panel-header, .editor-section-header { padding-left: 16px; padding-right: 16px; }
    .editor-section-content { padding-left: 16px; padding-right: 16px; }
    .preview-wrapper { padding: 12px; }
    .form-row { grid-template-columns: 1fr; }
    .modal-overlay { padding: 8px; }
    .modal-body, .modal-header, .modal-footer, .sidebar-body, .sidebar-header { padding-left: 16px; padding-right: 16px; }
    .list-item { flex-wrap: wrap; }
    .sidebar { width: 100%; right: -100%; }
    .toast-container { bottom: 16px; right: 16px; left: 16px; align-items: flex-end; }
    .toast { min-width: 0; }
    .info-section h2 { font-size: 1.4rem; }
    .info-section .info-grid, .info-three { grid-template-columns: 1fr; }
    .info-card { padding: 16px; }
    .step-num { left: 16px; }
}

/* ----- Print: only the certificate, at paper size (the page size is set by the script) ----- */
@media print {
    body * { visibility: hidden; }
    .certificate-canvas, .certificate-canvas * { visibility: visible; }
    .back-bar, body > header, body > footer, .theme-toggle, .app-hero, .app-toolbar, .info-section, .editor-panel, .panel-header, .toast-container, .modal-overlay, .sidebar, .sidebar-overlay, #zdu-cookie-banner, noscript { display: none !important; }
    body { padding: 0; margin: 0; background: #fff; }
    body::before { display: none; }
    .container.app-container, .app-shell, .main-content, .panel, .preview-panel, .preview-wrapper, .certificate-stage { position: static !important; overflow: visible !important; max-height: none !important; height: auto !important; width: auto !important; padding: 0 !important; margin: 0 !important; border: 0 !important; box-shadow: none !important; background: #fff !important; display: block !important; }
    .certificate-canvas { position: absolute; left: 0; top: 0; transform: scale(1.3333) !important; transform-origin: top left; box-shadow: none; }
    .certificate-inner, .border-classic, .border-modern, .border-elegant, .border-minimal, .border-ornate { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (prefers-reduced-motion: reduce) {
    .btn, .file-upload, .file-upload-icon, .template-card, .border-option, .list-item, .info-card, .modal, .toast, .sidebar { transition: none; animation: none; }
}

/* Phones: 16 px text, 44 px tap targets (AdSense audit H-04, 8 Oct 2026) */
@media (max-width: 639.98px) {
    main button, main select, main summary, main [role="button"],
    main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]) { min-height: 44px; }
    div#historyList.sidebar-body.history-list > p#noHistoryMsg.section-hint { font-size: 1rem; }
    main input[type="color"] { min-width: 44px; }
    .modal-close { min-width: 44px; min-height: 44px; }
}
