* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* ヘッダーのスタイル */
.header {
    background: #1f2937;
    color: white;
    padding: 8px 0;
    margin: -20px -20px 30px -20px;
    position: relative;
}

.header a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    font-weight: bold;
    color: white;
    text-decoration: none;
    font-size: 1.125rem;
}

.header a:hover {
    color: #e5e7eb;
}

.header img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2em;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: rgba(102, 126, 234, 0.05);
    margin-bottom: 30px;
}

.upload-area:hover {
    border-color: #764ba2;
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #764ba2;
    background: rgba(118, 75, 162, 0.1);
}

.upload-area.has-file {
    padding: 20px;
    cursor: default;
    background: rgba(102, 126, 234, 0.05);
}

.upload-area.has-file:hover {
    transform: none;
}

input[type="file"] {
    display: none;
}

.upload-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.upload-text {
    color: #666;
    font-size: 1.1em;
    margin-bottom: 10px;
}

.file-info {
    color: #999;
    font-size: 0.9em;
}

.file-loaded {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
}

.file-loaded-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-icon {
    font-size: 2em;
}

.file-details h3 {
    color: #333;
    margin-bottom: 5px;
}

.file-details p {
    color: #666;
    font-size: 0.9em;
}

.settings-bar {
    display: none;
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    animation: fadeIn 0.5s ease;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: end;
}

.setting-group {
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
    font-size: 0.9em;
}

select, input[type="number"] {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
    background: white;
}

select:focus, input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.btn.secondary {
    background: #6c757d;
}

.btn.danger {
    background: linear-gradient(135deg, #f093fb, #f5576c);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.pages-container {
    display: none;
    animation: fadeIn 0.5s ease;
}

.pages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.pages-title {
    font-size: 1.3em;
    color: #333;
    font-weight: 600;
}

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.page-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
}

.page-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.page-card.selected {
    box-shadow: 0 0 0 3px #667eea;
}

.page-canvas-wrapper {
    position: relative;
    background: #f8f9fa;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.page-canvas {
    max-width: 100%;
    height: auto;
    display: block;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.page-canvas:hover {
    transform: scale(1.02);
    opacity: 0.9;
}

.page-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.page-info {
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.page-number {
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.page-actions {
    display: flex;
    gap: 10px;
}

.page-btn {
    flex: 1;
    padding: 8px 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.page-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.page-btn.preview {
    background: #28a745;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.5em;
    color: #333;
}

.modal-close {
    font-size: 1.5em;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    text-align: center;
}

.modal-canvas {
    max-width: 100%;
    height: auto;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    animation: slideIn 0.3s ease;
    display: none;
}

.toast.success {
    background: #28a745;
}

.toast.error {
    background: #dc3545;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@media (max-width: 768px) {
    .pages-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
}
