:root {
    color-scheme: light;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #172033;
    background: #eef1f5;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

button,
.button,
input {
    font: inherit;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 15px;
    border: 1px solid #c4ccd8;
    border-radius: 7px;
    color: #172033;
    background: #fff;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.button:hover {
    background: #f3f6fa;
}

button:disabled {
    opacity: 0.45;
    cursor: default;
}

.primary {
    border-color: #215dba;
    color: #fff;
    background: #215dba;
}

.primary:hover {
    background: #194b99;
}

.danger {
    border-color: #b42318;
    color: #b42318;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 26px;
    color: #fff;
    background: #172b4d;
}

.app-header h1 {
    margin: 0 0 3px;
    font-size: 24px;
}

.app-header p {
    margin: 0;
    color: #cfdaed;
    font-size: 14px;
}

.tool-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 26px 0;
    background: #fff;
    border-bottom: 1px solid #d9dfe8;
}

.tool-tabs button {
    min-height: 42px;
    border: 0;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: transparent;
}

.tool-tabs button.active {
    border-bottom-color: #215dba;
    color: #194b99;
    font-weight: 650;
}

.notice {
    padding: 12px 26px;
    color: #172b4d;
    background: #dceaff;
    border-bottom: 1px solid #b5cef3;
}

.notice.error {
    color: #7a271a;
    background: #fee4e2;
    border-color: #fda29b;
}

.welcome {
    max-width: 760px;
    margin: 55px auto;
    padding: 35px 40px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 30px rgb(23 43 77 / 10%);
}

.welcome h2 {
    margin-top: 0;
}

.welcome li {
    margin: 12px 0;
}

.warning,
.editor-help,
.field-help {
    color: #596579;
    font-size: 13px;
    line-height: 1.45;
}

.warning {
    margin: 26px 0 0;
    padding: 14px;
    border-left: 4px solid #d69e2e;
    background: #fff8e1;
}

.workspace {
    padding: 16px;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 9px;
    background: #fff;
}

.document-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#document-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#page-label {
    margin-top: 3px;
    color: #68758a;
    font-size: 13px;
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.editor-layout {
    display: grid;
    grid-template-columns: 130px minmax(400px, 1fr) 310px;
    gap: 16px;
    align-items: start;
}

.pages-panel,
.properties-panel {
    padding: 16px;
    border-radius: 9px;
    background: #fff;
}

.pages-panel h2,
.properties-panel h2 {
    margin: 0 0 14px;
    font-size: 16px;
}

.page-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    max-height: calc(100vh - 190px);
    overflow: auto;
}

.page-list button {
    width: 100%;
}

.page-list button.active {
    border-color: #215dba;
    color: #fff;
    background: #215dba;
}

.viewer {
    min-width: 0;
    max-height: calc(100vh - 125px);
    padding: 18px;
    overflow: auto;
    border-radius: 9px;
    background: #d8dde5;
}

.page {
    position: relative;
    width: min(100%, 950px);
    margin: 0 auto;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 3px 16px rgb(23 32 51 / 24%);
}

#page-image {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    user-select: none;
}

.line-layer {
    position: absolute;
    inset: 0;
}

.pdf-line {
    position: absolute;
    min-height: 5px;
    margin: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 1px;
    background: transparent;
}

.pdf-line:hover {
    border-color: #2176d2;
    background: rgb(33 118 210 / 15%);
}

.pdf-line.selected {
    border-color: #d92d20;
    background: rgb(217 45 32 / 17%);
}

.properties-panel label {
    display: block;
    margin: 16px 0 6px;
    font-size: 13px;
    font-weight: 600;
}

.properties-panel input {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid #aeb8c6;
    border-radius: 6px;
    background: #fff;
}

.properties-panel form button {
    width: 100%;
    margin-top: 12px;
}

#selection-hint {
    color: #596579;
    line-height: 1.5;
}

.editor-help {
    margin-top: 24px;
    padding-top: 10px;
    border-top: 1px solid #e0e5ec;
}

.analyzer-section {
    max-width: 1100px;
    margin: 28px auto;
    padding: 0 20px;
}

.analyzer-picker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 24px 28px;
    border-radius: 10px;
    background: #fff;
}

.analyzer-picker h2 {
    margin: 0 0 8px;
}

.analyzer-picker p {
    margin: 0;
    color: #596579;
}

.analyzer-picker .button {
    flex-shrink: 0;
}

.analysis-empty {
    margin-top: 18px;
    padding: 32px;
    border: 1px dashed #aeb8c6;
    border-radius: 10px;
    color: #68758a;
    text-align: center;
    background: rgb(255 255 255 / 55%);
}

.analysis-summary {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 20px;
    margin: 24px 0 12px;
}

.analysis-summary h3 {
    margin: 0;
    overflow-wrap: anywhere;
}

#analysis-font-count {
    color: #68758a;
    white-space: nowrap;
}

.font-card {
    margin-bottom: 12px;
    padding: 20px 22px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 10px rgb(23 43 77 / 6%);
}

.font-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.font-card-header h4 {
    margin: 0;
    font-size: 17px;
    overflow-wrap: anywhere;
}

.font-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.font-badge {
    padding: 4px 8px;
    border-radius: 5px;
    color: #344054;
    background: #edf1f6;
    font-size: 12px;
    white-space: nowrap;
}

.font-badge.exact {
    color: #05603a;
    background: #dcfae6;
}

.font-badge.estimated {
    color: #854a0e;
    background: #fef0c7;
}

.font-match {
    margin: 14px 0 6px;
    font-size: 15px;
}

.font-details {
    margin: 5px 0;
    color: #596579;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.font-alias-button {
    margin-top: 12px;
}

.font-alias-saved {
    margin-top: 12px;
    color: #05603a;
    font-weight: 600;
}

[hidden] {
    display: none !important;
}

@media (max-width: 1050px) {
    .editor-layout {
        grid-template-columns: 100px minmax(350px, 1fr);
    }

    .properties-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 720px) {
    .app-header,
    .toolbar,
    .analyzer-picker {
        align-items: stretch;
        flex-direction: column;
    }

    .editor-layout {
        display: flex;
        flex-direction: column;
    }

    .pages-panel,
    .properties-panel,
    .viewer {
        width: 100%;
    }

    .page-list {
        flex-direction: row;
        max-height: none;
    }

    .page-list button {
        min-width: 90px;
    }

    .viewer {
        min-height: 400px;
        padding: 8px;
    }
}
