.templates-page {
    min-height: 100%;
    height: auto;
    overflow-y: auto;
}

.template-main {
    max-width: 1460px;
    margin: 0 auto;
    padding: 32px 28px 54px;
}

.template-intro {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
}

.template-intro h2 {
    margin: 0;
    font-size: 24px;
}

.template-intro p {
    margin: 9px 0 0;
    color: #71819a;
    font-size: 11px;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.api-notes {
    margin-bottom: 20px;
    border: 1px solid rgba(247, 215, 255, .18);
    border-radius: 12px;
    background: rgba(55, 20, 98, .68);
}

.api-notes summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    color: #efddff;
    cursor: pointer;
    font-size: 10px;
    font-weight: 800;
    list-style: none;
}

.api-notes summary::-webkit-details-marker {
    display: none;
}

.api-notes summary::before {
    margin-right: 8px;
    color: #e879f9;
    content: "＋";
}

.api-notes[open] summary::before {
    content: "－";
}

.api-notes summary span {
    flex: 1;
}

.api-notes summary small {
    color: #bc9bd4;
    font-size: 8px;
    font-weight: 500;
}

.api-note-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    border-top: 1px solid rgba(247, 215, 255, .12);
    background: rgba(247, 215, 255, .09);
}

.api-note-grid > div {
    min-width: 0;
    padding: 12px 15px;
    background: #2f1052;
}

.api-note-grid code {
    color: #f0abfc;
    font-family: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
    font-size: 9px;
}

.api-note-grid p {
    margin: 6px 0 0;
    color: #cbb1df;
    font-size: 8px;
    line-height: 1.55;
}

.template-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 15px;
    background:
        linear-gradient(180deg, rgba(72, 27, 126, .9), rgba(35, 11, 67, .95));
    box-shadow: 0 16px 34px rgba(52, 10, 91, .3);
    transition: transform .2s ease, border-color .2s ease;
}

.template-card:hover {
    border-color: rgba(240, 171, 252, .5);
    transform: translateY(-3px);
}

.template-cover {
    position: relative;
    display: block;
    height: 340px;
    overflow: hidden;
    background: #240b3f;
}

.template-cover iframe {
    width: 100%;
    height: 100%;
    border: 0;
    pointer-events: none;
}

.template-cover::after {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 64%, rgba(31, 8, 55, .76));
    content: "";
    pointer-events: none;
}

.template-pages,
.template-edit-hint {
    position: absolute;
    z-index: 2;
    padding: 6px 9px;
    border: 1px solid rgba(255, 233, 255, .2);
    border-radius: 7px;
    background: rgba(44, 14, 79, .8);
    color: #f3e6ff;
    font-size: 8px;
    font-weight: 700;
    backdrop-filter: blur(8px);
}

.template-pages {
    top: 12px;
    right: 12px;
}

.template-edit-hint {
    right: 12px;
    bottom: 12px;
    opacity: 0;
    transition: opacity .18s ease;
}

.template-card:hover .template-edit-hint {
    opacity: 1;
}

.template-meta {
    display: flex;
    min-height: 94px;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 15px;
}

.template-meta h3 {
    margin: 0 0 5px;
    font-size: 14px;
}

.template-copy {
    min-width: 0;
}

.template-meta p {
    max-width: 290px;
    margin: 0;
    overflow: hidden;
    color: #c4a9da;
    font-size: 9px;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.template-page-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.template-page-links a {
    display: grid;
    width: 25px;
    height: 22px;
    place-items: center;
    border: 1px solid rgba(240, 171, 252, .22);
    border-radius: 5px;
    background: rgba(101, 46, 152, .36);
    color: #d8b4fe;
    font-size: 7px;
    font-weight: 800;
    text-decoration: none;
}

.template-page-links a:hover {
    border-color: rgba(240, 171, 252, .6);
    color: #fff1ff;
}

.template-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 6px;
}

.template-dialog {
    width: min(460px, calc(100vw - 40px));
    padding: 0;
    border: 1px solid rgba(240, 171, 252, .32);
    border-radius: 15px;
    background: #321057;
    box-shadow: 0 28px 70px rgba(0, 0, 0, .55);
    color: var(--ink);
}

.template-dialog::backdrop {
    background: rgba(31, 6, 53, .74);
    backdrop-filter: blur(6px);
}

.template-dialog form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
}

.template-dialog header,
.template-dialog footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.template-dialog header {
    margin-bottom: 3px;
}

.template-dialog h2 {
    margin: 0;
    font-size: 18px;
}

.template-dialog label > span {
    display: block;
    margin-bottom: 6px;
    color: #ddc5f0;
    font-size: 9px;
    font-weight: 700;
}

.template-dialog input,
.template-dialog textarea,
.template-dialog select {
    width: 100%;
    border: 1px solid rgba(240, 171, 252, .26);
    border-radius: 9px;
    outline: none;
    background: #280d47;
    color: #f4eaff;
    font-size: 11px;
}

.template-dialog input,
.template-dialog select {
    height: 38px;
    padding: 0 11px;
}

.template-dialog textarea {
    resize: vertical;
    padding: 10px 11px;
    line-height: 1.55;
}

.template-dialog input:focus,
.template-dialog textarea:focus,
.template-dialog select:focus {
    border-color: rgba(240, 171, 252, .68);
    box-shadow: 0 0 0 3px rgba(232, 121, 249, .15);
}

.template-dialog footer {
    justify-content: flex-end;
    margin-top: 4px;
}

@media (max-width: 1050px) {
    .template-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .template-main {
        padding: 20px 14px 40px;
    }

    .template-grid {
        grid-template-columns: 1fr;
    }

    .api-note-grid {
        grid-template-columns: 1fr;
    }
}
