:root {
    --bg: #080b0f;
    --surface: #111820;
    --surface-2: #151d27;
    --surface-3: #0d131a;
    --border: #27313e;
    --border-strong: #354252;
    --text: #edf2f7;
    --muted: #8c98a8;
    --subtle: #657181;
    --green: #30d979;
    --green-strong: #22c965;
    --green-ink: #04120a;
    --blue: #5ca8ff;
    --amber: #f5bd4f;
    --red: #ff6b61;
    --radius: 8px;
}

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

html {
    background: var(--bg);
    scroll-behavior: smooth;
    scroll-padding-bottom: 7.5rem;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    line-height: 1.5;
    padding-bottom: calc(6.8rem + env(safe-area-inset-bottom));
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
}

.container {
    width: min(100%, 1200px);
    margin: 0 auto;
    padding: 1.5rem 1rem 2.5rem;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.brand-lockup,
.login-brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.brand-mark,
.login-mark {
    width: 3rem;
    height: 3rem;
    display: block;
    flex: 0 0 auto;
    object-fit: contain;
}

.app-kicker,
.login-kicker {
    color: var(--green);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1.2;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
}

.app-header h1,
.login-brand h1 {
    color: var(--text);
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.18;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.form-container,
.download-card,
.admin-panel,
.login-panel,
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.22);
}

.form-container {
    padding: 1rem;
    margin-bottom: 2rem;
}

.home-dashboard {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
}

.home-spotlight,
.home-panel,
.account-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.22);
}

.home-spotlight {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
    gap: 1rem;
    padding: 1rem;
    align-items: stretch;
}

.spotlight-art {
    min-height: 190px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--surface-3);
    background-position: center;
    background-size: cover;
}

.fallback-art,
.placeholder-art {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0b1016;
    color: var(--green);
}

.fallback-art span,
.placeholder-art span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    color: var(--text);
    font-weight: 900;
    letter-spacing: 0.04em;
}

.spotlight-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding: 0.25rem;
}

.section-kicker {
    color: var(--green);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
}

.spotlight-copy h2,
.panel-heading h2 {
    color: var(--text);
    font-size: 1.35rem;
    font-weight: 850;
    line-height: 1.2;
}

.spotlight-copy p:not(.section-kicker) {
    color: var(--muted);
    margin-top: 0.45rem;
}

.home-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.home-stats div {
    padding: 0.75rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.home-stats strong {
    display: block;
    color: var(--text);
    font-size: 1.25rem;
    line-height: 1;
}

.home-stats span {
    display: block;
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 750;
    text-transform: uppercase;
}

.home-panel {
    padding: 1rem;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.artwork-wall {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-rows: minmax(92px, 1fr);
    gap: 0.65rem;
}

.artwork-tile {
    min-height: 92px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--surface-3);
    background-position: center;
    background-size: cover;
    color: var(--text);
    cursor: pointer;
}

.artwork-tile:nth-child(1),
.artwork-tile:nth-child(7) {
    grid-column: span 2;
    grid-row: span 2;
}

.artwork-tile:nth-child(4),
.artwork-tile:nth-child(10) {
    grid-column: span 2;
}

.artwork-tile::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.18);
    transition: background-color 0.2s ease;
}

.artwork-tile:hover::after {
    background: rgba(0, 0, 0, 0.02);
}

.artwork-tile-meta {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    display: grid;
    gap: 0.1rem;
    padding: 0.55rem;
    background: rgba(8, 11, 15, 0.82);
    text-align: left;
}

.artwork-tile-meta strong,
.artwork-tile-meta small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.artwork-tile-meta strong {
    color: var(--text);
    font-size: 0.78rem;
}

.artwork-tile-meta small {
    color: var(--muted);
    font-size: 0.7rem;
}

.community-list {
    display: grid;
    gap: 0.75rem;
}

.community-item {
    display: grid;
    grid-template-columns: 4.6rem minmax(0, 1fr);
    gap: 0.85rem;
    align-items: center;
    padding: 0.75rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.community-art {
    width: 4.6rem;
    height: 4.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--surface-2);
    background-position: center;
    background-size: cover;
}

.community-art span {
    width: 2.4rem;
    height: 2.4rem;
    font-size: 0.82rem;
}

