@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

:root {
    --bg: #F7F8FC;
    --surface: #FFFFFF;
    --surface-2: #F0F2FF;
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --text-main: #111827;
    --text-sub: #6B7280;
    --text-muted: #9CA3AF;
    --border: #E5E7EB;
    --border-focus: #4F46E5;
    --danger: #EF4444;
    --warning: #F59E0B;
    --success: #10B981;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(79,70,229,0.08), 0 1px 4px rgba(0,0,0,0.04);
    --transition: all 0.2s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    background-image: radial-gradient(circle, #E0E7FF 1px, transparent 1px);
    background-size: 24px 24px;
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 4px; background: transparent; }
::-webkit-scrollbar-thumb { background: #E0E7FF; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

#app {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 56px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    margin: 0 -16px;
    padding: 0 16px;
    display: flex;
    align-items: center;
}

.header-inner {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.logo-block {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.03em;
}

.logo-sub {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--text-sub);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-btn {
    background: transparent;
    border: none;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-sub);
    cursor: pointer;
    transition: var(--transition);
    border-radius: 8px;
}

.text-btn:hover {
    color: var(--primary);
}

.user-status-mini {
    display: flex;
    align-items: center;
    gap: 8px;
}

#user-photo-mini {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

#user-name-mini {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
}

.logout-btn {
    background: transparent;
    border: none;
    font-size: 0.7rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.logout-btn:hover {
    color: var(--text-sub);
}

.tab-nav {
    display: flex;
    background: var(--bg);
    padding: 4px;
    border-radius: var(--radius-md);
    margin-top: 24px;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    padding: 14px;
    border: none;
    background: transparent;
    border-radius: calc(var(--radius-md) - 4px);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-sub);
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn.active {
    background: var(--surface);
    color: var(--primary);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.tab-pane {
    display: none;
    opacity: 0;
}

.tab-pane.active {
    display: block;
    animation: tabFadeIn 0.25s ease forwards;
}

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

.section {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-top: 20px;
}

.section:first-of-type {
    margin-top: 24px;
}

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

.section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-sub);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 4px 10px;
    border-radius: 99px;
}

.select-wrapper select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    background: var(--surface);
    appearance: none;
    cursor: pointer;
    transition: var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.select-wrapper select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.block-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: transparent;
    padding: 0;
    box-shadow: none;
    border: none;
    margin-top: 0;
}

.input-card {
    background: var(--surface);
    padding: 20px 20px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
    animation: fadeInUp 0.4s ease both;
}

.input-card:nth-child(1) { animation-delay: 0.05s; }
.input-card:nth-child(2) { animation-delay: 0.1s; }
.input-card:nth-child(3) { animation-delay: 0.15s; }
.input-card:nth-child(4) { animation-delay: 0.2s; }

.input-card:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1), var(--shadow-sm);
    transform: translateY(-1px);
}

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

.card-number {
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: 'Plus Jakarta Sans', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.input-card label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
}

textarea {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    resize: none;
    outline: none;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 68px;
    overflow: hidden;
}

textarea::placeholder {
    color: var(--text-muted);
}

.input-card textarea {
    min-height: 68px;
}

.example-hint {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--primary);
    text-align: center;
}

.action-area {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.primary-btn {
    flex: 3;
    padding: 16px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: -0.01em;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
    transition: var(--transition);
}

.primary-btn:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
    transform: translateY(-1px);
}

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

.tertiary-btn {
    flex: 1;
    padding: 16px;
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-sub);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.tertiary-btn:hover {
    border-color: #D1D5DB;
    background: #F9FAFB;
}

.secondary-btn {
    padding: 10px 16px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text-sub);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.secondary-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.accent-btn {
    padding: 10px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

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

.copy-btn-icon {
    padding: 10px 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text-sub);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.result-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.result-actions {
    display: flex;
    gap: 8px;
}

#result-text {
    height: 100px;
    background: var(--surface-2);
    border: 1.5px solid #C7D2FE;
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.7;
}

#final-text {
    height: 200px;
    background: var(--surface-2);
    border: 1.5px solid #C7D2FE;
    border-radius: var(--radius-md);
    padding: 18px;
    font-size: 1rem;
    line-height: 1.8;
}

.counter-container {
    margin-top: 20px;
}

.counter-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 10px;
}

.main-counter {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.large-count {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: 'Plus Jakarta Sans', sans-serif;
}

#byte-count {
    font-weight: 600;
    color: var(--text-sub);
    font-size: 0.85rem;
}

.limit-info {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.progress-bar-bg {
    height: 6px;
    background: #E0E7FF;
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    transition: width 0.5s ease;
}

.progress-bar-fill.warning {
    background: var(--warning);
}

.progress-bar-fill.danger {
    background: var(--danger);
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.popup-content {
    background: var(--surface);
    width: 100%;
    max-width: 520px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 20px 24px 40px;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 85vh;
    overflow-y: auto;
}

.popup-overlay.active .popup-content {
    transform: translateY(0);
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 99px;
    margin: 0 auto 20px;
}

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

.popup-header h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.sub-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 6px;
}

.close-btn {
    background: var(--bg);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-sub);
}

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

