@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');

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

body {
    font-family: 'Space Mono', monospace;
    background: #000;
    color: #fff;
    overflow: hidden;
    height: 100vh;
}

.screen {
    display: none;
    width: 100%;
    height: 100vh;
    position: relative;
}

.screen.active {
    display: flex;
    animation: fadeIn 0.3s ease-in;
}
/* Global dialogue scale variable (default 1) */
:root { --dialogue-scale: 1; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Main Menu */
#main-menu {
    flex-direction: column;
    background: #000;
    position: relative;
    overflow: hidden;
}

#main-menu::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image:
        linear-gradient(to right, rgba(255,255,255,0.06) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.06) 1px, transparent 1px);
    background-size: 20px 20px;
    animation: pan-grid 60s linear infinite;
    z-index: 0;
}

#main-menu > * {
    position: relative;
    z-index: 1;
}

.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: rgba(255,255,255,0.08);
    gap: 1rem;
}
/* Chroma Awards logo in main menu header */
.chroma-logo {
    display: block;
    margin-top: 0.5rem;
    max-height: 120px;
    width: auto;
    opacity: 0.9;
}

@media (max-width: 768px) {
    .chroma-logo {
        max-height: 96px;
    }
}

.menu-title .title {
    margin: 0;
    font-size: 1.6rem;
    letter-spacing: 1px;
}

.menu-title .subtitle {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.7;
}

.menu-toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.menu-toolbar .btn {
    padding: 0.6rem 0.9rem;
    min-width: unset;
    font-size: 0.9rem;
}

.menu-content {
    flex: 1;
    display: flex;
    padding: 1rem;
    overflow: hidden;
}

.menu-roster-panel {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    padding: 0;
    display: flex;
    flex-direction: column;
}

#menu-search {
    width: 100%;
    padding: 0.9rem 1rem;
    background: #0f0f0f;
    border: 1px solid #444;
    color: #fff;
    font-family: 'Space Mono', monospace;
    margin: 0 0 0.8rem 0;
}

#menu-roster-grid {
    flex: 1;
    overflow: auto;
    padding-right: 0.3rem;
}

/* Slightly larger thumbs on the main menu for discoverability */
#menu-roster-grid .roster-thumb {
    height: 140px;
}

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

.roster-card {
    background: #111;
    border: 1px solid #2a2a2a;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s, background 0.12s;
}

.roster-card:hover {
    transform: translateY(-3px);
    border-color: #eaeaea;
    background: #171717;
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}

.roster-card.healed {
    border-color: #4CAF50;
}
/* New: locked visual state */
.roster-card.locked {
    opacity: 0.55;
    filter: grayscale(0.9);
    cursor: not-allowed;
    position: relative;
}
.roster-card.blackout .roster-thumb { filter: brightness(0); }
.roster-card.blackout .roster-bio { visibility: hidden; }
.roster-card.editable { outline: 2px dashed #6ff; }
.roster-card.editable:hover { outline-color: #fff; }
.lock-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    border: 1px solid #fff;
    font-size: 0.65rem;
    padding: 0.2rem 0.4rem;
    letter-spacing: 0.5px;
    border-radius: 3px;
    pointer-events: none;
}
/* Ensure position context for badge on roster cards */
.roster-card { position: relative; }

.roster-thumb {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid #333;
}

.roster-info {
    padding: 0.5rem;
}

.roster-name {
    font-size: 0.9rem;
    line-height: 1.2;
}

.roster-meta {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 0.2rem;
}

.roster-bio {
    font-size: 0.72rem;
    opacity: 0.8;
    margin-top: 0.3rem;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .menu-title .title { font-size: 1.3rem; }
    .menu-title .subtitle { font-size: 0.75rem; }
    .roster-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .roster-thumb { height: 100px; }
}

@keyframes pan-grid {
    0% { background-position: 0 0; }
    100% { background-position: 1200px 1200px; }
}

.title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    text-align: center;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1rem;
    margin-bottom: 3rem;
    opacity: 0.7;
    text-align: center;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn {
    border: 1px solid #111;
    border-radius: 6px;
    background: linear-gradient(#fff, #eaeaea);
    box-shadow: 0 1px 0 rgba(255,255,255,0.35) inset, 0 6px 16px rgba(0,0,0,0.25);
    padding: 1rem 2rem;
    color: #000;
    border: none;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
    transition: transform 0.1s;
    min-width: 200px;
}

.btn:hover {
    transform: scale(1.05);
}

.btn:active {
    transform: scale(0.95);
}

/* Credits Screen */
#credits {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Align content to the top */
    text-align: center;
    padding: 2rem 1rem; /* Adjust padding */
    gap: 1.5rem;
    position: relative;
}

.credits-scroll-container {
    overflow-y: auto; /* Enable scrolling on this container */
    width: 100%;
    flex-grow: 1; /* Take available space */
    padding: 0 1rem; /* Add horizontal padding for content */
    display: flex;
    flex-direction: column;
    align-items: center; /* Center the content div horizontally */
}

#credits::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1;
}

