body {
    font-family: Arial, sans-serif;
    padding: 1rem;
    background: #f1f1f1;
    color: #333;
}
  
h3 {
    text-align: left;
    margin-bottom: 2rem;
}


h5 {
    font-size: 1rem !important;
}


  
/* Filter controls section */
.filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: center;
}
  
#search {
    padding: 0.5rem;
    font-size: 1rem;
}
  
.range-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}
  
  
.range-values {
    margin-top: 0.25rem;
    font-size: 0.9rem;
}
  
/* Video grid layout */
.container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}
  
/* Individual video card */
.video-block {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
  
.video-block h5 {
    margin-bottom: 0.5rem;
}
  
/* Pagination buttons */
.pagination {
    text-align: center;
    margin-top: 2rem;
}
  
.pagination button {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    cursor: pointer;
    margin: 0 0.5rem;
    border: none;
    background-color: #007bff;
    color: white;
    border-radius: 5px;
}
  
.pagination button:disabled {
    background-color: #ccc;
}
  
.pagination-info {
    font-size: 1rem;
    color: #333;
    margin-top: 1rem;
}
  
/* Disable iframe interactions */
iframe {
    pointer-events: none;
}
  
/* Custom Plyr spacing */
:root {
    --plyr-control-spacing: 5px;
}
  
/* Math challenge popup */
#video-popup {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    z-index: 9999;
}
  
#video-popup > div {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    font-size: 20px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
  
.popup- {
    font-size:20px;
}


.range-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap; /* prevent label and input from splitting */
}

.field input,
.field select {
  padding: 0.3rem;
  min-width: 70px;
}

/* Responsive: stack whole field blocks */
@media (max-width: 600px) {
  .range-inputs {
    flex-direction: column;
    align-items: flex-start;
  }

  .field {
    width: 100%;
  }

  .field input,
  .field select {
    flex: 1; /* stretch to available width */
  }
}

[hidden] {
    display: none !important;
}

.auth-screen {
    min-height: calc(100vh - 2rem);
    display: grid;
    place-items: center;
    background:
        radial-gradient(ellipse at 15% 20%, rgba(236, 167, 74, 0.18), transparent 32%),
        radial-gradient(ellipse at 85% 85%, rgba(57, 126, 113, 0.16), transparent 36%),
        #f4f2ed;
}

.auth-panel {
    width: min(100% - 2rem, 440px);
    padding: 2.25rem;
    background: #fff;
    border: 1px solid #dedbd3;
    border-top: 5px solid #397e71;
    box-shadow: 0 16px 46px rgba(39, 49, 45, 0.1);
}

.auth-panel h1 {
    margin: 0 0 0.65rem;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 2rem;
}

.eyebrow {
    color: #397e71;
    font-size: 0.75rem;
    font-weight: 700;
}

.auth-copy,
.settings-copy {
    color: #656962;
}

.app-page {
    width: min(100%, 1440px);
    margin: 0 auto;
    padding: 0.4rem 0.25rem 2rem;
}

#app-screen.has-subview .app-header {
    display: none;
}

.subpage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 0.5rem 0.25rem 1rem;
    border-bottom: 1px solid #dfe5df;
}

.subpage-header h1 {
    margin: 0;
    color: #26332d;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(1.6rem, 3vw, 2.15rem);
    font-weight: 600;
}

.subpage-header h1:focus {
    outline: none;
}

.subpage-header p:not(.app-eyebrow) {
    margin: 0.35rem 0 0;
    color: #6c756e;
}

.subpage-header .app-eyebrow {
    margin: 0 0 0.3rem;
}

.back-button {
    display: inline-flex;
    min-height: 2.65rem;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.9rem;
    border: 1px solid #dce4dd;
    border-radius: 10px;
    background: #fff;
    color: #3d5147;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
}

.back-button:hover {
    border-color: #bbcec2;
    background: #f5f8f5;
    color: #285d4f;
}

.back-button:focus-visible {
    outline: 3px solid rgba(57, 126, 113, 0.25);
    outline-offset: 2px;
}

.back-button span {
    font-size: 1.15rem;
    line-height: 1;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 1rem;
}

.settings-card,
.history-card {
    min-width: 0;
    padding: clamp(1rem, 2vw, 1.5rem);
    border: 1px solid #e1e6e0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 6px 22px rgba(38, 54, 44, 0.045);
}

.settings-card h2 {
    margin: 0;
    color: #293730;
    font-size: 1.2rem;
    font-weight: 650;
}

.section-kicker {
    margin: 0 0 0.35rem;
    color: #648075;
    font-size: 0.68rem;
    font-weight: 750;
    letter-spacing: 0.1em;
}

