/* Custom @font-face (fonty nie z Google Fonts) */
@font-face {
    font-family: "VWText";
    src: url("/static/fonts/VWText-Regular-web.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "VWText";
    src: url("/static/fonts/VWText-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "VWText";
    src: url("/static/fonts/VWText-Light.ttf") format("truetype");
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "VWHead";
    src: url("/static/fonts/VWHead-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "VWHead";
    src: url("/static/fonts/VWHead-Bold-web.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "VWHead";
    src: url("/static/fonts/VWHead-Light.ttf") format("truetype");
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Berlin Sans";
    src: url("/static/fonts/BRLNSR.TTF") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Berlin Sans";
    src: url("/static/fonts/BRLNSB.TTF") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    color: #2c3e50;
    line-height: 1.5;
}

/* Layout */
.site-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.site-main {
    flex: 1;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.08);
    max-width: 800px;
    width: 100%;
    padding: 48px;
    position: relative;
    margin: 40px 0;
}

.container-wide {
    max-width: 1100px;
}

/* Header / Nav */
.site-header {
    background: white;
    border-bottom: 1px solid #e1e8ed;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.site-logo {
    font-size: 20px;
    font-weight: 600;
    color: #1a252f;
    text-decoration: none;
    letter-spacing: -0.3px;
}

.site-logo span {
    color: #3b82f6;
}

.site-nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.site-nav a {
    padding: 8px 14px;
    color: #7a8c9e;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.site-nav a:hover {
    color: #3b82f6;
    background: #f0f4f8;
}

.site-nav a.active {
    color: #3b82f6;
    background: #dbeafe;
}

.lang-switcher {
    display: flex;
    gap: 6px;
}

.lang-btn {
    padding: 6px 12px;
    border: 1px solid #e1e8ed;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #7a8c9e;
    transition: all 0.2s ease;
    text-decoration: none;
}

.lang-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.lang-btn:hover:not(.active) {
    border-color: #cbd5e1;
}

/* Footer */
.site-footer {
    background: white;
    border-top: 1px solid #e1e8ed;
    padding: 24px;
    text-align: center;
    font-size: 13px;
    color: #7a8c9e;
}

.site-footer a {
    color: #3b82f6;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* Typography */
h1 {
    font-size: 32px;
    margin-bottom: 8px;
    color: #1a252f;
    font-weight: 600;
    letter-spacing: -0.5px;
}

h2 {
    font-size: 24px;
    color: #1a252f;
    font-weight: 600;
    margin-bottom: 16px;
    letter-spacing: -0.3px;
}

.subtitle {
    font-size: 14px;
    color: #7a8c9e;
    margin-bottom: 32px;
}

.intro {
    font-size: 15px;
    color: #475569;
    margin-bottom: 24px;
    line-height: 1.6;
}

/* Forms */
.form-group {
    margin-bottom: 28px;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 10px;
    color: #1a252f;
    font-size: 14px;
    letter-spacing: 0.2px;
}

input[type="file"],
input[type="text"],
textarea,
select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: #fafbfc;
    color: #1a252f;
}

input[type="file"]:focus,
input[type="text"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

select {
    appearance: none;
    padding-right: 32px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%237a8c9e" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

.select-wrapper {
    position: relative;
}

/* Rules */
.rules-container {
    margin-bottom: 20px;
    background: #f9fafc;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    padding: 16px;
}

.rule-item {
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.rule-item:last-child {
    margin-bottom: 0;
}

.rule-inputs {
    flex: 1;
}

.rule-inputs input,
.rule-inputs select {
    margin-bottom: 10px;
}

.rule-inputs input:last-child {
    margin-bottom: 0;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.3px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #3b82f6;
    color: white;
    width: 100%;
    margin-top: 8px;
}

.btn-primary:hover {
    background: #2563eb;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.btn-primary:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: transparent;
    color: #3b82f6;
    border: 1px solid #e1e8ed;
    margin-bottom: 20px;
    width: 100%;
}

.btn-secondary:hover {
    background: #f0f4f8;
    border-color: #cbd5e1;
}

.btn-remove {
    background: transparent;
    color: #94a3b8;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-top: 2px;
}

.btn-remove:hover {
    color: #ef4444;
    background: #fee2e2;
}

.btn-icon {
    background: transparent;
    border: none;
    color: #7a8c9e;
    cursor: pointer;
    padding: 6px 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: #ef4444;
    background: #fee2e2;
    border-radius: 4px;
}

/* Status */
.status {
    padding: 14px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 13px;
    display: none;
    font-weight: 500;
}

.status.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    display: block;
}

.status.error {
    background: #fee2e2;
    color: #7f1d1d;
    border: 1px solid #fecaca;
    display: block;
}

.status.info {
    background: #dbeafe;
    color: #0c2340;
    border: 1px solid #bfdbfe;
    display: block;
}

.note {
    font-size: 12px;
    color: #7a8c9e;
    margin-top: 8px;
}

.file-preview {
    display: flex;
    gap: 16px;
    margin-top: 14px;
    padding: 14px;
    background: #f9fafc;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    align-items: center;
}

.file-preview img {
    width: 70px;
    height: auto;
    aspect-ratio: 8.5 / 11;
    object-fit: contain;
    border: 1px solid #e1e8ed;
    border-radius: 3px;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.file-preview-info {
    flex: 1;
    min-width: 0;
}

.file-preview-name {
    font-size: 14px;
    font-weight: 500;
    color: #1a252f;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-pages {
    font-size: 13px;
    color: #7a8c9e;
}

/* Extract page */
.size-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #e1e8ed;
    border-radius: 3px;
    outline: none;
    padding: 0;
}

.size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.size-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.size-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
}

.results-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: #f9fafc;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    font-size: 14px;
    color: #475569;
}

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.image-card {
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.image-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.image-card-preview {
    position: relative;
    aspect-ratio: 1;
    background: #f0f4f8;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-card-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-card-info {
    padding: 10px 12px;
    font-size: 12px;
    color: #475569;
}

.image-card-info .dims {
    font-weight: 600;
    color: #1a252f;
}

.image-card-info .meta {
    color: #94a3b8;
    margin-top: 2px;
    display: flex;
    justify-content: space-between;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-size: 14px;
    grid-column: 1 / -1;
}

.search-section {
    border-top: 1px solid #e1e8ed;
    padding-top: 28px;
    margin-top: 32px;
}

.search-result {
    background: #f9fafc;
    padding: 12px 14px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 13px;
    border: 1px solid #e1e8ed;
    color: #475569;
}

/* Pages list */
.pages-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    max-height: 600px;
    overflow-y: auto;
    padding: 12px;
    background: #f9fafc;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
}

.page-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: white;
    border: 2px solid #e1e8ed;
    border-radius: 4px;
    cursor: grab;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

.page-item:active {
    cursor: grabbing;
}

.page-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.page-item.dragging {
    opacity: 0.4;
    transform: scale(0.95);
    border-color: #3b82f6;
}

.page-item.drop-before::before,
.page-item.drop-after::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #3b82f6;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
    pointer-events: none;
}

.page-item.drop-before::before {
    left: -8px;
}

.page-item.drop-after::after {
    right: -8px;
}

.page-item * {
    pointer-events: none;
}

.page-item button {
    pointer-events: auto;
}

.page-thumbnail {
    width: 100%;
    aspect-ratio: 8.5 / 11;
    background: #f0f4f8;
    border-radius: 2px;
    object-fit: contain;
    border: 1px solid #e1e8ed;
}

.page-label {
    font-size: 12px;
    font-weight: 600;
    color: #3b82f6;
    text-align: center;
}

.drag-handle {
    position: absolute;
    top: 4px;
    left: 4px;
    color: #cbd5e1;
    font-size: 14px;
    cursor: grab;
}

.page-item:hover .drag-handle {
    color: #7a8c9e;
}

.page-actions {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: auto;
}

/* Landing page */
.hero {
    text-align: center;
    padding: 40px 20px 60px;
}

.hero h1 {
    font-size: 42px;
    margin-bottom: 16px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.hero .subtitle {
    font-size: 18px;
    max-width: 600px;
    margin: 0 auto 32px;
    color: #475569;
}

.hero-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.hero .btn-primary,
.hero .btn-secondary {
    width: auto;
    padding: 14px 28px;
    font-size: 16px;
    margin-top: 0;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 40px;
}

.feature-card {
    background: white;
    padding: 32px 24px;
    border-radius: 8px;
    border: 1px solid #e1e8ed;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    display: block;
}

.feature-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.12);
    transform: translateY(-2px);
}

.feature-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.feature-card h3 {
    font-size: 18px;
    color: #1a252f;
    margin-bottom: 8px;
    font-weight: 600;
}

.feature-card p {
    font-size: 14px;
    color: #7a8c9e;
    line-height: 1.5;
}

/* Add page section */
.add-page-section {
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    padding: 0;
    background: #fafbfc;
}

.add-page-summary {
    padding: 16px 20px;
    cursor: pointer;
    font-weight: 600;
    color: #1a252f;
    user-select: none;
    list-style: none;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.add-page-summary::-webkit-details-marker {
    display: none;
}

.add-page-summary::after {
    content: "▼";
    font-size: 10px;
    color: #7a8c9e;
    transition: transform 0.2s ease;
}

.add-page-section[open] .add-page-summary::after {
    transform: rotate(180deg);
}

.add-page-summary:hover {
    background: #f0f4f8;
}

.add-page-section[open] .add-page-summary {
    border-bottom: 1px solid #e1e8ed;
}

.add-page-section > p,
.add-page-section > .add-page-grid {
    padding: 0 20px;
}

.add-page-section > p {
    padding-top: 20px;
}

.add-page-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    padding-bottom: 20px;
}

.add-page-form {
    min-width: 0;
}

.add-page-preview {
    position: sticky;
    top: 20px;
    align-self: start;
}

.add-page-preview canvas {
    width: 100%;
    height: auto;
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.add-page-preview label {
    margin-bottom: 10px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    margin: 0;
    font-weight: 400;
    transition: all 0.2s ease;
}

.radio-option:hover {
    border-color: #3b82f6;
}

.radio-option input[type="radio"] {
    width: auto;
    accent-color: #3b82f6;
}

.radio-option input[type="radio"]:checked + span {
    color: #3b82f6;
    font-weight: 500;
}

input[type="color"] {
    height: 42px;
    padding: 4px;
    cursor: pointer;
}

textarea {
    resize: vertical;
    min-height: 70px;
    font-family: inherit;
}

/* WYSIWYG Editor */
.add-page-wysiwyg {
    padding: 0 20px 20px;
}

.presets-bar {
    margin-bottom: 16px;
}

.presets-label {
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 8px;
}

.presets-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.preset-card {
    flex-shrink: 0;
    width: 110px;
    cursor: pointer;
    text-align: center;
    transition: transform 0.15s ease;
}

.preset-card:hover {
    transform: translateY(-2px);
}

.preset-preview {
    width: 100%;
    aspect-ratio: 8.5 / 11;
    border-radius: 4px;
    border: 1px solid #e1e8ed;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.preset-card:hover .preset-preview {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.preset-preview .pl {
    position: absolute;
    border-radius: 1px;
}

.preset-name {
    margin-top: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
}

.wysiwyg-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.radio-group-inline {
    flex-direction: row;
    gap: 8px;
}

.bg-color-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bg-color-group label {
    margin: 0;
    font-size: 13px;
    color: #475569;
}

.bg-color-group input[type="color"] {
    height: 32px;
    width: 50px;
    padding: 2px;
}

.wysiwyg-preview-wrap {
    display: flex;
    justify-content: center;
    padding: 24px;
    background: #f0f4f8;
    border-radius: 8px;
    margin-bottom: 16px;
    min-height: 600px;
}

.wysiwyg-preview {
    position: relative;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 595 / 842;
    background: white;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.wysiwyg-element {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    padding: 4px 8px;
    min-height: 20px;
    outline: none;
    border: 1px dashed transparent;
    border-radius: 2px;
    word-wrap: break-word;
    cursor: text;
    transition: border-color 0.15s ease;
    line-height: 1.2;
}

.wysiwyg-element:hover {
    border-color: #cbd5e1;
}

.wysiwyg-element:focus {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.03);
}

.wysiwyg-element:empty::before {
    content: attr(data-placeholder);
    color: #cbd5e1;
    pointer-events: none;
}

/* Font family mapping */
/* Font is now applied directly via element.style.fontFamily (full CSS font stack) */

/* Floating toolbar */
.floating-toolbar {
    position: fixed;
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    max-width: 95vw;
}

.floating-toolbar input[type="color"] {
    width: 32px;
    height: 28px;
    padding: 2px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #e1e8ed;
}

.floating-toolbar select {
    padding: 4px 24px 4px 8px;
    font-size: 12px;
    height: 28px;
    width: 110px;
}

.toolbar-sep {
    width: 1px;
    height: 20px;
    background: #e1e8ed;
    margin: 0 4px;
}

.toolbar-drag {
    cursor: grab !important;
}

.toolbar-drag:active {
    cursor: grabbing !important;
}

/* Field with controls (kept for backwards compat) */
.field-group {
    margin-bottom: 20px;
}

.field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.field-header label {
    margin-bottom: 0;
    font-size: 13px;
}

.field-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.field-controls input[type="color"] {
    width: 32px;
    height: 28px;
    padding: 2px;
    border-radius: 4px;
    cursor: pointer;
}

.field-controls select {
    padding: 4px 24px 4px 8px;
    font-size: 12px;
    height: 28px;
    background-size: 12px;
    background-position: right 6px center;
}

.field-controls select[data-control="font"] {
    width: 90px;
}

.size-control {
    display: flex;
    align-items: center;
    border: 1px solid #e1e8ed;
    border-radius: 4px;
    background: white;
    overflow: hidden;
    height: 28px;
}

.size-btn {
    width: 22px;
    height: 100%;
    border: none;
    background: transparent;
    color: #7a8c9e;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.size-btn:hover {
    background: #f0f4f8;
    color: #3b82f6;
}

.size-btn:active {
    background: #dbeafe;
}

.size-control input[type="number"] {
    width: 40px;
    border: none;
    border-left: 1px solid #e1e8ed;
    border-right: 1px solid #e1e8ed;
    height: 100%;
    padding: 0 4px;
    text-align: center;
    font-size: 12px;
    background: #fafbfc;
    -moz-appearance: textfield;
}

.size-control input[type="number"]::-webkit-inner-spin-button,
.size-control input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.size-control input[type="number"]:focus {
    background: white;
    outline: none;
}

.page-item-new {
    border-color: #3b82f6;
    border-style: dashed;
}

.btn-edit:hover {
    color: #3b82f6 !important;
    background: #dbeafe !important;
}

.btn-edit.has-edits {
    color: #10b981;
    position: relative;
}

.btn-edit.has-edits::after {
    content: "";
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
}

.btn-primary.editing {
    background: #10b981;
}

.btn-primary.editing:hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

/* Edit modal */
.edit-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.edit-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
}

.edit-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 28px;
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.edit-modal-header h3 {
    margin: 0;
    font-size: 22px;
    color: #1a252f;
}

.edit-modal-close:hover {
    color: #1a252f !important;
    background: #f0f4f8 !important;
}

.edit-modal-large {
    max-width: 1100px;
    width: 95vw;
    max-height: 92vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: max-width 0.2s ease;
}

.edit-modal-large.landscape {
    max-width: 1600px;
}

.edit-modal-large > .edit-modal-header,
.edit-modal-large > .intro {
    flex-shrink: 0;
    padding: 20px 24px 0;
}

.edit-modal-large > .intro {
    padding-top: 8px;
    padding-bottom: 16px;
}

.edit-modal-large > .edit-modal-footer {
    flex-shrink: 0;
    padding: 16px 24px 20px;
    border-top: 1px solid #e1e8ed;
    background: white;
    margin-top: 0;
}

.edit-modal-large > .page-edit-wrap,
.edit-modal-large > .page-edit-loading {
    flex: 1 1 auto;
    overflow: auto;
    margin: 0 24px 16px;
}

/* Extra large modal for add page */
.edit-modal-xlarge {
    max-width: 1400px;
    width: 98vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
}

.edit-modal-xlarge > .edit-modal-header,
.edit-modal-xlarge > .intro {
    flex-shrink: 0;
    padding: 20px 24px 0;
}

.edit-modal-xlarge > .intro {
    padding-top: 8px;
    padding-bottom: 16px;
}

.edit-modal-xlarge > .floating-toolbar {
    flex-shrink: 0;
    padding: 0 24px;
}

.edit-modal-xlarge > .add-page-wysiwyg {
    flex: 1 1 auto;
    overflow: auto;
    margin: 0 24px 16px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.edit-modal-xlarge > .edit-modal-footer {
    flex-shrink: 0;
    padding: 16px 24px 20px;
    border-top: 1px solid #e1e8ed;
    background: white;
    margin-top: 0;
}

/* Autoscroll for WYSIWYG preview in modal */
.edit-modal-xlarge .wysiwyg-preview-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    padding: 16px;
}

.edit-modal-xlarge .wysiwyg-preview {
    overflow: visible;
    flex-shrink: 0;
}

.edit-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.preset-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
}