.community-copy {
    min-width: 0;
}

.community-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
}

.community-heading h3 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-size: 0.98rem;
    font-weight: 850;
}

.community-heading span,
.community-copy p,
.community-preview span {
    color: var(--muted);
    font-size: 0.82rem;
}

.community-heading span {
    flex: 0 0 auto;
}

.owner-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.owner-avatar,
.account-avatar {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 900;
    object-fit: cover;
}

.account-identity {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.account-avatar {
    width: 3.25rem;
    height: 3.25rem;
    font-size: 0.9rem;
}

.community-preview {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.community-preview span {
    max-width: 100%;
    padding: 0.25rem 0.45rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.social-post-form {
    display: grid;
    gap: 0.75rem;
}

.social-post-form label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    color: #d7dde5;
    font-size: 0.88rem;
    font-weight: 800;
}

.social-post-form label span {
    color: var(--subtle);
    font-size: 0.78rem;
    font-weight: 700;
}

.social-post-form select,
.social-post-form textarea,
.social-post-form input[type="file"] {
    width: 100%;
    min-height: 3rem;
    padding: 0.85rem 1rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
}

.social-post-form textarea {
    resize: vertical;
    min-height: 6rem;
}

.social-post-form select:focus,
.social-post-form textarea:focus,
.social-post-form input[type="file"]:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(48, 217, 121, 0.13);
}

.post-form-meta {
    display: flex;
    justify-content: flex-end;
    margin-top: -0.35rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 750;
}

.post-form-meta .is-over {
    color: var(--red);
}

.social-feed {
    display: grid;
    gap: 0.85rem;
}

.social-post {
    display: grid;
    gap: 0.8rem;
    padding: 0.9rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.social-post-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.social-post-header time {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
}

.social-post-quote {
    color: var(--text);
    font-size: 1rem;
    font-weight: 750;
    line-height: 1.45;
}

.post-photo {
    min-height: 180px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--surface-2);
    background-position: center;
    background-size: cover;
}

.post-download-link {
    display: grid;
    grid-template-columns: 3.4rem minmax(0, 1fr);
    gap: 0.7rem;
    align-items: center;
    padding: 0.65rem;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.055);
    border-radius: 8px;
}

.post-download-art {
    width: 3.4rem;
    height: 3.4rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--surface-2);
    background-position: center;
    background-size: cover;
}

.post-download-art span {
    width: 2rem;
    height: 2rem;
    font-size: 0.72rem;
}

