:root {
    --md-primary: #6750a4;
    --md-on-primary: #ffffff;

    --md-surface: #fffbfe;
    --md-surface-container: #f3edf7;
    --md-surface-container-high: #ece6f0;

    --md-on-surface: #1d1b20;
    --md-on-surface-variant: #49454f;

    --md-outline: #79747e;
    --md-outline-variant: #cac4d0;

    --md-radius-small: 8px;
    --md-radius-medium: 12px;
    --md-radius-large: 16px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;

    background: var(--md-surface);
    color: var(--md-on-surface);

    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    line-height: 1.5;
}

a {
    color: inherit;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;

    background: color-mix(
        in srgb,
        var(--md-surface) 92%,
        transparent
    );

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    border-bottom: 1px solid var(--md-outline-variant);
}

.navbar {
    padding: 14px 0;
}

.header-content {
    display: flex;

    flex-direction: column;

    align-items: center;

    gap: 10px;

    width: 100%;
}

.app-logo {
    width: 100%;

    font-size: 21px;
    font-weight: 700;

    text-decoration: none;

    letter-spacing: -0.3px;

    text-align: center;
}

.header-actions {
    display: flex;

    align-items: center;

    width: 100%;

    gap: 10px;
}

.search-form {
    flex: 1 1 auto;

    width: auto;

    min-width: 0;
}