.preset-selector label {
    margin: 0;
    font-size: 13px;
    color: #475569;
    white-space: nowrap;
}

.preset-selector select {
    width: auto;
    min-width: 200px;
    padding: 8px 32px 8px 12px;
    font-size: 14px;
}

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

/* Custom select with font preview */
.custom-select {
    position: relative;
    display: inline-block;
    min-width: 220px;
}

.custom-select.custom-select-sm {
    min-width: 130px;
}

.custom-select.custom-select-sm .custom-select-trigger {
    padding: 4px 8px;
    font-size: 12px;
    height: 28px;
}

.custom-select.custom-select-sm .custom-select-dropdown {
    bottom: auto;
    top: 100%;
    margin-top: 4px;
    margin-bottom: 0;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    color: #1a252f;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    text-align: left;
}

.custom-select-trigger:hover {
    border-color: #cbd5e1;
}

.custom-select.open .custom-select-trigger {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.custom-select-trigger svg {
    color: #7a8c9e;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.custom-select.open .custom-select-trigger svg {
    transform: rotate(180deg);
}

.custom-select-current {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 4px;
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 320px;
    overflow-y: auto;
    z-index: 2100;
    display: none;
    padding: 4px;
}

.custom-select.open .custom-select-dropdown {
    display: block;
}

.custom-select-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 15px;
    color: #1a252f;
    border-radius: 4px;
    transition: background 0.1s ease;
    user-select: none;
}

