:root {
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1f2430;
    --border: #2a3040;
    --text: #e6e8ee;
    --text-dim: #9aa3b2;
    --primary: #6d5efc;
    --primary-hover: #7d70ff;
    --accent: #26d0a0;
    --danger: #f2555a;
    --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

h1 { font-size: 1.6rem; margin: 0 0 1.25rem; font-weight: 650; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; font-weight: 600; }
h3 { font-size: 1rem; margin: 0 0 .5rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }

/* ---- Layout ---- */
.page { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #14162200 0%, #0c0e14 100%), var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.25rem 1.25rem;
    font-size: 1.15rem; font-weight: 700;
    border-bottom: 1px solid var(--border);
}
.brand .logo {
    width: 28px; height: 28px; border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 15px;
}

.nav { padding: 1rem .75rem; display: flex; flex-direction: column; gap: .25rem; }
.nav a {
    display: flex; align-items: center; gap: .6rem;
    padding: .6rem .75rem; border-radius: 8px;
    color: var(--text-dim); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary); color: #fff; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 56px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: flex-end;
    padding: 0 1.5rem; gap: 1rem; color: var(--text-dim);
}
.content { padding: 1.75rem; max-width: 1100px; width: 100%; }

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }

.book-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex; flex-direction: column;
    transition: border-color .15s, transform .15s;
}
.book-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.book-cover {
    aspect-ratio: 3 / 2;
    background: linear-gradient(135deg, #262b3a, #191c26);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: var(--text-dim);
}
.book-body { padding: .9rem 1rem; flex: 1; display: flex; flex-direction: column; gap: .25rem; }
.book-title { font-weight: 650; font-size: 1rem; }
.book-author { color: var(--text-dim); font-size: .85rem; }
.book-actions { display: flex; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid var(--border); }

/* ---- Forms ---- */
label { display: block; font-size: .85rem; color: var(--text-dim); margin-bottom: .35rem; font-weight: 500; }
input[type=text], input[type=number], input[type=password], select, textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: .6rem .7rem;
    font-size: .95rem;
    font-family: inherit;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.field { margin-bottom: 1rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 160px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: .45rem;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    padding: .55rem .95rem;
    border-radius: 8px;
    font-size: .9rem; font-weight: 550;
    cursor: pointer;
    transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #04231b; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: .35rem .6rem; font-size: .8rem; }

/* ---- Misc ---- */
.badge {
    display: inline-block; padding: .2rem .55rem; border-radius: 999px;
    font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.badge-pending { background: #3a3320; color: #e5c368; }
.badge-running { background: #1f3350; color: #6db2f2; }
.badge-completed { background: #16352a; color: var(--accent); }
.badge-failed { background: #3a1e20; color: var(--danger); }
.badge-none { background: var(--surface-2); color: var(--text-dim); }

.muted { color: var(--text-dim); }
.hint { font-size: .8rem; color: var(--text-dim); margin-top: .3rem; }
.empty {
    text-align: center; padding: 3rem 1rem; color: var(--text-dim);
    border: 1px dashed var(--border); border-radius: var(--radius);
}

.progress-track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .4s; }

.dropzone {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 1.5rem; text-align: center; color: var(--text-dim);
    background: var(--surface-2);
}

.chapter-block { border: 1px solid var(--border); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; background: var(--surface); }
.chapter-head { display: flex; gap: .75rem; align-items: center; margin-bottom: .6rem; }
.chapter-head input { max-width: 320px; }

.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.spacer { flex: 1; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.tab { padding: .6rem .9rem; cursor: pointer; color: var(--text-dim); border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }
