:root {
    --bg: #f8fafc;
    --paper: #ffffff;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-2: #cbd5e1;
    --accent: #0284c7;
    --accent-hover: #0369a1;
    --accent-soft: #e0f2fe;
    --dark: #0f172a;
    --dark-hover: #1e293b;
    --ok: #16a34a;
    --err: #dc2626;
    --err-bg: #fef2f2;
    --radius: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.07), 0 1px 3px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.wrap {
    width: min(980px, calc(100% - 32px));
    margin: 0 auto;
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(248, 250, 252, 0.85);
    backdrop-filter: saturate(150%) blur(12px);
    -webkit-backdrop-filter: saturate(150%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--dark);
    color: #38bdf8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.brand-icon svg { width: 18px; height: 18px; }

.brand-name {
    font-size: 16px;
    letter-spacing: -0.02em;
}

.brand-tag {
    font-size: 11px;
    font-weight: 650;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 2px 8px;
    border-radius: 999px;
}

.top-links {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 14px;
    color: var(--muted);
}
.top-links a:hover { color: var(--ink); }

/* Hero */
.hero {
    padding: 56px 0 32px;
    text-align: center;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    border-radius: 999px;
    background: var(--paper);
    border: 1px solid var(--line);
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.hero-badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.hero h1 {
    margin: 18px 0 10px;
    font-size: clamp(1.9rem, 4.5vw, 2.9rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.hero-sub {
    margin: 0 auto 28px;
    max-width: 560px;
    color: var(--muted);
    font-size: 15.5px;
}

/* Parse form */
.parse-box {
    display: flex;
    gap: 10px;
    max-width: 760px;
    margin: 0 auto;
    background: var(--paper);
    padding: 8px;
    border-radius: 16px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.parse-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.12), var(--shadow-md);
}

.input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding-left: 10px;
}

.input-icon {
    color: var(--muted);
    display: inline-flex;
    flex-shrink: 0;
}
.input-icon svg { width: 18px; height: 18px; }

.input-wrap input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--ink);
    font-size: 15px;
    padding: 10px 4px;
}
.input-wrap input::placeholder { color: #94a3b8; }

.icon-btn {
    border: 0;
    background: #f1f5f9;
    color: var(--muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn:hover { background: #e2e8f0; color: var(--ink); }

.paste-btn {
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--ink-2);
    padding: 7px 12px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 150ms ease, border-color 150ms ease;
}
.paste-btn:hover { background: #e2e8f0; border-color: var(--line-2); }

.submit-btn {
    border: 0;
    background: var(--dark);
    color: #fff;
    padding: 0 26px;
    height: 46px;
    border-radius: 11px;
    font-size: 15px;
    font-weight: 650;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
    transition: background 150ms ease, transform 120ms ease;
}
.submit-btn:hover { background: var(--accent); }
.submit-btn:active { transform: scale(0.98); }
.submit-btn:disabled { opacity: 0.7; cursor: wait; }

.btn-spin {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-bar {
    max-width: 760px;
    margin: 14px auto 0;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--err-bg);
    border: 1px solid #fecaca;
    color: var(--err);
    font-size: 14px;
    text-align: left;
}

/* Result card */
.result-area {
    margin: 16px auto 36px;
}

.tweet-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.tweet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}

.author {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    background: #e2e8f0;
    flex-shrink: 0;
}

.author-meta { min-width: 0; }
.author-name {
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.author-handle {
    font-size: 13px;
    color: var(--muted);
}

.origin-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 9px;
    background: var(--accent-soft);
    white-space: nowrap;
    flex-shrink: 0;
}
.origin-link:hover { background: #bae6fd; }

.tweet-text {
    padding: 14px 22px 0;
    margin: 0;
    color: var(--ink-2);
    font-size: 14.5px;
    white-space: pre-wrap;
    word-break: break-word;
}

.media-list {
    padding: 20px 22px 22px;
    display: grid;
    gap: 22px;
}

.video-item {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
    padding: 16px;
    border-radius: 16px;
    background: var(--bg);
    border: 1px solid var(--line);
}

.player-box {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #020617;
    aspect-ratio: 16 / 9;
}

.player-box video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #020617;
}

.video-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--paper);
    border: 1px solid var(--line);
    color: var(--ink-2);
}

.badge-primary {
    background: var(--dark);
    border-color: var(--dark);
    color: #fff;
}

.variant-list {
    display: grid;
    gap: 10px;
}

.variant-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    background: var(--paper);
    border: 1px solid var(--line);
}

.variant-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.variant-label {
    font-weight: 650;
    font-size: 14px;
    color: var(--ink);
}

.variant-sub {
    font-size: 12px;
    color: var(--muted);
}

.variant-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.dl-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 9px;
    border: 0;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
    transition: background 150ms ease;
}
.dl-btn:hover { background: var(--accent-hover); }

.sub-btn {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}
.sub-btn:hover { background: #e2e8f0; color: var(--ink); }

/* Photos */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.photo-card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.photo-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    background: #e2e8f0;
}

.photo-foot {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.photo-foot span { font-size: 12px; color: var(--muted); }

/* History */
.history-area {
    margin: 12px 0 40px;
}

.section-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.section-bar h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--ink-2);
}

.text-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}
.text-btn:hover { color: var(--err); }

.history-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--paper);
    border: 1px solid var(--line);
    cursor: pointer;
    text-align: left;
    transition: border-color 150ms ease, transform 150ms ease;
}
.history-item:hover { border-color: var(--accent); transform: translateY(-1px); }

.history-thumb {
    width: 56px;
    height: 40px;
    border-radius: 7px;
    object-fit: cover;
    background: #0f172a;
    flex-shrink: 0;
}

.history-meta { min-width: 0; flex: 1; }
.history-title {
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-sub {
    font-size: 12px;
    color: var(--muted);
}

/* Features */
.features {
    padding: 16px 0 64px;
}

.feat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.feat-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}

.feat-num {
    display: inline-block;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 2px 9px;
    border-radius: 999px;
    margin-bottom: 12px;
}

.feat-card h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.feat-card p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.feat-card code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12.5px;
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 5px;
    color: var(--ink);
}

/* Footer */
.foot {
    border-top: 1px solid var(--line);
    background: var(--paper);
}

.foot-inner {
    min-height: 60px;
    padding: 14px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
    color: var(--muted);
}

/* Toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(16px);
    background: var(--dark);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease, transform 200ms ease;
    z-index: 50;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.25);
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 820px) {
    .video-item { grid-template-columns: 1fr; }
    .feat-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .hero { padding: 36px 0 24px; }
    .parse-box { flex-direction: column; padding: 10px; gap: 8px; }
    .input-wrap { padding-left: 4px; }
    .submit-btn { width: 100%; height: 44px; }
    .tweet-head { padding: 14px 16px; }
    .tweet-text { padding: 12px 16px 0; }
    .media-list { padding: 14px 16px 16px; }
    .video-item { padding: 12px; gap: 14px; }
    .variant-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .variant-actions { justify-content: flex-end; }
}
