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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* 제목 스타일 */
.title {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 3rem;
    font-weight: 800;
    text-align: center;
    margin: 0;
    padding: 30px 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

/* 헤더 스타일 */
.header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 20px;
    margin-bottom: 20px;
}

/* 중앙 컬럼에 제목 고정 */
.header .title {
    grid-column: 2;
    justify-self: center;
    padding: 0;
    margin: 0;
}

/* 오른쪽 컬럼에 버튼/사용자 배지 고정 */
.header .login-btn,
.header .user-info {
    grid-column: 3;
    justify-self: end;
}

/* 로그인 버튼 스타일 */
.login-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    min-width: 100px;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

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

.image-container {
    padding: 40px 20px;
    text-align: center;
}

.upload-area {
    border: 3px dashed #ddd;
    border-radius: 15px;
    padding: 60px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #667eea;
    background: #e8f0ff;
    transform: scale(1.02);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.upload-icon {
    width: 64px;
    height: 64px;
    opacity: 0.6;
}

.upload-text {
    font-size: 1.2rem;
    color: #555;
    font-weight: 500;
}

.upload-hint {
    font-size: 0.9rem;
    color: #888;
}

.preview-area {
    margin-top: 20px;
}

.preview-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.image-info {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 20px;
    font-size: 0.9rem;
    color: #666;
}

.controls {
    padding: 30px 20px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

.controls h3 {
    text-align: center;
    color: #333;
    margin-bottom: 25px;
    font-size: 1.3rem;
}

.format-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.format-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.format-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

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

/* 품질 조절 */
.quality-control {
    margin: 20px 0;
    text-align: center;
}

.quality-control label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
}

#qualitySlider {
    width: 100%;
    max-width: 300px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

#qualitySlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

#qualitySlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* 크기 조절 */
.size-control {
    margin: 20px 0;
    text-align: center;
}

.size-control h4 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1rem;
}

.size-inputs {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.size-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.size-input-group label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.size-input-group input {
    width: 100px;
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    transition: border-color 0.3s ease;
}

.size-input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.size-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.size-btn {
    padding: 8px 12px;
    background: #f8f9fa;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    color: #495057;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.size-btn:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
    transform: translateY(-2px);
}

.size-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.aspect-ratio {
    margin: 15px 0;
}

.aspect-ratio label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #666;
    cursor: pointer;
}

.aspect-ratio input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
}

.download-section {
    text-align: center;
}

.download-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.4);
}

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

/* 반응형 디자인 */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 15px;
    }
    
    .title {
        font-size: 2rem;
        padding: 25px 15px;
    }
    
    .image-container {
        padding: 30px 15px;
    }
    
    .upload-area {
        padding: 40px 15px;
    }
    
    .size-inputs {
        flex-direction: column;
        gap: 10px;
    }
    
    .size-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .format-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .format-btn {
        padding: 10px 15px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .size-options {
        grid-template-columns: 1fr;
    }
    
    .format-buttons {
        grid-template-columns: 1fr;
    }
    
    .upload-text {
        font-size: 1rem;
    }
    
    .upload-hint {
        font-size: 0.8rem;
    }
    
    .size-input-group input {
        width: 80px;
        font-size: 0.8rem;
    }

    /* 사용자 정보 뱃지 */
    .user-info {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
}

/* 사용자 정보 배지 - 버튼 스타일 */
.user-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
    transition: all 0.3s ease;
    margin-left: auto;
}

.user-info .user-icon {
    width: 18px;
    height: 18px;
}

.user-info .user-name {
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-info:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(102, 126, 234, 0.45);
}

.user-info:active {
    transform: translateY(0);
}

@media (max-width: 480px) {
    .user-info {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
}

/* 하단 우측 고정 로그아웃 버튼 */
.logout-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    padding: 12px 18px;
    border: none;
    border-radius: 26px;
    background: linear-gradient(135deg, #ff6b6b 0%, #f06595 100%);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 10px 25px rgba(240, 101, 149, 0.35);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    z-index: 999;
}

.logout-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(240, 101, 149, 0.45);
}

.logout-fab:active {
    transform: translateY(0);
}

@media (max-width: 480px) {
    .logout-fab {
        right: 16px;
        bottom: 16px;
        padding: 10px 14px;
        font-size: 0.9rem;
    }
}