.credits-content {
    max-width: 600px;
    width: 100%; /* Ensure it takes up space in the scroll container */
    line-height: 1.8;
    position: relative;
    z-index: 2;
    padding-bottom: 2rem; /* Add padding at the bottom */
}

.credits-content h1 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: #6ff;
}

#credits-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

#credits-links a {
    color: #fff;
    text-decoration: underline;
}

.credits-subtitle {
    color: #ff6;
    font-size: 1rem;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

.credits-links-small {
    font-size: 0.8rem;
    line-height: 1.8;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem 1rem;
}

.credits-links-small a {
    color: #fff;
    text-decoration: none;
    transition: color 0.2s;
}

.credits-links-small a:hover {
    color: #6ff;
    text-decoration: underline;
}

.credits-logo {
    height: 60px;
    vertical-align: middle;
    transition: transform 0.2s;
}
.credits-logo:hover {
    transform: scale(1.1);
}
.credits-logo.large {
    height: auto;
    width: 100%;
    max-width: 350px;
}

.credits-content p {
    font-size: 0.9rem;
}

.credits-youtube-link {
    font-size: 0.8rem;
    color: #6ff;
}

.credits-toolbar {
    position: sticky;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0,0,0,0.8);
    padding: 1rem;
    z-index: 3;
    display: flex;
    justify-content: center;
    gap: 1rem;
    border-top: 1px solid #444;
}

.credits-video-wrapper {
    width: 100%;
    max-width: 560px;
    aspect-ratio: 16 / 9;
    background: #111;
    border: 1px solid #444;
    margin: 0 auto 1rem;
    border-radius: 8px;
    overflow: hidden;
}

.credits-video-wrapper iframe {
    position: static;
    width: 100%;
    height: 100%;
}

/* Community Credits */
.community-credits-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    min-height: 100px;
    padding: 1rem;
    border: 1px dashed transparent;
    transition: border-color 0.3s;
}

.community-credits-container.edit-mode {
    border-color: #555;
}

.credit-item {
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.credit-item img {
    display: block;
    width: 120px;
    height: 120px;
    object-fit: contain;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    padding: 5px;
}

.credit-item a:hover img {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(111, 255, 255, 0.5);
}

.credit-item-controls {
    position: absolute;
    top: -8px;
    right: -8px;
    display: none;
    gap: 5px;
    background: #000;
    padding: 4px;
    border-radius: 5px;
    border: 1px solid #fff;
}

.edit-mode .credit-item-controls {
    display: flex;
}

.credit-control-btn {
    background: #333;
    color: #fff;
    border: 1px solid #fff;
    cursor: pointer;
    width: 24px;
    height: 24px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.credit-control-btn:hover {
    background: #fff;
    color: #000;
}

.credit-item.dragging {
    opacity: 0.5;
    transform: scale(1.1);
}

.credits-edit-controls {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #444;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Habitat View (Journal View) */
#journal-view {
    flex-direction: column;
}

.journal-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1rem;
    overflow: hidden;
}

.journal-page {
    width: 45vw;
    height: 80vh;
    max-width: 600px;
    background: #1a1a1a;
    border: 2px solid #555;
    padding: 2rem;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    display: none; /* Initially hide all pages */
}

.journal-page.active {
    display: block;
}

.journal-page.cover {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

#journal-cover h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

#therapist-office-view {
    border: 2px dashed #444;
    padding: 1rem;
    margin: 2rem 0;
    width: 80%;
    position: relative;
    overflow: hidden;
}

#therapist-office-view.glitching::before,
#therapist-office-view.glitching::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1a1a;
    overflow: hidden;
    clip: rect(0, 900px, 0, 0);
}

#therapist-office-view.glitching::before {
    left: 2px;
    text-shadow: -1px 0 red;
    animation: glitch-anim-1 2s infinite linear alternate-reverse;
    animation-duration: calc(4s - (var(--glitch-intensity, 0) * 3.5s));
}

#therapist-office-view.glitching::after {
    left: -2px;
    text-shadow: -1px 0 blue;
    animation: glitch-anim-2 2s infinite linear alternate-reverse;
    animation-duration: calc(4s - (var(--glitch-intensity, 0) * 3.5s));
}