.custom-select-item:hover {
    background: #f0f4f8;
}

.custom-select-item.selected {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 600;
}

.edit-text-controls {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.edit-text-controls .field-toggle {
    width: 32px;
    height: 32px;
}

.edit-modal-footer .btn-primary,
.edit-modal-footer .btn-secondary {
    width: auto;
    padding: 10px 20px;
    margin: 0;
}

.page-edit-loading {
    text-align: center;
    padding: 60px 20px;
    color: #7a8c9e;
    font-size: 14px;
}

.page-edit-wrap {
    background: #f0f4f8;
    border-radius: 6px;
    border: 1px solid #e1e8ed;
    padding: 16px;
}

.page-edit-img-wrap {
    position: relative;
    display: block;
    max-width: 720px;
    margin: 0 auto;
    line-height: 0;
}

.page-edit-wrap img {
    display: block;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    width: 100%;
    height: auto;
}

.page-edit-overlays {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.page-edit-overlays .text-overlay {
    pointer-events: auto;
}

.text-overlay {
    position: absolute;
    pointer-events: auto;
    box-sizing: border-box;
    border: 1px solid transparent;
    border-radius: 2px;
    padding: 0;
    cursor: text;
    outline: none;
    background: transparent;
    color: transparent;
    white-space: nowrap;
    overflow: visible;
    line-height: 1;
    width: auto;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.text-overlay:hover {
    border-color: #3b82f6;
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
    z-index: 10;
}

.text-overlay:focus {
    border-color: #3b82f6;
    background: white;
    color: #1a252f;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    overflow: visible;
    z-index: 20;
}

.text-overlay.edited {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #1a252f;
}

.text-overlay.edited:focus {
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

.edit-rules-container {
    margin: 20px 0;
    background: #f9fafc;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    padding: 12px;
    min-height: 50px;
}

.edit-rule {
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.edit-rule:last-child {
    margin-bottom: 0;
}

.edit-rule input,
.edit-rule select {
    width: 100%;
}

.edit-rule .btn-rule-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    border-radius: 4px;
}

.edit-rule .btn-rule-remove:hover {
    color: #ef4444;
    background: #fee2e2;
}

.page-badge {
    background: #3b82f6;
    color: white;
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.field-toggle {
    width: 28px;
    height: 28px;
    border: 1px solid #e1e8ed;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #7a8c9e;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.field-toggle:hover {
    border-color: #3b82f6;
    color: #3b82f6;
}

.field-toggle.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

@media (max-width: 800px) {
    .add-page-grid {
        grid-template-columns: 1fr;
    }

    .add-page-preview {
        position: static;
    }

    .field-controls {
        flex-wrap: wrap;
    }
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 24px;
        margin: 20px 0;
    }

    h1 {
        font-size: 24px;
    }

    .hero h1 {
        font-size: 28px;
    }

    .hero .subtitle {
        font-size: 16px;
    }

    .site-header {
        flex-direction: column;
        gap: 12px;
    }
}
