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

:root {
    --bg: #ffffff;
    --text: #37352f;
    --text-secondary: #787774;
    --border: #e9e9e7;
    --hover: #f7f6f3;
    --primary: #2383e2;
    --primary-hover: #1a6dc9;
    --success: #0f7b6c;
    --error: #e03e3e;
}

body {
    font-family: 'Noto Sans KR', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 60px 20px 40px;
}

/* 헤더 */
.header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
}

.settings-btn {
    margin-left: auto;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* 검색 박스 */
.search-section {
    margin-bottom: 32px;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 12px 48px 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: 'Noto Sans KR', sans-serif;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(35, 131, 226, 0.1);
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* 메시지 */
.message {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

/* 검색 이력 */
.search-history {
    margin-bottom: 32px;
}

.search-history-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.history-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.history-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

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

.history-item-text {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--text-secondary);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.history-item-delete:hover {
    opacity: 1;
    background: var(--error);
}

.message.success {
    background: #e6fcf5;
    color: var(--success);
}

.message.error {
    background: #ffe2dd;
    color: var(--error);
}

.message.loading {
    background: var(--hover);
    color: var(--text-secondary);
}

/* 책 리스트 */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.book-item {
    cursor: pointer;
    transition: transform 0.2s;
}

.book-item:hover {
    transform: translateY(-4px);
}

.book-cover-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 2/3;
    margin-bottom: 12px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-item.selected .book-cover-wrapper {
    outline: 3px solid var(--primary);
}

.book-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.book-author {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 추가 버튼 */
.add-button-wrapper {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 100;
}

.add-button {
    padding: 14px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(35, 131, 226, 0.3);
    transition: all 0.2s;
    display: none;
    font-family: 'Noto Sans KR', sans-serif;
}

.add-button.show {
    display: block;
    animation: slideUp 0.3s ease;
}

.add-button:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 16px rgba(35, 131, 226, 0.4);
    transform: translateY(-2px);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

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

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

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

.input-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Noto Sans KR', sans-serif;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.help-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.5;
}

.help-text a {
    color: var(--primary);
    text-decoration: none;
}

.help-text a:hover {
    text-decoration: underline;
}

.save-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    font-family: 'Noto Sans KR', sans-serif;
}

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

/* 빈 상태 */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 15px;
}

/* 로딩 스피너 */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

@media (max-width: 640px) {
    .container {
        padding: 40px 16px 80px;
    }

    .title {
        font-size: 24px;
    }

    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 16px;
    }

    .add-button-wrapper {
        bottom: 20px;
        right: 20px;
    }
}
