:root {
    --bg: #f5f6fb;
    --panel: #ffffff;
    --primary: #1d3557;
    --primary-hover: #15304d;
    --accent: #457b9d;
    --border: #dfe3ec;
    --text: #1f1f1f;
    --muted: #6c7486;
    --radius: 14px;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0 1rem 2rem;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 2.5rem 0 1rem;
}

.title-block h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 2.75rem);
}

.subtitle {
    margin: 0.4rem 0 0;
    color: var(--muted);
}

main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 1100px;
    margin: 0 auto;
}

.panel {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.05);
}

.panel-header h2 {
    margin: 0;
}

.panel-header p {
    margin: 0.3rem 0 1rem;
    color: var(--muted);
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    color: var(--muted);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.drop-zone:focus-visible,
.drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(69, 123, 157, 0.05);
}

.drop-zone i {
    font-size: 3rem;
    color: var(--accent);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.controls label {
    font-weight: 500;
}

.controls input[type="range"] {
    width: 100%;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 500;
}

.toggle input {
    position: absolute;
    opacity: 0;
}

.toggle-indicator {
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #cfd6e5;
    position: relative;
    transition: background 0.2s;
}

.toggle-indicator::after {
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle input:checked + .toggle-indicator {
    background: var(--accent);
}

.toggle input:checked + .toggle-indicator::after {
    transform: translateX(18px);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

button {
    border: none;
    border-radius: 999px;
    padding: 0.85rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    transition: background 0.2s, color 0.2s, transform 0.1s;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.primary {
    background: var(--primary);
    color: #fff;
}

.primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.primary.ghost {
    background: rgba(29, 53, 87, 0.1);
    color: var(--primary);
}

.secondary {
    background: rgba(29, 53, 87, 0.08);
    color: var(--primary);
}

.ghost-button {
    background: rgba(29, 53, 87, 0.08);
    color: var(--primary);
}

.status {
    color: var(--muted);
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.image-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    cursor: grab;
    min-height: 220px;
}

.image-card .page-number {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
}

.image-card.dragging {
    opacity: 0.5;
}

.image-card.dragover {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(69, 123, 157, 0.3);
}

.image-card img {
    width: 100%;
    height: 150px;
    object-fit: contain;
    border-radius: 10px;
    background: #f8fafc;
}

.image-card footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--muted);
}

.image-card .filename {
    font-weight: 600;
    color: var(--text);
}

.image-card .remove-button {
    border-radius: 50%;
    width: 32px;
    height: 32px;
    justify-content: center;
    background: rgba(220, 53, 69, 0.08);
    color: #dc3545;
}

.image-card .remove-button:hover {
    background: rgba(220, 53, 69, 0.2);
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--muted);
}

.empty-state i {
    font-size: 2.5rem;
    color: var(--accent);
}

footer {
    text-align: center;
    margin: 2rem 0;
    color: var(--muted);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 640px) {
    body {
        padding: 0 0.75rem 2rem;
    }

    .image-card {
        min-height: 200px;
    }

    .actions {
        flex-direction: column;
        align-items: stretch;
    }
}