@media (max-width: 760px) {
    .app-header {
        flex-wrap: wrap;
    }

    .app-brand {
        flex: 1 1 100%;
    }

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

    .app-actions {
        flex-wrap: nowrap;
    }

    .settings-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.account-panel {
    display: grid;
    gap: 0.8rem;
}

.account-email {
    margin: -0.6rem 0 0;
    color: #656962;
    font-size: 0.9rem;
}

.account-form {
    display: grid;
    gap: 0.5rem;
    max-width: 520px;
}

.account-form-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
}

.account-message {
    min-height: 1.2em;
    margin: 0;
    color: #4d6555;
    font-size: 0.85rem;
}

.weekly-statistics {
    min-width: 0;
}

.daily-chart {
    display: grid;
    grid-template-columns: 3.1rem minmax(0, 1fr);
    gap: 0.35rem;
    min-height: 11.5rem;
}

.daily-chart-axis {
    display: flex;
    height: 10rem;
    flex-direction: column;
    justify-content: space-between;
    padding: 0 0.25rem 0 0;
    color: #606a64;
    font-size: 0.68rem;
    line-height: 1;
    text-align: right;
}

.daily-chart-scroll {
    min-width: 0;
    overflow-x: auto;
}

.daily-chart-columns {
    display: grid;
    width: 100%;
    height: 11.5rem;
    grid-template-columns: repeat(var(--chart-count), minmax(0, 1fr));
    align-items: stretch;
    background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(25% - 1px), #e7e9e6 calc(25% - 1px), #e7e9e6 25%);
    border-bottom: 1px solid #aeb7b0;
}

.daily-chart-columns.is-month {
    min-width: calc(var(--chart-count) * 2rem);
}

.daily-chart-column {
    display: grid;
    min-width: 0;
    grid-template-rows: 10rem 1.5rem;
    justify-items: center;
}

.daily-chart-plot-area {
    display: flex;
    width: 100%;
    height: 10rem;
    align-items: flex-end;
    justify-content: center;
    padding: 0 0.3rem;
}

.daily-chart-bar {
    width: min(68%, 1.4rem);
    min-height: 0;
    border-radius: 2px 2px 0 0;
    background: #43856f;
    transition: height 180ms ease-out;
}

.daily-chart-label {
    align-self: center;
    color: #303632;
    font-size: 0.72rem;
    line-height: 1;
    white-space: nowrap;
}

@media (max-width: 420px) {
    .daily-chart {
        grid-template-columns: 2.7rem minmax(0, 1fr);
        gap: 0.2rem;
    }

    .daily-chart-axis {
        font-size: 0.62rem;
    }
}

.current-week {
    color: #245d56;
}

.pending-users-list {
    display: grid;
    gap: 0.4rem;
}

.report-recipients-list {
    display: grid;
    gap: 0.4rem;
}

.report-recipient-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-top: 1px solid #e7e9e6;
    padding-top: 0.4rem;
    overflow-wrap: anywhere;
}