.word-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.word-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.word-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.word-orig {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.word-recommends {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.recommend-tag {
    background: var(--surface);
    border: 1.5px solid var(--border);
    padding: 8px 14px;
    border-radius: 99px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

.recommend-tag:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.recommend-tag:active {
    transform: scale(0.97);
}

.auth-modal-content {
    text-align: center;
    padding: 40px 32px;
}

.lock-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 16px;
}

.modal-body h4 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-main);
}

.modal-body p {
    font-size: 0.9rem;
    color: var(--text-sub);
    line-height: 1.6;
    margin-bottom: 8px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .tertiary-btn {
    flex: 1;
}

.modal-actions .primary-btn {
    flex: 1.5;
}

.explorer-header {
    margin-bottom: 8px;
}

.explorer-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.article-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.article-card {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.article-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: #C7D2FE;
}

.article-card .article-content {
    cursor: default;
}

.detail-btn {
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--primary-light);
    border: 1.5px solid var(--primary);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition);
}

.detail-btn:hover {
    background: var(--primary);
    color: white;
}

.article-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.article-card.selected::after {
    content: "✓";
    position: absolute;
    top: 14px;
    right: 14px;
    width: 22px;
    height: 22px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.article-content h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
    line-height: 1.4;
}

.article-content p {
    font-size: 0.85rem;
    color: var(--text-sub);
    line-height: 1.6;
    margin-bottom: 12px;
}

.keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.keyword-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: #4F46E5;
    background: #EEF2FF;
    padding: 4px 10px;
    border-radius: 99px;
}

.floating-action-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    background: var(--surface);
    backdrop-filter: blur(12px);
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 100;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    width: calc(100% - 32px);
    max-width: 488px;
    border: 1px solid var(--border);
}

.floating-action-bar.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.floating-action-bar.hidden {
    pointer-events: none;
}

.selected-article-info {
    flex: 1;
    min-width: 0;
}

#selected-article-title {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.floating-action-bar .primary-btn {
    flex: none;
    padding: 12px 20px;
    font-size: 0.9rem;
}

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

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

footer {
    text-align: center;
    padding: 32px 0 16px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.hidden {
    display: none !important;
}

#article-list-view.active {
    display: block;
}

.detail-view {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: 100vh;
    background: var(--bg);
    z-index: 200;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.detail-view.active {
    display: block;
    transform: translateX(0);
}

.detail-view:not(.active) {
    transform: translateX(100%);
}

.detail-header {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    padding: 16px;
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    padding: 8px 0;
}

.back-btn:hover {
    opacity: 0.7;
}

.back-arrow {
    font-size: 1.2rem;
}

.detail-content {
    max-width: 520px;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

.detail-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.4;
    margin-bottom: 16px;
}

.detail-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.detail-divider {
    height: 1px;
    background: var(--border);
    margin-bottom: 24px;
}

.detail-body {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-main);
}

.detail-body p {
    margin-bottom: 16px;
    text-align: justify;
}

.detail-body p:last-of-type {
    margin-bottom: 0;
}

.sources-section {
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.sources-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 12px;
}

.sources-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.source-link {
    font-size: 0.82rem;
    color: var(--primary);
    text-decoration: none;
    line-height: 1.5;
    word-break: break-all;
}

.source-link:hover {
    text-decoration: underline;
}

.detail-fill-btn {
    width: 100%;
    margin-top: 16px;
    margin-bottom: 0;
    padding: 14px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
    transition: var(--transition);
}

.detail-fill-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.detail-action {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    padding: 16px;
    border-top: 1px solid var(--border);
    z-index: 10;
}

.detail-content {
    max-width: 520px;
    margin: 0 auto;
    padding: 24px 16px 0;
}

.fill-blocks-btn {
    width: 100%;
    padding: 18px 24px;
    font-size: 1.1rem;
}

@keyframes highlight-pulse {
    0%, 100% { box-shadow: var(--shadow-sm); }
    50% { box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.3), var(--shadow-md); }
}

@media (max-width: 480px) {
    #app {
        padding: 0 12px 32px;
    }
    
    header {
        margin: 0 -12px;
        padding-left: 12px;
        padding-right: 12px;
    }
    
    .section {
        padding: 20px;
        border-radius: var(--radius-md);
    }
    
    .input-card {
        padding: 16px;
    }
    
    .large-count {
        font-size: 1.5rem;
    }
    
    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .result-actions {
        width: 100%;
    }
    
    .result-actions button {
        flex: 1;
    }

    .detail-title {
        font-size: 1.3rem;
    }

    .detail-content {
        padding: 20px 12px 0;
    }
}
