:root {
    --bg: #eef2ff;
    --card: #ffffff;
    --ink: #1a1f36;
    --muted: #6b7394;
    --line: #e6eaf5;
    --grad1: #7c5cff;
    --grad2: #ff5ca8;
    --grad3: #21d4fd;
    --grad4: #ffb86c;
    --shadow: 0 20px 50px rgba(80, 90, 160, 0.18);
    --radius: 22px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    font-family: 'Poppins', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ===== BACKGROUND BLOBS ===== */
.bg-blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 18s ease-in-out infinite;
}
.b1 { width: 380px; height: 380px; background: var(--grad1); top: -90px; left: -60px; }
.b2 { width: 320px; height: 320px; background: var(--grad2); top: 20%; right: -90px; animation-delay: -4s; }
.b3 { width: 300px; height: 300px; background: var(--grad3); bottom: -70px; left: 25%; animation-delay: -8s; }
.b4 { width: 260px; height: 260px; background: var(--grad4); top: 45%; left: 45%; animation-delay: -12s; }
@keyframes float {
    0%, 100% { transform: translate(0,0) scale(1); }
    33% { transform: translate(40px,-50px) scale(1.1); }
    66% { transform: translate(-30px,40px) scale(0.95); }
}

/* ===== HERO ===== */
.hero {
    text-align: center;
    padding: 30px 20px 22px;
    animation: fadeDown 0.8s ease both;
}
.badge {
    display: inline-block;
    background: rgba(124,92,255,0.12);
    color: var(--grad1);
    font-weight: 600;
    font-size: 0.82rem;
    padding: 7px 16px;
    border-radius: 999px;
    margin-bottom: 14px;
    border: 1px solid rgba(124,92,255,0.25);
}
.title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(2.4rem, 6vw, 4rem);
    font-weight: 700;
    letter-spacing: -2px;
}
.grad {
    background: linear-gradient(120deg, var(--grad1), var(--grad2), var(--grad3));
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shine 4s linear infinite;
}
@keyframes shine { to { background-position: 200% center; } }
.subtitle {
    max-width: 560px;
    margin: 12px auto 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.55;
}
@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== CONTAINER (single column, compact) ===== */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 20px 30px;
}

.card {
    position: relative;
    background: var(--card);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
    overflow: hidden;
    animation: fadeUp 0.8s ease both;
}
.card-glow {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--grad1), var(--grad2), var(--grad3), var(--grad4));
    background-size: 300% auto;
    animation: shine 5s linear infinite;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== GRID FIELDS (2 kolom ringkas) ===== */
.grid-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
    margin-bottom: 16px;
}
@media (max-width: 560px) {
    .grid-fields { grid-template-columns: 1fr; }
}

.field { margin-bottom: 16px; }
.field > label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 7px;
}
.hint { font-weight: 400; color: var(--muted); font-size: 0.78rem; }

/* ===== SELECT ===== */
select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: #fafbff;
    color: var(--ink);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%237c5cff' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    transition: border 0.2s, box-shadow 0.2s;
}
select:focus {
    outline: none;
    border-color: var(--grad1);
    box-shadow: 0 0 0 4px rgba(124,92,255,0.12);
}

/* ===== COLLAPSIBLE INSTRUMEN ===== */
.collapse-head {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: #fafbff;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ink);
    cursor: pointer;
    transition: all 0.2s;
}
.collapse-head:hover { border-color: var(--grad1); }
.collapse-head .arrow { transition: transform 0.3s; color: var(--grad1); }
.collapse-head.open .arrow { transform: rotate(180deg); }
.pick-count {
    color: var(--grad1);
    font-size: 0.78rem;
    font-weight: 600;
}
.collapse-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 4px;
}
.collapse-body.open {
    max-height: 320px;
    padding: 14px 4px 4px;
    overflow-y: auto;
}

