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

:root {
    --bg-main: #FDFBF9;
    --bg-card: #FFFFFF;
    --bg-input: #F8F6F4;
    --text-dark: #2D2A26;
    --text-body: #4A4540;
    --text-muted: #8A8279;
    --border: #E8E4DF;
    --primary: #E85A3C;
    --primary-soft: #F4A261;
    --accent: #D4A853;
    --success: #5B9A6E;
    --danger: #C45B47;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', sans-serif;
    background: var(--bg-main);
    color: var(--text-body);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 100px;
}

/* 헤더 */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.back-btn, .settings-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-body);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
}

.back-btn:hover, .settings-btn:hover {
    border-color: var(--text-muted);
}

.back-btn svg, .settings-btn svg {
    width: 20px;
    height: 20px;
}

header h1 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-dark);
    letter-spacing: -0.01em;
}

header h1::before {
    content: none;
}

/* API 상태 */
.api-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}

.api-status.error .status-dot {
    background: var(--danger);
}

/* 기본 모드 */
.basic-mode {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.input-group {
    margin-bottom: 14px;
}

.input-group:last-child {
    margin-bottom: 0;
}

.input-group label {
    display: block;
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.required {
    color: var(--danger);
}

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text-body);
    outline: none;
    transition: all 0.15s;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    border-color: var(--primary);
    background: var(--bg-card);
}

.input-group textarea {
    resize: vertical;
    min-height: 70px;
}

.input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    border: 1px solid transparent;
    transition: all 0.15s;
}

.input-wrap:focus-within {
    border-color: var(--primary);
    background: var(--bg-card);
}

.input-wrap input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 0;
}

.input-wrap .unit {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* 카테고리 버튼 */
.category-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.category-btn {
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
}

.category-btn:hover {
    border-color: var(--text-muted);
}

.category-btn.active {
    background: var(--text-dark);
    border-color: var(--text-dark);
    color: white;
}

/* 생성 버튼 */
.generate-btn {
    width: 100%;
    padding: 14px;
    background: var(--text-dark);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s;
    margin-top: 16px;
}

.generate-btn:hover {
    background: var(--primary);
}

.generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 1.1rem;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.loading-spinner.hidden {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 고급 모드 토글 */
.advanced-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 12px;
}

.advanced-toggle:hover {
    border-color: var(--text-muted);
}

.advanced-toggle.active {
    background: var(--bg-input);
}

.toggle-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

.advanced-toggle.active .toggle-icon {
    transform: rotate(180deg);
}

/* 고급 모드 */
.advanced-mode {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.advanced-mode.hidden {
    display: none;
}

.advanced-section {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.advanced-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.advanced-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 12px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.form-grid.four-cols {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 600px) {
    .form-grid.four-cols {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 다중 선택 버튼 */
.multi-select-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.multi-btn {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
}

.multi-btn:hover {
    border-color: var(--text-muted);
}

.multi-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(232, 90, 60, 0.06);
}

.sub-category-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sub-category-buttons .multi-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
}

/* 색상 선택 */
.color-picker-wrap {
    display: flex;
    gap: 8px;
}

.color-picker-wrap input[type="color"] {
    width: 44px;
    height: 40px;
    padding: 3px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border);
}

.color-picker-wrap input[type="text"] {
    flex: 1;
}

/* 결과 탭 */
.results-section.hidden {
    display: none;
}

.results-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    border: 1px solid var(--border);
    overflow-x: auto;
}

.result-tab {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.result-tab.active {
    background: var(--text-dark);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 결과 카드 */
.result-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border);
    margin-bottom: 10px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.card-icon {
    font-size: 1rem;
}

.card-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-dark);
}

/* 상품명 리스트 */
.name-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.name-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    gap: 10px;
}

.name-item .name {
    flex: 1;
    font-weight: 500;
    font-size: 0.9rem;
    word-break: break-word;
    color: var(--text-body);
}

.name-item .platform-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: 6px;
    white-space: nowrap;
}

.copy-single-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.copy-single-btn:hover {
    background: var(--text-dark);
    color: white;
}

.copy-single-btn svg {
    width: 16px;
    height: 16px;
}