/* 포맷 버튼 active 상태 */
.format-btn.active {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    box-shadow: 0 6px 20px rgba(32, 201, 151, 0.35);
}

/* 크기 초기화 버튼 */
.size-actions {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.size-reset-btn {
    padding: 10px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    background: #fff;
    color: #495057;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.size-reset-btn:hover {
    background: #f1f3f5;
    border-color: #ced4da;
}

/* 헤더 좌측 컨트롤 (홈 + 언어) */
.left-controls {
    grid-column: 1;
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 언어 선택 */
.lang-select {
    padding: 8px 10px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    background: #fff;
    color: #495057;
    font-weight: 600;
    cursor: pointer;
}

.lang-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

/* 홈 버튼 */
.home-btn {
    grid-column: 1;
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 20px;
    background: #fff;
    color: #495057;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.home-btn:hover {
    background: #f8f9fa;
    border-color: #ced4da;
    transform: translateY(-1px);
}

.home-icon {
    width: 18px;
    height: 18px;
}

/* 언어별 폰트 설정 */
html { font-family: 'Segoe UI', 'Noto Sans KR', 'Noto Sans SC', Tahoma, Geneva, Verdana, sans-serif; }
html[lang="ko"] { font-family: 'Noto Sans KR', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
html[lang="zh"] { font-family: 'Noto Sans SC', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
html[lang="en"] { font-family: 'Segoe UI', 'Noto Sans KR', 'Noto Sans SC', Tahoma, Geneva, Verdana, sans-serif; }

/* 왼쪽 하단 고정 언어 선택 */
.lang-floating {
    position: fixed;
    left: 24px;
    bottom: 24px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    z-index: 999;
}

.lang-label {
    color: #495057;
    font-weight: 700;
}

@media (max-width: 480px) {
    .lang-floating {
        left: 16px;
        bottom: 16px;
        padding: 6px 10px;
    }
}

/* 커스텀 프리셋 */
.custom-preset-item { padding: 6px 8px; border:2px solid #e9ecef; border-radius:10px; background:#fff; }
.custom-preset-main { gap:8px; }
.custom-preset-btn { padding:6px 10px; border:2px solid #e9ecef; border-radius:8px; background:#f8f9fa; color:#495057; font-size:0.9rem; }
.custom-preset-btn:hover { background:#667eea; color:#fff; border-color:#667eea; }
.custom-preset-dim { color:#666; font-size:0.8rem; }
.custom-preset-del { padding:4px 6px; font-size:0.95rem; }

/* 인라인 프리셋 저장 버튼 정렬/크기 */
.size-inputs { align-items: end; }
.save-preset-inline { display:flex; align-items:flex-end; }
.save-preset-inline .save-preset-btn {
  height: 40px;
  padding: 8px 12px;
  margin-left: 4px;
  border-radius: 8px;
  font-size: 0.9rem;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}
.save-preset-inline .save-preset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}
.save-preset-inline .save-preset-btn:active { transform: translateY(0); }

/* 커스텀 크기 프리셋 - 컴팩트 인라인 필 형태 */
.custom-size { margin-top: 12px; max-width: 640px; margin-left:auto; margin-right:auto; }
.custom-size-header { margin-bottom: 6px; }
.custom-size-header #customSizeTitle { font-weight: 700; color:#333; font-size: 0.9rem; }
.custom-size-options { display:flex; flex-wrap: wrap; gap:8px; }
.custom-preset-pill { display:inline-flex; align-items:center; gap:8px; padding: 6px 10px; border:2px solid #e9ecef; border-radius:999px; background:#fff; cursor:pointer; }
.custom-preset-pill:hover { background:#f8f9ff; border-color:#667eea; }
.custom-preset-name { font-weight:600; color:#495057; font-size:0.9rem; }
.custom-preset-dim { color:#666; font-size:0.8rem; }
.custom-preset-del { background:transparent; border:none; color:#dc3545; font-weight:900; cursor:pointer; padding:0 6px; border-radius:999px; line-height:1; }
.custom-preset-del:hover { background: rgba(220,53,69,0.12); }

@media (max-width: 480px) {
  .custom-size { max-width: 100%; }
  .save-preset-inline .save-preset-btn { height: 40px; padding: 8px 12px; }
}
