:root {
    --bg: #050506;
    --sidebar: #101014;
    --panel: #17171c;
    --panel-soft: #202026;
    --line: rgba(255, 255, 255, 0.09);
    --text: #f5f5f7;
    --muted: #a1a1aa;
    --subtle: #6f6f7a;
    --accent: #fa233b;
    --accent-strong: #ff375f;
    --danger: #ff453a;
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, sans-serif;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

button,
textarea,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: wait;
    opacity: 0.7;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
    width: 100%;
}

.sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 28px 18px;
}

.brand {
    align-items: center;
    display: flex;
    gap: 12px;
    padding: 0 8px;
}

.brand-mark {
    align-items: center;
    background: var(--accent);
    border-radius: 8px;
    color: #fff;
    display: flex;
    height: 38px;
    justify-content: center;
    width: 38px;
}

.brand strong,
.brand span {
    display: block;
}

.brand span {
    color: var(--muted);
    font-size: 0.82rem;
    margin-top: 2px;
}

.side-nav {
    display: grid;
    gap: 4px;
}

.nav-item {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--muted);
    display: flex;
    gap: 12px;
    padding: 11px 12px;
    text-align: left;
    min-width: 0;
}

.nav-item.active,
.nav-item:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text);
}

.library-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 5px;
    margin-top: auto;
    padding: 14px;
}

.auth-card,
.metrics-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    padding: 14px;
}

.auth-card strong {
    font-size: 0.9rem;
}

.auth-card input {
    background: #0b0b0e;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    min-height: 36px;
    padding: 0 10px;
    width: 100%;
}

.auth-actions,
.otp-row {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
}

.auth-card button,
.metrics-card button {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    font-weight: 800;
    min-height: 34px;
}

.otp-row {
    display: none;
}

.metrics-card div {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.metrics-card span {
    color: var(--muted);
    font-size: 0.78rem;
}

.library-card span,
.library-card small {
    color: var(--muted);
    font-size: 0.78rem;
}

.workspace {
    min-width: 0;
    padding: 34px clamp(22px, 4vw, 56px) 56px;
}

.topbar {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 26px;
    min-width: 0;
}

.topbar p,
.panel-heading p {
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin: 0 0 5px;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    letter-spacing: 0;
    margin: 0;
}

h1 {
    font-size: clamp(2rem, 4vw, 3.4rem);
    font-weight: 800;
    line-height: 1.04;
}

h2 {
    font-size: clamp(1.55rem, 3vw, 2.3rem);
    line-height: 1.12;
}

h3 {
    font-size: 1rem;
}

.stepper {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.stepper::-webkit-scrollbar {
    display: none;
}

.step-pill {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
    padding: 9px 15px;
    white-space: nowrap;
}

.step-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.studio-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: none;
    padding: clamp(20px, 3vw, 32px);
    min-width: 0;
}

.studio-panel.active-section {
    display: block;
}

.panel-heading {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.conversation-layout,
.lyrics-layout {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) 320px;
    min-width: 0;
}

.chat-column,
.lyrics-editor-wrap,
.details-panel,
.revision-panel,
.production-state,
.result-area {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.chat-column,
.details-panel,
.revision-panel,
.production-state,
.result-area {
    padding: 18px;
}

.chat-window {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 430px;
    min-height: 300px;
    overflow-y: auto;
    padding: 2px 2px 16px;
}

.chat-bubble {
    border-radius: 18px;
    font-size: 0.96rem;
    line-height: 1.48;
    max-width: min(76%, 620px);
    padding: 12px 15px;
    white-space: pre-wrap;
}

.ai-bubble {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.user-bubble {
    align-self: flex-end;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text);
}

.chat-input-area {
    align-items: flex-end;
    background: #111115;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 10px;
    padding: 10px;
}

textarea {
    background: transparent;
    border: 0;
    color: var(--text);
    outline: none;
    resize: none;
    width: 100%;
}

#story {
    height: 64px;
}

#lyrics-editor {
    display: block;
    min-height: 420px;
    height: min(590px, 62vh);
    line-height: 1.72;
    padding: 22px;
}

#lyric-feedback {
    background: #111115;
    border: 1px solid var(--line);
    border-radius: 8px;
    height: 210px;
    line-height: 1.5;
    margin: 16px 0;
    padding: 14px;
}