/* 키워드 정보 */
.keyword-info {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(232, 90, 60, 0.06);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--primary);
}

/* 설명 리스트 */
.description-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.description-item {
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.description-item .label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.description-item .label span {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-dark);
}

.description-item .content {
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text-body);
}

/* 해시태그 */
.hashtag-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hashtag-group {
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.hashtag-group .label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.hashtag-group .label span {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-dark);
}

.hashtag-group .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tag {
    padding: 4px 10px;
    background: var(--bg-card);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-body);
    font-weight: 500;
}

/* 분석 */
.analysis-input {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.analysis-input input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-body);
    outline: none;
}

.analysis-input input:focus {
    border-color: var(--primary);
}

.analyze-btn {
    padding: 10px 16px;
    background: var(--text-dark);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.analyze-btn:hover {
    background: var(--primary);
}

.analysis-result, .competitor-result {
    padding: 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.analysis-result.hidden, .competitor-result.hidden {
    display: none;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.score-item {
    padding: 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.score-item .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.score-item .stars {
    font-size: 1rem;
    letter-spacing: 1px;
}

.improvement-section {
    padding: 12px;
    background: rgba(232, 90, 60, 0.06);
    border-radius: var(--radius-sm);
}

.improvement-section h4 {
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.improvement-section ul {
    margin-left: 18px;
    font-size: 0.85rem;
    color: var(--text-body);
}

.improvement-section li {
    margin-bottom: 4px;
}

.improved-name {
    margin-top: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.improved-name .name {
    font-weight: 600;
    color: var(--primary);
}

/* 플랫폼 탭 */
.platform-tabs {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.platform-tab {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
}

.platform-tab.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(232, 90, 60, 0.06);
}

.platform-content {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border);
}

.platform-item-group {
    margin-bottom: 12px;
}

.platform-item-group:last-child {
    margin-bottom: 0;
}

.platform-item-group .label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.platform-item-group .content {
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.platform-item-group .text {
    flex: 1;
    word-break: break-word;
    font-size: 0.9rem;
    color: var(--text-body);
}

/* 액션 버튼 */
.action-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    max-width: 600px;
    margin: 0 auto;
}

.action-buttons.hidden {
    display: none;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 10px 6px;
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-body);
    cursor: pointer;
    transition: all 0.15s;
}

.action-btn:hover {
    background: var(--text-dark);
    color: white;
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

/* 모달 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content.large {
    max-height: 90vh;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

.modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
}

.close-btn svg {
    width: 18px;
    height: 18px;
}

.modal-body {
    padding: 20px;
}

.setting-group {
    margin-bottom: 16px;
}

.setting-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-body);
    margin-bottom: 8px;
}

.setting-group input,
.setting-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text-body);
    outline: none;
}

.api-key-input {
    display: flex;
    gap: 8px;
}

.api-key-input input {
    flex: 1;
}

.toggle-visibility {
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
}

.toggle-visibility svg {
    width: 20px;
    height: 20px;
}

.api-usage {
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.api-usage strong {
    color: var(--primary);
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.toggle-track {
    display: block;
    width: 44px;
    height: 24px;
    background: var(--bg-input);
    border-radius: 12px;
    position: relative;
    transition: all 0.2s;
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--text-dark);
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-footer {
    padding: 12px 20px 20px;
}

.save-settings-btn {
    width: 100%;
    padding: 14px;
    background: var(--text-dark);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.15s;
}

.save-settings-btn:hover {
    background: var(--primary);
}

/* 히스토리 */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    padding: 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.history-item:hover {
    background: var(--bg-main);
}

.history-item .name {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: var(--text-dark);
}

.history-item .meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* 토스트 */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    padding: 12px 20px;
    background: var(--text-dark);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease;
    z-index: 1001;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* 반응형 */
@media (max-width: 600px) {
    .container {
        padding: 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .results-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .result-tab {
        flex: none;
        padding: 8px 12px;
    }
}

/* Footer */
.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 32px 20px;
    margin-top: 40px;
    text-align: center;
}

.footer-brand {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.footer-contact {
    font-size: 13px;
    color: var(--text-muted);
}