@keyframes glitch-anim-1 {
    0% { clip: rect(42px, 9999px, 44px, 0); }
    5% { clip: rect(12px, 9999px, 69px, 0); }
    10% { clip: rect(7px, 9999px, 86px, 0); }
    15% { clip: rect(47px, 9999px, 13px, 0); }
    20% { clip: rect(77px, 9999px, 49px, 0); }
    25% { clip: rect(2px, 9999px, 79px, 0); }
    30% { clip: rect(61px, 9999px, 19px, 0); }
    35% { clip: rect(4px, 9999px, 93px, 0); }
    40% { clip: rect(31px, 9999px, 63px, 0); }
    45% { clip: rect(81px, 9999px, 5px, 0); }
    50% { clip: rect(25px, 9999px, 57px, 0); }
    55% { clip: rect(18px, 9999px, 99px, 0); }
    60% { clip: rect(63px, 9999px, 2px, 0); }
    65% { clip: rect(37px, 9999px, 50px, 0); }
    70% { clip: rect(10px, 9999px, 88px, 0); }
    75% { clip: rect(72px, 9999px, 23px, 0); }
    80% { clip: rect(45px, 9999px, 78px, 0); }
    85% { clip: rect(91px, 9999px, 41px, 0); }
    90% { clip: rect(55px, 9999px, 6px, 0); }
    95% { clip: rect(8px, 9999px, 74px, 0); }
    100% { clip: rect(59px, 9999px, 33px, 0); }
}

@keyframes glitch-anim-2 {
    0% { clip: rect(85px, 9999px, 97px, 0); }
    5% { clip: rect(23px, 9999px, 48px, 0); }
    10% { clip: rect(1px, 9999px, 66px, 0); }
    15% { clip: rect(87px, 9999px, 34px, 0); }
    20% { clip: rect(51px, 9999px, 20px, 0); }
    25% { clip: rect(98px, 9999px, 52px, 0); }
    30% { clip: rect(35px, 9999px, 7px, 0); }
    35% { clip: rect(78px, 9999px, 28px, 0); }
    40% { clip: rect(15px, 9999px, 90px, 0); }
    45% { clip: rect(69px, 9999px, 40px, 0); }
    50% { clip: rect(41px, 9999px, 83px, 0); }
    55% { clip: rect(4px, 9999px, 60px, 0); }
    60% { clip: rect(89px, 9999px, 14px, 0); }
    65% { clip: rect(33px, 9999px, 73px, 0); }
    70% { clip: rect(9px, 9999px, 45px, 0); }
    75% { clip: rect(74px, 9999px, 17px, 0); }
    80% { clip: rect(29px, 9999px, 81px, 0); }
    85% { clip: rect(95px, 9999px, 3px, 0); }
    90% { clip: rect(66px, 9999px, 27px, 0); }
    95% { clip: rect(39px, 9999px, 55px, 0); }
    100% { clip: rect(11px, 9999px, 94px, 0); }
}

#path-to-self-btn {
    margin-top: 2rem;
    background: none;
    border: 1px solid #666;
    color: #666;
}

#path-to-self-btn:hover {
    border-color: #fff;
    color: #fff;
}

#view-collectibles-btn {
    margin-top: 2rem;
    background: none;
    border: 1px solid #666;
    color: #666;
}

#view-collectibles-btn:hover {
    border-color: #fff;
    color: #fff;
}

#journal-pages {
    display: flex;
    flex-direction: column;
}

.journal-pages-container {
    position: relative;
}

.journal-patient-page {
    background: #fdfbf5;
    color: #1a1a1a;
    border-color: #ccc;
    display: none; /* Handled by JS */
}

.journal-patient-page.active {
    display: flex;
    gap: 1rem;
}

.patient-portrait-container {
    width: 40%;
}

.patient-portrait {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    border: 2px solid #333;
}

.patient-details {
    width: 60%;
    display: flex;
    flex-direction: column;
}

.patient-details h2 {
    font-size: 1.5rem;
}

.patient-details p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.start-session-btn {
    margin-top: auto;
    width: 100%;
    padding: 1rem;
    background: #333;
    color: #fdfbf5;
}

.start-session-btn.healed-btn {
    background: #5a9;
    color: #fff;
}


.start-session-btn:hover {
    background: #000;
}

.locked-patient-page {
    background: #222;
    color: #555;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    text-align: center;
}

.journal-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
    gap: 1rem;
}

.stat {
    font-size: 0.9rem;
}

.habitat-grid {
    display: none; /* DEPRECATED */
}

.npc-card {
    background: #222;
    border: 2px solid #444;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.npc-card:hover {
    border-color: #fff;
    transform: translateY(-5px);
}

