:root {
    --bg: #101114;
    --bg-2: #181a1f;
    --card: #1f2229;
    --line: rgba(255, 255, 255, 0.08);
    --text: #f4f1ea;
    --muted: #9aa3ad;
    --green: #2ba471;
    --green-2: #3dcf8e;
    --gold: #e2b340;
    --danger: #e85d4c;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
[hidden] { display: none !important; }
body {
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(43, 164, 113, 0.18), transparent 50%),
        radial-gradient(900px 420px at 100% 0%, rgba(226, 179, 64, 0.08), transparent 45%),
        var(--bg);
    color: var(--text);
}

.app {
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 20px 80px;
}

.top {
    margin-bottom: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.top-links { display: flex; gap: 8px; }
.brand {
    display: flex;
    gap: 14px;
    align-items: center;
    text-decoration: none;
    color: inherit;
}
.logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    object-fit: cover;
    background: #111;
    box-shadow: 0 10px 24px rgba(43, 164, 113, 0.35);
}
.mark {
    width: 42px; height: 42px; border-radius: 12px;
    background: linear-gradient(160deg, var(--green-2), var(--green));
    box-shadow: 0 10px 24px rgba(43, 164, 113, 0.35);
    position: relative;
}
.mark::after {
    content: "";
    position: absolute;
    inset: 11px 10px 11px 16px;
    border: 2px solid #fff;
    border-left: 0;
    border-radius: 2px;
}
.brand strong { display: block; font-size: 20px; letter-spacing: 0.04em; }
.brand span { color: var(--muted); font-size: 13px; }

.hero h1 { margin: 0 0 8px; font-size: 32px; letter-spacing: 0.02em; }
.hero-desc { color: var(--muted); margin: 0 0 18px; }
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

.search-box {
    display: flex;
    gap: 10px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 8px;
    box-shadow: var(--shadow);
}
.search-box input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    padding: 12px 14px;
}
.format-switch {
    display: flex;
    background: #15171c;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}
.fmt-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
}
.fmt-btn.on {
    background: #2a2e36;
    color: var(--green-2);
    font-weight: 600;
}
.tips { color: var(--muted); font-size: 13px; margin: 12px 4px 0; }

