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

body, html {
    height: 100%;
    background: #0a0a0a;
    color: #e0e0e0;
    font-family: 'Roboto Mono', monospace;
    overflow: hidden;
}

/* ── Input Area ── */
#input-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    gap: 1rem;
}

#input-area h1 {
    font-size: 1.4rem;
    color: #ff8c00;
}

#input-area p {
    font-size: 0.75rem;
    color: #888;
    max-width: 500px;
    text-align: center;
}

#transcript {
    width: 100%;
    max-width: 700px;
    height: 50vh;
    background: #111;
    color: #ccc;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 1rem;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8rem;
    resize: none;
    outline: none;
}

#transcript:focus {
    border-color: #ff8c00;
}

#parse-btn {
    padding: 0.6rem 2.5rem;
    background: #ff8c00;
    color: #000;
    border: none;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

#parse-btn:hover {
    background: #ffaf4d;
}

/* ── Hidden utility ── */
.hidden {
    display: none !important;
}

/* ── Timeline View ── */
#timeline-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ── Header ── */
#timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #111;
    border-bottom: 1px solid #222;
    font-size: 0.75rem;
    color: #888;
    flex-shrink: 0;
}

#header-hints {
    font-size: 0.65rem;
    color: #555;
    flex: 1;
    text-align: center;
}

#header-hints kbd {
    display: inline-block;
    padding: 0.05rem 0.35rem;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 3px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.6rem;
    color: #aaa;
    margin-right: 0.15rem;
}

#header-actions {
    display: flex;
    gap: 0.4rem;
}

#clear-bookmarks-btn {
    padding: 0.25rem 0.8rem;
    background: transparent;
    color: #a064dc;
    border: 1px solid #a064dc55;
    border-radius: 3px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s;
}

#clear-bookmarks-btn:hover {
    color: #c08cff;
    border-color: #c08cff;
}

#reset-btn {
    padding: 0.25rem 0.8rem;
    background: transparent;
    color: #888;
    border: 1px solid #444;
    border-radius: 3px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s;
}

#reset-btn:hover {
    color: #ff8c00;
    border-color: #ff8c00;
}

/* ── Search Bar ── */
#search-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 1rem;
    background: #111;
    border-bottom: 1px solid #222;
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    max-width: 280px;
    padding: 0.3rem 0.6rem;
    background: #1a1a1a;
    color: #ccc;
    border: 1px solid #333;
    border-radius: 3px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.75rem;
    outline: none;
}

#search-input:focus {
    border-color: #ff8c00;
}

#filter-toggle {
    display: flex;
    gap: 0.25rem;
}

.filter-btn {
    padding: 0.2rem 0.6rem;
    background: transparent;
    color: #666;
    border: 1px solid #333;
    border-radius: 3px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.15s;
}

.filter-btn:hover {
    color: #aaa;
    border-color: #555;
}

.filter-btn.active {
    color: #ff8c00;
    border-color: #ff8c00;
}

#match-counter {
    font-size: 0.7rem;
    color: #888;
    white-space: nowrap;
}

#search-clear {
    padding: 0.1rem 0.45rem;
    background: transparent;
    color: #666;
    border: 1px solid #333;
    border-radius: 3px;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s;
}

#search-clear:hover {
    color: #ff8c00;
    border-color: #ff8c00;
}

/* ── Search match states ── */
.segment.match {
    opacity: 1 !important;
    box-shadow: inset 0 -3px 0 0 #fff;
}

.segment.no-match {
    opacity: 0.2 !important;
}

.segment.match.active {
    box-shadow: inset 0 0 0 2px #fff, inset 0 -3px 0 0 #fff;
}

.search-highlight {
    background: rgba(255, 140, 0, 0.35);
    color: #fff;
    border-radius: 2px;
    padding: 0 1px;
}

/* ── Timeline Bar ── */
#timeline-bar {
    position: relative;
    height: 48px;
    background: #111;
    border-bottom: 1px solid #222;
    padding: 8px 1rem;
    flex-shrink: 0;
    cursor: pointer;
}

#segments {
    display: flex;
    height: 100%;
    width: 100%;
    border-radius: 3px;
    overflow: hidden;
}

.segment {
    height: 100%;
    transition: opacity 0.1s;
    position: relative;
}

.segment.user {
    background: #4a9eff;
}

.segment.ai {
    background: #ff8c00;
}

.segment:hover {
    opacity: 0.85;
}

.segment.active {
    opacity: 1;
    box-shadow: inset 0 0 0 2px #fff;
}

.segment:not(.active) {
    opacity: 0.45;
}

/* ── Range Handles & Overlays ── */
.range-handle {
    position: absolute;
    top: 0;
    width: 8px;
    height: 100%;
    background: rgba(160, 100, 220, 0.3);
    border-left: 2px solid rgba(160, 100, 220, 0.7);
    cursor: ew-resize;
    z-index: 2;
}

