:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    --ink: #172033;
    --muted: #64748b;
    --line: #d9e1ea;
    --accent: #087f8c;
    --accent-dark: #075f69;
}

* { box-sizing: border-box }

body {
    margin: 0;
    min-width: 320px;
    background: #e9eef4;
    color: var(--ink);
}

button, input, textarea { font: inherit }

.oby-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 68px;
    padding: 10px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    background: rgba(8, 11, 20, .96);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.oby-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
}

.oby-brand span {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 900;
}

.oby-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.oby-language-switcher {
    display: inline-flex;
    padding: 3px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 6px;
    background: rgba(255, 255, 255, .08);
}

.oby-language-switcher button {
    width: 38px;
    height: 32px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 11px;
    font-weight: 900;
}

.oby-language-switcher button.is-active {
    background: #fff;
    color: #080b14;
}

.oby-primary-btn, .oby-secondary-btn, .oby-section-title button, .oby-remove-btn {
    min-height: 38px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 800;
    padding: 0 14px;
}

.oby-primary-btn {
    border: 0;
    background: var(--accent);
    color: #fff;
}

.oby-primary-btn:hover { background: var(--accent-dark) }

.oby-secondary-btn {
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.oby-workspace {
    width: min(1600px, calc(100% - 28px));
    margin: 20px auto 50px;
    display: grid;
    grid-template-columns: 410px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.oby-editor {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 108px);
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .12);
}

.oby-editor-heading, .oby-form-section {
    padding: 18px;
    border-bottom: 1px solid #e8edf3;
}

.oby-editor-heading p {
    margin: 0 0 5px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.oby-editor-heading h1 {
    margin: 0 0 6px;
    font-size: 24px;
}

.oby-editor-heading span {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.oby-form-section h2 {
    margin: 0;
    font-size: 15px;
}

.oby-field-grid {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 11px;
}

.oby-field {
    min-width: 0;
    display: grid;
    gap: 5px;
}

.oby-field.oby-wide { grid-column: 1 / -1 }

.oby-field span {
    color: #536175;
    font-size: 11px;
    font-weight: 800;
}

.oby-field input, .oby-field textarea {
    width: 100%;
    border: 1px solid #cdd7e2;
    border-radius: 6px;
    background: #fbfdff;
    color: var(--ink);
    outline: none;
    padding: 9px 10px;
}

.oby-field textarea {
    min-height: 72px;
    resize: vertical;
}

.oby-field input:focus, .oby-field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(8, 127, 140, .12);
}

.oby-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.oby-section-title button {
    min-height: 32px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font-size: 12px;
}

.oby-repeat-list {
    margin-top: 13px;
    display: grid;
    gap: 11px;
}

.oby-repeat-entry {
    padding: 12px;
    border: 1px solid #dce4ed;
    border-radius: 7px;
    background: #f7f9fc;
    display: grid;
    gap: 10px;
}

.oby-repeat-entry .oby-field-grid { margin-top: 0 }

.oby-entry-actions {
    display: flex;
    justify-content: flex-end;
}

.oby-remove-btn {
    min-height: 30px;
    border: 1px solid #d5dde7;
    background: #fff;
    color: #536175;
    font-size: 11px;
}

.oby-preview {
    min-width: 0;
    overflow-x: auto;
    display: grid;
    justify-content: center;
    gap: 24px;
    padding-bottom: 30px;
}

.oby-page {
    width: 210mm;
    min-height: 297mm;
    padding: 15mm 10mm 10mm 20mm;
    background: #fff;
    color: #000;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .18);
    font-family: "Times New Roman", Times, serif;
    font-size: 11pt;
    line-height: 1.08;
}

.oby-doc-title, .oby-person-name, .oby-section-heading, .oby-relatives-heading {
    margin: 0;
    text-align: center;
    font-size: 14pt;
    font-weight: 700;
}

.oby-person-name { margin-top: 9mm }

.oby-intro {
    margin: 9mm 0 5mm;
    white-space: pre-wrap;
}

.oby-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 15mm;
    row-gap: 4mm;
}

.oby-info-grid div, .oby-stacked-info p {
    min-width: 0;
    margin: 0;
}

.oby-info-grid strong, .oby-info-grid span, .oby-stacked-info strong, .oby-stacked-info span {
    display: block;
}

.oby-info-grid span, .oby-stacked-info span {
    margin-top: 1.5mm;
    white-space: pre-wrap;
}

.oby-stacked-info {
    margin-top: 5mm;
    display: grid;
    gap: 4mm;
}

.oby-section-heading { margin: 9mm 0 5mm }

.oby-work-output {
    display: grid;
    gap: 3mm;
}

.oby-work-row {
    display: grid;
    grid-template-columns: 42mm minmax(0, 1fr);
    gap: 3mm;
}

.oby-relatives-heading {
    max-width: 175mm;
    margin: 0 auto;
    line-height: 1.15;
}

.oby-relatives-title { margin: 1mm 0 5mm }

.oby-relatives-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 9.5pt;
    line-height: 1.15;
}

.oby-relatives-table th, .oby-relatives-table td {
    border: 1px solid #000;
    padding: 2.2mm 1.5mm;
    vertical-align: middle;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.oby-relatives-table th {
    text-align: center;
    font-weight: 700;
}

.oby-relatives-table th:nth-child(1) { width: 14% }
.oby-relatives-table th:nth-child(2) { width: 22% }
.oby-relatives-table th:nth-child(3) { width: 18% }
.oby-relatives-table th:nth-child(4) { width: 22% }
.oby-relatives-table th:nth-child(5) { width: 24% }

.oby-phone { margin: 8mm 0 0 }

@media (max-width: 1180px) {
    .oby-workspace { grid-template-columns: 1fr }
    .oby-editor { position: static; max-height: none }
}

@media (max-width: 620px) {
    .oby-toolbar { align-items: flex-start; flex-direction: column; padding: 12px }
    .oby-workspace { width: calc(100% - 16px); margin-top: 10px }
    .oby-field-grid { grid-template-columns: 1fr }
    .oby-page { transform-origin: top left }
}

@page {
    size: A4 portrait;
    margin: 0;
}

@media print {
    body { background: #fff }
    .oby-toolbar, .oby-editor { display: none !important }
    .oby-workspace, .oby-preview {
        width: auto;
        margin: 0;
        padding: 0;
        display: block;
        overflow: visible;
    }
    .oby-page {
        width: 210mm;
        height: 297mm;
        min-height: 297mm;
        margin: 0;
        box-shadow: none;
        break-after: page;
        page-break-after: always;
    }
    .oby-page:last-child {
        break-after: auto;
        page-break-after: auto;
    }
}