.btn {
    border: 1px solid var(--line);
    background: #2a2e36;
    color: var(--text);
    border-radius: 12px;
    padding: 10px 16px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.btn.primary {
    background: linear-gradient(180deg, var(--green-2), var(--green));
    border-color: transparent;
    color: #072616;
    font-weight: 700;
    min-width: 92px;
}
.btn.ghost { background: transparent; }
.btn:hover { filter: brightness(1.08); }

.status {
    margin: 18px 0 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: #2a2e36;
    color: var(--muted);
}
.status.err { background: rgba(232, 93, 76, 0.12); color: #ffb4ab; }
.status.ok { background: rgba(43, 164, 113, 0.12); color: #b6f0d1; }

.candidates, .history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 20px;
}
.pick, .hist {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    text-align: left;
    color: inherit;
    padding: 0;
    box-shadow: var(--shadow);
}
.pick img, .hist img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    background: #111;
    display: block;
}
.pick div, .hist div { padding: 12px 14px 14px; }
.pick b, .hist b { display: block; font-size: 15px; }
.pick small, .hist small { color: var(--muted); }

.result {
    margin-top: 28px;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
}
.poster-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.poster-card img {
    width: 100%;
    display: block;
    min-height: 360px;
    object-fit: cover;
    background: #111;
}
.meta { padding: 16px; }
.meta h2 { margin: 0 0 6px; font-size: 20px; }
.meta p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
#movie-score { color: var(--gold); font-weight: 700; }
.poster-path {
    font-size: 12px;
    word-break: break-all;
    color: var(--green-2) !important;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.text-wrap {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
    box-shadow: var(--shadow);
    min-height: 520px;
    display: flex;
    flex-direction: column;
}
.text-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 13px;
}
.output-tabs {
    display: flex;
    gap: 4px;
    background: #15171c;
    border-radius: 8px;
    padding: 2px;
}
.out-tab {
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}
.out-tab.on {
    background: var(--green);
    color: #0b120d;
    font-weight: 700;
}
.md-preview {
    flex: 1;
    min-height: 460px;
    overflow: auto;
    border-radius: 12px;
    background: #15171c;
    padding: 20px;
}
.md-preview[hidden] { display: none !important; }
textarea.output-hidden { display: none; }

.md-card {
    max-width: 640px;
    margin: 0 auto;
    background: linear-gradient(180deg, #1c1f26 0%, #12141a 100%);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.md-card-head {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--line);
}
.md-card-head h2 {
    margin: 0 0 8px;
    font-size: 22px;
    color: #f2ead8;
}
.md-card-sub {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}
.md-card-sub em { color: #c9b8a0; font-style: normal; }
.md-card-poster {
    display: block;
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    background: #0a0a0a;
}
.md-card-body { padding: 16px 20px 20px; }
.md-card-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-bottom: 16px;
}
.md-card-table th,
.md-card-table td {
    border: 1px solid var(--line);
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
}
.md-card-table th {
    width: 88px;
    color: var(--green-2);
    background: rgba(122, 184, 122, 0.08);
    font-weight: 600;
}
.md-card-table td { color: #ddd6c8; }
.md-card-intro h3 {
    margin: 0 0 10px;
    font-size: 15px;
    color: var(--green-2);
}
.md-card-quote {
    margin: 0;
    padding: 12px 14px;
    border-left: 3px solid var(--gold);
    background: rgba(212, 175, 55, 0.06);
    color: #ccc4b5;
    font-size: 14px;
    line-height: 1.75;
    border-radius: 0 8px 8px 0;
}
.md-card-quote p { margin: 0 0 8px; }
.md-card-quote p:last-child { margin-bottom: 0; }
.md-card-foot {
    padding: 12px 20px 16px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
}
.md-card-foot a {
    color: var(--green-2);
    text-decoration: none;
}
.md-card-foot a:hover { text-decoration: underline; }
.md-card-rating { color: var(--gold); font-weight: 700; }
.md-card-empty { color: var(--muted); text-align: center; padding: 40px 0; }

textarea {
    flex: 1;
    width: 100%;
    min-height: 460px;
    resize: vertical;
    border: 0;
    outline: 0;
    background: #15171c;
    color: #efe7d6;
    border-radius: 12px;
    padding: 16px;
    font-family: "Cascadia Mono", "Sarasa Gothic SC", "Microsoft YaHei", monospace;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre;
}

.guide {
    margin-top: 40px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 24px 26px;
    line-height: 1.8;
    box-shadow: var(--shadow);
}
.guide h2, .guide h3 { color: var(--green-2); margin-top: 0; }
.guide h3 { margin-top: 20px; }
.guide a { color: var(--gold); }
.guide ol, .guide ul { padding-left: 1.2em; }
.guide p { color: #ddd6c8; }
.foot {
    margin-top: 36px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}
.foot a {
    color: var(--green-2);
    text-decoration: none;
}
.foot a:hover { text-decoration: underline; }
.foot-legal { margin-top: 8px; font-size: 12px; }
.legal-page { margin-top: 8px; }
.legal-nav { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; }
.legal-nav a { color: var(--green-2); }

.install-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.install-card {
    width: min(560px, 100%);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 28px;
    box-shadow: var(--shadow);
}
.eyebrow { color: var(--green-2); letter-spacing: 0.12em; text-transform: uppercase; font-size: 12px; margin: 0 0 8px; }
.lead, .hint { color: var(--muted); }
.install-form { display: grid; gap: 12px; margin-top: 18px; }
.install-form label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.install-form input, .install-form button {
    font: inherit;
}
.install-form input {
    background: #15171c;
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
}
.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin: 16px 0;
}
.alert.ok { background: rgba(43, 164, 113, 0.14); }
.alert.err { background: rgba(232, 93, 76, 0.14); color: #ffb4ab; }
code { color: var(--gold); }

@media (max-width: 860px) {
    .result { grid-template-columns: 1fr; }
    .search-box { flex-direction: column; }
    .btn.primary { width: 100%; }
    .top { flex-direction: column; align-items: flex-start; }
    .format-switch { width: 100%; justify-content: center; }
}
