body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Lato, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #222;
    background-color: #fff;
    margin: 0;
    padding: 0;
}

.page-layout {
    display: flex;
    min-height: calc(100vh - 60px);
}

.sidebar {
    width: 300px;
    background-color: #f8f9fa;
    border-right: 1px solid #eaecf0;
    padding: 20px 15px;
    overflow-y: auto;
    position: fixed;
    top: 60px;
    bottom: 0;
    left: 0;
}

.sidebar-title {
    font-size: 1.2em;
    font-weight: 600;
    color: #222;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eaecf0;
}

.stories-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.story-group {
    border-radius: 5px;
}

.story-group-summary {
    display: flex;
    align-items: stretch;
    gap: 6px;
    border-radius: 5px;
    cursor: pointer;
    list-style: none;
}

.story-group-summary::-webkit-details-marker {
    display: none;
}

.story-group-caret {
    width: 24px;
    flex: 0 0 24px;
    color: #0645ad;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.story-group-caret::before {
    content: "▾";
    font-size: 1.25em;
    font-weight: 700;
}

.story-group:not([open]) .story-group-caret::before {
    content: "▸";
}

.story-group-summary:hover .story-group-caret {
    color: #0b0080;
}

.story-link-original {
    flex: 1;
    border-radius: 5px;
}

.story-link-original:hover,
.story-link-original.active {
    background-color: #eaecf0;
}

.story-link-original.active {
    background-color: #e3f2fd;
    border-left: 3px solid #0645ad;
}

.story-translations {
    margin-left: 22px;
    margin-top: 6px;
    padding-left: 10px;
    border-left: 1px solid #d0d7de;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.story-item {
    border-radius: 5px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.story-item:hover {
    background-color: #eaecf0;
}

.story-item.active {
    background-color: #e3f2fd;
    border-left: 3px solid #0645ad;
}

.story-link {
    display: block;
    padding: 12px;
    text-decoration: none;
    color: inherit;
}

.story-title-sidebar {
    font-size: 0.95em;
    font-weight: 600;
    color: #222;
    margin-bottom: 4px;
    line-height: 1.3;
}

.story-languages {
    font-size: 0.8em;
    color: #0645ad;
    margin-bottom: 2px;
    font-weight: 500;
}

.main-content {
    margin-left: 300px;
    flex: 1;
    padding: 0;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
}

.welcome-header,
.error-header {
    text-align: center;
    padding: 60px 20px;
}

.welcome-header h1,
.error-title {
    font-size: 2.5em;
    color: #222;
    margin-bottom: 15px;
}

.welcome-header p,
.error-message p {
    font-size: 1.1em;
    color: #54595d;
}

.error-title {
    color: #d73027;
    font-weight: normal;
}

.error-message {
    margin-bottom: 30px;
}

.error-actions {
    margin-top: 30px;
}

.home-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: #0645ad;
    color: #fff;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 5px;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.home-button:hover {
    background-color: #0b0080;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.home-button:active {
    transform: translateY(0);
}

.story-header {
    border-bottom: 3px solid #a2a9b1;
    margin-bottom: 20px;
    padding-bottom: 10px;
    position: relative;
}

.story-controls {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 8px;
}

.swap-button,
.layout-button {
    background-color: #f8f9fa;
    border: 1px solid #a2a9b1;
    border-radius: 5px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9em;
    color: #0645ad;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.swap-button:hover,
.layout-button:hover {
    background-color: #eaecf0;
    border-color: #0645ad;
}

.swap-button:active,
.layout-button:active {
    transform: translateY(1px);
}

.swap-icon,
.layout-icon {
    font-size: 1.2em;
    font-weight: bold;
}

.swap-text,
.layout-text {
    font-weight: 500;
}

.title-section {
    margin-bottom: 10px;
}

.story-title {
    font-size: 2.3em;
    font-weight: normal;
    margin: 0 0 10px 0;
    color: #000;
    border: none;
}

.original-title {
    font-size: 1.3em;
    color: #54595d;
    margin: 5px 0;
    font-style: italic;
}

.language-swap-link {
    color: #0645ad;
    cursor: pointer;
    text-decoration: none;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.language-swap-link:hover {
    background-color: #f8f9fa;
    text-decoration: underline;
}

.language-swap-link:active {
    background-color: #eaecf0;
}

.story-meta {
    font-size: 0.9em;
    color: #54595d;
    margin-bottom: 10px;
}

.story-meta .meta-item {
    margin-right: 15px;
}

.parallel-content {
    margin-top: 30px;
}

.sentence-pair {
    margin-bottom: 15px;
    padding: 8px 0;
}

.translated-sentence {
    font-size: 1.1em;
    line-height: 1.7;
    margin-bottom: 4px;
    color: #222;
}

.original-sentence {
    font-size: 1em;
    line-height: 1.6;
    color: #54595d;
    font-style: italic;
    margin-top: 8px;
}

.level-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: bold;
    transition: all 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.level-badge.level-a1 {
    background-color: rgb(144, 238, 144);
    color: #000;
}

.level-badge.level-a2 {
    background-color: rgb(173, 216, 230);
    color: #000;
}

.level-badge.level-b1 {
    background-color: rgb(255, 255, 0);
    color: #000;
}

.level-badge.level-b2 {
    background-color: rgb(255, 165, 0);
    color: #000;
}

.level-badge.level-c1 {
    background-color: rgb(255, 0, 0);
    color: #fff;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
}

.level-badge.level-c2 {
    background-color: rgb(128, 0, 128);
    color: #fff;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
}

.author-link {
    color: #0645ad;
    text-decoration: none;
}

.author-link:hover {
    text-decoration: underline;
}

.parallel-content.column-layout .sentence-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #eaecf0;
    border-radius: 5px;
    background-color: #fafafa;
}

.parallel-content.column-layout .translated-sentence,
.parallel-content.column-layout .original-sentence {
    margin: 0;
    padding: 10px;
    border-radius: 3px;
    font-style: normal;
}

.parallel-content.column-layout .translated-sentence {
    background-color: #fff;
    border-left: 3px solid #0645ad;
}

.parallel-content.column-layout .original-sentence {
    background-color: #f8f9fa;
    border-left: 3px solid #a2a9b1;
    color: #54595d;
}

@media (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }

    .main-content {
        margin-left: 250px;
    }
}

@media (max-width: 768px) {
    .page-layout {
        flex-direction: column;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #eaecf0;
        padding: 15px;
    }

    .main-content {
        margin-left: 0;
    }

    .stories-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 10px;
    }

    .swap-button {
        position: static;
        margin: 10px 0;
        align-self: flex-start;
    }

    .story-header {
        display: flex;
        flex-direction: column;
    }

    .parallel-content.column-layout .sentence-pair {
        grid-template-columns: 1fr;
    }
}
