:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --danger: #ef4444;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --glass-bg: rgba(30, 41, 59, 0.7);

    --radius-lg: 16px;
    --radius-md: 8px;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 20px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.logo span {
    font-size: 32px;
    color: var(--primary);
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: white;
}

.subtitle {
    color: var(--text-muted);
    font-size: 15px;
}

/* Upload */
.dropzone {
    background: var(--glass-bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.dropzone:hover,
.dropzone.drag-active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.icon-upload {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Editor Stream */
.hidden {
    display: none !important;
}

.stream-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Removed sticky positioning as requested to prevent covering content */
    margin-bottom: 20px;
    background: transparent;
    padding: 10px 0;
}

.instruction-badge {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.pages-container {
    display: flex;
    flex-direction: column;
    gap: 60px;
    align-items: center;
}

/* Page Block */
.page-block {
    background: var(--bg-card);
    padding: 0;
    /* Removing padding to make it flush */
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    width: 100%;
    overflow: hidden;
}

.page-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-weight: 600;
    color: var(--text-muted);
}

.canvas-wrapper-center {
    display: flex;
    justify-content: center;
    padding: 24px;
    background: #252525;
    /* neutral dark bg behind paper */
}

.canvas-wrapper {
    position: relative;
    /* Fit content logic */
    display: inline-block;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    background: white;
    /* paper color */
    max-width: 100%;
    /* overflow: hidden;  <-- removing this so handles can stick out if needed, though they shouldn't */
}

canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Footer for Download Button */
.page-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
}

/* Interaction Layer */
.interaction-overlay {
    position: absolute;
    inset: 0;
    cursor: crosshair;
    /* Default creation cursor */
    touch-action: none;
}

/* Redaction Box */
.redaction-box {
    position: absolute;
    border: 2px solid var(--danger);
    background: rgba(239, 68, 68, 0.25);
    cursor: move;
    /* Move existing box */
}

/* Handles */
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--danger);
    bottom: -6px;
    right: -6px;
    cursor: nwse-resize;
    border-radius: 50%;
    border: 2px solid white;
}

.close-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-size: 16px;
    z-index: 10;
}

.close-btn:hover {
    transform: scale(1.1);
}

/* Buttons */
.btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    border-radius: var(--radius-md);
    padding: 10px 24px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-secondary:hover {
    background: #334155;
    color: white;
}