:root {
    --waveform-height: 80px;
    --my-bottom-offset: 94px;
    /* Background colors */
    --bg-primary: #f0f0f0;
    --bg-white: #fff;
    --bg-brown: #542E2E;
    --bg-black: #000;
    
    /* Text colors */
    --text-primary: #333;
    --text-black: #000;
    --text-white: #fff;
    
    /* Gradient colors */
    --gradient-orange-start: #FFA73B;
    --gradient-orange-end: #F58121;
    
    /* Accent colors */
    --accent-red: #ff4444;
    --accent-blue: #2D7FF9;
    --neon-green: #00FF00;
    --waveform-bg: #D6D6D6;
    /* Overlay colors */
    --overlay-dark-10: rgba(0, 0, 0, 0.1);
    --overlay-white-10: rgba(255, 255, 255, 0.1);
    --overlay-white-20: rgba(255, 255, 255, 0.2);
    --overlay-white-30: rgba(255, 255, 255, 0.3);
    --overlay-white-50: rgba(255, 255, 255, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
}

html {
    overflow: hidden;
    height: 100dvh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg-primary);
    -webkit-touch-callout: none;
}

#app {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    touch-action: pan-y;
    user-select: none;
}

/* Header Styles */
.header {
    background: linear-gradient(to right, var(--gradient-orange-start), var(--gradient-orange-end));
    border-radius: 0 0 20px 20px;
    padding: 0 20px 20px 20px;
    flex: 0 0 15%;
    min-height: 120px;
}

.nav-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.nav-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-black);
    cursor: pointer;
    padding: 5px;
    touch-action: manipulation;
}

.book-thumbnail {
    background: var(--bg-white);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 8px var(--overlay-dark-10);
}

.book-thumbnail img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.next-text {
    color: var(--text-black);
    font-weight: 600;
    font-size: 16px;
}

/* Content Area Styles */
.content-area {
    background: var(--bg-white);
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    touch-action: pan-y;
}

.text-content {
    line-height: 1.6;
    font-size: 18px;
    color: var(--text-primary);
}

.text-content p {
    margin-bottom: 8px;
}

