/* 이미지 도구 페이지(cup.html, cutout.html) 공용 스타일 */

/* ========== 색상 (라이트 기본) ========== */
:root {
    --bg-1: #eef2ff;
    --bg-2: #fdf2f8;
    --card: rgba(255, 255, 255, 0.85);
    --surface: #f3f4f6;
    --raised: #ffffff;
    --text: #1e1b4b;
    --muted: #6b7280;
    --line: #e5e7eb;
    --accent-1: #6366f1;
    --accent-2: #ec4899;
    --shadow: rgba(79, 70, 229, 0.15);
    --check-1: #ffffff;
    --check-2: #e5e7eb;
    --error: #dc2626;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-1: #0f172a;
        --bg-2: #1e1b4b;
        --card: rgba(30, 41, 59, 0.8);
        --surface: #334155;
        --raised: #475569;
        --text: #f1f5f9;
        --muted: #94a3b8;
        --line: #334155;
        --shadow: rgba(0, 0, 0, 0.35);
        --check-1: #334155;
        --check-2: #1e293b;
        --error: #f87171;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg-1: #0f172a;
    --bg-2: #1e1b4b;
    --card: rgba(30, 41, 59, 0.8);
    --surface: #334155;
    --raised: #475569;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --line: #334155;
    --shadow: rgba(0, 0, 0, 0.35);
    --check-1: #334155;
    --check-2: #1e293b;
    --error: #f87171;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

/* 배경 그라데이션은 html에 (긴 페이지·모바일에서도 끝까지 이어지게) */
html {
    min-height: 100%;
    background: linear-gradient(135deg, var(--bg-1), var(--bg-2)) no-repeat;
    background-color: var(--bg-1);
}

body {
    font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    color: var(--text);
    background: transparent;
    min-height: 100vh;
    margin: 0;
    padding: 0 16px 48px;
}

h1, h2 {
    margin: 0;
    letter-spacing: -0.02em;
}

/* ========== 상단 바 / 페이지 이동 ========== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 0;
    backdrop-filter: blur(12px);
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.nav a {
    padding: 8px 14px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.nav a:hover {
    color: var(--text);
    background: var(--surface);
}

.nav a.current {
    color: var(--text);
    background: var(--raised);
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* ========== 세그먼트 버튼 ========== */
.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    padding: 4px;
    gap: 2px;
    border-radius: 12px;
    background: var(--surface);
}

.segmented button {
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    background: transparent;
    border-radius: 9px;
}

.segmented button.active {
    color: var(--text);
    background: var(--raised);
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

/* ========== 레이아웃 ========== */
.hero {
    max-width: 1180px;
    margin: 20px auto 24px;
}

.hero h1 {
    font-size: 34px;
    font-weight: 900;
}

.hero p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.6;
}

.tool {
    display: grid;
    gap: 20px;
    max-width: 1180px;
    margin: 0 auto;
}

@media (min-width: 900px) {
    .tool {
        grid-template-columns: 360px minmax(0, 1fr);
        align-items: start;
    }
}

.panel {
    padding: 24px;
    background: var(--card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: 0 20px 50px var(--shadow);
}

.panel h2 {
    font-size: 16px;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

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

.field-label {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 700;
}

.field-label output {
    color: var(--muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.field-help {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent-1);
}

input[type="color"] {
    width: 44px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: none;
    cursor: pointer;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.check input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-1);
}

/* ========== 업로드 영역 ========== */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 28px 16px;
    border: 2px dashed var(--line);
    border-radius: 18px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent-1);
    background: var(--surface);
}

.dropzone .dropzone-icon {
    font-size: 34px;
}

.dropzone strong {
    font-size: 15px;
}

.dropzone span {
    font-size: 12px;
    color: var(--muted);
}

/* ========== 미리보기 ========== */
.preview-grid {
    display: grid;
    gap: 16px;
}

@media (min-width: 640px) {
    .preview-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.preview figure {
    margin: 0;
}

.preview figcaption {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 700;
}

.preview figcaption span {
    color: var(--muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* 투명 부분이 보이도록 체크무늬 배경 */
.canvas-box {
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background-color: var(--check-1);
    background-image:
        linear-gradient(45deg, var(--check-2) 25%, transparent 25%),
        linear-gradient(-45deg, var(--check-2) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--check-2) 75%),
        linear-gradient(-45deg, transparent 75%, var(--check-2) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    overflow: hidden;
}

.canvas-box img,
.canvas-box canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.canvas-box .empty {
    color: var(--muted);
    font-size: 14px;
    background: var(--card);
    padding: 6px 12px;
    border-radius: 8px;
}

/* ========== 상태 표시 ========== */
.status {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    font-size: 14px;
    color: var(--muted);
}

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

.progress {
    height: 6px;
    border-radius: 999px;
    background: var(--surface);
    overflow: hidden;
}

.progress div {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
    transition: width 0.2s;
}

/* ========== 버튼 ========== */
button {
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    padding: 14px 18px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s, background 0.2s, color 0.2s;
}

button:active:not(:disabled) {
    transform: scale(0.97);
}

button:focus-visible {
    outline: 3px solid rgba(99, 102, 241, 0.4);
    outline-offset: 2px;
}

button.primary {
    width: 100%;
    color: white;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}

button.primary:hover:not(:disabled) {
    box-shadow: 0 10px 26px rgba(99, 102, 241, 0.5);
}

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

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    z-index: 20;
    transform: translateX(-50%);
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--text);
    color: var(--bg-1);
    font-size: 14px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 28px;
    }

    .panel {
        padding: 20px 16px;
    }
}