.send-button,
.icon-button {
    align-items: center;
    background: var(--accent);
    border: 0;
    border-radius: 999px;
    color: white;
    display: inline-flex;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.icon-button {
    background: rgba(255, 255, 255, 0.08);
}

.input-action {
    flex: 0 0 auto;
}

.icon-button.active {
    background: var(--danger);
}

.primary-button,
.secondary-button,
.ghost-button {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-weight: 800;
    gap: 8px;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    text-align: center;
}

.primary-button {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: white;
}

.secondary-button,
.ghost-button {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
}

.wide {
    margin-top: 14px;
    width: 100%;
}

.details-panel,
.revision-panel {
    align-content: start;
    display: grid;
}

.detail-row {
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 15px 0;
    min-width: 0;
}

.detail-row span,
.lyrics-count {
    color: var(--muted);
    font-size: 0.84rem;
}

.detail-row strong {
    font-size: 0.9rem;
    text-align: right;
    word-break: break-word;
}

.lyrics-count {
    border-top: 1px solid var(--line);
    padding: 10px 16px;
    text-align: right;
}

.lyrics-count.warning {
    color: var(--danger);
}

.production-button {
    display: none;
}

.progress-container {
    display: none;
}

.progress-copy {
    align-items: center;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.progress-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}

.progress-bar {
    background: var(--accent);
    height: 100%;
    transition: width 0.5s ease;
    width: 0;
}

.result-area {
    display: none;
    margin-top: 18px;
}

.audio-variations {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.audio-variation {
    background: #111115;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.audio-variation-header {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 10px;
    min-width: 0;
}

.audio-variation-title {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    min-width: 0;
}

.download-button {
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    display: inline-flex;
    font-size: 0.84rem;
    font-weight: 800;
    gap: 8px;
    min-height: 34px;
    padding: 0 12px;
    text-decoration: none;
    white-space: nowrap;
}

.download-button:hover {
    background: rgba(255, 255, 255, 0.13);
}

.audio-variation audio {
    width: 100%;
}

.hidden-fields {
    display: none;
}

@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 232px minmax(0, 1fr);
    }

    .conversation-layout,
    .lyrics-layout {
        grid-template-columns: minmax(0, 1fr) 280px;
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        align-items: stretch;
        border-bottom: 1px solid var(--line);
        border-right: 0;
        display: grid;
        gap: 14px;
        grid-template-columns: 1fr 1fr;
        padding: 18px;
    }

    .brand,
    .side-nav,
    .library-card {
        grid-column: 1 / -1;
    }

    .side-nav {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .nav-item {
        justify-content: center;
        text-align: center;
    }

    .auth-card,
    .metrics-card {
        min-width: 0;
    }

    .conversation-layout,
    .lyrics-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .sidebar {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .workspace {
        padding: 22px 14px 34px;
    }

    .topbar,
    .panel-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
    }

    .topbar {
        margin-bottom: 18px;
    }

    .side-nav {
        display: flex;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .side-nav::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        flex: 0 0 auto;
        min-height: 42px;
        padding: 10px 12px;
    }

    .studio-panel {
        padding: 14px;
    }

    .chat-column,
    .details-panel,
    .revision-panel,
    .production-state,
    .result-area {
        padding: 14px;
    }

    .chat-window {
        height: min(54vh, 390px);
        min-height: 280px;
    }

    .chat-bubble {
        max-width: 92%;
    }

    .chat-input-area {
        gap: 8px;
        padding: 8px;
    }

    #story {
        height: 72px;
    }

    #lyrics-editor {
        height: min(56vh, 480px);
        min-height: 340px;
        padding: 16px;
    }

    #lyric-feedback {
        height: 160px;
    }

    .audio-variation-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 430px) {
    .brand {
        padding: 0;
    }

    h1 {
        font-size: 1.9rem;
    }

    .auth-actions,
    .otp-row {
        grid-template-columns: 1fr;
    }

    .step-pill {
        padding-inline: 12px;
    }

    .send-button,
    .icon-button {
        height: 40px;
        width: 40px;
    }

    .primary-button,
    .secondary-button,
    .ghost-button {
        width: 100%;
    }

    .detail-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .detail-row strong {
        text-align: left;
    }
}
