body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f4f4f9;
}

header {
    background: #333;
    color: #fff;
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.playback-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.playback-controls button {
    padding: 8px 20px;
    font-size: 1rem;
    cursor: pointer;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
}

.playback-controls button:hover {
    background: #0056b3;
}

/* Dropdown styling */
#main-mode-select, #play-mode-select, #audio-source-select {
    padding: 6px 10px;
    font-size: 0.9rem;
    background-color: #007bff !important;
    color: white !important;
    border: 1px solid #0056b3;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.settings {
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
    align-items: center;
    flex-wrap: wrap;
}

.settings input[type="number"] {
    width: 50px;
}

main {
    padding: 20px;
    max-width: 1000px;
    margin: auto;
}

/* Media Player Sticky Styling */
#media-container {
    position: sticky;
    top: 130px; 
    z-index: 90;
    background: #fff;
}

@media (max-width: 992px) {
    #media-container {
        top: 100px;
    }
    body.is-playing #media-container {
        top: 55px;
    }
}

/* Table-like Chunk Styling */
.chunk {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 12px 15px;
    margin-bottom: 0; /* Tight spacing within sentence */
    background: #fff;
    border-left: 2px solid #ccc;  /* Table outer border (left) */
    border-right: 2px solid #ccc; /* Table outer border (right) */
    border-top: 1px dashed #eee;  /* Internal divider (top) */
    cursor: pointer;
    scroll-margin-top: 150px; 
}

/* Top of the entire document or first in sentence should have solid top */
.chunk:first-child {
    border-top: 2px solid #ccc;
}

/* Sentence End markers */
.chunk.sentence-end {
    margin-bottom: 25px;         /* Space between sentences */
    border-bottom: 2px solid #ccc; /* Table outer border (bottom) */
}

/* If a chunk follows a sentence-end, it's the start of a new sentence table */
.chunk.sentence-end + .chunk {
    border-top: 2px solid #ccc;
}

.chunk:hover {
    background: #fdfdfd;
}

.chunk.active, .chunk.active-prev {
    background: #e7f3ff !important;
    border-left-color: #007bff;
    border-right-color: #007bff;
}

/* If active, make the dividers blue too */
.chunk.active, .chunk.active-prev {
    border-top-color: #b3d7ff;
}
.chunk.active.sentence-end, .chunk.active-prev.sentence-end {
    border-bottom-color: #007bff;
}

.chunk textarea {
    width: 100%;
    border: 1px solid #ccc;
    padding: 5px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
}

.en-text {
    font-size: 1.2rem;
    font-weight: 500;
    color: #222;
}

.ja-text {
    font-size: 1.1rem;
    color: #555;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
}

.toast {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    white-space: nowrap;
}

/* Mobile Overrides */
@media (max-width: 992px) {
    .chunk {
        grid-template-columns: 1fr;
        gap: 2px;
        padding: 8px 12px !important;
        scroll-margin-top: 110px;
    }

    .en-text { font-size: 1.1rem; }
    .ja-text { font-size: 1.0rem; }

    body.is-playing header > div:first-child,
    body.is-playing header .playback-controls > button:not(#play-btn),
    body.is-playing header .playback-controls > div:not(#source-selector), 
    body.is-playing header label,
    body.is-playing header .settings,
    body.is-playing header #settings-panel {
        display: none !important;
    }

    body.is-playing #play-mode-select,
    body.is-playing #main-mode-select {
        display: none !important;
    }

    body.is-playing header { padding: 5px !important; }
    body.is-playing .chunk { scroll-margin-top: 55px !important; }
    body.is-playing .controls { margin-top: 0 !important; }
    body.is-playing .playback-controls { justify-content: center; }
}
