/* ---------- Theme tokens ---------- */
:root {
    --bg: #0b0d10;
    --surface: #12161a;
    --elev: #181d22;
    --text: #e8eef4;
    --muted: #9fb0bf;
    --border: #26313b;
    --primary: #4ea8ff;
    /* azul Pro-ish */
    --danger: #ff6b6b;
    --success: #4dd4a3;
    --shadow: 0 4px 16px rgba(0, 0, 0, .35);
    --radius: 12px;
    --radius-sm: 10px;
    --radius-lg: 16px;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f6f8fb;
        --surface: #ffffff;
        --elev: #ffffff;
        --text: #0b1220;
        --muted: #5b6b7a;
        --border: #e4e9ef;
        --primary: #1570ef;
        /* azul más intenso en claro */
        --shadow: 0 8px 24px rgba(16, 24, 40, .08);
    }
}

/* ---------- Reset suave ---------- */
* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

html {
    scroll-behavior: smooth
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Layout ---------- */
header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0) 0%, var(--bg) 60%);
    border-bottom: 1px solid var(--border);
}

header h1 {
    margin: 0;
    font-size: 18px;
    letter-spacing: .2px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

#logo {
    height: 28px;
    width: auto;
    display: block
}

.actions {
    display: flex;
    align-items: center;
    gap: 8px
}

.user {
    color: var(--muted);
    font-size: 13px
}

main {
    display: block !important;
    grid-template-columns: 360px 1fr;
    /* sidebar + contenido */
    gap: 16px;
    padding: 16px clamp(16px, 4vw, 40px);
    /* gutters fluidos */
    width: 100%;
    max-width: 100%;
    /* sin límite fijo */
    margin: 0 auto;
}

aside {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 60vh;
}

aside>header,
section>header {
    padding: 12px 14px;
    font-weight: 600;
    letter-spacing: .2px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(0deg, var(--elev), var(--surface));
}

section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ---------- Pills & small UI ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(78, 168, 255, .12);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
}

.pill.negative {
    background: rgba(255, 107, 107, 0.18);
    color: #ff6b6b;
}

/* ---------- Lists (left column & editor lists) ---------- */
.list {
    padding: 8px;
    overflow: auto;
    max-height: calc(100vh - 220px);
}

.list .item,
.list .doc-row,
.list .qe-item {
    background: var(--elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin: 8px 0;
    transition: transform .08s ease, box-shadow .2s ease, border-color .2s ease;
}

.list .item:hover,
.list .doc-row:hover,
.list .qe-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, .25);
    border-color: color-mix(in oklab, var(--primary) 30%, var(--border));
}

.item .title,
.item .pill {
    display: inline-block;
    margin-bottom: 10px;
}

.doc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px
}

.doc-row .meta {
    display: flex;
    flex-direction: column;
    gap: 4px
}

.doc-row .title {
    font-weight: 600
}

.doc-row .subtitle {
    color: var(--muted);
    font-size: 12px
}

/* ---------- Form ---------- */
.form {
    padding: 14px
}

.grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid .full {
    grid-column: 1 / -1
}

.grid .row {
    display: flex;
    gap: 14px;
    align-items: flex-end
}

label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px
}

.hint {
    color: var(--muted);
    font-size: 12px
}

input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    color: var(--text);
    background: var(--elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.4
}

input::placeholder,
textarea::placeholder {
    color: color-mix(in oklab, var(--muted) 70%, transparent)
}

input:focus,
select:focus,
textarea:focus {
    border-color: color-mix(in oklab, var(--primary) 50%, var(--border));
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--primary) 14%, transparent);
}

/* Boolean + required */
.qe-required {
    transform: translateY(1px)
}

/* Question item grid */
.qe-item {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 180px;
}

.qe-item .qe-options-wrap {
    grid-column: 1 / -1
}

.qe-item .btn.danger {
    align-self: flex-end
}

/* ---------- Buttons ---------- */
.btn,
button,
.primary,
.danger {
    appearance: none;
    border: none;
    cursor: pointer;
    height: 36px;
    padding: 0 14px;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: .2px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform .06s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
}

