/* ================================================
   통합 개인 단어장 시스템 스타일 (완전 리팩토링)
   personal_wordbook.css - COMPLETE REFACTORED VERSION
   ================================================ */

/* ================================================
   CSS 변수 정의
   ================================================ */
:root {
  /* 기존 game_effects.css의 변수 상속 */
  /* 단어장 전용 변수 추가 */
  --wordbook-padding: 20px;
  --wordbook-padding-mobile: 16px;
  --wordbook-padding-small: 12px;
  --wordbook-bottom-spacing: 140px;
  --wordbook-bottom-spacing-mobile: 150px;
  --wordbook-bottom-spacing-small: 180px;
}

/* ================================================
   🔧 핵심: 단어장 탭 메인 컨테이너
   ================================================ */

#vocabularyTab {
    /* 포지션 및 레이아웃 */
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
    
    /* 높이 설정 - 탭바 높이 제외 */
    height: calc(100vh - var(--tab-bar-total-height, 52px));
    height: calc(100dvh - var(--tab-bar-total-height, 52px));
    
    /* 스크롤 설정 */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    
    /* 패딩 설정 */
    padding: var(--wordbook-padding);
    padding-bottom: var(--wordbook-bottom-spacing);
    box-sizing: border-box;
    
    /* PC용 스크롤바 스타일 */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

/* PC용 웹킷 스크롤바 */
#vocabularyTab::-webkit-scrollbar {
    width: 6px;
}

#vocabularyTab::-webkit-scrollbar-track {
    background: transparent;
}

#vocabularyTab::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    transition: background 0.2s ease;
}

#vocabularyTab::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ================================================
   메인 섹션 스타일
   ================================================ */

.personal-wordbooks-section,
.shared-wordbooks-section {
    /* 레이아웃 */
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
    
    /* 간격 */
    margin: 0 0 20px 0;
    padding: var(--wordbook-padding);
    
    /* 스타일 */
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: white;
}

/* 섹션 헤더 */
.wordbook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.wordbook-title {
    font-size: 1.2em;
    font-weight: 700;
    color: white;
    margin: 0;
}

/* ================================================
   단어장 그리드
   ================================================ */

.wordbooks-grid,
.shared-wordbooks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin: 0;
    height: auto;
    min-height: auto;
}

/* ================================================
   단어장 카드
   ================================================ */

.wordbook-card {
    /* 레이아웃 */
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 120px;
    
    /* 스타일 */
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    
    /* 간격 */
    padding: 12px 16px 16px 16px;
    
    /* 인터랙션 */
    cursor: pointer !important;
    transition: all 0.3s ease;
    color: white;
}

.wordbook-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* 카드 내용 */
.wordbook-name {
    font-size: 1.1em;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: white;
    padding-right: 100px;
    line-height: 1.3;
}

.wordbook-description {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0;
    line-height: 1.4;
    min-height: 1.4em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 20px;
    flex: 1;
}

.wordbook-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.7);
    margin-top: auto;
}

.wordbook-word-count {
    font-weight: 700 !important;
    color: var(--success) !important;
    font-size: 1.1em !important;
}

/* ================================================
   카드 액션 버튼
   ================================================ */

.wordbook-simple-buttons {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    z-index: 15;
    align-items: center;
}

.wordbook-btn {
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 6px;
    font-size: 14px;
    color: white;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wordbook-btn:hover {
    transform: scale(1.1);
}

.wordbook-btn:active {
    transform: scale(0.95);
}

/* 버튼별 스타일 */
.favorite-btn.active {
    background: rgba(255, 215, 0, 0.8);
}

.edit-btn {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
}

.delete-btn {
    background: linear-gradient(135deg, #e17055 0%, #d63031 100%);
}

.share-btn {
    background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%);
}

.copy-shared-btn {
    background: linear-gradient(135deg, #00b894 0%, #00a085 100%);
}

.delete-shared-btn {
    background: linear-gradient(135deg, #e17055 0%, #d63031 100%);
}

/* ================================================
   편집 모드
   ================================================ */

.wordbook-card.editing {
    background: rgba(255, 255, 255, 0.15) !important;
    border: 2px solid rgba(102, 126, 234, 0.5) !important;
    cursor: default !important;
}

.wordbook-card.editing .wordbook-simple-buttons {
    display: none;
}

.wordbook-card.editing::after {
    display: none !important;
}

/* 편집 입력 필드 */
.edit-name-input,
.edit-description-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 6px;
    padding: 8px 12px;
    color: #333;
    transition: all 0.3s ease;
    box-sizing: border-box;
    font-family: inherit;
}

.edit-name-input {
    font-size: 1.1em;
    font-weight: 600;
    margin: 0 0 8px 0;
    padding-right: 100px;
}

.edit-description-input {
    font-size: 0.9em;
    margin-bottom: 12px;
    min-height: 60px;
    max-height: 80px;
    resize: vertical;
    line-height: 1.4;
    padding-right: 100px;
}

.edit-name-input:focus,
.edit-description-input:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.8);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: rgba(255, 255, 255, 1);
}