.npc-card.healed {
    border-color: #4CAF50;
}

.npc-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.npc-info {
    padding: 1rem;
}

.npc-name {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.npc-status {
    font-size: 0.8rem;
    opacity: 0.7;
}

.healed-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #4CAF50;
    color: #fff;
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
}

/* Therapy Session */
#therapy-session {
    flex-direction: column;
}

.session-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.session-header {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.trust-badge {
    border: 1px solid #fff;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1;
    background: rgba(255,255,255,0.06);
    margin-left: auto;
}
/* On narrow screens, keep trust badge readable */
@media (max-width: 768px) {
    .trust-badge { font-size: 0.85rem; }
}

.habitat-display {
    flex: 1;
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    align-items: flex-end;
}

.habitat-display::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.35) 30%, transparent 60%);
    pointer-events: none;
}

.dialogue-box {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    padding: 0.85rem 1rem;
    border: 1px solid rgba(255,255,255,0.7);
    max-width: 64%;
    width: auto;
    border-radius: 8px;
    animation: slideUp 0.3s ease-out;
    max-height: 42vh;
    overflow: auto;
    line-height: 1.7;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.8);
    font-size: calc(1rem * var(--dialogue-scale, 1));
}

/* Patient Bio Window */
.patient-bio-window {
    position: absolute;
    bottom: calc(1rem + 170px + 0.5rem); /* Above the portrait */
    right: 1rem;
    width: 300px;
    max-height: 40vh;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(4px);
    border: 1px solid #fff;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    display: none; /* toggled via JS */
    flex-direction: column;
    animation: fadeIn 0.2s;
}
.pbw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 34px;
    padding: 0 0.5rem;
    background: rgba(255,255,255,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.4);
    font-size: 0.9rem;
    cursor: default;
    flex-shrink: 0;
}
.pbw-content {
    padding: 0.8rem;
    overflow-y: auto;
}
.pbw-content h4 {
    margin-bottom: 0.5rem;
}
.pbw-content p {
    font-size: 0.8rem;
    line-height: 1.4;
    margin-bottom: 0.4rem;
}
.pbw-content p strong {
    opacity: 0.7;
}


/* Keep portrait visible; ensure spacing on small screens */
.npc-portrait {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    width: 170px;
    height: 170px;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.85);
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.5);
    pointer-events: all; /* Make it clickable */
    cursor: pointer;
    transition: transform 0.2s ease-in-out;
}

.npc-portrait:hover {
    transform: scale(1.03);
}

@media (max-width: 768px) {
    /* On mobile, stretch dialog but keep top offset so it doesn't fully cover content */
    .dialogue-box {
        max-width: calc(100% - 2rem);
        bottom: 0.8rem;
        left: 0.8rem;
        right: 0.8rem;
    }
    .npc-portrait {
        width: 140px;
        height: 140px;
        right: 0.8rem;
        bottom: 0.8rem;
    }
}

.speaker {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-bottom: 0.5rem;
}

.dialogue-text {
    font-size: 1em;
    line-height: 1.6;
    margin-bottom: 1rem;
    min-height: 5rem;
}

/* Memory Game */
.memory-game-container {
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 1rem 0;
    perspective: 1000px;
}

.memory-card {
    width: 100px;
    height: 100px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: pointer;
}

.memory-card.flipped {
    transform: rotateY(180deg);
}

.memory-card .card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    border: 1px solid #fff;
}

.card-back {
    background-color: #333;
    color: #fff;
    transform: rotateY(180deg);
}

.card-front {
    background-color: #555;
    color: #fff;
}


.choices {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 2rem;
}

.choice-btn {
    padding: 0.8rem;
    background: #222;
    color: #fff;
    border: 1px solid #fff;
    cursor: pointer;
    text-align: left;
    font-family: 'Space Mono', monospace;
    font-size: 0.9em;
    transition: all 0.2s;
}

.choice-btn:hover {
    background: #fff;
    color: #000;
}

.player-input-container {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 1em;
}

#player-response {
    flex-grow: 1;
    padding: 0.8rem;
    background: #222;
    border: 1px solid #fff;
    color: #fff;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
}

.send-btn {
    padding: 0.8rem 1rem;
    background: #fff;
    color: #000;
    border: none;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
}

.send-btn:hover {
    background: #ccc;
}

.conclude-btn {
    width: 100%;
    margin-top: 1rem;
    background: #4CAF50;
    color: #fff;
}

/* Typing Indicator */
.typing-indicator {
    padding: 1rem 0;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 4px;
    background-color: #fff;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 40%, 100% {
        transform: translateY(0);
    }
    20% {
        transform: translateY(-8px);
    }
}

