:root {
    --primary-color: #2c3e50;
    --secondary-color: #2E86AB;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --light-bg: #f0f5f7;
    --card-bg: #ffffff;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #d0dde5;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);

    /* Role type colors */
    --color-teacher:  #2E86AB;
    --color-tutor:    #A23B72;
    --color-peer:     #F18F01;
    --color-narrator: #C73E1D;
    --color-expert:   #3B1F2B;
    --color-challenger: #44BBA4;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-dark);
    line-height: 1.6;
}

/* ── Header ─────────────────────────────────────────── */
header {
    background: linear-gradient(135deg, #2c3e50 0%, #2E86AB 100%);
    color: white;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}
header h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.subtitle { font-size: 1.1rem; opacity: 0.9; }

/* ── Design Principles Banner ───────────────────────── */
.ideology-banner {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #d8e8f0;
    padding: 1.5rem 2rem;
}
.ideology-content {
    max-width: 1600px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}
.ideology-principle {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}
.ideology-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}
.ideology-principle strong {
    color: #7ec8e3;
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}
.ideology-principle p {
    font-size: 0.85rem;
    line-height: 1.5;
    opacity: 0.9;
}
.ideology-principle em {
    color: #a0d8f0;
    font-style: normal;
    font-weight: 600;
}

/* ── Main Layout ────────────────────────────────────── */
main {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    max-width: 1600px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* ── Filters Sidebar ────────────────────────────────── */
.filters {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 2rem;
}
.claude-skill-btn {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}
.claude-skill-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102,126,234,0.4);
}
.filters h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}
.filter-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.filter-section:last-of-type { border-bottom: none; }
.filter-section h3 {
    font-size: 1rem;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
    font-weight: 600;
}
.filter-section h3 small {
    font-weight: 400;
    color: var(--text-light);
}
.filter-section label {
    display: block;
    margin-bottom: 0.5rem;
    cursor: pointer;
    user-select: none;
}
.filter-section input[type="checkbox"] { margin-right: 0.5rem; }
.filter-section select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}
#searchInput {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}
#searchInput:focus {
    outline: none;
    border-color: var(--secondary-color);
}
.filter-actions { margin-top: 1rem; }
#resetFilters {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--text-light);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}
#resetFilters:hover { background-color: var(--primary-color); }
.stats {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}
.stats span {
    font-weight: 600;
    color: var(--secondary-color);
}

/* ── Grid Area ──────────────────────────────────────── */
.cards-grid {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.view-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}
.sort-controls label { margin-right: 0.5rem; font-weight: 600; }
.sort-controls select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}
.view-toggle button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: white;
    cursor: pointer;
    transition: all 0.3s;
}
.view-toggle button:first-child { border-radius: 4px 0 0 4px; }
.view-toggle button:last-child { border-radius: 0 4px 4px 0; border-left: none; }
.view-toggle button.active {
    background-color: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}
.view-toggle button:hover:not(.active) { background-color: var(--light-bg); }

/* ── Card Layouts ───────────────────────────────────── */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}
.list-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ── Character Card ─────────────────────────────────── */
.char-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow);
    border-left: 4px solid #ccc;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}
.char-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--secondary-color);
}

/* Portrait */
.char-portrait {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    flex-shrink: 0;
    background-color: #e8eef2;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #b0bec5;
    overflow: hidden;
    border: 2px solid #d0dde5;
}
.char-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.char-portrait .placeholder-icon {
    font-size: 2.2rem;
    opacity: 0.6;
}

