* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #14161a;
    color: #eaeaea;
    display: flex;
    justify-content: center;
    padding: 32px 16px;
}

.wrap {
    width: 100%;
    max-width: 480px;
}

.wrap-wide {
    max-width: 760px;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.sub {
    color: #a3a3a3;
    font-size: 0.9rem;
    margin-bottom: 24px;
    line-height: 1.4;
}

#results-list {
    list-style: none;
    margin: 0 0 20px 0;
    padding: 0;
}

.section-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #a3a3a3;
    margin: 20px 0 8px;
}

.section-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 20px;
}

.section-label-row .section-label {
    margin: 0;
}

.clear-btn {
    background: none;
    border: 1px solid #3a2222;
    color: #f87171;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.78rem;
    cursor: pointer;
}

.clear-btn:hover {
    background: #2a1a1a;
}

.delete-vote-btn {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 10px;
    font-size: 0.85rem;
    text-align: center;
}

.copy-link-btn {
    width: 100%;
    padding: 12px;
    background: #1f2228;
    border: 1px solid #2c2f37;
    color: #8ab4ff;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 4px;
}

.copy-link-btn:hover {
    background: #232733;
}

.recap-box {
    margin-top: 14px;
    padding: 12px 14px;
    background: #1a2a1e;
    border: 1px solid #2c4a2c;
    border-radius: 10px;
}

.recap-box .section-label {
    color: #8fd6a3;
    margin: 0 0 6px;
}

.recap-list {
    margin: 0;
    padding-left: 20px;
    font-size: 0.88rem;
    color: #cdeed6;
}

.recap-list li {
    margin-bottom: 2px;
}

.search-input {
    width: 100%;
    padding: 12px 14px;
    background: #1f2228;
    border: 1px solid #2c2f37;
    border-radius: 10px;
    color: #eaeaea;
    font-size: 0.95rem;
    margin-top: 4px;
}

.search-input::placeholder {
    color: #6b6f78;
}

.ranked-list, .available-list {
    list-style: none;
    margin: 0 0 12px 0;
    padding: 0;
    max-height: 340px;
    overflow-y: auto;
}

.ranked-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #1f2228;
    border: 1px solid #2c2f37;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.rank-num {
    flex: 0 0 auto;
    min-width: 22px;
    text-align: center;
    font-weight: 700;
    color: #4f7cff;
    font-size: 0.9rem;
}

.ranked-item .rank-num {
    background: none;
    border: 1px dashed #384054;
    border-radius: 6px;
    padding: 5px 8px;
    font: inherit;
    font-weight: 700;
    color: #4f7cff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ranked-item .rank-num:hover,
.ranked-item .rank-num:focus-visible {
    background: #232a3a;
    border-color: #4f7cff;
}

.ranked-item .title {
    flex: 1;
    font-size: 0.95rem;
}

.ranked-controls {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
}

.ctrl-btn {
    background: #2c2f37;
    color: #eaeaea;
    border: 1px solid #3a3e47;
    border-radius: 6px;
    width: 30px;
    height: 30px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ctrl-btn:hover:not(:disabled) {
    background: #353942;
}

.ctrl-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.remove-btn:hover {
    background: #3a2222;
    border-color: #5a2c2c;
    color: #f87171;
}

.available-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #1f2228;
    border: 1px solid #2c2f37;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    user-select: none;
}

.available-item:hover {
    border-color: #4f7cff;
    background: #202436;
}

.available-item .title {
    font-size: 0.95rem;
}

.add-plus {
    flex: 0 0 auto;
    color: #4f7cff;
    font-size: 1.1rem;
    font-weight: 700;
}

.empty-hint {
    color: #6b6f78;
    font-size: 0.85rem;
    padding: 10px 2px;
    list-style: none;
}

#submit-btn {
    width: 100%;
    padding: 14px;
    background: #4f7cff;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

#submit-btn:hover {
    background: #3d67e6;
}

.status {
    text-align: center;
    min-height: 1.2em;
    margin-top: 12px;
    font-size: 0.9rem;
}