/* Journal */
#journal {
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
}

.journal-header {
    margin-bottom: 2rem;
}

.journal-stats {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

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

.journal-entry {
    background: #222;
    padding: 1rem;
    border-left: 4px solid #444;
    transition: all 0.2s;
}
/* New: journal thumbnail shows Main image (habitat) */
.journal-entry .journal-thumb {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border: 1px solid #333;
    margin-bottom: 0.5rem;
}

.journal-entry:hover {
    background: #333;
    border-left-color: #fff;
}

.journal-entry.healed {
    border-left-color: #4CAF50;
}

/* Character Creator */
.creator-container {
    display: flex;
    gap: 2rem;
    flex-grow: 1;
    overflow-y: auto;
}

.creator-form {
    width: 40%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.creator-form h3 {
    margin-bottom: 0.5rem;
}

.creator-form p {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

#creator-prompt {
    width: 100%;
    height: 150px;
    padding: 0.8rem;
    background: #222;
    border: 1px solid #fff;
    color: #fff;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    resize: vertical;
}

.creator-divider {
    text-align: center;
    margin: 1rem 0;
    font-weight: bold;
}

.creator-preview {
    width: 60%;
    border-left: 2px solid #555;
    padding-left: 2rem;
    display: flex;
    flex-direction: column;
}

#creator-preview-content {
    border: 1px dashed #444;
    padding: 1rem;
    flex-grow: 1;
}

#creator-preview-content .placeholder-text {
    color: #666;
}

#creator-preview-content img {
    max-width: 100%;
    margin-bottom: 1rem;
}

/* Collectibles */
.collectibles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    overflow-y: auto;
    padding: 1rem;
    flex-grow: 1;
}

.collectible-item {
    background: #222;
    border: 1px solid #444;
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
}

.collectible-item img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: contain;
    margin-bottom: 0.5rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease-in;
}

.modal-content {
    background: #000;
    border: 2px solid #fff;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    animation: slideUp 0.3s ease-out;
}
/* Slightly wider radio modal on small screens */
@media (max-width: 768px) {
    .modal-content {
        max-width: 95vw;
        width: 95vw;
    }
}

.modal-content.large {
    max-width: 90vw;
    width: 90vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

#radio-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

#path-to-self-iframe {
    flex-grow: 1;
    border: none;
    width: 100%;
    height: 100%;
}

.modal-title {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.modal-input {
    width: 100%;
    padding: 0.8rem;
    background: #222;
    border: 1px solid #fff;
    color: #fff;
    font-family: 'Space Mono', monospace;
    margin-bottom: 1rem;
}

.modal-input.drop-hover {
    border-color: #6ff !important;
    box-shadow: 0 0 0 2px rgba(111,255,255,0.2);
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Award */
.award-popup {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #000;
    border: 2px solid #FFD700;
    padding: 1.5rem;
    max-width: 300px;
    display: none;
    animation: slideIn 0.5s;
    z-index: 1001;
}

.award-popup.active {
    display: block;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
    }
    to {
        transform: translateX(0);
    }
}

.award-title {
    color: #FFD700;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.award-popup p {
    font-size: 1rem;
}

/* Global Loader Overlay */
.global-loader {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background: #000;
    border: 2px solid #fff;
    padding: 1.5rem 2rem;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.loader-text {
    font-size: 0.95rem;
    opacity: 0.85;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Ending Screen */
#ending {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.ending-title {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.ending-stats {
    margin: 2rem 0;
    font-size: 1.2rem;
}

.ending-message {
    max-width: 600px;
    line-height: 1.8;
    margin-bottom: 2rem;
}

/* Connection Map */
#connection-map {
    flex-direction: column;
    background: #000;
}

.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
    min-height: 300px; /* ensure visible canvas dimensions */
}

.map-container:active {
    cursor: grabbing;
}

.map-canvas {
    width: 100%;
    height: 100%;
}

.map-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 0.5rem 1rem;
    border: 1px solid #fff;
    border-radius: 4px;
    pointer-events: none;
    display: none;
    font-size: 0.9rem;
    z-index: 10;
}

.map-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
}