#range-right {
    border-left: none;
    border-right: 2px solid rgba(160, 100, 220, 0.7);
}

.range-overlay {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: none;
    z-index: 1;
}

.segment.out-of-range {
    opacity: 0.2 !important;
}

/* ── Scrubber Handle ── */
#scrubber {
    position: absolute;
    top: 2px;
    width: 3px;
    height: calc(100% - 4px);
    background: #fff;
    border-radius: 2px;
    pointer-events: none;
    transition: left 0.12s ease;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
}

/* ── Output Panel ── */
#output-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1rem 1.25rem;
    gap: 0;
}

#speaker-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    flex-shrink: 0;
    margin-bottom: 0.5rem;
}

#speaker-label.user {
    color: #4a9eff;
}

#speaker-label.ai {
    color: #ff8c00;
}

#message-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    background: #141414;
    border-radius: 6px;
    border-left: 3px solid #333;
    padding: 1.1rem 1.25rem;
    transition: border-color 0.2s;
}

#message-scroll.user-accent {
    border-left-color: #4a9eff;
}

#message-scroll.ai-accent {
    border-left-color: #ff8c00;
}

#message-text {
    font-size: 0.9rem;
    line-height: 1.7;
    color: #d4d4d4;
    word-wrap: break-word;
    margin: 0;
}

#message-text p {
    margin: 0 0 0.6em;
}

#message-text p:last-child {
    margin-bottom: 0;
}

#message-text a {
    color: #ff8c00;
    text-decoration: none;
    word-break: break-all;
}

#message-text a:hover {
    text-decoration: underline;
}

/* Scrollbar styling */
#message-scroll::-webkit-scrollbar {
    width: 6px;
}

#message-scroll::-webkit-scrollbar-track {
    background: transparent;
}

#message-scroll::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

#message-scroll::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ── Ghost Preview ── */
#ghost-preview {
    opacity: 0.25;
    margin-top: 1.25rem;
    border-top: 1px solid #252525;
    padding-top: 0.75rem;
    pointer-events: none;
    user-select: none;
}

#ghost-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.4rem;
}

#ghost-label.user {
    color: #4a9eff;
}

#ghost-label.ai {
    color: #ff8c00;
}

#ghost-text {
    font-size: 0.8rem;
    line-height: 1.5;
    color: #ccc;
    word-wrap: break-word;
    margin: 0;
}

#ghost-text p {
    margin: 0 0 0.5em;
}

#ghost-text p:last-child {
    margin-bottom: 0;
}

/* ── Word Cloud ── */
#wordcloud-section {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-top: 1px solid #222;
    background: #222;
}

#wc-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    background: #0e0e0e;
    border-bottom: 1px solid #1a1a1a;
}

#phrase-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #555;
}

#phrase-slider {
    width: 60px;
    accent-color: #a064dc;
    cursor: pointer;
}

#phrase-value {
    font-size: 0.65rem;
    color: #888;
    min-width: 0.8em;
}

#wc-filter-toggle {
    display: flex;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.wc-filter-btn {
    padding: 0.15rem 0.5rem;
    background: transparent;
    color: #555;
    border: 1px solid #333;
    border-radius: 3px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.6rem;
    cursor: pointer;
    transition: all 0.15s;
}

.wc-filter-btn:hover {
    color: #aaa;
    border-color: #555;
}

.wc-filter-btn.active {
    color: #a064dc;
    border-color: #a064dc;
}

#wc-panels {
    display: flex;
    gap: 1px;
    height: 130px;
}

.wc-panel {
    flex: 1;
    background: #0e0e0e;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wc-title {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #555;
    padding: 0.4rem 0.75rem 0.2rem;
    flex-shrink: 0;
}

.wc-words {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0.75rem 0.5rem;
    line-height: 1.8;
    word-wrap: break-word;
}

.wc-words span {
    display: inline-block;
    margin-right: 0.4em;
    color: #888;
    cursor: pointer;
    transition: color 0.15s;
}

.wc-words span:hover {
    color: #e0e0e0;
}

/* ── Word Cloud hover on timeline ── */
/* ── Bookmarked segments ── */
.segment.bookmarked {
    box-shadow: inset 0 3px 0 0 #a064dc;
    opacity: 0.8 !important;
}

.segment.bookmarked.active {
    box-shadow: inset 0 0 0 2px #fff, inset 0 3px 0 0 #a064dc;
}

/* ── Word Cloud hover on timeline ── */
.segment.wc-hover {
    opacity: 0.9 !important;
    box-shadow: inset 0 -3px 0 0 #ff8c00;
}

.segment.wc-dim {
    opacity: 0.15 !important;
}

.wc-words::-webkit-scrollbar {
    width: 4px;
}

.wc-words::-webkit-scrollbar-track {
    background: transparent;
}

.wc-words::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 2px;
}