/* 색상 선택기 */
.edit-color-picker {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 12px 0;
    padding: 8px 0;
    flex-wrap: wrap;
}

.edit-color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.edit-color-option.selected {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
}

.edit-color-option.selected::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* 편집 액션 버튼 */
.edit-action-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 12px 0;
    padding: 8px 0;
}

.edit-save-btn,
.edit-cancel-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.edit-save-btn {
    background: rgba(0, 184, 148, 0.9);
    color: white;
}

.edit-cancel-btn {
    background: rgba(255, 107, 107, 0.9);
    color: white;
}

.edit-save-btn:hover,
.edit-cancel-btn:hover {
    transform: scale(1.1);
}

.edit-save-btn:active,
.edit-cancel-btn:active {
    transform: scale(0.95);
}

/* ================================================
   공통 버튼 스타일
   ================================================ */

.btn {
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9em;
    padding: 10px 16px;
    text-decoration: none;
    user-select: none;
    box-sizing: border-box;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-lg {
    padding: 12px 20px;
    font-size: 1em;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-success {
    background: var(--success-gradient);
    color: white;
}

.btn-danger {
    background: var(--danger-gradient);
    color: white;
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #e0e0e0;
}

/* 생성 버튼 */
.create-wordbook-btn {
    background: var(--success-gradient);
    color: white;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 184, 148, 0.3);
}

/* ================================================
   모달 스타일
   ================================================ */

/* 생성 모달 */
.create-wordbook-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 1000 !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(5px) !important;
}

.create-wordbook-content {
    background: white;
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    margin: 0 !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
}

/* 단어 관리 모달 */
.word-management-modal {
    max-width: 800px !important;
    height: 85vh !important;
    max-height: 85vh !important;
    width: 95% !important;
    display: flex !important;
    flex-direction: column !important;
}

.word-management-modal.themed {
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border: 3px solid var(--theme-color, #667eea);
}

.word-management-modal.themed .modal-body {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    margin: 12px 0;
    padding: 20px;
    backdrop-filter: blur(5px);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.word-management-modal.themed .modal-header {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px 8px 0 0;
    padding: 16px 20px;
    margin-bottom: 0;
    border-bottom: 2px solid var(--theme-color, #667eea);
    flex-shrink: 0;
}

/* 모달 헤더 */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.3em;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* ================================================
   단어 목록 스타일
   ================================================ */

/* 액션 바 */
.words-list-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.words-selection {
    display: flex;
    align-items: center;
    gap: 10px;
}

.selected-count {
    display: inline-flex;
    align-items: center;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.85em;
    font-weight: 600;
}

.select-all-container {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    user-select: none;
}

.words-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f1f3f5;
}

.action-btn:hover {
    transform: translateY(-1px);
}

.play-all-btn {
    background: #74b9ff;
    color: white;
}

.delete-btn {
    background: #ff7675;
    color: white;
}

/* 단어 목록 컨테이너 */
.words-list-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 10px;
    min-height: 0;
}

.words-list {
    display: flex;
    flex-direction: column;
}

/* 단어 아이템 */
.word-item,
.shared-word-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
    gap: 16px;
    cursor: pointer;
}

.word-item:hover,
.shared-word-item:hover {
    background: #f8f9fa;
    transform: translateX(2px);
}

.word-item:last-child,
.shared-word-item:last-child {
    border-bottom: none;
}

.word-item.selected {
    background: rgba(102, 126, 234, 0.1);
    border-left: 4px solid #667eea;
}