.map-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid #fff;
    color: #fff;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .top-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .journal-container {
        flex-direction: column;
        padding: 1rem;
        height: auto;
    }

    .journal-page {
        width: 90vw;
        height: auto;
        min-height: 70vh;
        margin-bottom: 1rem;
    }
    
    .journal-patient-page.active {
        flex-direction: column;
    }

    .patient-portrait-container, .patient-details {
        width: 100%;
    }

    .journal-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .top-bar > div {
        width: 100%;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .dialogue-box {
        padding: 1rem;
    }
    
    .dialogue-text {
        font-size: 0.9rem;
    }
    
    .choice-btn {
        font-size: 0.8rem;
    }
    
    #journal {
        padding: 1rem;
    }
    
    .journal-list {
        grid-template-columns: 1fr;
    }
    
    .journal-stats {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .award-popup {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
    
    .ending-title {
        font-size: 1.5rem;
    }
    
    .ending-stats {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.5rem;
    }
    
    .btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
        min-width: 180px;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    .modal-title {
        font-size: 1.2rem;
    }
}

#therapist-office-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        repeating-linear-gradient(0deg, rgba(255,255,255,0.04) 0px, rgba(255,255,255,0.04) 1px, transparent 2px, transparent 4px),
        radial-gradient(circle at 20% 30%, rgba(255,0,0,0.04), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(0,255,255,0.04), transparent 40%);
    opacity: 0; /* controlled by JS */
    mix-blend-mode: screen;
}

.floating-radio {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    z-index: 1100;
    background: #fff;
    color: #000;
    border: none;
    padding: 0.8rem 1rem;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
}

.floating-radio:hover { transform: scale(1.05); }

/* Roster panel for easy NPC discovery */
.roster-panel {
    width: 34%;
    min-width: 300px;
    max-width: 480px;
    height: 80vh;
    overflow: hidden;
    border: 2px solid #444;
    background: #0a0a0a;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.roster-header {
    margin-bottom: 0.8rem;
}
#roster-search {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: #161616;
    border: 1px solid #555;
    color: #fff;
    font-family: 'Space Mono', monospace;
}
.roster-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.8rem;
    overflow-y: auto;
    padding-right: 0.3rem;
}
.roster-card {
    background: #141414;
    border: 1px solid #333;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
.roster-card:hover {
    transform: translateY(-3px);
    border-color: #4CAF50;
}
.roster-card.healed {
    border-color: #4CAF50;
}
.roster-thumb {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid #333;
}
.roster-info {
    padding: 0.5rem;
}
.roster-name {
    font-size: 0.85rem;
    line-height: 1.2;
}
.roster-meta {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 0.2rem;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .roster-panel { width: 40%; }
}
@media (max-width: 768px) {
    .journal-container { flex-direction: column; align-items: stretch; }
    .roster-panel { width: 100%; height: 45vh; }
}

/* Add: Path to Self floating overlay */
.path-self-float {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    width: 320px;
    height: 180px;
    background: #000;
    border: 2px solid #fff;
    z-index: 1200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    display: none; /* toggled via JS */
}
/* Maximized PiP */
.path-self-float.max {
    width: 560px;
    height: 315px; /* 16:9 */
}

.psf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 34px;
    padding: 0 0.5rem;
    background: rgba(255,255,255,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.4);
    font-size: 0.9rem;
}

.psf-btn {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.6);
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
}

.psf-btn:hover { background: rgba(255,255,255,0.15); }

#path-self-float-iframe, .path-self-float iframe {
    width: 100%;
    height: calc(100% - 34px);
    border: 0;
}

/* Lift the floating radio button when PiP is present to avoid overlap */
.floating-radio.with-pip {
    bottom: calc(1rem + 200px);
}
/* Lift more when maximized */
.floating-radio.with-pip.max {
    bottom: calc(1rem + 335px);
}

/* Push therapy dialogue box right when PiP is open */
body.pip-open #therapy-session .dialogue-box {
    left: calc(320px + 1.5rem);
    max-width: calc(100% - 320px - 3rem - 190px); /* subtract PiP + margins + portrait width */
}
/* When PiP is maximized, push further */
body.pip-open.pip-max #therapy-session .dialogue-box {
    left: calc(560px + 1.5rem);
    max-width: calc(100% - 560px - 3rem - 190px);
}

/* Responsive: slightly smaller PiP on small screens */
@media (max-width: 480px) {
    .path-self-float {
        width: 260px;
        height: 146px;
    }
    .path-self-float.max {
        width: 360px;
        height: 202px;
    }
    .floating-radio.with-pip {
        bottom: calc(1rem + 166px);
    }
    .floating-radio.with-pip.max {
        bottom: calc(1rem + 230px);
    }
    body.pip-open #therapy-session .dialogue-box {
        left: calc(260px + 1rem);
        max-width: calc(100% - 260px - 2.5rem - 160px);
    }
    body.pip-open.pip-max #therapy-session .dialogue-box {
        left: calc(360px + 1rem);
        max-width: calc(100% - 360px - 2.5rem - 160px);
    }
}