.char-card-body { flex: 1; min-width: 0; }
.char-card-body h3 {
    color: var(--primary-color);
    margin-bottom: 0.3rem;
    font-size: 1.1rem;
}
.char-card-body .logline {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 0.6rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-style: italic;
}
.char-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}
.badge {
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}
.badge.role-teacher       { background: #2E86AB22; color: #2E86AB; border: 1px solid #2E86AB44; }
.badge.role-tutor         { background: #A23B7222; color: #A23B72; border: 1px solid #A23B7244; }
.badge.role-peer          { background: #F18F0122; color: #c57400; border: 1px solid #F18F0144; }
.badge.role-narrator      { background: #C73E1D22; color: #C73E1D; border: 1px solid #C73E1D44; }
.badge.role-domain-expert { background: #3B1F2B22; color: #3B1F2B; border: 1px solid #3B1F2B44; }
.badge.role-challenger    { background: #44BBA422; color: #2a8a77; border: 1px solid #44BBA444; }
.badge.grade              { background-color: #d1ecf1; color: #0c5460; }
.badge.specificity        { background-color: #e7e7f1; color: #383d75; }
.badge.mistake            { background-color: #fff3cd; color: #856404; }
.badge.seed               { background-color: #ffeaa7; color: #6c5200; border: 1px solid #d4ac0d; }

.char-traits {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}
.char-traits strong { color: var(--text-dark); }

/* Role-type left border colors */
.char-card[data-role="Teacher"]       { border-left-color: var(--color-teacher); }
.char-card[data-role="Tutor"]         { border-left-color: var(--color-tutor); }
.char-card[data-role="Peer"]          { border-left-color: var(--color-peer); }
.char-card[data-role="Narrator"]      { border-left-color: var(--color-narrator); }
.char-card[data-role="Domain Expert"] { border-left-color: var(--color-expert); }
.char-card[data-role="Challenger"]    { border-left-color: var(--color-challenger); }

/* List view */
.list-layout .char-card {
    flex-direction: row;
    align-items: flex-start;
}

/* ── Modal ──────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    animation: fadeIn 0.3s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background-color: var(--card-bg);
    margin: 3% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 1000px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
    animation: slideDown 0.3s;
}
@keyframes slideDown {
    from { transform: translateY(-50px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

.close, .close-skill {
    color: var(--text-light);
    float: right;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}
.close:hover, .close-skill:hover { color: var(--accent-color); }

/* Modal header with portrait */
.modal-header {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}
.modal-portrait {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    flex-shrink: 0;
    background-color: #e8eef2;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #b0bec5;
    overflow: hidden;
    border: 3px solid #d0dde5;
}
.modal-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.modal-header-text { flex: 1; }
.modal-header-text h2 {
    color: var(--primary-color);
    margin-bottom: 0.3rem;
    font-size: 1.8rem;
}
.modal-header-text .modal-logline {
    font-style: italic;
    color: var(--text-light);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.modal-section {
    margin-bottom: 1.5rem;
}
.modal-section h3 {
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}
.modal-section p,
.modal-section ul {
    color: var(--text-dark);
    line-height: 1.8;
}
.modal-section ul { margin-left: 1.5rem; }
.modal-section ul li { margin-bottom: 0.4rem; }

/* Personality dimensions */
.personality-bars {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 0.75rem;
}
.dim-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.dim-label {
    width: 80px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
}
.dim-bar {
    flex: 1;
    height: 8px;
    background: #e8eef2;
    border-radius: 4px;
    overflow: hidden;
}
.dim-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}
.dim-value {
    width: 20px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
}

/* Sample dialogue */
.dialogue-block {
    background: #f8f9fa;
    border-left: 3px solid var(--secondary-color);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    border-radius: 0 4px 4px 0;
    font-style: italic;
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
}
.dialogue-label {
    font-style: normal;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--secondary-color);
    margin-bottom: 0.25rem;
    letter-spacing: 0.5px;
}

/* Visual profile in modal */
.visual-profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 2rem;
    font-size: 0.9rem;
}
.visual-field {
    padding: 0.3rem 0;
}
.visual-field strong {
    color: var(--text-dark);
    display: inline;
}

/* Image gen prompt box */
.image-prompt-box {
    background: #f0f5f7;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #444;
    margin-top: 0.75rem;
    position: relative;
}
.image-prompt-box .copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
}
.image-prompt-box .copy-btn:hover {
    background: var(--secondary-color);
    color: white;
}

/* Skill modal */
#skillModalBody h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}
#skillModalBody .modal-section { margin-bottom: 1.5rem; }
#skillModalBody ul { margin-left: 1.5rem; }
#skillModalBody li { margin-bottom: 0.4rem; }
.example-prompts {
    color: #666;
    font-style: italic;
    line-height: 2;
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 1024px) {
    main { grid-template-columns: 250px 1fr; gap: 1.5rem; }
    .ideology-content { grid-template-columns: 1fr; gap: 1rem; }
    .personality-bars { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    main { grid-template-columns: 1fr; }
    .filters { position: relative; top: 0; }
    .grid-layout { grid-template-columns: 1fr; }
    .modal-header { flex-direction: column; align-items: center; text-align: center; }
    .modal-content { width: 95%; margin: 2% auto; padding: 1.5rem; }
    .ideology-content { grid-template-columns: 1fr; }
    header h1 { font-size: 2rem; }
    .visual-profile-grid { grid-template-columns: 1fr; }
}