.db-explorer {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.db-explorer .form-select {
    max-width: 16rem;
}

.db-table-count {
    font-size: 0.85rem;
    color: #6c757d;
}

.db-table-scroll {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.db-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.db-table th,
.db-table td {
    padding: 0.35rem 0.55rem;
    border-bottom: 1px solid #eef0f2;
    text-align: left;
    white-space: nowrap;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.db-table thead th {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 1;
    font-weight: 600;
}

.db-table tbody tr:hover {
    background: #f6f8f7;
}

.db-table-status {
    padding: 0.5rem 0.55rem;
    margin: 0;
    color: #6c757d;
    font-size: 0.85rem;
}

.upload-card {
    margin-top: 1rem;
}

.upload-quota {
    margin: 0.25rem 0;
    color: #4a534d;
    font-size: 0.9rem;
}

.upload-list {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.upload-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    border-top: 1px solid #e7e9e6;
    padding-top: 0.4rem;
}

.upload-row-title {
    overflow-wrap: anywhere;
    flex: 1 1 auto;
}

.upload-row-meta {
    color: #6c757d;
    font-size: 0.85rem;
    white-space: nowrap;
}

.limit-input {
    max-width: 9rem;
}

.pending-user-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    border-top: 1px solid #e7e9e6;
    padding-top: 0.5rem;
}

.auth-actions {
    display: flex;
    gap: 0.65rem;
}

.auth-actions .btn {
    flex: 1;
}

.auth-link {
    display: block;
    margin: 0.85rem auto 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #4d6555;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.user-email {
    display: block;
    max-width: 15rem;
    overflow: hidden;
    color: #25332c;
    font-size: 0.88rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-header {
    display: flex;
    max-width: 1200px;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 auto 1.25rem;
    padding: 1rem;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.app-brand,
.app-header-tools,
.account-chip,
.app-actions,
.app-action {
    display: flex;
    align-items: center;
}

.app-brand {
    min-width: 0;
    gap: 0.85rem;
}

.app-brand-mark {
    display: grid;
    width: 2.6rem;
    height: 2.6rem;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 8px;
    background: #eef3f0;
    color: #397e71;
}

.app-brand-mark svg {
    width: 1.65rem;
    height: 1.65rem;
}

.app-eyebrow {
    margin: 0 0 0.15rem;
    color: #737871;
    font-size: 0.65rem;
    font-weight: 750;
    letter-spacing: 0.12em;
}

.app-brand h1 {
    margin: 0;
    color: #333;
    font-family: Arial, sans-serif;
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.15;
}

.app-header-tools {
    justify-content: flex-end;
    gap: 1rem;
}

.account-chip {
    min-width: 0;
    gap: 0.6rem;
    padding-right: 0.75rem;
    border-right: 1px solid #e3e4e0;
}

.account-avatar {
    display: grid;
    width: 2.4rem;
    height: 2.4rem;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    background: #f1f1f1;
    color: #555b55;
}

.account-avatar svg {
    width: 1.35rem;
    height: 1.35rem;
}

.account-label {
    display: block;
    margin-bottom: 0.1rem;
    color: #737871;
    font-size: 0.7rem;
}

.app-actions {
    flex-wrap: wrap;
    gap: 0.45rem;
}

.app-action {
    min-height: 2.35rem;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.45rem 0.7rem;
    border: 1px solid #d6d8d5;
    border-radius: 5px;
    background: #fff;
    color: #444;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 500;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.app-action:hover {
    border-color: #aeb4af;
    background: #f6f6f6;
    color: #222;
}

.app-action:focus-visible {
    outline: 3px solid rgba(57, 126, 113, 0.25);
    outline-offset: 2px;
}

.app-action svg {
    width: 1.05rem;
    height: 1.05rem;
    flex: 0 0 auto;
}

.app-action-logout {
    border-color: #ded4d1;
    color: #795348;
}

.app-action-logout:hover {
    border-color: #c9ada4;
    background: #faf5f3;
    color: #793f32;
}

#datasource-list {
    max-height: min(45vh, 420px);
    overflow: auto;
    border-top: 1px solid #e3e4e0;
}

.channel-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.2rem;
    border-bottom: 1px solid #e3e4e0;
}

.channel-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.channel-meta {
    display: block;
    color: #737871;
    font-size: 0.78rem;
}

.channel-actions {
    display: flex;
    gap: 0.4rem;
}

.channel-search {
    margin: 0.85rem 0 0.75rem;
}

.channel-search-empty {
    margin: 0 0 1rem;
    color: #737871;
    font-size: 0.9rem;
}

.video-release-date {
    margin: -0.2rem 0 0.6rem;
    color: #737871;
    font-size: 0.82rem;
}

.history-list {
    display: grid;
    gap: 0.6rem;
}

.history-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(10rem, auto);
    align-items: center;
    gap: 0.2rem 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid #e8ece7;
    border-radius: 12px;
    background: #fcfdfb;
}

.history-item > a {
    overflow: hidden;
    color: #2e5548;
    font-weight: 650;
    text-overflow: ellipsis;
    text-decoration: none;
    white-space: nowrap;
}

.history-item > a:hover {
    color: #1f7561;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.history-item time {
    grid-column: 2;
    grid-row: 1 / span 2;
    color: #737871;
    font-size: 0.82rem;
    text-align: right;
}

.history-empty {
    margin: 0;
    padding: 2rem 1rem;
    color: #737871;
    text-align: center;
}

.history-channel {
    display: block;
    color: #737871;
    font-size: 0.83rem;
}

@media (max-width: 600px) {
    .auth-panel {
        padding: 1.5rem;
    }

    .app-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.85rem;
    }

    .app-header-tools {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .account-chip {
        padding-right: 0;
        border-right: 0;
    }

    .app-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .app-action {
        gap: 0.35rem;
        padding-inline: 0.4rem;
        font-size: 0.78rem;
    }

    .user-email {
        max-width: min(58vw, 15rem);
    }

    .app-page {
        padding-inline: 0;
    }

    .subpage-header {
        align-items: flex-start;
        flex-direction: column;
        padding-inline: 0.15rem;
    }

    .back-button {
        width: 100%;
        justify-content: center;
    }

    .history-item {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.3rem;
        padding: 0.8rem;
    }

    .history-item time {
        grid-column: 1;
        grid-row: auto;
        text-align: left;
    }

    #add-channel-form {
        flex-direction: column;
    }
}