/* NPC Thought Bubble */
.thought-bubble {
    position: absolute;
    right: 200px;
    bottom: 150px;
    width: 200px;
    height: 150px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #111;
    border-radius: 15px;
    padding: 8px;
    z-index: 50;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    display: flex; /* keep as flex for centering */
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.4s ease-out;
    --tail-offset: 20px;
}

.thought-bubble::after {
    content: '';
    position: absolute;
    bottom: -24px;
    right: var(--tail-offset);
    width: 0;
    height: 0;
    border: 12px solid transparent;
    border-top-color: #111;
    transform: translateX(50%);
}
.thought-bubble::before {
    content: '';
    position: absolute;
    bottom: -20px;
    right: var(--tail-offset);
    width: 0;
    height: 0;
    border: 12px solid transparent;
    border-top-color: rgba(255, 255, 255, 0.95);
    transform: translateX(50%);
    z-index: 1;
}

#npc-thought-image-container {
    width: 100%;
    height: 100%;
}

#npc-thought-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.thought-bubble-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #333;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@media (max-width: 768px) {
    .thought-bubble {
        right: 150px;
        bottom: 120px;
        width: 150px;
        height: 112px;
    }
}

@media (max-width: 480px) {
    .thought-bubble {
        right: 0.8rem;
        bottom: 160px; /* Above the portrait */
        width: 120px;
        height: 90px;
        --tail-offset: 50%; /* Center the tail */
    }
}

/* Rorschach Test Screen */
#rorschach-test {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.rorschach-container {
    max-width: 600px;
    width: 100%;
    background: #111;
    border: 1px solid #444;
    padding: 2rem;
}

#rorschach-image-container {
    width: 100%;
    height: 300px;
    background: #fff;
    margin: 1.5rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ccc;
}

#rorschach-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#rorschach-input {
    width: 100%;
    height: 80px;
    padding: 0.8rem;
    background: #222;
    border: 1px solid #fff;
    color: #fff;
    font-family: 'Space Mono', monospace;
    resize: vertical;
    margin-bottom: 1rem;
}

.rorschach-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.rorschach-analysis {
    min-height: 50px;
    font-size: 0.9rem;
    line-height: 1.6;
    text-align: left;
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-left: 3px solid #6ff;
}

/* Photo upload styles for the new Image Analysis Test */
.photo-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    border: 2px dashed #666;
    border-radius: 8px;
    background: rgba(255,255,255,0.02);
    transition: border-color 0.3s, background 0.3s;
    cursor: pointer;
}

.photo-upload-area:hover {
    border-color: #999;
    background: rgba(255,255,255,0.05);
}

.photo-upload-area .btn {
    font-size: 1.1rem;
    padding: 1rem 2rem;
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.8rem;
    opacity: 0.7;
    margin: 0;
    text-align: center;
}

.uploaded-photo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    min-height: 200px;
    max-height: 400px;
}

.uploaded-photo-container img {
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Image loading polish */
.loading {
    filter: blur(8px) saturate(0.8);
    transition: filter 300ms ease;
}
.loaded {
    filter: none;
}
.skeleton {
    position: relative;
    background: #151515;
    overflow: hidden;
}
.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
    animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
    100% { transform: translateX(100%); }
}

/* Fade-in for habitat backgrounds */
.habitat-display.fade-in {
    opacity: 0;
    transition: opacity 350ms ease;
}
.habitat-display.bg-ready {
    opacity: 1;
}

/* Ensure roster images show skeleton while loading */
.roster-thumb.loading {
    background: #111;
}
.npc-portrait.loading {
    background: rgba(255,255,255,0.06);
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
    .loading { transition: none; filter: none; }
    .habitat-display.fade-in { transition: none; opacity: 1; }
    .skeleton::after { animation: none; }
}

.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
}
.qr-btn {
    padding: 0.45rem 0.6rem;
    background: #1b1b1b;
    color: #fff;
    border: 1px solid #666;
    font-size: 0.85rem;
    cursor: pointer;
}
.qr-btn:hover { background: #fff; color: #000; }

.btn:focus-visible, .choice-btn:focus-visible, .qr-btn:focus-visible, .map-btn:focus-visible, .psf-btn:focus-visible, .floating-radio:focus-visible {
  outline: 2px solid #6ff;
  outline-offset: 2px;
}

#menu-roster-grid::-webkit-scrollbar, .roster-grid::-webkit-scrollbar, .community-credits-container::-webkit-scrollbar, .journal-list::-webkit-scrollbar {
  width: 8px; height: 8px;
}
#menu-roster-grid::-webkit-scrollbar-thumb, .roster-grid::-webkit-scrollbar-thumb, .community-credits-container::-webkit-scrollbar-thumb, .journal-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15); border-radius: 8px;
}
#menu-roster-grid::-webkit-scrollbar-track, .roster-grid::-webkit-scrollbar-track, .community-credits-container::-webkit-scrollbar-track, .journal-list::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
}

