:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --primary: #1a5f4a;
    --primary-light: #e8f5f0;
    --accent: #2d8a6e;
    --warn: #c47a1a;
    --danger: #c0392b;
    --border: #dce3ea;
    --text: #1e2a32;
    --muted: #6b7c87;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

header {
    background: var(--primary);
    color: #fff;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow);
}
header h1 { font-size: 1.35rem; font-weight: 600; }
.subtitle { font-size: .9rem; opacity: .9; margin-top: .2rem; }

.layout {
    display: flex;
    min-height: calc(100vh - 70px);
}

/* Sidebar */
#sidebar {
    width: 280px;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: 1rem;
    overflow-y: auto;
    flex-shrink: 0;
}
#sidebar h2 { font-size: 1rem; color: var(--muted); margin-bottom: .75rem; text-transform: uppercase; letter-spacing: .04em; }

.block-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: .7rem .85rem;
    margin-bottom: .4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
    transition: all .15s;
}
.block-item:hover { border-color: var(--accent); background: var(--primary-light); }
.block-item.active { border-color: var(--primary); background: var(--primary-light); box-shadow: inset 3px 0 0 var(--primary); }
.block-item .name { font-weight: 600; font-size: .95rem; }
.block-item .meta { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.block-item .diff-ok { color: #1a7a4c; }
.block-item .diff-bad { color: var(--danger); font-weight: 600; }

.sidebar-footer { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.hint { font-size: .8rem; color: var(--muted); }

/* Main */
#main {
    flex: 1;
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
}

#block-header { margin-bottom: 1.25rem; }
#block-header h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.block-stats {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem 1.25rem;
    align-items: center;
    font-size: .9rem;
    background: var(--card);
    padding: .65rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.block-stats .diff-ok { color: #1a7a4c; }
.block-stats .diff-bad { color: var(--danger); }

.placeholder { color: var(--muted); padding: 2rem; text-align: center; }

/* Question card + drag */
.q-sortable { display: flex; flex-direction: column; gap: 0; }

.q-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .85rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow .15s, opacity .15s, border-color .15s;
}
.q-card.dragging { opacity: .55; border-color: var(--accent); }
.q-card.drag-over { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

.q-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .7rem .9rem;
    background: #f8fafb;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.drag-handle {
    cursor: grab;
    color: var(--muted);
    font-size: 1.1rem;
    user-select: none;
    padding: 0 .2rem;
    line-height: 1;
}
.drag-handle:active { cursor: grabbing; }

.q-title {
    font-weight: 600;
    font-size: .95rem;
    flex: 1;
    min-width: 180px;
    outline: none;
    padding: .2rem .3rem;
    border-radius: 4px;
}
.q-title:focus { background: #fff; box-shadow: 0 0 0 2px var(--accent); }

.q-type {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: .15rem .45rem;
    border-radius: 4px;
    background: #e8eef3;
    color: var(--muted);
    white-space: nowrap;
}
.q-type.multi { background: #e8f0e8; color: #2d6a3e; }
.q-type.text { background: #f0e8e8; color: #6a2d2d; }

.q-max-group {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .82rem;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: .2rem .45rem;
}
.q-max-group label { white-space: nowrap; }
.q-max-points {
    width: 64px;
    border: none;
    text-align: right;
    font-weight: 700;
    font-size: .9rem;
    color: var(--primary);
    outline: none;
}

.q-notes { font-size: .8rem; color: var(--muted); padding: .35rem 1rem; font-style: italic; }

/* Answers */
.answers-list { padding: .4rem 1rem 1rem; }

.answers-header {
    display: grid;
    grid-template-columns: 1fr 90px 70px 70px;
    gap: .5rem;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
    padding: .3rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: .3rem;
}
.answers-header .col-pct { text-align: center; }
.answers-header .col-pts { text-align: right; }

.answer-row {
    display: grid;
    grid-template-columns: 1fr 90px 50px 20px 70px;
    gap: .4rem;
    align-items: center;
    padding: .35rem 0;
    border-bottom: 1px solid #f0f3f5;
}
.answer-row:last-of-type { border-bottom: none; }

.answer-text {
    border: 1px solid transparent;
    background: transparent;
    padding: .3rem .4rem;
    border-radius: 4px;
    font-size: .9rem;
    width: 100%;
}
.answer-text:focus { border-color: var(--accent); background: #fff; outline: none; }

.pct-group {
    display: flex;
    align-items: center;
    gap: 2px;
}
.answer-pct, .new-a-pct {
    width: 62px;
    text-align: right;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: .3rem .35rem;
    font-size: .9rem;
    font-weight: 600;
}
.answer-pct:focus, .new-a-pct:focus { border-color: var(--accent); outline: none; }
.pct-symbol { font-size: .8rem; color: var(--muted); }

.pts-display {
    text-align: right;
    font-weight: 700;
    font-size: .9rem;
    color: var(--primary);
}
.pts-label { font-size: .75rem; color: var(--muted); }

.a-actions, .q-actions { display: flex; gap: .3rem; flex-shrink: 0; }

.no-answers { color: var(--muted); font-size: .85rem; padding: .4rem 0; }

.add-answer-row {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-top: .55rem;
    padding-top: .5rem;
    border-top: 1px dashed var(--border);
}
.add-answer-row .new-a-text {
    flex: 1;
    padding: .35rem .5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: .9rem;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 5px;
    padding: .4rem .75rem;
    font-size: .85rem;
    cursor: pointer;
    font-weight: 500;
    transition: background .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--accent); }
.btn-warn { background: #f5e6d0; color: var(--warn); }
.btn-warn:hover { background: #edd9b8; }
.btn-danger { background: #fdecea; color: var(--danger); }
.btn-danger:hover { background: #f9d6d2; }
.btn-sm { padding: .25rem .5rem; font-size: .78rem; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f0f3f5; }

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1.25rem;
}
.panel h3 { font-size: .95rem; margin-bottom: .6rem; }
.form-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.form-row input, .form-row select {
    padding: .45rem .6rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: .9rem;
}
.form-row input[type="number"] { width: 80px; }

.hidden { display: none !important; }

.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #1e2a32;
    color: #fff;
    padding: .7rem 1.2rem;
    border-radius: var(--radius);
    font-size: .9rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    z-index: 100;
    transition: opacity .3s;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--primary); }

@media (max-width: 900px) {
    .layout { flex-direction: column; }
    #sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
    .answer-row, .answers-header {
        grid-template-columns: 1fr 80px 45px 18px 60px;
    }
}