.status.ok { color: #4ade80; }
.status.err { color: #f87171; }

.sub.small {
    font-size: 0.8rem;
    margin-bottom: 10px;
}

.watched-list {
    list-style: none;
    margin: 0 0 12px 0;
    padding: 0;
    max-height: 240px;
    overflow-y: auto;
}

.watched-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #1a1c20;
    border: 1px solid #24272d;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 6px;
    color: #9a9a9a;
}

.watched-list-item .title {
    font-size: 0.9rem;
    text-decoration: line-through;
    text-decoration-color: #444;
}

.watched-list-item .meta {
    font-size: 0.8rem;
    color: #6b6f78;
    flex: 0 0 auto;
}

.plain-list {
    list-style: none;
    margin: 0 0 20px 0;
    padding: 0;
}

.plain-list-item {
    background: #1f2228;
    border: 1px solid #2c2f37;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #c7c7c7;
}

.no-counter {
    list-style: none;
    margin: 0 0 20px 0;
    padding: 0;
}

.suggest-box {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #2c2f37;
}

.suggest-label {
    display: block;
    font-size: 0.85rem;
    color: #a3a3a3;
    margin-bottom: 8px;
}

.suggest-row {
    display: flex;
    gap: 8px;
}

#suggest-input {
    flex: 1;
    padding: 10px 12px;
    background: #1f2228;
    border: 1px solid #2c2f37;
    border-radius: 8px;
    color: #eaeaea;
    font-size: 0.95rem;
}

#suggest-input::placeholder {
    color: #6b6f78;
}

#suggest-btn {
    padding: 10px 18px;
    background: #2c2f37;
    color: #eaeaea;
    border: 1px solid #3a3e47;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

#suggest-btn:hover {
    background: #353942;
}

.movie-item.flash, .ranked-item.flash, .available-item.flash {
    border-color: #f87171;
    background: #2a1f1f;
}

.admin-login {
    display: flex;
    gap: 8px;
}

.admin-login input {
    flex: 1;
    padding: 12px 14px;
    background: #1f2228;
    border: 1px solid #2c2f37;
    border-radius: 10px;
    color: #eaeaea;
    font-size: 0.95rem;
}

.admin-login button {
    padding: 12px 18px;
    background: #4f7cff;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

.logout-link {
    color: #8ab4ff;
    text-decoration: none;
    margin-left: 6px;
}

.admin-list {
    list-style: none;
    margin: 16px 0;
    padding: 0;
}

.admin-table-head {
    display: none;
}

.admin-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #1f2228;
    border: 1px solid #2c2f37;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
}

.admin-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
}

.admin-item-title-text {
    word-break: break-word;
}

.row-checkbox {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    accent-color: #4f7cff;
    cursor: pointer;
}

.admin-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.bulk-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin: 10px 0;
    padding: 10px 14px;
    background: #1a1c20;
    border: 1px solid #2c2f37;
    border-radius: 10px;
    font-size: 0.85rem;
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #c7c7c7;
}

.select-all-label input {
    width: 20px;
    height: 20px;
    accent-color: #4f7cff;
    cursor: pointer;
}

.bulk-count {
    color: #a3a3a3;
    margin-right: auto;
}

.bulk-btn {
    font-size: 0.85rem;
}

.bulk-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.bulk-form {
    margin: 0;
}

.admin-item-row-end {
    justify-content: flex-end;
}

.admin-item-actions {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.admin-item .meta {
    color: #a3a3a3;
    font-size: 0.8rem;
    flex: 0 0 auto;
}

@media (min-width: 640px) {
    .admin-table {
        border: 1px solid #2c2f37;
        border-radius: 10px;
        overflow: hidden;
        background: #1f2228;
    }

    .admin-table-head {
        display: grid;
        grid-template-columns: 1fr 90px auto;
        gap: 12px;
        padding: 10px 16px;
        color: #a3a3a3;
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        border-bottom: 1px solid #2c2f37;
    }

    .admin-table-no-votes .admin-table-head {
        grid-template-columns: 1fr auto;
    }

    .head-actions {
        justify-self: end;
    }

    .admin-list {
        max-height: none;
        overflow: visible;
    }

    .admin-item {
        display: grid;
        grid-template-columns: 1fr 90px auto;
        align-items: center;
        gap: 12px;
        background: transparent;
        border: none;
        border-radius: 0;
        border-bottom: 1px solid #2c2f37;
        padding: 8px 16px;
        margin-bottom: 0;
    }

    .admin-table-no-votes .admin-item {
        grid-template-columns: 1fr auto;
    }

    .admin-list li.admin-item:last-child {
        border-bottom: none;
    }

    .admin-item-title {
        grid-column: 1;
    }

    .admin-item-row {
        display: contents;
    }

    .admin-item .meta {
        grid-column: 2;
    }

    .admin-item-actions {
        grid-column: 3;
        justify-self: end;
    }

    .admin-table-no-votes .admin-item-actions {
        grid-column: 2;
    }
}

.admin-add-watched {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 0.85rem;
    color: #a3a3a3;
}

.watch-btn {
    background: #1e2a1e;
    color: #4ade80;
    border: 1px solid #2c4a2c;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
}

.watch-btn:hover {
    background: #263626;
}

.delete-btn {
    background: #3a2222;
    color: #f87171;
    border: 1px solid #5a2c2c;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
}

.delete-btn:hover {
    background: #4a2828;
}

.footer-links {
    text-align: center;
    margin-top: 24px;
}

.footer-links a {
    color: #8ab4ff;
    text-decoration: none;
    font-size: 0.9rem;
}

.result-item {
    display: flex;
    align-items: stretch;
    background: #1f2228;
    border: 1px solid #2c2f37;
    border-radius: 10px;
    margin-bottom: 8px;
    overflow: hidden;
}

.result-item .rank-num {
    flex: 0 0 auto;
    align-self: center;
    min-width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #262a33;
    border-radius: 7px;
    font-size: 0.85rem;
    margin: 0 0 0 14px;
}

.result-item-no-rank .result-title {
    padding-left: 14px;
}

.result-title {
    flex: 1 1 auto;
    min-width: 0;
    align-self: center;
    font-weight: 600;
    font-size: 0.98rem;
    line-height: 1.3;
    word-break: break-word;
    text-align: left;
    padding: 12px 14px;
}

.result-votes {
    flex: 0 0 auto;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    padding: 8px 14px;
    border-left: 1px solid #2c2f37;
    background: #181a1f;
    font-size: 1.05rem;
    font-weight: 700;
    color: #eaeaea;
}

.result-votes-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #7a7f89;
    margin-top: 1px;
}

.watched-badge {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #4ade80;
    border: 1px solid #2c4a2c;
    background: #1e2a1e;
    border-radius: 5px;
    padding: 1px 6px;
    vertical-align: middle;
}

/* -----------------------------------------------------------------
   Print / "Save as PDF" — the dark card styling above relies on
   background colors that most browsers strip out when printing
   unless "print backgrounds" is explicitly enabled, which turns the
   page into unstyled, unindented plain text. This gives print output
   its own clean, readable look: light background, visible borders
   (borders print reliably, unlike background colors), and hides
   controls that don't make sense on paper (search box, vote/rank
   buttons, forms, nav links).
   ----------------------------------------------------------------- */
@media print {
    * {
        box-shadow: none !important;
    }

    body {
        background: #fff;
        color: #111;
        padding: 0;
        display: block;
    }

    .wrap, .wrap-wide {
        max-width: 100%;
    }

    h1, h2 {
        color: #111;
    }

    .sub, .section-label {
        color: #444;
    }

    /* Controls that only make sense on a live page. */
    .search-input,
    .suggest-box,
    #submit-btn,
    #status,
    .ranked-controls,
    .add-plus,
    .footer-links,
    .admin-login,
    .admin-item-actions,
    .logout-link,
    .copy-link-btn,
    #copy-status,
    .clear-btn,
    .bulk-toolbar,
    .row-checkbox,
    .admin-add-box {
        display: none !important;
    }

    /* Card-style items: swap dark theme for a bordered, light look. */
    .result-item,
    .plain-list-item,
    .watched-list-item,
    .available-item,
    .ranked-item,
    .admin-item {
        background: #fff;
        border: 1px solid #999;
        color: #111;
        break-inside: avoid;
    }

    .result-title, .admin-item-title, .ranked-item .title, .plain-list-item {
        color: #111;
    }

    .result-votes {
        background: #f2f2f2;
        border-left: 1px solid #999;
        color: #111;
    }

    .result-votes-label {
        color: #666;
    }

    .meta, .watched-list-item .meta {
        color: #555;
    }

    .rank-num, .result-item .rank-num {
        background: #eee;
        border: 1px solid #999;
        color: #111;
    }

    .watched-badge {
        background: #eee;
        border: 1px solid #999;
        color: #111;
    }

    .watched-list-item .title {
        text-decoration-color: #999;
    }

    a {
        color: #111;
        text-decoration: underline;
    }
}
