:root {
    --bg-main: #f5f5f5;
    --bg-panel: #ffffff;
    --bg-panel-header: #f0f0f0;
    --bg-input: #ffffff;
    --accent: #0ea5e9;
    --accent-hover: #0284c7;
    --accent-glow: rgba(14, 165, 233, 0.2);
    --success: #22c55e;
    --error: #ef4444;
    --text: #1a1a1a;
    --text-secondary: #666;
    --text-dim: #999;
    --border: #e0e0e0;
    --border-light: #d0d0d0;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { overscroll-behavior-x: none; }
body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-main);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px 20px;
}

/* Header */
.header {
    background: linear-gradient(180deg, #fff 0%, #f5f5f5 100%);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    margin: 0 calc(-50vw + 50%) 20px;
    padding-left: calc(50vw - 50% + 24px);
    padding-right: calc(50vw - 50% + 24px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.header-logo-link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.header-logo {
    height: 38px;
    width: auto;
    display: block;
}
.privacy-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(34, 197, 94, 0.15); color: var(--success);
    padding: 6px 12px; border-radius: 4px; font-size: 0.75rem;
    font-weight: 500; border: 1px solid rgba(34, 197, 94, 0.3);
}

/* Intro Box */
.intro-box {
    background: var(--bg-panel); border: 1px solid var(--border-light);
    border-radius: 8px; padding: 20px 24px; margin-bottom: 24px;
}
.intro-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.intro-desc { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.7; }

/* Drop Zone */
.drop-zone {
    background: var(--bg-panel); border: 2px dashed var(--border-light);
    border-radius: 8px; padding: 60px 40px; text-align: center;
    cursor: pointer; transition: all 0.2s ease;
}
.drop-zone:hover, .drop-zone.dragover, .drop-zone:focus-visible {
    border-color: var(--accent); background: rgba(14, 165, 233, 0.05);
    box-shadow: inset 0 0 30px rgba(14, 165, 233, 0.1);
    outline: none;
}
.drop-zone-icon { font-size: 3rem; margin-bottom: 16px; }
.drop-zone h2 { font-size: 1.1rem; font-weight: 500; margin-bottom: 8px; }
.drop-zone p { color: var(--text-secondary); font-size: 0.85rem; }
.drop-zone-formats { margin-top: 12px; }
.drop-zone input[type="file"] { display: none; }

/* Card */
.card {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: 6px; margin-top: 16px; box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
    display: flex; align-items: center; gap: 8px; padding: 10px 16px;
    background: var(--bg-panel-header); border-bottom: 1px solid var(--border);
}
.card-header h3 {
    font-size: 0.85rem; font-weight: 500; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-secondary);
}
.card-header span { font-size: 0.9rem; }
.card-body { padding: 16px; }
.image-info-mini {
    margin-left: auto; font-size: 0.75rem; color: var(--text-dim);
    font-family: 'Consolas', monospace;
}

/* Tool row */
.tool-row {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 10px; flex-wrap: wrap;
}
.tool-row-label {
    font-size: 0.8rem; color: var(--text-secondary);
    font-weight: 500; min-width: 60px;
}
.tool-group { display: flex; gap: 4px; flex-wrap: wrap; }
.tool-btn {
    background: var(--bg-input); border: 1px solid var(--border); color: var(--text);
    padding: 8px 12px; border-radius: 4px; cursor: pointer; font-size: 0.85rem;
    transition: all 0.15s ease; display: inline-flex; align-items: center; gap: 6px;
    min-height: 38px;
}
.tool-btn:hover {
    border-color: var(--accent); background: rgba(14, 165, 233, 0.08);
}
.tool-btn.active {
    border-color: var(--accent);
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.2) 0%, rgba(14, 165, 233, 0.1) 100%);
    box-shadow: inset 0 0 8px var(--accent-glow);
    color: var(--accent);
    font-weight: 600;
}
.tool-btn .ti { font-size: 1rem; }
.tool-btn .tl { font-size: 0.8rem; }

/* Slider */
.slider-wrap {
    display: flex; align-items: center; gap: 10px; flex: 1; min-width: 180px;
}
.slider-wrap input[type="range"] {
    flex: 1; -webkit-appearance: none; appearance: none;
    height: 6px; background: var(--border); border-radius: 3px; outline: none;
}
.slider-wrap input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent); cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.slider-wrap input[type="range"]::-moz-range-thumb {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent); cursor: pointer; border: none;
}
.slider-value {
    font-family: 'Consolas', monospace; font-size: 0.85rem;
    color: var(--text-secondary); min-width: 50px; text-align: right;
}

