* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #f1f5f9;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.app {
    width: 1500px;
    max-width: 100%;
    height: 950px;
    max-height: 98vh;
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 35px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    background: white;
    padding: 14px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.file-info {
    display: flex;
    gap: 16px;
    font-weight: 600;
    color: #0f172a;
    font-size: 14px;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.actions button {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    padding: 7px 18px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #1e293b;
    transition: 0.15s;
    cursor: pointer;
}

.actions button:hover:not(:disabled) {
    background: #eef2f6;
    border-color: #94a3b8;
}

.actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.trust-message {
    font-size: 12px;
    color: #475569;
    background: #f1f5f9;
    padding: 6px 16px;
    border-radius: 40px;
    border: 1px solid #cbd5e1;
    white-space: nowrap;
}

.main {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    gap: 24px;
    overflow-y: auto;
}

.tool-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-btn {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 12px 18px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #1e293b;
    transition: 0.15s;
    cursor: pointer;
}

.tool-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.tool-btn.active {
    background: #e6f0ff;
    border-color: #3b82f6;
    color: #1e4b8a;
    box-shadow: 0 2px 8px rgba(59,130,246,0.1);
}

.tool-options {
    background: #fafcff;
    border-radius: 20px;
    padding: 20px 18px;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.option-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    color: #334155;
}

.option-row label {
    font-weight: 600;
    display: flex;
    justify-content: space-between;
}

.option-row input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    cursor: pointer;
}

.option-row input[type="range"] {
    width: 100%;
    accent-color: #3b82f6;
}

.option-row select {
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: white;
}

.upload-area {
    margin-top: auto;
    background: #f1f6fc;
    border-radius: 24px;
    padding: 24px 12px;
    text-align: center;
    border: 2px dashed #9aa8b9;
}

#dropZone {
    font-size: 14px;
    color: #0f172a;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.browse-btn {
    background: white;
    border: 1px solid #3b82f6;
    color: #3b82f6;
    padding: 8px 28px;
    border-radius: 40px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.browse-btn:hover {
    background: #3b82f6;
    color: white;
}

.loading {
    background: #e6f0ff;
    padding: 12px;
    border-radius: 40px;
    text-align: center;
    font-weight: 500;
    color: #1e4b8a;
    margin-top: 8px;
}

.hidden { display: none; }

.viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    background: #f1f5f9;
    overflow: hidden;
}

.canvas-container {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #d9e2ef;
    border-radius: 20px;
    overflow: auto;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.04);
    min-height: 400px;
}

/* CRITICAL: No width/height overrides – only max constraints for scaling */
#pdfCanvas, #overlayCanvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 8px 28px rgba(0,0,0,0.14);
    border-radius: 12px;
    background: white;
}

#overlayCanvas {
    pointer-events: auto;
}

.page-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 28px;
    margin-top: 18px;
    padding: 10px 20px;
    background: white;
    border-radius: 60px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.02);
}

.page-nav button {
    background: none;
    border: 1px solid #cbd5e1;
    padding: 8px 20px;
    border-radius: 40px;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    transition: 0.15s;
}

.page-nav button:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.page-nav button:disabled {
    opacity: 0.4;
    cursor: default;
}

#pageIndicator {
    font-weight: 700;
    color: #0f172a;
    min-width: 120px;
    text-align: center;
}

@media (max-width: 1000px) {
    .main { flex-direction: column; }
    .sidebar { width: 100%; max-height: 300px; }
}