.post-download-link strong,
.post-download-link span {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.post-download-link strong {
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 850;
}

.post-download-link span {
    color: var(--muted);
    font-size: 0.8rem;
}

.account-panel {
    margin-top: 2rem;
    padding: 1rem;
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.account-stat {
    min-width: 0;
    padding: 0.85rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.account-stat span {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--subtle);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.account-stat strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.liquid-tabbar {
    position: fixed;
    left: 50%;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    z-index: 1500;
    width: min(calc(100vw - 1.5rem), 430px);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0.42rem;
    background: rgba(17, 24, 32, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 22px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transform: translateX(-50%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    backdrop-filter: blur(24px) saturate(160%);
}

.tabbar-item {
    min-height: 3.15rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.16rem;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 18px;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.tabbar-item svg {
    width: 1.2rem;
    height: 1.2rem;
    fill: currentColor;
}

.tabbar-item span {
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.01em;
    line-height: 1;
    white-space: nowrap;
}

.tabbar-item.is-active,
.tabbar-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.tabbar-item.is-active {
    box-shadow: inset 0 0 0 1px rgba(48, 217, 121, 0.18);
    color: #d8ffe5;
}

.liquid-tabbar .tabbar-item {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Tab views */
.tab-view {
    display: none;
}

.tab-view:not([hidden]) {
    display: grid;
    gap: 0.85rem;
}

/* Compact stat strip */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.stat-strip > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.6rem 0.4rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.stat-strip strong {
    font-size: 1.15rem;
    font-weight: 850;
    color: var(--text);
    line-height: 1;
}

.stat-strip span {
    font-size: 0.66rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Composer */
.composer {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 0.85rem;
}

.composer-form {
    display: grid;
    gap: 0.65rem;
}

.composer-row {
    display: grid;
    grid-template-columns: 2.4rem 1fr;
    gap: 0.6rem;
    align-items: start;
}

.composer-avatar {
    width: 2.4rem;
    height: 2.4rem;
    font-size: 0.8rem;
}

.composer-form textarea {
    width: 100%;
    resize: none;
    border: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    line-height: 1.35;
    padding: 0.3rem 0;
}

.composer-form textarea:focus {
    outline: none;
}

.composer-form select {
    width: 100%;
    padding: 0.5rem 0.65rem;
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    font: inherit;
    font-size: 0.85rem;
}

.composer-footer {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.composer-photo {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.composer-photo:hover {
    color: var(--text);
}

.composer-photo.has-photo {
    color: var(--green);
    border-color: rgba(48, 217, 121, 0.4);
}

#quote-word-count {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.composer-footer .btn {
    padding: 0.45rem 0.9rem;
    font-size: 0.82rem;
}

/* Timeline */
.timeline {
    display: grid;
    gap: 0.6rem;
}

.tl-item {
    display: grid;
    grid-template-columns: 2.4rem 1fr;
    gap: 0.6rem;
    padding: 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.tl-avatar .owner-avatar {
    width: 2.4rem;
    height: 2.4rem;
    font-size: 0.78rem;
}

.tl-body {
    display: grid;
    gap: 0.4rem;
    min-width: 0;
}

.tl-meta {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.tl-meta strong {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text);
}

.tl-meta time {
    font-size: 0.72rem;
    color: var(--muted);
}

.tl-quote {
    font-size: 0.92rem;
    line-height: 1.4;
    color: var(--text);
}

.tl-sub {
    font-size: 0.78rem;
    color: var(--muted);
}

.tl-photo {
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    background-color: var(--surface-3);
}

.tl-ref {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.78rem;
    color: var(--muted);
    min-width: 0;
}

.tl-ref-title {
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tl-art {
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border-radius: 7px;
    background-size: cover;
    background-position: center;
    background-color: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 800;
    color: var(--muted);
}

.input-group {
    display: flex;
    gap: 0.875rem;
    align-items: center;
}

.input-group input[type="text"],
.login-form input,
.admin-form input,
.admin-form select {
    width: 100%;
    min-height: 3rem;
    padding: 0.85rem 1rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-group input[type="text"]:focus,
.login-form input:focus,
.admin-form input:focus,
.admin-form select:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(48, 217, 121, 0.13);
}

.input-group button,
.login-submit,
.btn-primary {
    background: rgba(48, 217, 121, 0.1);
    color: #c7f9d8;
    border: 1px solid rgba(48, 217, 121, 0.62);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 800;
    transition: background-color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.input-group button {
    min-height: 3rem;
    padding: 0.85rem 1.35rem;
    white-space: nowrap;
}

.input-group button:hover,
.login-submit:hover,
.btn-primary:hover {
    background: rgba(48, 217, 121, 0.18);
    border-color: var(--green);
}

.input-group button:disabled,
.btn-disabled {
    background: var(--surface-2);
    color: var(--subtle);
    cursor: not-allowed;
}

.downloads-section {
    display: grid;
    gap: 2rem;
}

.downloads-section h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.downloads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 1rem;
}

.download-card {
    overflow: hidden;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.download-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.card-album-art {
    height: 118px;
    background-color: var(--surface-2);
    background-position: center;
    background-size: cover;
    position: relative;
}

.card-album-art::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 44px;
    background: linear-gradient(transparent, rgba(17, 24, 32, 0.95));
}

.card-content {
    padding: 1.2rem;
}

.card-header,
.admin-panel-header,
.admin-user-heading,
.invite-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.card-header {
    margin-bottom: 1rem;
}

.card-title {
    flex: 1;
    margin-right: 0.75rem;
    color: var(--text);
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.3;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.status-badge,
.mail-status,
.role-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.32rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-processing {
    background: rgba(245, 189, 79, 0.14);
    border: 1px solid rgba(245, 189, 79, 0.34);
    color: var(--amber);
}

.status-zipping {
    background: rgba(92, 168, 255, 0.14);
    border: 1px solid rgba(92, 168, 255, 0.34);
    color: var(--blue);
}

.status-ready,
.mail-ready,
.role-admin {
    background: rgba(48, 217, 121, 0.14);
    border: 1px solid rgba(48, 217, 121, 0.34);
    color: var(--green);
}

.status-expired,
.status-failed,
.status-cancelled {
    background: rgba(255, 107, 97, 0.12);
    border: 1px solid rgba(255, 107, 97, 0.34);
    color: var(--red);
}

.mail-missing,
.role-user {
    background: rgba(140, 152, 168, 0.14);
    border: 1px solid rgba(140, 152, 168, 0.28);
    color: #cbd5e1;
}

.card-info,
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.card-info {
    margin-bottom: 1.25rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    color: var(--subtle);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.info-value {
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 650;
}

.playlist-icon-btn,
.btn-icon,
.btn-secondary {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.playlist-icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.55rem;
    font-size: 0.8rem;
}

.playlist-icon-btn:hover,
.btn-icon:hover,
.btn-secondary:hover {
    background: #1a2430;
    border-color: var(--border-strong);
}

.track-count {
    background: var(--surface-3);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.2rem 0.45rem;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.btn {
    min-height: 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 0.9rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 750;
    text-decoration: none;
}

.btn-danger,
.btn-danger-outline {
    border: 1px solid rgba(255, 107, 97, 0.55);
    color: #ffaea7;
}

.btn-danger {
    background: rgba(255, 107, 97, 0.18);
}

.btn-danger-outline {
    background: transparent;
}

.btn-danger:hover,
.btn-danger-outline:hover {
    background: rgba(255, 107, 97, 0.12);
}

.btn-icon {
    min-width: 2.35rem;
    min-height: 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: var(--muted);
}

.status-cancellable {
    cursor: pointer;
}

.status-cancellable:hover {
    background: rgba(255, 107, 97, 0.14) !important;
    border-color: rgba(255, 107, 97, 0.5) !important;
    color: var(--red) !important;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    padding: 0.7rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 6px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--green);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    min-width: 3rem;
    color: var(--green);
    font-size: 0.86rem;
    font-weight: 800;
    text-align: right;
}

.status-info {
    margin: 0.75rem 0;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid var(--green);
    border-radius: 6px;
}

.track-progress {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 800;
}

.current-action,
.current-track,
.track-failed {
    margin-top: 0.25rem;
    font-size: 0.82rem;
}

.current-action {
    color: #cbd5e1;
    font-weight: 650;
}

.current-track {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-failed {
    color: #ffaea7;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 2.5rem 1rem;
    color: var(--subtle);
    text-align: center;
}

.notification {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1200;
    max-width: min(420px, calc(100vw - 2rem));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.35);
}

.notification.success {
    border-color: rgba(48, 217, 121, 0.36);
}

.notification.error {
    border-color: rgba(255, 107, 97, 0.44);
}

/* Global activity popups (new posts / downloads) */
#activity-stack {
    position: fixed;
    top: max(0.85rem, env(safe-area-inset-top));
    right: 0.85rem;
    z-index: 1300;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: min(360px, calc(100vw - 1.7rem));
    pointer-events: none;
}

.activity-popup {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.activity-popup.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.activity-avatar {
    flex: 0 0 auto;
}

.activity-avatar .owner-avatar {
    width: 2.2rem;
    height: 2.2rem;
    font-size: 0.74rem;
}

.activity-text {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.activity-line {
    font-size: 0.82rem;
    color: var(--muted);
}

.activity-line strong {
    color: var(--text);
    font-weight: 800;
}

.activity-title {
    font-size: 0.8rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-media {
    flex: 0 0 auto;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 9px;
    background-size: cover;
    background-position: center;
    background-color: var(--surface-3);
    border: 1px solid var(--border);
}

.activity-close {
    flex: 0 0 auto;
    align-self: flex-start;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.activity-close:hover {
    color: var(--text);
}

/* Owner chip on active download cards */
.download-owner {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
    padding: 0.3rem 0.55rem 0.3rem 0.35rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 999px;
    width: fit-content;
}

.download-owner .owner-avatar {
    width: 1.7rem;
    height: 1.7rem;
    font-size: 0.64rem;
}

.download-owner-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
}

/* Persistent mini audio player (sits above the bottom tab bar) */
#mini-player {
    position: fixed;
    left: 50%;
    bottom: calc(max(0.75rem, env(safe-area-inset-bottom)) + 4.4rem);
    transform: translateX(-50%);
    z-index: 1400;
    width: min(calc(100vw - 1.5rem), 430px);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    background: rgba(17, 24, 32, 0.92);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
}

#mini-player[hidden] {
    display: none;
}

.mp-toggle {
    flex: 0 0 auto;
    width: 2.6rem;
    height: 2.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--green);
    color: #04140a;
    cursor: pointer;
}

.mp-toggle .icon-pause {
    display: none;
}

#mini-player.is-playing .mp-toggle .icon-play {
    display: none;
}

#mini-player.is-playing .mp-toggle .icon-pause {
    display: block;
}

.mp-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.mp-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mp-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mp-artist {
    font-size: 0.74rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mp-progress {
    height: 5px;
    border-radius: 999px;
    background: var(--surface-3);
    cursor: pointer;
    overflow: hidden;
}

.mp-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--green);
    border-radius: 999px;
    transition: width 0.15s linear;
}

.mp-close {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}

.mp-close:hover {
    color: var(--text);
}

/* Currently-loaded (but paused) popup track */
.popup-track-play.is-current {
    border-color: rgba(48, 217, 121, 0.5);
    color: var(--green);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(4px);
}

.modal-content {
    width: min(100%, 640px);
    max-height: 84vh;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    color: var(--text);
    font-size: 1rem;
}

.modal-close {
    width: 2rem;
    height: 2rem;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.4rem;
}

.modal-close:hover {
    background: var(--surface-2);
    color: var(--text);
}

.modal-body {
    max-height: calc(84vh - 66px);
    overflow-y: auto;
    padding: 1.2rem;
}

.playlist-info {
    margin-bottom: 1.5rem;
}

.tracklist-section h4 {
    margin-bottom: 0.75rem;
    color: var(--text);
    font-size: 0.95rem;
}

.popup-track-list {
    max-height: 320px;
    overflow-y: auto;
}

.popup-track-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.popup-track-item:hover {
    background: rgba(255, 255, 255, 0.035);
}

.popup-track-play {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-3);
    color: var(--green);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.popup-track-play:hover {
    background: rgba(48, 217, 121, 0.12);
    border-color: rgba(48, 217, 121, 0.4);
}

.popup-track-play.is-disabled {
    border: none;
    background: transparent;
    cursor: default;
}

.popup-track-play .icon-pause {
    display: none;
}

.popup-track-play.is-playing {
    background: var(--green);
    border-color: var(--green);
    color: #04140a;
}

.popup-track-play.is-playing .icon-play {
    display: none;
}

.popup-track-play.is-playing .icon-pause {
    display: block;
}

.popup-track-info {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.popup-track-title {
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.popup-track-artist,
.popup-track-duration,
.no-tracks {
    color: var(--muted);
    font-size: 0.82rem;
}

.popup-track-duration {
    min-width: 3rem;
    text-align: right;
}

.no-tracks {
    padding: 2rem;
    text-align: center;
}

.login-page {
    background: var(--bg);
}

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

.login-panel {
    width: min(100%, 430px);
    margin: 0 auto;
    padding: 1.25rem;
}

.login-brand {
    margin-bottom: 1.5rem;
}

.login-error,
.flash-message {
    overflow-wrap: anywhere;
}

.login-error {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    background: rgba(255, 107, 97, 0.12);
    border: 1px solid rgba(255, 107, 97, 0.4);
    border-radius: 6px;
    color: #ffaea7;
    font-size: 0.92rem;
}

.login-form {
    display: grid;
    gap: 0.75rem;
}

.login-form label,
.admin-form label {
    display: grid;
    gap: 0.35rem;
    color: #d7dde5;
    font-size: 0.88rem;
    font-weight: 750;
}

.login-submit {
    min-height: 3.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.45rem;
    padding: 0.85rem 1rem;
    text-decoration: none;
}

.auth-message-text {
    color: #d7dde5;
    font-size: 1rem;
    line-height: 1.6;
}

.auth-message-action {
    width: 100%;
}

.flash-stack {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.flash-message {
    padding: 0.875rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.92rem;
}

.flash-success {
    background: rgba(48, 217, 121, 0.12);
    border-color: rgba(48, 217, 121, 0.34);
    color: #b7f7c7;
}

.flash-error {
    background: rgba(255, 107, 97, 0.12);
    border-color: rgba(255, 107, 97, 0.38);
    color: #ffaea7;
}

.flash-info {
    background: rgba(92, 168, 255, 0.12);
    border-color: rgba(92, 168, 255, 0.34);
    color: #bfdbfe;
}

.admin-container {
    max-width: 1120px;
}

.admin-panel {
    padding: 1rem;
    margin-bottom: 1rem;
}

.admin-panel-header {
    margin-bottom: 1rem;
}

.admin-panel-header h2 {
    margin-bottom: 0.25rem;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 800;
}

.admin-panel-header p,
.admin-user-heading p,
.admin-meta,
.invite-row span {
    color: var(--muted);
    font-size: 0.86rem;
}

.admin-form {
    display: grid;
    gap: 0.8rem;
}

.invite-form {
    grid-template-columns: minmax(0, 1fr) 10rem auto;
    align-items: end;
}

.admin-user-list,
.invite-list {
    display: grid;
    gap: 1rem;
}

.admin-user-card,
.invite-row {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.admin-user-heading {
    margin-bottom: 1rem;
}

.admin-user-heading h3 {
    color: var(--text);
    font-size: 1rem;
    font-weight: 800;
}

.user-edit-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-checks,
.admin-meta {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.check-row {
    display: inline-flex !important;
    grid-template-columns: none !important;
    align-items: center;
    gap: 0.45rem !important;
}

.check-row input {
    width: 1rem;
    min-height: 1rem;
}

.password-form {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    align-items: end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.invite-row strong {
    color: var(--text);
}

.invite-row span {
    display: block;
    margin-top: 0.2rem;
}

.processing-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 0.45rem;
    border: 2px solid rgba(245, 189, 79, 0.22);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

@media (min-width: 560px) {
    .container {
        padding: 2rem 1.25rem 3rem;
    }

    .login-shell {
        padding: 2rem;
    }

    .login-panel {
        padding: 1.75rem;
    }
}

@media (max-width: 768px) {
    .app-header,
    .admin-panel-header,
    .admin-user-heading,
    .invite-row,
    .home-spotlight,
    .panel-heading {
        flex-direction: column;
        align-items: stretch;
    }

    .home-spotlight {
        display: flex;
    }

    .spotlight-art {
        min-height: 220px;
    }

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

    .artwork-wall {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-auto-rows: minmax(96px, 1fr);
    }

    .artwork-tile:nth-child(n) {
        grid-column: span 1;
        grid-row: span 1;
    }

    .artwork-tile:nth-child(1),
    .artwork-tile:nth-child(6) {
        grid-column: span 2;
        grid-row: span 2;
    }

    .app-header-actions,
    .app-header-actions form,
    .logout-button,
    .app-header-actions .btn {
        width: 100%;
    }

    .app-header-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group,
    .card-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group button,
    .card-actions .btn,
    .card-actions .btn-icon {
        width: 100%;
    }

    .downloads-grid,
    .invite-form,
    .user-edit-form,
    .password-form,
    .card-info,
    .info-grid,
    .account-grid {
        grid-template-columns: 1fr;
    }

    .account-actions,
    .account-actions form,
    .account-actions .btn,
    .account-actions .logout-button {
        width: 100%;
    }

    .liquid-tabbar {
        width: min(calc(100vw - 1rem), 430px);
    }

    .card-header {
        flex-direction: column;
    }

    .card-title {
        margin-right: 0;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .playlist-icon-btn {
        flex: 1;
        justify-content: center;
    }

    .progress-container {
        flex-direction: column;
        align-items: stretch;
    }

    .progress-text {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .brand-mark,
    .login-mark {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 0.82rem;
    }

    .app-header h1,
    .login-brand h1 {
        font-size: 1.32rem;
    }

    .form-container,
    .card-content,
    .admin-panel,
    .admin-user-card,
    .login-panel {
        padding: 1rem;
    }

    .downloads-section h2 {
        font-size: 1rem;
    }

    .card-album-art {
        height: 96px;
    }
}