.word-item-checkbox {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

.word-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.word-korean {
    font-weight: 700;
    color: #2d3436;
    font-size: 1.1em;
}

.word-japanese {
    color: #636e72;
    font-size: 0.95em;
}

.word-hanja {
    color: #888;
    font-style: italic;
    font-size: 0.85em;
}

.word-meaning {
    color: #666;
    font-size: 0.85em;
    margin-top: 4px;
}

.word-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.word-action-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.word-action-btn:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

/* ================================================
   페이지네이션
   ================================================ */

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    flex-shrink: 0;
}

.pagination-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: #e9ecef;
    transform: translateY(-1px);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 0.9em;
    color: #666;
    font-weight: 600;
}

/* ================================================
   폼 스타일
   ================================================ */

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    font-family: inherit;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* 컬러 피커 */
.color-picker-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.color-option.selected {
    border-color: #333;
    transform: scale(1.1);
}

/* 폼 액션 */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* ================================================
   검색 모달
   ================================================ */

.search-input-container {
    margin-bottom: 20px;
}

.search-input {
    font-size: 16px !important;
    padding: 12px 16px !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: 8px !important;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    border-color: #667eea !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}

.search-results-container {
    min-height: 300px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    padding: 12px;
}

.search-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #666;
    height: 100%;
    min-height: 200px;
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.placeholder-text {
    font-size: 16px;
    line-height: 1.5;
}

.search-result-item {
    background: white !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    margin-bottom: 8px !important;
    transition: all 0.2s ease !important;
}

.search-result-item:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ================================================
   빈 상태
   ================================================ */

.empty-wordbooks {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.7);
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-wordbooks h3 {
    margin-bottom: 12px;
    color: white;
}

.empty-words {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-words h3 {
    margin-bottom: 12px;
    color: #333;
}

/* ================================================
   기타 컴포넌트
   ================================================ */

/* 클릭 유도 툴팁 */
.wordbook-card::after {
    content: '👆 クリックして管理';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.7em;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.wordbook-card:hover::after {
    opacity: 1;
    bottom: -30px;
}

/* 공유 정보 */
.shared-by-info {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-style: italic;
}

/* 로딩 상태 */
.vocabulary-loading {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

/* 재생 상태 */
.status-playing {
    background: rgba(0, 184, 148, 0.2);
    color: #00b894;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    margin-left: 8px;
    animation: fadeInStatus 0.3s ease-out;
}

.play-all-btn.playing {
    background: #e17055 !important;
    animation: playingPulse 2s infinite;
}

/* ================================================
   애니메이션
   ================================================ */

@keyframes fadeInStatus {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes playingPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes fadeInEdit {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ================================================
   반응형 디자인
   ================================================ */

@media (max-width: 768px) {
    #vocabularyTab {
        height: calc(100vh - var(--tab-bar-total-height, 52px) - env(safe-area-inset-top, 0));
        height: calc(100dvh - var(--tab-bar-total-height, 52px) - env(safe-area-inset-top, 0));
        padding: var(--wordbook-padding-mobile);
        padding-bottom: var(--wordbook-bottom-spacing-mobile);
        gap: 16px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    #vocabularyTab::-webkit-scrollbar {
        display: none;
    }
    
    .personal-wordbooks-section,
    .shared-wordbooks-section {
        padding: var(--wordbook-padding-mobile);
        margin: 0 0 16px 0;
    }
    
    .wordbooks-grid,
    .shared-wordbooks-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .create-wordbook-content {
        width: 95%;
        padding: 20px;
    }
    
    .word-management-modal {
        width: 98% !important;
        height: 90vh !important;
        max-height: 90vh !important;
    }
    
    .word-management-modal.themed .modal-header {
        padding: 12px 16px;
    }
    
    .word-management-modal.themed .modal-body {
        padding: 16px;
    }
    
    .word-item {
        padding: 12px;
        gap: 12px;
    }
    
    .word-japanese {
        font-size: 0.85em;
    }
    
    .wordbook-header-section {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .words-list-container {
        max-height: 300px;
    }
    
    .search-results-container {
        max-height: 300px;
    }
    
    .search-placeholder {
        padding: 40px 16px;
        min-height: 150px;
    }
    
    .placeholder-icon {
        font-size: 36px;
        margin-bottom: 12px;
    }
    
    .placeholder-text {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    #vocabularyTab {
        padding: var(--wordbook-padding-small);
        padding-bottom: var(--wordbook-bottom-spacing-small);
        gap: 12px;
    }
    
    .personal-wordbooks-section,
    .shared-wordbooks-section {
        padding: var(--wordbook-padding-small);
        margin: 0 0 12px 0;
    }
    
    .wordbooks-grid,
    .shared-wordbooks-grid {
        gap: 8px;
    }
    
    .word-management-modal {
        height: calc(85vh - env(safe-area-inset-bottom, 20px)) !important;
        max-height: calc(85vh - env(safe-area-inset-bottom, 20px)) !important;
    }
    
    .word-management-modal.themed .modal-header {
        padding: 10px 12px;
    }
    
    .word-management-modal.themed .modal-body {
        padding: 12px;
    }
    
    .wordbook-card {
        padding: 10px 12px 12px 12px;
    }
    
    .wordbook-simple-buttons {
        top: 6px;
        right: 6px;
        gap: 3px;
    }
    
    .wordbook-btn {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    
    .wordbook-name {
        font-size: 1em;
        padding-right: 80px;
    }
    
    .wordbook-description {
        font-size: 0.85em;
        padding-right: 15px;
    }
    
    .edit-name-input {
        font-size: 1em;
        padding: 6px 10px;
        padding-right: 80px;
    }
    
    .edit-description-input {
        font-size: 0.85em;
        padding: 6px 10px;
        min-height: 50px;
        max-height: 70px;
        padding-right: 15px;
    }
    
    .edit-save-btn,
    .edit-cancel-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .edit-action-buttons {
        gap: 15px;
        margin: 10px 0;
    }
    
    .word-actions {
        flex-direction: column;
        gap: 4px;
    }
    
    .word-action-btn {
        min-width: 24px;
        height: 24px;
        font-size: 0.7em;
    }
    
    .pagination-controls {
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 5px;
    }
    
    .pagination-info {
        order: -1;
        width: 100%;
        text-align: center;
    }
    
    .search-input {
        font-size: 16px !important;
    }
    
    .shared-by-info {
        font-size: 0.75em;
    }
    
    .wordbook-card::after {
        content: '👆 タップして管理';
        font-size: 0.65em;
    }
    
    .search-results-container {
        max-height: 250px;
    }
    
    .copy-shared-btn,
    .delete-shared-btn {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

/* ================================================
   iOS Safari 특별 대응
   ================================================ */

@supports (-webkit-touch-callout: none) {
    #vocabularyTab {
        position: relative;
        height: calc(100vh - var(--tab-bar-total-height, 52px));
        min-height: calc(100vh - var(--tab-bar-total-height, 52px));
        -webkit-overflow-scrolling: touch;
        overflow-y: scroll;
        overscroll-behavior-y: contain;
    }
    
    body {
        position: relative;
        overflow: visible;
        width: 100%;
        height: auto;
    }
}

/* ================================================
   iOS Safe Area 대응
   ================================================ */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        #vocabularyTab {
            padding-bottom: calc(var(--wordbook-bottom-spacing-mobile) + env(safe-area-inset-bottom, 0px));
        }
    }
    
    @media (max-width: 480px) {
        #vocabularyTab {
            padding-bottom: calc(var(--wordbook-bottom-spacing-small) + env(safe-area-inset-bottom, 0px));
        }
    }
}

/* ================================================
   터치 디바이스 최적화
   ================================================ */

@media (hover: none) and (pointer: coarse) {
    #vocabularyTab {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        touch-action: pan-y;
    }
    
    .wordbook-btn:active {
        background: rgba(0, 0, 0, 0.8);
        transform: scale(0.95);
    }
    
    .wordbook-card {
        -webkit-tap-highlight-color: transparent;
    }
}

/* ================================================
   접근성 개선
   ================================================ */

.wordbook-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.word-item-checkbox:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* ================================================
   유틸리티 클래스
   ================================================ */

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ================================================
   스크롤바 커스터마이징
   ================================================ */

.words-list-container::-webkit-scrollbar {
    width: 6px;
}

.words-list-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.words-list-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.words-list-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}