/* ===== CHIPS (instrumen) ===== */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
    padding: 7px 13px;
    border-radius: 999px;
    background: #f1f3fb;
    border: 1.5px solid transparent;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.chip:hover { transform: translateY(-2px); background: #e8ebfa; }
.chip.active {
    background: linear-gradient(120deg, var(--grad1), var(--grad2));
    color: #fff;
    box-shadow: 0 6px 14px rgba(124,92,255,0.35);
}

/* ===== TEXTAREA ===== */
textarea {
    width: 100%;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    background: #fafbff;
    color: var(--ink);
    transition: border 0.2s, box-shadow 0.2s;
}
textarea:focus {
    outline: none;
    border-color: var(--grad1);
    box-shadow: 0 0 0 4px rgba(124,92,255,0.12);
}
.counter { text-align: right; font-size: 0.74rem; color: var(--muted); margin-top: 5px; }

/* ===== BOTTOM ROW (toggle + generate sejajar) ===== */
.bottom-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}
.switch-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 0.85rem;
    white-space: nowrap;
}
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #d7dcf0; border-radius: 999px; transition: 0.3s;
}
.slider::before {
    content: ''; position: absolute;
    height: 20px; width: 20px; left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%; transition: 0.3s;
}
.switch input:checked + .slider { background: linear-gradient(120deg, var(--grad1), var(--grad2)); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.btn-generate {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(120deg, var(--grad1), var(--grad2), var(--grad3));
    background-size: 200% auto;
    color: #fff;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.02rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 12px 28px rgba(124,92,255,0.4);
}
.btn-generate:hover {
    background-position: right center;
    transform: translateY(-3px);
    box-shadow: 0 16px 36px rgba(124,92,255,0.5);
}
.btn-generate:active { transform: translateY(-1px); }
.btn-generate:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-loader {
    display: inline-block;
    width: 20px; height: 20px;
    border: 3px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}
.btn-loader[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26,31,54,0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 200;
    animation: overlayIn 0.3s ease both;
}
.modal-overlay[hidden] { display: none; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    position: relative;
    background: var(--card);
    border-radius: var(--radius);
    padding: 30px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 30px 70px rgba(0,0,0,0.3);
    animation: modalIn 0.4s cubic-bezier(0.2,0.9,0.3,1.2) both;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(40px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
    position: absolute;
    top: 18px; right: 18px;
    width: 34px; height: 34px;
    border: none;
    border-radius: 50%;
    background: #f1f3fb;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}
.modal-close:hover { background: var(--grad2); color: #fff; transform: rotate(90deg); }
.modal-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.4rem;
    margin-bottom: 22px;
}

.result-block { margin-bottom: 18px; animation: fadeUp 0.4s ease both; }
.result-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.result-label { font-weight: 600; font-size: 0.88rem; }
.result-box {
    background: #f7f9ff;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: 13px 15px;
    font-size: 0.92rem;
    line-height: 1.6;
    word-wrap: break-word;
}
.result-box.lyrics {
    white-space: pre-wrap;
    max-height: 280px;
    overflow-y: auto;
    font-family: 'Poppins', sans-serif;
}
.btn-copy {
    background: rgba(124,92,255,0.1);
    color: var(--grad1);
    border: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-copy:hover { background: var(--grad1); color: #fff; }
.btn-copy.copied { background: #2ecc71; color: #fff; }
.btn-copy-all {
    width: 100%;
    margin-top: 8px;
    padding: 14px;
    border: 2px dashed var(--grad1);
    background: transparent;
    color: var(--grad1);
    border-radius: 14px;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-copy-all:hover { background: rgba(124,92,255,0.08); }

/* ===== ERROR (inline di modal area / toast) ===== */
.error-state {
    background: #fff0f3;
    border: 1.5px solid #ffccd5;
    color: #c9184a;
    padding: 14px;
    border-radius: 12px;
    font-size: 0.88rem;
    margin-bottom: 16px;
}

/* ===== FOOTER ===== */
.footer { text-align: center; padding: 30px 20px; color: var(--muted); font-size: 0.85rem; }
.footer strong { color: var(--grad1); }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--ink);
    color: #fff;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.2,0.8,0.2,1);
    z-index: 300;
    pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ===== RESPONSIVE / PRESISI MOBILE ===== */
@media (max-width: 600px) {
    .hero { padding: 34px 18px 18px; }
    .container { padding: 12px 16px 24px; }
    .card { padding: 22px 18px; border-radius: 18px; }

    .bottom-row {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }
    .switch-wrap { justify-content: center; }
    .btn-generate { width: 100%; }

    .modal { padding: 24px 20px; border-radius: 18px; max-height: 88vh; }
    .modal-title { font-size: 1.25rem; }
    .result-box { font-size: 0.9rem; }
    .toast { left: 16px; right: 16px; transform: translateY(100px); width: auto; }
    .toast.show { transform: translateY(0); }
}

@media (max-width: 380px) {
    .title { font-size: 2.1rem; }
    .chip { font-size: 0.78rem; padding: 6px 11px; }
}

/* ===== HOVER HANYA DI PERANGKAT YANG MENDUKUNG (anti macet di mobile) ===== */
@media (hover: none) {
    .chip:hover { transform: none; background: #f1f3fb; }
    .btn-generate:hover { transform: none; }
}

/* ===== NAVBAR + BRAND ===== */
.navbar {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 24px 0;
    display: flex;
    justify-content: center;
    animation: fadeDown 0.7s ease both;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
}
.brand-logo {
    display: inline-flex;
    filter: drop-shadow(0 6px 14px rgba(124,92,255,0.45));
    animation: bob 3.5s ease-in-out infinite;
}
@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
.brand-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: 0.5px;
    color: var(--ink);
}

/* ===== TOMBOL KONVERSI JUDUL ===== */
.btn-convert {
    width: 100%;
    margin-top: 10px;
    padding: 11px;
    border: 1.5px solid var(--grad3);
    border-radius: 12px;
    background: rgba(33,212,253,0.08);
    color: #0a8fb5;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-convert:hover { background: rgba(33,212,253,0.18); }
.btn-convert:disabled { opacity: 0.6; cursor: not-allowed; }
.conv-loader {
    display: inline-block;
    width: 15px; height: 15px;
    border: 2.5px solid rgba(10,143,181,0.3);
    border-top-color: #0a8fb5;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}
.result-sub { margin-top: 12px; margin-bottom: 0; }

/* ===== RIWAYAT ===== */
.history-card { margin-top: 22px; }
.history-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.history-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.15rem;
}
.btn-clear {
    background: rgba(201,24,74,0.08);
    color: #c9184a;
    border: none;
    padding: 7px 14px;
    border-radius: 9px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-clear:hover { background: #c9184a; color: #fff; }
.history-note {
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 14px;
}
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #f7f9ff;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    animation: fadeUp 0.35s ease both;
}
.history-item:hover {
    border-color: var(--grad1);
    transform: translateX(3px);
    box-shadow: 0 6px 16px rgba(124,92,255,0.12);
}
.history-info { min-width: 0; }
.history-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-item-meta {
    font-size: 0.76rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.history-time {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
}
