* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: #f5f7fb;
    color: #202635;
}

.app {
    width: min(760px, calc(100% - 32px));
    margin: 48px auto;
}

.app-header {
    margin-bottom: 28px;
}

.app-header h1 {
    margin: 0;
    font-size: 36px;
    line-height: 1.1;
}

.app-header p {
    margin: 6px 0 0;
    color: #687080;
}


/* Form */

.generation-form,
.generation-card {
    background: #ffffff;
    border: 1px solid #dde2ea;
    border-radius: 16px;
    padding: 24px;
}

.generation-form {
    display: grid;
    gap: 22px;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

.field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

#lyrics-counter,
#prompt-counter {
    color: #8a93a3;
    font-size: 13px;
    font-weight: 500;
    transition: color 0.2s ease;
}

#lyrics-counter.counter-warning,
#prompt-counter.counter-warning {
    color: #b26a00;
}

#lyrics-counter.counter-limit,
#prompt-counter.counter-limit {
    color: #b42318;
    font-weight: 700;
}

input,
select,
textarea,
button {
    font: inherit;
}

select,
textarea {
    width: 100%;
    border: 1px solid #ccd3dd;
    border-radius: 10px;
    padding: 12px 13px;
    background: #ffffff;
    color: #202635;
    outline: none;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

textarea {
    resize: vertical;
    line-height: 1.5;
}

textarea:focus,
select:focus {
    border-color: #6d5dfc;
    box-shadow:
        0 0 0 3px rgba(109, 93, 252, 0.12);
}

textarea::placeholder {
    color: #9aa2b1;
}


/* Advanced settings */

.advanced-settings {
    overflow: hidden;
    border: 1px solid #dde2ea;
    border-radius: 12px;
    background: #fafbfe;
}

.advanced-settings summary {
    padding: 15px 16px;
    cursor: pointer;
    font-weight: 700;
    user-select: none;
}

.advanced-settings[open] summary {
    border-bottom: 1px solid #e4e8ef;
}

.advanced-settings-content {
    display: grid;
    gap: 20px;
    padding: 18px 16px;
}

fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

legend {
    margin-bottom: 10px;
    font-weight: 600;
}

fieldset label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-right: 20px;
    margin-bottom: 8px;
    font-weight: 500;
    cursor: pointer;
}

input[type="radio"],
input[type="checkbox"] {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: #6d5dfc;
}


/* Duration */

.duration-settings {
    display: grid;
    gap: 12px;
}

.duration-settings > label:first-child {
    font-weight: 600;
}

.duration-settings > label:nth-child(2) {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    width: fit-content;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
}

#duration-custom {
    display: grid;
    gap: 10px;
}

#duration-custom[hidden] {
    display: none;
}

.duration-control {
    display: flex;
    align-items: center;
    gap: 14px;
}

.duration-control button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid #ccd3dd;
    border-radius: 10px;
    background: #ffffff;
    color: #202635;
    font-size: 22px;
    font-weight: 600;
    cursor: pointer;
}

.duration-control button:hover:not(:disabled) {
    border-color: #6d5dfc;
    background: #f4f2ff;
}

.duration-control button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#duration-display {
    min-width: 72px;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.duration-settings small {
    color: #7a8392;
    font-size: 13px;
    font-weight: 400;
}


/* Primary action */

.generation-form > button[type="submit"] {
    width: 100%;
    border: 0;
    border-radius: 11px;
    padding: 14px 18px;
    background: #202635;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
    transition:
        opacity 0.2s ease,
        transform 0.1s ease;
}

.generation-form > button[type="submit"]:hover {
    opacity: 0.92;
}

.generation-form > button[type="submit"]:active {
    transform: translateY(1px);
}


/* Generation result */

#generation-output {
    margin-top: 24px;
}

.generation-card {
    display: grid;
    gap: 14px;
}

.generation-info {
    color: #687080;
    font-size: 14px;
    word-break: break-all;
}

.status {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.success {
    color: #157347;
}

.error {
    color: #b42318;
}

audio {
    width: 100%;
}

.download {
    display: inline-block;
    width: fit-content;
    font-weight: 700;
}


/* User */

.app-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-actions span {
    color: #687080;
    font-size: 14px;
    font-weight: 600;
}

.user-actions form {
    margin: 0;
}

.secondary-button {
    border: 1px solid #ccd3dd;
    border-radius: 9px;
    padding: 8px 12px;
    background: #ffffff;
    color: #202635;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}


/* History */

.history {
    display: grid;
    gap: 16px;
    margin-top: 32px;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.history-header h2 {
    margin: 0 0 4px;
    font-size: 24px;
}

.history-header p {
    margin: 0;
    color: #7a8392;
    font-size: 14px;
}

.history-count {
    display: grid;
    place-items: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    background: #eceafd;
    color: #5145cd;
    font-size: 13px;
    font-weight: 700;
}

.history-list {
    display: grid;
    gap: 14px;
}

.history-card,
.history-empty {
    border: 1px solid #e1e5eb;
    border-radius: 14px;
    background: #ffffff;
    padding: 18px;
}

.history-card {
    display: grid;
    gap: 14px;
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.history-card-header strong {
    display: block;
    overflow-wrap: anywhere;
}

.history-date {
    margin-top: 5px;
    color: #8a93a3;
    font-size: 13px;
}

.history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    color: #687080;
    font-size: 13px;
}

.history-status {
    height: fit-content;
    border-radius: 999px;
    padding: 5px 9px;
    background: #eef1f5;
    color: #687080;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.history-status-completed {
    background: #e7f6ed;
    color: #157347;
}

.history-status-failed {
    background: #fdeceb;
    color: #b42318;
}

.history-status-processing,
.history-status-pending {
    background: #fff4dd;
    color: #98620b;
}

.history-empty {
    color: #7a8392;
    text-align: center;
}


/* Delete generation */

.delete-generation-form {
    margin: 0;
}

.delete-button {
    width: fit-content;
    border: 1px solid #f0b8b4;
    border-radius: 9px;
    padding: 8px 12px;
    background: #ffffff;
    color: #b42318;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.delete-button:hover {
    background: #fdeceb;
}


/* Mobile */

@media (max-width: 600px) {
    .app {
        width: min(100% - 20px, 760px);
        margin: 20px auto;
    }

    .app-header h1 {
        font-size: 30px;
    }

    .generation-form,
    .generation-card {
        padding: 18px;
    }

    fieldset label {
        display: flex;
        margin-right: 0;
    }

    .app-header-row,
    .history-card-header {
        align-items: stretch;
        flex-direction: column;
    }

    .user-actions {
        justify-content: space-between;
    }
}