.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.9); color: #fff; border: 2px solid #fff; padding: 0.6rem 0.9rem;
  z-index: 1300; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Settings modal */
.settings-group { margin-bottom: 1rem; }
.settings-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; }
.settings-hint { font-size: 0.8rem; opacity: 0.7; margin-top: 0.25rem; }
/* Skip typing button */
.skip-btn { border-color: rgba(255,255,255,0.6); }

/* Command Palette (Cmd/Ctrl+K) */
.cmdk {
    max-width: 720px;
    width: 92vw;
    padding: 1.25rem;
}
.cmdk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .5rem;
}
.cmdk-list {
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid #333;
    background: #0b0b0b;
}
.cmdk-item {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: .75rem;
    padding: .55rem .75rem;
    border-bottom: 1px solid #151515;
    align-items: center;
    cursor: pointer;
}
.cmdk-item:last-child { border-bottom: none; }
.cmdk-item:hover, .cmdk-item.active {
    background: rgba(255,255,255,0.08);
}
.cmdk-thumb {
    width: 56px; height: 56px; object-fit: cover; border: 1px solid #333;
}
.cmdk-meta {
    display: grid;
    gap: 2px;
}
.cmdk-name { font-size: .95rem; }
.cmdk-sub { font-size: .75rem; opacity: .75; }
.cmdk-hint {
    margin-top: .6rem;
    font-size: .75rem; opacity: .7;
}

/* Small hint for main-menu search focus via '/' */
#menu-search::placeholder { content: "Search patients…"; }

/* Quick replies number hints */
.qr-btn::before {
    content: attr(data-key);
    display: inline-block;
    min-width: 1.1em;
    padding: 0 .25em;
    margin-right: .35rem;
    border: 1px solid #555;
    border-radius: 3px;
    font-size: .75em;
    opacity: .75;
}

.cot-bar { display:flex; gap:.5rem; align-items:center; margin-left:auto; }
.cot-avatars { display:flex; gap:.25rem; }
.cot-avatars img { width:22px; height:22px; border-radius:50%; border:1px solid #fff; object-fit:cover; }
.cot-actions .psf-btn { padding:.2rem .45rem; }
.cot-reactions { position:absolute; inset:0; pointer-events:none; }
.reaction { position:absolute; font-size:1.4rem; animation: floatUp 1.2s ease-out forwards; opacity:.95; }
@keyframes floatUp { from{ transform:translateY(0) scale(1); opacity:.95; } to{ transform:translateY(-120px) scale(1.2); opacity:0; } }
.cot-insights { display:flex; flex-wrap:wrap; gap:.4rem; margin-left:auto; }
.insight-chip { border:1px solid #6ff; color:#6ff; padding:.2rem .5rem; border-radius:14px; font-size:.8rem; background:rgba(0,255,255,0.08); }
.insight-chip .by { opacity:.8; margin-left:.35rem; font-size:.75em; }
.pbw-actions { display:flex; gap:.4rem; margin-top:.5rem; }

/* Permission Request Modal */
#permission-request-modal .modal-content {
    max-width: 500px;
    text-align: center;
}

.permission-content {
    padding: 1rem 0;
}

.permission-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.permission-message {
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.permission-features {
    margin-bottom: 1.5rem;
}

.permission-feature {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    text-align: left;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.feature-icon {
    font-size: 1.5rem;
    margin-top: 0.25rem;
}

.feature-text {
    flex: 1;
    line-height: 1.4;
}

.feature-text strong {
    display: block;
    margin-bottom: 0.25rem;
}

.permission-note {
    font-size: 0.9rem;
    opacity: 0.8;
    font-style: italic;
    margin-bottom: 1.5rem;
}

#permission-request-modal .modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

#permission-allow-btn {
    background: #4CAF50;
    border-color: #4CAF50;
}

#permission-allow-btn:hover {
    background: #45a049;
    border-color: #45a049;
}

#permission-text-only-btn {
    background: #666;
    border-color: #666;
}

#permission-text-only-btn:hover {
    background: #555;
    border-color: #555;
}
.pbw-notes { width:100%; min-height:72px; padding:.5rem; background:#111; color:#fff; border:1px solid #444; font-family:'Space Mono', monospace; font-size:.9rem; resize: vertical; }

@keyframes pulse {
  0% { transform: translateY(0); opacity: 0.85; }
  50% { transform: translateY(-1px); opacity: 1; }
  100% { transform: translateY(0); opacity: 0.85; }
}