:root {
    --bg: #1E1E2E;
    --surface: #11111B;
    --mauve: #C6A0F6;
    --blue: #89B4FA;
    --pink: #F5C2E7;
    --peach: #FAB387;
    --text: #CAD3F5;
    --subtext: #9AA4D4;
    --muted: #6E7185;
    --accent: #74C7EC; /* sapphire */
    --glass: rgba(255, 255, 255, 0.03);
    --card-shadow: 0 6px 18px var(--surface);
    --radius: .75em;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    background: linear-gradient(180deg, var(--bg) 0%, #16161D 100%);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    padding: 28px;
}

.app {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 18px;
}

.logo {
    display: flex;
    align-items: center;
    gap: .75em;
}

.logo .badge {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--mauve), var(--blue));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--surface);
    box-shadow: var(--card-shadow);
}

.controls {
    margin-left: auto;
    display: flex;
    gap: .75em;
    align-items: center;
}

.title {
    font-size: 20px;
    font-weight: 700
}

.subtitle {
    color: var(--subtext);
    font-size: 13px
}

input[type="text"], input[type="number"], select {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.03);
    padding: .5em .75em;
    border-radius: var(--radius);
    color: var(--text);
    outline: none
}

button {
    background: linear-gradient(90deg, var(--accent), var(--mauve));
    border: none;
    color: #0b0b0b;
    padding: .5em .75em;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600
}

button.ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: .5em .75em;
    border-radius: var(--radius);
    cursor: pointer
}

.layout {
    display: grid;
    grid-template-columns:360px 1fr;
    gap: 2em;
    margin-top: 2em;
}

/* Sidebar / Search */
.panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
    padding: 1em;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    height: calc(100vh - 170px);
    overflow: auto
}

.search-row {
    display: flex;
    gap: .5em
}

.search-results {
    margin-top: .75em;
    display: flex;
    flex-direction: column;
    gap: .75em;
    max-height: 60vh;
    overflow: auto;
    padding-right: 6px;
}

.result {
    display: flex;
    gap: .75em;
    align-items: center;
    padding: .5em;
    border-radius: .5em;
    background: var(--glass);
    border: 1px solid rgba(255, 255, 255, 0.02)
}

.result img {
    width: 3.5em;
    height: 5em;
    object-fit: cover;
    border-radius: .3em;
    background-color: var(--muted);
}

.result .meta {
    flex: 1;
}

.result .meta h4 {
    margin: 0;
    font-size: 14px;
}

.result .meta p {
    margin: 6px 0 0 0;
    color: var(--muted);
    font-size: .75em;
}

/* Library */
.toolbar {
    display: flex;
    gap: .5em;
    align-items: center;
    margin-bottom: 2em;
}

.library-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20em, 1fr));
    gap: .75em;
}

.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
    padding: .75em;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    display: flex;
    gap: .75em;
}

.card img {
    width: 5em;
    height: 8em;
    object-fit: cover;
    border-radius: .5em;
}

.card .info {
    flex: 1;
    min-width: 6em;
}

.card .info h3 {
    margin: 0;
    font-size: .9em;
}

.card .actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 6em;
}

.muted {
    color: var(--muted);
    font-size: .75em;
}

.progress {
    height: .5em;
    background: rgba(255, 255, 255, 0.03);
    border-radius: .5em;
    overflow: hidden;
    margin-top: .5em;
}

.progress > i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--blue));
    width: 0;
}

.small {
    font-size: .75em;
}

.modal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6));
    z-index: 60;
}

.modal.open {
    display: flex;
}

.modal .dialog {
    width: 760px;
    max-width: 95%;
    background: var(--surface);
    padding: 1em;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.flex {
    display: flex;
    gap: .75em;
}

.spaced {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

textarea {
    width: 100%;
    height: 10em;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: .5em;
    padding: .5em;
    color: var(--text);
}

footer {
    margin-top: 2em;
    color: var(--muted);
    font-size: .75em;
    text-align: center;
}

/* responsive */
@media (max-width: 880px) {
    .layout {
        grid-template-columns:1fr;
    }

    .controls {
        flex-wrap: wrap;
    }
}