.search-box {
    display: flex;

    align-items: center;

    width: 100%;
    height: 48px;

    background: var(--md-surface-container);

    border: 1px solid transparent;

    border-radius: 24px;

    overflow: hidden;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.search-box:focus-within {
    border-color: var(--md-primary);

    box-shadow:
        0 0 0 3px color-mix(
            in srgb,
            var(--md-primary) 15%,
            transparent
        );
}

.search-box .form-control {
    width: 100%;
    height: 100%;

    min-width: 0;

    padding: 0 16px;

    background: transparent;

    border: 0;

    color: var(--md-on-surface);

    box-shadow: none;

    outline: none;
}

.search-box .form-control::placeholder {
    color: var(--md-on-surface-variant);
}

.search-button {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 48px;
    height: 48px;

    flex-shrink: 0;

    border: 0;

    background: transparent;

    color: var(--md-on-surface-variant);

    cursor: pointer;

    font-size: 24px;

    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.search-button:hover {
    background: var(--md-surface-container-high);

    color: var(--md-primary);
}

.search-button:active {
    transform: scale(0.96);
}

.about-button {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 48px;
    height: 48px;

    flex: 0 0 48px;

    padding: 0;

    border-radius: 50%;

    font-size: 20px;
}

.about-button i {
    line-height: 1;
}

main {
    width: 100%;
}

.popular-section,
.latest-section {
    padding: 32px 0;
}

.popular-section {
    padding-bottom: 18px;
}

.latest-section {
    padding-top: 20px;
}

.section-heading {
    display: flex;

    align-items: flex-end;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 20px;
}

.section-heading h1 {
    margin: 0;

    font-size: 24px;
    font-weight: 700;

    letter-spacing: -0.3px;
}

.section-heading p {
    margin: 5px 0 0;

    color: var(--md-on-surface-variant);

    font-size: 14px;
}

.popular-list {
    display: flex;

    gap: 16px;

    overflow-x: auto;

    padding: 4px 2px 16px;

    scroll-snap-type: x mandatory;

    scrollbar-width: thin;

    overscroll-behavior-x: contain;
}

.popular-list::-webkit-scrollbar {
    height: 6px;
}

.popular-list::-webkit-scrollbar-track {
    background: transparent;
}

.popular-list::-webkit-scrollbar-thumb {
    background: var(--md-outline-variant);

    border-radius: 10px;
}

.popular-card {
    flex: 0 0 180px;

    scroll-snap-align: start;
}

.popular-card-link {
    display: block;

    color: inherit;

    text-decoration: none;

    border-radius: var(--md-radius-medium);

    transition:
        transform 0.2s ease,
        opacity 0.2s ease;
}

.popular-card-link:hover {
    transform: translateY(-3px);
}

.popular-card-link:active {
    transform: scale(0.98);
}

.popular-card-image-wrapper {
    position: relative;

    width: 180px;
    height: 250px;

    overflow: hidden;

    border-radius: var(--md-radius-medium);

    background: var(--md-surface-container);
}

.popular-card-image {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;
}

.popular-badges {
    position: absolute;

    top: 8px;
    left: 8px;

    display: flex;

    align-items: center;

    gap: 5px;

    max-width: calc(100% - 16px);

    pointer-events: none;

    z-index: 5;
}

.popular-type {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    min-height: 24px;

    padding: 3px 8px;

    border-radius: var(--md-radius-small);

    font-size: 11px;
    font-weight: 600;

    line-height: 1;

    white-space: nowrap;

    color: #ffffff;

    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.popular-type-manhwa {
    background: #6750a4;
}

.popular-type-manhua {
    background: #ba1a1a;
}

.popular-type-manga {
    background: #006a6a;
}

.popular-hot {
    position: absolute;

    right: 8px;
    bottom: 8px;

    display: flex;

    align-items: center;
    justify-content: center;

    width: 32px;
    height: 32px;

    padding: 0;

    margin: 0;

    background: color-mix(
        in srgb,
        var(--md-primary) 88%,
        transparent
    );

    color: var(--md-on-primary);

    border-radius: 50%;

    font-size: 18px;

    line-height: 1;

    white-space: nowrap;

    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    pointer-events: none;

    z-index: 6;
}

.popular-card-title {
    display: -webkit-box;

    margin: 10px 2px 6px;

    overflow: hidden;

    font-size: 15px;
    font-weight: 700;

    line-height: 1.4;

    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.popular-card-info {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 8px;

    margin: 0 2px;

    font-size: 13px;
}

.popular-chapter {
    min-width: 0;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    color: var(--md-on-surface-variant);
}

.popular-rating {
    flex-shrink: 0;

    font-weight: 700;
}

.latest-list {
    display: flex;

    flex-direction: column;

    gap: 12px;
}

.latest-card {
    display: block;

    width: 100%;
    height: 220px;

    min-height: 220px;
    max-height: 220px;

    background: var(--md-surface-container);

    border: 1px solid transparent;

    border-radius: var(--md-radius-large);

    overflow: hidden;

    transition:
        transform 0.2s ease,
        border-color 0.2s ease;
}

.latest-card:hover {
    border-color: var(--md-outline-variant);

    transform: translateY(-2px);
}

.latest-card-link {
    display: flex;

    width: 100%;
    height: 100%;

    min-height: 0;

    gap: 16px;

    padding: 14px;

    color: inherit;

    text-decoration: none;

    overflow: hidden;
}

.latest-card-image-wrapper {
    position: relative;

    width: 110px;
    height: 155px;

    min-width: 110px;
    min-height: 155px;

    max-width: 110px;
    max-height: 155px;

    flex: 0 0 110px;

    overflow: hidden;

    border-radius: var(--md-radius-medium);

    background: var(--md-surface-container-high);
}

.latest-card-image-wrapper img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;
}

.latest-card-badges {
    position: absolute;

    top: 8px;
    left: 8px;

    display: flex;

    align-items: center;

    gap: 5px;

    max-width: calc(100% - 16px);

    pointer-events: none;

    z-index: 5;
}

.latest-content {
    display: flex;

    flex-direction: column;

    width: 100%;
    height: 190px;

    min-width: 0;
    min-height: 0;

    max-height: 190px;

    overflow: hidden;
}

.latest-content h3 {
    display: block;

    width: 100%;
    height: 28px;

    min-height: 28px;
    max-height: 28px;

    flex: 0 0 28px;

    margin: 2px 0 10px;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    font-size: 18px;
    font-weight: 700;

    line-height: 28px;
}

.latest-content ul {
    display: block;

    width: 100%;
    height: 150px;

    min-width: 0;
    min-height: 150px;

    max-height: 150px;

    flex: 0 0 150px;

    margin: 0;

    padding: 0 6px 0 0;

    list-style: none;

    overflow-x: hidden;
    overflow-y: auto;

    scrollbar-width: thin;

    scrollbar-color:
        var(--md-outline-variant)
        transparent;
}

.latest-content ul::-webkit-scrollbar {
    width: 5px;
}

.latest-content ul::-webkit-scrollbar-track {
    background: transparent;
}

.latest-content ul::-webkit-scrollbar-thumb {
    background: var(--md-outline-variant);

    border-radius: 10px;
}

.latest-content li {
    display: flex;

    align-items: center;
    justify-content: space-between;

    width: 100%;

    min-width: 0;
    min-height: 36px;

    gap: 12px;

    padding: 7px 0;

    border-bottom: 1px solid var(--md-outline-variant);

    font-size: 14px;
}

.latest-content li:last-child {
    border-bottom: 0;
}

.latest-content li span {
    display: block;

    min-width: 0;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;
}

.latest-content li small {
    display: block;

    flex-shrink: 0;

    color: var(--md-on-surface-variant);

    font-size: 12px;
}

.latest-rating {
    margin-left: 8px;

    font-weight: 700;

    white-space: nowrap;
}

.latest-chapter {
    display: inline-block;

    max-width: 100%;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;
}

.search-result-info {
    display: flex !important;

    align-items: center;

    justify-content: flex-start !important;

    gap: 12px;
}

.loading {
    width: 100%;

    padding: 50px 20px;

    color: var(--md-on-surface-variant);

    text-align: center;
}

.error {
    width: 100%;

    padding: 18px;

    background: var(--md-surface-container);

    border: 1px solid var(--md-outline-variant);

    border-radius: var(--md-radius-medium);

    color: var(--md-on-surface-variant);
}

.app-footer {
    margin-top: 20px;

    padding: 30px 0;

    border-top: 1px solid var(--md-outline-variant);

    color: var(--md-on-surface-variant);

    text-align: center;
}

.app-footer p {
    margin: 0;

    font-size: 14px;
}

@media (max-width: 700px) {

    .navbar {
        padding: 12px 0;
    }

    .header-content {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .app-logo {
        width: 100%;
        font-size: 19px;
        text-align: center;
    }

    .header-actions {
        display: flex;
        align-items: center;
        width: 100%;
        gap: 8px;
    }

    .search-form {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
    }

    .search-box {
        height: 44px;
    }

    .search-button {
        width: 44px;
        height: 44px;
    }

    .about-button {
        width: 44px;
        height: 44px;

        flex: 0 0 44px;

        font-size: 18px;
    }

    .popular-section,
    .latest-section {
        padding: 24px 0;
    }

    .section-heading {
        margin-bottom: 16px;
    }

    .section-heading h1 {
        font-size: 21px;
    }

    .section-heading p {
        font-size: 13px;
    }

    .popular-list {
        gap: 12px;
        padding-bottom: 12px;
    }

    .popular-card {
        flex-basis: 140px;
    }

    .popular-card-image-wrapper {
        width: 140px;
        height: 195px;
    }

    .popular-badges {
        top: 6px;
        left: 6px;

        gap: 4px;

        max-width: calc(100% - 12px);
    }

    .popular-type {
        min-height: 22px;

        padding: 3px 7px;

        font-size: 10px;

        border-radius: 5px;
    }

    .popular-hot {
        right: 6px;
        bottom: 6px;

        width: 28px;
        height: 28px;

        font-size: 16px;
    }

    .popular-card-title {
        font-size: 14px;
    }

    .popular-card-info {
        font-size: 12px;
    }

    .latest-list {
        gap: 10px;
    }

    .latest-card {
        height: 180px;

        min-height: 180px;
        max-height: 180px;
    }

    .latest-card-link {
        height: 100%;

        min-height: 0;

        gap: 12px;

        padding: 12px;
    }

    .latest-card-image-wrapper {
        width: 90px;
        height: 125px;

        min-width: 90px;
        min-height: 125px;

        max-width: 90px;
        max-height: 125px;

        flex-basis: 90px;
    }

    .latest-card-badges {
        top: 6px;
        left: 6px;

        gap: 4px;

        max-width: calc(100% - 12px);
    }

    .latest-content {
        height: 154px;

        max-height: 154px;
    }

    .latest-content h3 {
        height: 24px;

        min-height: 24px;
        max-height: 24px;

        flex-basis: 24px;

        margin: 0 0 8px;

        font-size: 16px;

        line-height: 24px;
    }

    .latest-content ul {
        height: 122px;

        min-height: 122px;
        max-height: 122px;

        flex-basis: 122px;
    }

    .latest-content li {
        min-height: 32px;

        padding: 6px 0;

        font-size: 13px;
    }

    .latest-content li small {
        font-size: 11px;
    }

}

@media (max-width: 380px) {

    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .header-content {
        gap: 6px;
    }

    .app-logo {
        font-size: 17px;
    }

    .header-actions {
        gap: 6px;
    }

    .search-box {
        height: 42px;
    }

    .search-button {
        width: 42px;
        height: 42px;
    }

    .about-button {
        width: 42px;
        height: 42px;

        flex: 0 0 42px;

        font-size: 17px;
    }

    .popular-card {
        flex-basis: 125px;
    }

    .popular-card-image-wrapper {
        width: 125px;
        height: 175px;
    }

    .popular-badges {
        top: 5px;
        left: 5px;

        gap: 3px;

        max-width: calc(100% - 10px);
    }

    .popular-type {
        min-height: 20px;

        padding: 3px 6px;

        font-size: 9px;
    }

    .popular-hot {
        right: 5px;
        bottom: 5px;

        width: 26px;
        height: 26px;

        font-size: 15px;
    }

    .latest-card {
        height: 165px;

        min-height: 165px;
        max-height: 165px;
    }

    .latest-card-link {
        height: 100%;
    }

    .latest-card-image-wrapper {
        width: 78px;
        height: 110px;

        min-width: 78px;
        min-height: 110px;

        max-width: 78px;
        max-height: 110px;

        flex-basis: 78px;
    }

    .latest-card-badges {
        top: 5px;
        left: 5px;

        gap: 3px;

        max-width: calc(100% - 10px);
    }

    .latest-content {
        height: 139px;

        max-height: 139px;
    }

    .latest-content h3 {
        height: 22px;

        min-height: 22px;
        max-height: 22px;

        flex-basis: 22px;

        font-size: 15px;

        line-height: 22px;
    }

    .latest-content ul {
        height: 109px;

        min-height: 109px;
        max-height: 109px;

        flex-basis: 109px;
    }

    .latest-content li {
        min-height: 30px;

        font-size: 12px;
    }

}

@media (prefers-color-scheme: dark) {

    :root {
        --md-primary: #d0bcff;
        --md-on-primary: #381e72;

        --md-surface: #141218;
        --md-surface-container: #211f26;
        --md-surface-container-high: #2b2930;

        --md-on-surface: #e6e0e9;
        --md-on-surface-variant: #cac4d0;

        --md-outline: #938f99;
        --md-outline-variant: #49454f;
    }

}