/* Audio Controls Styles */
.audio-controls {
    background: var(--bg-brown);
    flex: 0 0 40%;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.timeline-container {
    flex: 1;
    overflow-x: auto;
    padding: 20px 0 10px 0;
    touch-action: pan-x;
    position: relative;
    scroll-behavior: smooth;
}
.timeline-container {
    scrollbar-width: none;   /* Firefox */
    -ms-overflow-style: none; /* IE/Edge (legacy) */
}
  
.timeline-container::-webkit-scrollbar {
    display: none;           /* Chrome, Safari */
}

.playback-time {
    position: absolute;
    bottom: var(--my-bottom-offset);
    right: 15px;
    background: var(--overlay-white-20);
    color: var(--text-white);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 6px;
}
.zoom-buttons {
    position: absolute;
    bottom: var(--my-bottom-offset);
    right: 135px;
    background: var(--overlay-white-20);
    color: var(--text-white);
    padding: 4px 8px;border-radius: 4px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 18px;
}
.zoom-buttons button {
    font-size:38px;
    font-weight:normal;
}

.playback-time-text {
    pointer-events: none;
}

.zoom-btn {
    background: var(--bg-white);
    color: var(--bg-brown);
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.zoom-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.timeline {
    position: relative;
}

.time-markers {
    position: relative;
    height: 16px;
    margin-bottom: 10px;
    color: var(--text-white);
    font-size: 12px;
    font-weight: 500;
}
.time-markers.absolute span {
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}

.waveform-area {
    position: relative;
    height: calc(var(--waveform-height) + 10px);
    background: var(--overlay-white-10);
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 0;
}

.drop-marker-abs {
    position: absolute;
    top: -7px;
    bottom: -7px;
    width: 0;
    border-left: 5px dotted var(--neon-green);
    pointer-events: none;
    z-index: 60;
}

.waveform-segment {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    
    justify-content: center;
    height: var(--waveform-height);
    overflow:hidden;
    background: var(--waveform-bg);
    border-radius: 10px;
    padding: 5px;
    border:1px var(--bg-white) solid;
    flex-shrink: 0;
}

/* Dragging visual feedback */
.waveform-segment.dragging {
    opacity: 0.7;
    outline: 2px dashed var(--overlay-white-50);
}

/* Smooth width collapse when removing a segment */
.waveform-segment.collapsing {
    transition: width 200ms ease, margin-right 200ms ease, padding 200ms ease, opacity 200ms ease;
    opacity: 0.6;
}


.waveform-bars {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 50px;
    flex-shrink: 0;
}

.bar {
    width: 3px;
    border-radius:8px;
    background: var(--bg-black);
    border-radius: 1px;
    min-height: 2px;
}

.segment-transcript {
    font-size: 11px;
    color: var(--text-black);
    padding: 2px 4px;
    width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
    margin-top: 2px;
}

/* Selected segment styling */
.waveform-segment.selected {
    background:var(--bg-primary);
}
.waveform-segment.selected .bar {
    background: var(--accent-red);
}
.waveform-segment.selected .segment-transcript {
    color: var(--accent-red);
    font-weight: 600;
}

/* Temporary recording segment styling */
.waveform-segment.recording {
    background: rgba(255, 68, 68, 0.25);
    border-color: var(--accent-red);
}
.waveform-segment.recording .bar {
    background: var(--accent-red);
}
.waveform-segment.recording .segment-transcript {
    color: var(--accent-red);
    font-weight: 600;
    font-style: italic;
}

.add-silence-btn {
    background: var(--bg-white);
    color: var(--bg-brown);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 10px;
    touch-action: manipulation;
}

.playhead {
    position: absolute;
    top: 20px;
    height: 140px;
    width: 3px;
    background: var(--bg-white);
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}

/* Control Buttons */
.control-buttons {
    display: flex;
    justify-content: space-around;
    padding: 15px 10px;
    background: var(--overlay-dark-10);
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    width: 50px;
}

.control-btn:hover {
    background: var(--overlay-white-10);
}

.control-btn:active {
    background: var(--overlay-white-20);
}

.control-btn.active {
    background: var(--overlay-white-20);
}

.control-btn.record-btn.active {
    background: var(--accent-red);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.control-btn:disabled:hover {
    background: none;
}

.control-btn:disabled:active {
    background: none;
}

.icon {
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.icon img {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
    pointer-events: none;
}

.control-btn span {
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
}

/* Rearrangement View Styles */
.rearrangement-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: auto;
}

/* Hide during initial Vue load */
#app.vue-loading .rearrangement-overlay {
    display: none;
}

.rearrangement-container {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 20px;
    max-width: 90%;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.rearrangement-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--bg-primary);
}

.rearrangement-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.rearrangement-actions {
    display: flex;
    gap: 10px;
}

.rearrangement-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 70px;
}

.rearrangement-btn-ok {
    background: var(--accent-blue);
    color: var(--text-white);
}

.rearrangement-btn-ok:hover {
    background: #1e6dd8;
    transform: translateY(-1px);
}

.rearrangement-btn-ok:active {
    transform: translateY(0);
}

.rearrangement-btn-cancel {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.rearrangement-btn-cancel:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

.rearrangement-btn-cancel:active {
    transform: translateY(0);
}

.rearrangement-segments {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    overflow-y: auto;
    padding: 10px 0;
}

.rearrangement-segment {
    width: 60px;
    min-height: 60px;
    background: var(--waveform-bg);
    border: 2px solid var(--bg-white);
    border-radius: 8px;
    padding: 8px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: pan-x pan-y;
    pointer-events: auto;
    -webkit-user-drag: element;
    -moz-user-select: none;
    -khtml-user-drag: element;
}

.rearrangement-segment[draggable="true"] {
    cursor: grab;
}

.rearrangement-segment[draggable="true"]:active {
    cursor: grabbing;
}

.rearrangement-segment:active {
    cursor: grabbing;
}

.rearrangement-segment:hover {
    border-color: var(--accent-blue);
    transform: scale(1.05);
}

.rearrangement-segment.rearrangement-dragging {
    opacity: 1;
    border-color: var(--accent-blue);
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: grabbing !important;
    cursor: -webkit-grabbing !important;
}

.rearrangement-segment.rearrangement-drop-target {
    border-color: var(--neon-green);
    border-style: dashed;
    background: rgba(0, 255, 0, 0.1);
}

.rearrangement-segment-content {
    font-size: 11px;
    color: var(--text-black);
    text-align: center;
    line-height: 1.3;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    pointer-events: none;
}

.rearrangement-drop-marker {
    width: 4px;
    height: 60px;
    background: var(--neon-green);
    border-radius: 2px;
    flex-shrink: 0;
    margin: 0 3px;
    box-shadow: 0 0 8px var(--neon-green);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