.btn {
    background: var(--elev);
    color: var(--text);
    border: 1px solid var(--border)
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, .25)
}

.primary {
    background: var(--primary);
    color: white
}

.primary:hover {
    filter: saturate(1.1) brightness(1.02);
    transform: translateY(-1px)
}

.danger {
    background: var(--danger);
    color: white
}

.danger:hover {
    filter: brightness(1.03);
    transform: translateY(-1px)
}

/* Toolbar under lists / editor */
.btnbar {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    padding-top: 8px;
}

/* ---------- Auth wall ---------- */
.authWall {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, rgba(0, 0, 0, .45), rgba(0, 0, 0, .65));
    backdrop-filter: blur(6px);
    z-index: 1000;
}

.authWall>div {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    min-width: 320px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow);
    margin: auto;
}

/* ---------- Helpers ---------- */
hr {
    border: 0;
    height: 1px;
    background: var(--border)
}

.kv {
    display: flex;
    gap: 10px;
    align-items: center
}

.kv .k {
    color: var(--muted);
    width: 120px
}

.kv .v {
    flex: 1
}

/* ---------- Scrollbar ---------- */
*::-webkit-scrollbar {
    height: 10px;
    width: 10px
}

*::-webkit-scrollbar-track {
    background: transparent
}

*::-webkit-scrollbar-thumb {
    background: color-mix(in oklab, var(--border) 70%, var(--text));
    border-radius: 999px;
    border: 2px solid transparent;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    main {
        grid-template-columns: 1fr;
    }

    aside {
        order: 2
    }

    section {
        order: 1
    }
}

/* Small refinements */
a {
    color: var(--primary);
    text-decoration: none
}

a:hover {
    text-decoration: underline
}

code,
pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    background: var(--elev);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 8px;
}

/* Empty states */
.empty {
    color: var(--muted);
    font-size: 14px;
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    background: var(--elev);
}

:root {
    /* …tus tokens existentes… */
    --cat-fitness: #00C853;
    --cat-nutrition: #FF9800;
    --cat-professional: #2196F3;
    --cat-finance: #00DEF5;
    --cat-skills: #AB00C8;
}

.doc-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    /* una línea */
    white-space: nowrap;
}

.doc-row .meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    /* importante para ellipsis */
    flex: 1;
    /* ocupa todo el espacio central */
}

.doc-row .title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-row .subtitle {
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-row .actions {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

/* Pill con color por categoría */
.pill[data-cat="fitness"] {
    color: var(--cat-fitness);
    background: color-mix(in oklab, var(--cat-fitness) 18%, transparent);
}

.pill[data-cat="nutrition"] {
    color: var(--cat-nutrition);
    background: color-mix(in oklab, var(--cat-nutrition) 18%, transparent);
}

.pill[data-cat="professional"] {
    color: var(--cat-professional);
    background: color-mix(in oklab, var(--cat-professional) 18%, transparent);
}

.pill[data-cat="finance"] {
    color: var(--cat-finance);
    background: color-mix(in oklab, var(--cat-finance) 18%, transparent);
}

.pill[data-cat="skills"] {
    color: var(--cat-skills);
    background: color-mix(in oklab, var(--cat-skills) 18%, transparent);
}

/* ---------- Modal dialog ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(11, 13, 16, 0.62);
    backdrop-filter: blur(2px);
    z-index: 999;
    padding: 16px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.modal p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Acento en la fila completa (un borde de 2px a la izquierda) */
.doc-row[data-cat="fitness"] {
    border-left: 2px solid var(--cat-fitness);
}

.doc-row[data-cat="nutrition"] {
    border-left: 2px solid var(--cat-nutrition);
}

.doc-row[data-cat="professional"] {
    border-left: 2px solid var(--cat-professional);
}

.doc-row[data-cat="finance"] {
    border-left: 2px solid var(--cat-finance);
}

.doc-row[data-cat="skills"] {
    border-left: 2px solid var(--cat-skills);
}

#logo {
    height: 28px;
    width: auto;
    display: block;
    filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .05));
    /* sutil */
}

header h1 {
    display: flex;
    align-items: center;
    gap: 10px;
}
