:root {
    --primary-color: #01894d;
    --primary-hover: #00703e;
    --brand-orange: #f39800;
    --bg-color: #f8fafb;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-muted: #666666;
    --border-color: #e5e7eb;
    --section-bg: #f1f3f5;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

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

body {
    font-family: 'Outfit', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Header */
.main-header {
    background-color: var(--primary-color);
    border-bottom: 2px solid var(--brand-orange);
    padding: 12px 0;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.main-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title-area {
    display: flex;
    align-items: center;
}

.brand-logo {
    font-size: 1.25rem;
    font-weight: 800;
}

.subtitle {
    font-size: 0.85rem;
    margin-left: 12px;
    opacity: 0.85;
}

.header-link {
    text-decoration: none;
    color: #fff;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.header-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 20px;
}

/* Info Section */
.info-section {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    margin-bottom: 2rem;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.info-header {
    width: 100%;
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-color);
}

.info-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.toggle-icon {
    width: 24px;
    height: 24px;
    transition: transform 0.3s;
}

.info-section.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.info-content {
    padding: 0 1.5rem 1.5rem;
    display: block;
}

.info-section.collapsed .info-content {
    display: none;
}

.usage-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 1.5rem;
}

.usage-step {
    background-color: var(--section-bg);
    padding: 1.2rem;
    border-radius: var(--radius);
    position: relative;
}

.usage-step::before {
    content: attr(data-step);
    position: absolute;
    top: -10px;
    left: -10px;
    width: 24px;
    height: 24px;
    background-color: var(--brand-orange);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
}

/* Layout */
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .upload-grid {
        grid-template-columns: 1fr;
    }
}

.card {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-title {
    font-size: 1.1rem;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-number {
    background-color: var(--primary-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 2.5rem 1rem;
    text-align: center;
    transition: all 0.2s;
    background-color: #fafafa;
    cursor: pointer;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary-color);
    background-color: #f0f7ff;
}

.file-label {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius);
    margin-top: 10px;
    cursor: pointer;
}

.file-info-mini {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Sticky Panel */
.sticky-panel {
    position: sticky;
    top: 20px;
    z-index: 100;
    margin-bottom: 2rem;
    border-top: 4px solid var(--primary-color);
}

.controls-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    font-size: 0.9rem;
}

.mode-selector {
    display: flex;
    background-color: var(--section-bg);
    padding: 4px;
    border-radius: var(--radius);
    gap: 4px;
}

.mode-btn {
    border: none;
    background: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.mode-btn:hover {
    background-color: rgba(0,0,0,0.05);
}

.mode-btn.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--section-bg);
    padding: 4px 8px;
    border-radius: var(--radius);
}

.nav-btn {
    border: 1px solid var(--border-color);
    background: white;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Diff Settings Panel */
.diff-settings-panel {
    background-color: #f8fafb;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 1.5rem;
}

.settings-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-end;
}

.settings-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-item label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-group input[type="range"] {
    width: 150px;
}

.slider-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-reset {
    padding: 8px 16px;
    background-color: #eee;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background-color 0.2s;
}

.btn-reset:hover {
    background-color: #ddd;
}

/* Adjust Info Bar */
.adjust-info-bar {
    margin-top: 1.25rem;
    padding: 1rem 1.5rem;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.adjust-info-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.adjust-desc {
    display: flex;
    align-items: center;
    gap: 15px;
}

.adjust-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--section-bg);
    padding: 6px 15px;
    border-radius: 30px;
}

.adjust-controls label {
    font-size: 0.85rem;
    font-weight: 700;
}

.btn-adjust {
    padding: 8px 20px;
    background-color: white;
    border: 1px solid var(--brand-orange);
    color: var(--brand-orange);
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-adjust:hover, .btn-adjust.active {
    background-color: var(--brand-orange);
    color: white;
}

.btn-auto-align {
    background-color: var(--brand-orange);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 10px;
    white-space: nowrap;
}

.btn-auto-align:hover {
    background-color: #d88700;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn-auto-align:active {
    transform: translateY(0);
}

/* Viewer */
.viewer-container {
    min-height: 400px;
    position: relative;
    padding-bottom: 50px;
    transition: cursor 0.2s;
}

.viewer-container.adjusting {
    cursor: move;
}

.viewer-container.adjusting canvas {
    cursor: move;
}

.view-panel {
    display: none;
}

.view-panel.active {
    display: block;
}

.view-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .view-split {
        grid-template-columns: 1fr;
    }
}

.canvas-wrapper {
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: auto;
}

.canvas-label {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

canvas {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border-color);
    background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f0f0f0 75%), linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Overlay View */
.canvas-wrapper-overlay {
    position: relative;
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 15px;
    display: flex;
    justify-content: center;
    overflow: auto;
}

#canvasBase {
    position: relative;
    z-index: 1;
}

#canvasOverlay {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    pointer-events: none;
}

/* Onion Skin View */
.onion-comparison {
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 15px;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.onion-wrapper {
    position: relative;
    display: inline-block;
    user-select: none;
}

.onion-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    overflow: hidden;
    z-index: 2;
    border-right: none;
}

#canvasOnionB {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none; /* Important for slider */
    border: none;
}

.onion-handle {
    position: absolute;
    top: 0;
    left: 50%;
    bottom: 0;
    width: 2px;
    background-color: var(--primary-color);
    z-index: 3;
    cursor: ew-resize;
    transform: translateX(-50%);
}

.handle-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 2px;
    background-color: var(--primary-color);
}

.handle-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Toast/Loading */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.9rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    bottom: 50px;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    gap: 15px;
}

.hidden {
    display: none !important;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
