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

html {
    background: #0d0d0d;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0d0d0d;
    color: #e8e8e8;
    min-height: 100vh;
    display: flex;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 270px;
    background: #151515;
    border-right: 1px solid #252525;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid #252525;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: #ffffff;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 99;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* Nav */
.sidebar-nav {
    padding: 12px;
    border-bottom: 1px solid #252525;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: #999;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s;
    margin-bottom: 4px;
}

.nav-item:hover { background: #1e1e1e; color: #e8e8e8; }
.nav-item.active { background: #1c1c1c; color: #7aa2f7; font-weight: 600; }

.nav-icon { font-size: 16px; width: 22px; text-align: center; }

/* Sidebar History List */
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.history-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
    margin-bottom: 2px;
}

.history-item:hover { background: #1e1e1e; }

.history-item .title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #e8e8e8;
}

.history-item .meta {
    font-size: 11px;
    color: #666;
    margin-top: 3px;
}

.history-empty {
    text-align: center;
    padding: 30px 16px;
    color: #666;
    font-size: 13px;
}

.api-status {
    padding: 14px 18px;
    border-top: 1px solid #252525;
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.connected { background: #73daca; }
.status-dot.disconnected { background: #f7768e; }

/* ===== Main ===== */
.main {
    margin-left: 270px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #0d0d0d;
}

.topbar {
    background: #131313;
    border-bottom: 1px solid #252525;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    color: #e8e8e8;
    transition: background .15s;
}

.menu-toggle:hover { background: #1e1e1e; }

.topbar h1 {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -.02em;
}

.content {
    flex: 1;
    padding: 28px;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
}

/* ===== Forms ===== */
.input-card {
    background: #161616;
    border: 1px solid #252525;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
    padding: 32px;
    margin-bottom: 28px;
}

.input-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 24px;
    color: #ffffff;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #aaa;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 13px 16px;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color .2s, box-shadow .2s;
    background: #1a1a1a;
    color: #e8e8e8;
    line-height: 1.5;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #555;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #7aa2f7;
    box-shadow: 0 0 0 3px rgba(122,162,247,.12);
}

.form-group textarea { resize: vertical; min-height: 110px; }

/* Video Preview */
.video-preview {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 20px;
}

.preview-thumb {
    width: 130px;
    height: 73px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

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

.preview-title {
    font-size: 15px;
    font-weight: 600;
    color: #e8e8e8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.preview-channel {
    font-size: 13px;
    color: #888;
}

.btn-analyze {
    width: 100%;
    padding: 15px;
    background: #7aa2f7;
    color: #0d0d0d;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .2s, transform .1s;
}

.btn-analyze:hover { background: #6b94e8; }
.btn-analyze:active { transform: scale(.99); }
.btn-analyze:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0,0,0,.2);
    border-top-color: #0d0d0d;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

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

/* ===== Results ===== */
.results { display: none; }
.results.active { display: block; }

.result-section {
    background: #161616;
    border: 1px solid #252525;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
    margin-bottom: 24px;
    overflow: hidden;
}

.result-header {
    padding: 18px 22px;
    background: #121212;
    border-bottom: 1px solid #252525;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.result-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.copy-btn {
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    color: #999;
    transition: background .15s, color .15s;
}

.copy-btn:hover { background: #282828; color: #e8e8e8; }

.result-body { padding: 22px; }

/* Tags Copy Box */
.tags-copybox {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 18px;
    font-size: 14px;
    line-height: 1.9;
    color: #e8e8e8;
    word-break: break-word;
    user-select: all;
    cursor: text;
}

.char-count {
    font-size: 13px;
    color: #888;
    font-weight: 500;
}

.char-count-warn {
    color: #f7768e;
    font-weight: 600;
}

/* Keywords List */
.keywords-list {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 14px 18px;
    max-height: 500px;
    overflow-y: auto;
}

.keyword-line {
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid #222;
    color: #e8e8e8;
}

.keyword-line:last-child {
    border-bottom: none;
}

.keyword-count {
    font-size: 13px;
    color: #888;
    font-weight: 500;
}

/* Tips */
.tip-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #222;
    font-size: 14px;
    line-height: 1.6;
    color: #e8e8e8;
}

.tip-item:last-child { border-bottom: none; }
.tip-icon { flex-shrink: 0; margin-top: 2px; color: #e0af68; }

/* ===== History Page ===== */
.history-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.history-count {
    font-size: 15px;
    color: #888;
    font-weight: 500;
}

.btn-clear-all {
    background: none;
    border: 1px solid rgba(247,118,142,.4);
    color: #f7768e;
    padding: 9px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    transition: background .15s;
}

.btn-clear-all:hover {
    background: rgba(247,118,142,.12);
}

/* Blog List */
.blog-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.blog-card {
    background: #161616;
    border: 1px solid #252525;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
    display: flex;
    overflow: hidden;
    transition: border-color .2s, box-shadow .2s, transform .15s;
}

.blog-card:hover {
    border-color: #333;
    box-shadow: 0 6px 20px rgba(0,0,0,.4);
    transform: translateY(-1px);
}

.blog-card-left {
    flex-shrink: 0;
    width: 250px;
    position: relative;
}

.blog-thumb-link {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
}

.blog-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    min-height: 140px;
}

.blog-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0,0,0,.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    transition: background .2s, transform .2s;
}

.blog-thumb-link:hover .blog-play {
    background: rgba(255,0,0,.8);
    transform: translate(-50%, -50%) scale(1.1);
}

.blog-thumb-empty {
    width: 100%;
    height: 100%;
    min-height: 140px;
    background: #1a1a1a;
}

.blog-card-right {
    flex: 1;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.blog-card-title {
    font-size: 17px;
    font-weight: 600;
    color: #e8e8e8;
    margin-bottom: 8px;
    cursor: pointer;
    transition: color .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.blog-card-title:hover {
    color: #7aa2f7;
}

.blog-card-desc {
    font-size: 14px;
    color: #888;
    line-height: 1.6;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.blog-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #252525;
}

.blog-date {
    font-size: 13px;
    color: #666;
}

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

.blog-btn {
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    color: #e8e8e8;
    padding: 7px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    transition: background .15s;
}

.blog-btn:hover {
    background: #282828;
}

.blog-btn-danger {
    color: #f7768e;
    border-color: rgba(247,118,142,.3);
}

.blog-btn-danger:hover {
    background: rgba(247,118,142,.12);
}

.history-grid-empty {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 15px;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: #161616;
    border: 1px solid #252525;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    width: 90%;
    max-width: 440px;
    padding: 32px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #ffffff;
}

/* Detail Modal */
.modal-detail {
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
}

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

.modal-detail-header h3 { margin-bottom: 0; }

.btn-close-detail {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #888;
    padding: 4px 10px;
    border-radius: 8px;
    transition: background .15s;
}

.btn-close-detail:hover { background: #1e1e1e; }

.detail-section { margin-bottom: 28px; }

.detail-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #252525;
}

.detail-section h4 {
    font-size: 15px;
    font-weight: 700;
    color: #e8e8e8;
    margin: 0;
}

/* ===== Alert ===== */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 20px;
    display: none;
    font-weight: 500;
}

.alert.active { display: flex; align-items: center; gap: 10px; }
.alert-error { background: rgba(247,118,142,.1); color: #f7768e; border: 1px solid rgba(247,118,142,.25); }
.alert-success { background: rgba(115,218,202,.1); color: #73daca; border: 1px solid rgba(115,218,202,.25); }
.alert-warning { background: rgba(224,175,104,.1); color: #e0af68; border: 1px solid rgba(224,175,104,.25); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main { margin-left: 0; }
    .menu-toggle { display: block; }
    .topbar { padding: 14px 18px; }
    .topbar h1 { font-size: 18px; }
    .content { padding: 20px 16px; }
    .input-card { padding: 24px 20px; }
    .input-card h3 { font-size: 17px; }
    .result-header { padding: 14px 16px; }
    .result-body { padding: 16px; }

    .blog-card { flex-direction: column; }
    .blog-card-left { width: 100%; }
    .blog-thumb { min-height: 180px; }
    .blog-card-right { padding: 16px 18px; }

    .modal { padding: 24px 20px; }
    .modal-detail { max-width: 95%; }

    .video-preview { flex-direction: column; align-items: stretch; }
    .preview-thumb { width: 100%; height: auto; aspect-ratio: 16/9; }
}

@media (max-width: 480px) {
    .content { padding: 14px 12px; }
    .input-card { padding: 20px 16px; }
    .topbar { padding: 12px 14px; }
    .topbar h1 { font-size: 16px; }
    .blog-card-right { padding: 14px 16px; }
    .blog-card-title { font-size: 15px; }
    .history-toolbar { flex-direction: column; gap: 12px; align-items: flex-start; }
    .modal { max-width: 98%; padding: 20px 16px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444; }
