:root {
    --bg-top: #f2f8ff;
    --bg-bottom: #f8efe4;
    --surface: rgba(255, 255, 255, 0.8);
    --surface-strong: #ffffff;
    --ink: #1e2430;
    --muted: #5c677b;
    --line: #d8dfec;
    --brand: #0d6f5d;
    --brand-soft: #dbf0ec;
    --danger: #b85050;
    --radius: 18px;
    --shadow: 0 20px 45px rgba(18, 27, 44, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Space Grotesk", sans-serif;
    color: var(--ink);
    background: radial-gradient(circle at 10% 15%, #e9f7ff 0%, transparent 38%),
                radial-gradient(circle at 95% 85%, #fce7d1 0%, transparent 34%),
                linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.page-shell {
    width: min(1200px, 94vw);
    margin: 2rem auto 3rem;
    display: grid;
    gap: 1.25rem;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.auth-card {
    width: min(460px, 94vw);
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    padding: 1.5rem 1.5rem 1.25rem;
}

.auth-form {
    margin-top: 1rem;
    display: grid;
    gap: 0.75rem;
}

.auth-logo {
    display: block;
    width: calc(100% + 3rem);
    height: clamp(120px, 30vw, 175px);
    margin: -1.5rem -1.5rem 0.9rem;
    object-fit: cover;
    border-radius: var(--radius) var(--radius) 14px 14px;
    border-bottom: 1px solid rgba(30, 36, 48, 0.1);
}

.header-card,
.composer-card,
.table-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.header-card {
    padding: 1.5rem 1.75rem;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.session-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.45rem;
}

.session-side {
    display: grid;
    gap: 0.55rem;
    justify-items: end;
}

.main-nav {
    display: inline-flex;
    gap: 0.45rem;
    background: rgba(13, 111, 93, 0.08);
    padding: 0.35rem;
    border-radius: 999px;
}

.nav-link {
    color: #26403e;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.75);
}

.nav-link.is-active {
    background: #ffffff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.session-user {
    font-size: 0.84rem;
    color: var(--muted);
    font-weight: 600;
}

.logout-btn {
    height: 34px;
    padding: 0 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    background: linear-gradient(135deg, #3e5167, #2f3d4d);
}

.eyebrow {
    margin: 0;
    color: var(--brand);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
}

h1 {
    margin: 0.25rem 0 0.35rem;
    font-size: clamp(1.5rem, 4.2vw, 2.4rem);
}

.subhead {
    margin: 0;
    color: var(--muted);
}

.composer-card {
    padding: 1.25rem 1.5rem 1.4rem;
}

.composer-card h2 {
    margin: 0 0 0.9rem;
    font-size: 1.1rem;
}

.presence-panel h2 {
    margin: 0 0 0.8rem;
    font-size: 1.05rem;
}

.presence-pills {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 0.45rem;
}

.presence-pill {
    border-radius: 999px;
    border: 1px solid #dbe4ef;
    padding: 0.36rem 0.56rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 34px;
}

.presence-pill strong {
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.presence-pill span {
    font-size: 0.72rem;
    color: #5b677d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.presence-pill::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    flex: 0 0 auto;
}

.presence-pill.is-online {
    background: #e4f7e9;
    border-color: #c6e7ce;
}

.presence-pill.is-online::before {
    background: #22a248;
}

.presence-pill.is-offline {
    background: #eef1f7;
}

.presence-pill.is-offline::before {
    background: #94a0b4;
}

#add-title-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
    gap: 0.75rem;
}

label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
}

input,
button {
    border-radius: 10px;
    border: 1px solid var(--line);
    font: inherit;
}

label input {
    height: 40px;
    padding: 0 0.65rem;
    background: var(--surface-strong);
}

label input:focus,
.rating-input:focus {
    outline: 2px solid #92d6c7;
    outline-offset: 1px;
}

button {
    align-self: end;
    height: 40px;
    padding: 0 1rem;
    border: none;
    color: white;
    background: linear-gradient(135deg, #0b7562, #095649);
    font-weight: 600;
    cursor: pointer;
}

button:hover {
    filter: brightness(1.06);
}

.feedback {
    min-height: 1.1rem;
    margin: 0.75rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.feedback.error {
    color: var(--danger);
}

.table-card {
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 0.75rem 0.25rem;
}

.table-toolbar input[type="search"] {
    width: min(320px, 100%);
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 0.65rem;
    background: #ffffff;
    margin-right: auto;
}

.secondary-btn {
    height: 34px;
    width: auto;
    padding: 0 0.8rem;
    border-radius: 8px;
    background: linear-gradient(135deg, #485d7a, #34465f);
    font-size: 0.84rem;
}

.stats-card {
    padding: 0.6rem 0.75rem 0.9rem;
}

.stats-card h2 {
    margin: 0.55rem 0.6rem 0.8rem;
    font-size: 1.06rem;
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.card-header-row h2 {
    margin-bottom: 0.4rem;
}

.small-btn {
    height: 30px;
    padding: 0 0.65rem;
    font-size: 0.8rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(190px, 1fr));
    gap: 0.85rem;
}

.summary-card {
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow);
    padding: 0.95rem 1rem;
}

.summary-card p {
    margin: 0;
    font-size: 0.83rem;
    color: var(--muted);
}

.summary-card h3 {
    margin: 0.35rem 0 0;
    font-size: clamp(1.2rem, 2.8vw, 1.8rem);
}

.activity-chart {
    width: 100%;
    min-height: 280px;
    margin-top: 0.8rem;
    border: 1px solid #dbe4ef;
    border-radius: 12px;
    background: #ffffff;
    padding: 0.65rem;
}

.activity-svg {
    width: 100%;
    height: 245px;
    display: block;
}

.activity-grid-line {
    stroke: #e8edf5;
    stroke-width: 1;
}

.activity-axis {
    stroke: #b8c4d8;
    stroke-width: 1.2;
}

.activity-line {
    transition: filter 140ms ease;
}

.activity-line:hover {
    filter: brightness(1.1);
}

.activity-point {
    transition: r 120ms ease;
}

.activity-point:hover {
    r: 3.2;
}

.activity-xlabels {
    margin-top: 0.2rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.76rem;
    color: #70819e;
}

.activity-legend {
    margin-top: 0.6rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.activity-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.activity-legend-item span {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
}

.recommendations-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 0.8rem;
    margin-top: 0.8rem;
}

.recommendation-card {
    border: 1px solid #dbe4ef;
    background: #ffffff;
    border-radius: 14px;
    padding: 0.75rem 0.85rem;
}

.recommendation-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.recommendation-list {
    margin: 0;
    padding-left: 1.15rem;
    display: grid;
    gap: 0.35rem;
}

.recommendation-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.7rem;
}

.breakdowns-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.8rem;
    margin-top: 0.8rem;
}

.breakdown-card {
    border: 1px solid #dbe4ef;
    background: #ffffff;
    border-radius: 14px;
    padding: 0.75rem 0.85rem;
    display: grid;
    gap: 0.75rem;
}

.breakdown-card h3 {
    margin: 0;
    font-size: 1rem;
}

.breakdowns-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 0.55rem;
}

.breakdowns-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #51617b;
}

.person-tabs {
    display: inline-flex;
    gap: 0.3rem;
    padding: 0.24rem;
    border: 1px solid #d7e1ee;
    border-radius: 999px;
    background: #eef3f9;
}

.person-tab {
    border: none;
    height: 30px;
    padding: 0 0.7rem;
    border-radius: 999px;
    background: transparent;
    color: #3b4a61;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.person-tab:hover {
    background: rgba(255, 255, 255, 0.7);
    filter: none;
}

.person-tab.is-active {
    background: #ffffff;
    color: #115d4f;
    box-shadow: 0 2px 8px rgba(30, 53, 78, 0.14);
}

.breakdown-section {
    display: grid;
    gap: 0.45rem;
}

.breakdown-section h4 {
    margin: 0;
    font-size: 0.93rem;
}

.breakdown-sides {
    display: grid;
    gap: 0.65rem;
}

.breakdown-side h5 {
    margin: 0;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #5b677d;
}

.mini-table-scroll {
    margin-top: 0.35rem;
    overflow-x: hidden;
}

.mini-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.mini-table th,
.mini-table td {
    font-size: 0.76rem;
    padding: 0.42rem 0.45rem;
    white-space: normal;
    overflow-wrap: anywhere;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

table.mini-table {
    min-width: 0;
}

thead th {
    text-align: left;
    background: rgba(13, 111, 93, 0.07);
    color: #173331;
    font-size: 0.83rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 0.85rem 0.75rem;
}

thead th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.25rem;
}

thead th.sortable::after {
    content: "⇅";
    position: absolute;
    right: 0.5rem;
    opacity: 0.35;
}

thead th.sortable.is-sorted-asc::after {
    content: "↑";
    opacity: 0.85;
}

thead th.sortable.is-sorted-desc::after {
    content: "↓";
    opacity: 0.85;
}

tbody td {
    padding: 0.7rem 0.75rem;
    border-top: 1px solid #e4e9f3;
    vertical-align: middle;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.58);
}

.poster {
    width: 56px;
    height: 84px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 7px 18px rgba(0, 0, 0, 0.22);
}

.title-name {
    font-weight: 600;
}

.title-toggle {
    all: unset;
    cursor: pointer;
    font-weight: 700;
    color: #1b2330;
    line-height: 1.25;
}

.title-toggle:hover {
    color: var(--brand);
    text-decoration: underline;
}

.is-expanded {
    background: rgba(13, 111, 93, 0.06);
}

.rating-input {
    width: 86px;
    height: 36px;
    border: 1px solid var(--line);
    padding: 0 0.45rem;
    text-align: center;
    background: var(--surface-strong);
}

.watchlist-input {
    width: 20px;
    height: 20px;
    accent-color: #0d6f5d;
    cursor: pointer;
}

.avg-pill {
    display: inline-block;
    min-width: 54px;
    text-align: center;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    background: #eceff5;
    color: #3b4557;
    font-weight: 700;
}

.avg-pill.avg-high {
    background: #dff6e8;
    color: #1b6b3a;
}

.avg-pill.avg-medium {
    background: #fff1c8;
    color: #8a6500;
}

.avg-pill.avg-low {
    background: #ffe0df;
    color: #972f2f;
}

.avg-pill.avg-none {
    background: #eceff5;
    color: #4c5566;
}

.is-hidden {
    display: none;
}

.details-row {
    display: none;
}

.details-row.is-open {
    display: table-row;
}

.details-row td {
    padding: 0.9rem 0.75rem 1.1rem;
    background: rgba(13, 111, 93, 0.04);
}

.details-card {
    display: grid;
    gap: 0.75rem;
    padding: 0.95rem;
    border-radius: 14px;
    border: 1px solid #d7e3ef;
    background: #fff;
}

.details-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
}

.imdb-link {
    color: #145fae;
    font-weight: 600;
    text-decoration: none;
}

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

.notes-input {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    resize: vertical;
    min-height: 96px;
}

.save-notes-btn {
    width: auto;
}

.danger-btn {
    width: auto;
    background: linear-gradient(135deg, #bf3d3d, #9f2323);
}

@media (max-width: 980px) {
    #add-title-form {
        grid-template-columns: 1fr;
    }

    button {
        width: 100%;
    }

    .details-actions {
        justify-content: flex-start;
    }

    .save-notes-btn,
    .danger-btn {
        width: auto;
    }

    .topbar {
        flex-direction: column;
    }

    .session-bar {
        align-items: flex-start;
    }

    .session-side {
        justify-items: start;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .recommendations-grid {
        grid-template-columns: 1fr;
    }

    .breakdowns-grid {
        grid-template-columns: 1fr;
    }

    .card-header-row .small-btn {
        width: auto;
    }

    .person-tab {
        width: auto;
    }

    .presence-pills {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }

    .stats-card .table-scroll {
        overflow-x: visible;
    }

    .stats-card table {
        min-width: 0;
        table-layout: fixed;
    }

    .stats-card thead {
        display: none;
    }

    .stats-card tbody,
    .stats-card tr,
    .stats-card td {
        display: block;
        width: 100%;
    }

    .stats-card tbody tr {
        border: 1px solid #dbe4ef;
        border-radius: 12px;
        background: #ffffff;
        margin-bottom: 0.65rem;
        overflow: hidden;
    }

    .stats-card tbody td {
        border-top: 1px solid #edf1f7;
        padding: 0.5rem 0.65rem;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .stats-card tbody td:first-child {
        border-top: none;
    }

    .stats-card tbody td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #6a7891;
        margin-bottom: 0.16rem;
    }
}