/* Action row */
.action-row {
    display: flex; gap: 8px; flex-wrap: wrap;
    margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.action-btn {
    background: var(--bg-input); border: 1px solid var(--border); color: var(--text);
    padding: 10px 16px; border-radius: 4px; cursor: pointer; font-size: 0.88rem;
    font-weight: 500; transition: all 0.15s ease; min-height: 40px;
}
.action-btn:hover:not(:disabled) {
    border-color: var(--accent); background: rgba(14, 165, 233, 0.08);
}
.action-btn:disabled {
    opacity: 0.4; cursor: not-allowed;
}
.action-btn.primary {
    background: linear-gradient(180deg, var(--accent) 0%, #0284c7 100%);
    color: #fff; border-color: var(--accent);
    box-shadow: 0 2px 6px rgba(14, 165, 233, 0.3);
    margin-left: auto;
}
.action-btn.primary:hover:not(:disabled) {
    background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
}

/* Canvas stage */
.canvas-stage {
    position: relative; background: #2a2a2a; border-radius: 4px;
    overflow: hidden; display: flex; align-items: center; justify-content: center;
    min-height: 240px; max-height: 70vh;
    background-image:
        linear-gradient(45deg, #3a3a3a 25%, transparent 25%),
        linear-gradient(-45deg, #3a3a3a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #3a3a3a 75%),
        linear-gradient(-45deg, transparent 75%, #3a3a3a 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: crosshair;
}
.canvas-stage canvas {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
}
.canvas-stage #overlayCanvas {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.canvas-stage #imageCanvas {
    position: relative;
    z-index: 1;
}
.canvas-stage #overlayCanvas { z-index: 2; }

.hint {
    margin-top: 10px; font-size: 0.75rem; color: var(--text-dim); text-align: center;
}

/* Download */
.download-btn {
    width: 100%;
    background: linear-gradient(180deg, var(--success) 0%, #16a34a 100%);
    border: none; color: #fff; padding: 16px; border-radius: 6px;
    font-size: 1rem; font-weight: 600; cursor: pointer; margin-top: 16px;
    transition: all 0.2s ease; display: flex; align-items: center;
    justify-content: center; gap: 10px; text-transform: uppercase;
    letter-spacing: 1px; box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}
.download-btn:hover {
    transform: translateY(-1px); box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}
.reset-btn {
    width: 100%; background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-secondary); padding: 12px; border-radius: 6px;
    font-size: 0.9rem; cursor: pointer; margin-top: 10px;
    transition: all 0.15s ease;
}
.reset-btn:hover {
    border-color: var(--accent); color: var(--accent);
}

/* How-to-use */
.how-to-use .step {
    display: flex; gap: 14px; margin-bottom: 14px;
}
.how-to-use .step:last-child { margin-bottom: 0; }
.step-num {
    flex-shrink: 0; width: 32px; height: 32px;
    background: var(--accent); color: #fff; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.95rem;
}
.step-content h4 {
    font-size: 0.95rem; margin-bottom: 4px;
}
.step-content p {
    font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6;
}

/* FAQ */
.faq details {
    border-bottom: 1px solid var(--border); padding: 12px 0;
}
.faq details:last-child { border-bottom: none; }
.faq summary {
    font-weight: 500; cursor: pointer; padding: 4px 0;
    font-size: 0.92rem;
}
.faq summary:hover { color: var(--accent); }
.faq details p {
    margin-top: 8px; color: var(--text-secondary);
    font-size: 0.85rem; line-height: 1.7; padding-left: 16px;
}

/* Promo banners */
.promo-banner {
    margin-top: 24px; padding: 24px;
    border-radius: 8px; text-align: center;
    color: #fff;
}
.promo-tsumeru { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); }
.promo-osameru { background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%); }
.promo-kieruka { background: linear-gradient(135deg, #ec4899 0%, #be185d 100%); }
.promo-shaki { background: linear-gradient(135deg, #f97316 0%, #c2410c 100%); }
.promo-banner-label { font-size: 0.85rem; color: rgba(255,255,255,0.7); margin-bottom: 8px; }
.promo-banner-title { font-size: 1.4rem; font-weight: 700; color: #fff; margin-bottom: 8px; }
.promo-banner-subtitle { font-size: 0.85rem; color: rgba(255,255,255,0.85); margin-bottom: 16px; }
.promo-banner-btn {
    display: inline-block; padding: 12px 28px; background: #fff; color: #1a1a1a;
    text-decoration: none; border-radius: 6px; font-weight: 600;
    transition: all 0.2s ease;
}
.promo-banner-btn:hover {
    transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Footer */
.footer {
    margin-top: 40px; padding-top: 24px;
    border-top: 1px solid var(--border); text-align: center;
}
.footer-links { margin-bottom: 12px; }
.footer-links a {
    color: var(--text-secondary); text-decoration: none;
    margin: 0 8px; font-size: 0.85rem;
    display: inline-block; padding: 4px 0;
}
.footer-links a:hover { color: var(--accent); }
.footer p {
    font-size: 0.8rem; color: var(--text-dim);
    margin-top: 6px;
}
.footer p a { color: inherit; }

/* Loading Overlay */
.loading-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 1000; gap: 20px;
}
.loading-spinner {
    width: 56px; height: 56px;
    border: 5px solid rgba(255,255,255,0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: #fff; font-size: 0.95rem; }

/* Error toast */
.error-toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: var(--error); color: #fff; padding: 12px 20px;
    border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    z-index: 1100; font-size: 0.9rem; max-width: 90vw;
}

/* Responsive */
@media (max-width: 640px) {
    .container { padding: 0 12px 20px; }
    .header { padding: 12px 16px; padding-left: calc(50vw - 50% + 16px); padding-right: calc(50vw - 50% + 16px); }
    .intro-box { padding: 16px; }
    .intro-title { font-size: 1.1rem; }
    .tool-row-label { min-width: 50px; font-size: 0.75rem; }
    .tool-btn { padding: 8px 10px; }
    .tool-btn .tl { display: none; }
    .tool-btn .ti { font-size: 1.2rem; }
    .action-btn { padding: 10px 12px; font-size: 0.8rem; }
    .action-btn.primary { margin-left: 0; flex: 1; }
    .drop-zone { padding: 40px 16px; }
    .canvas-stage { min-height: 200px; }
    .promo-banner-title { font-size: 1.15rem; }
    .footer-links a { margin: 0 6px; font-size: 0.78rem; }
}
