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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

.top-bar {
    background: white;
    padding: 20px 40px;
    margin: -20px -20px 30px -20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100vw;
    max-width: 100vw;
    box-sizing: border-box;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.top-bar-left h1 {
    font-size: 1.8em;
    margin: 0;
    color: #2d3748;
}

.top-bar-left h1 a {
    text-decoration: none !important;
    color: inherit;
    cursor: pointer;
}

.top-bar-left p {
    font-size: 0.95em;
    margin: 0;
    color: #4a5568;
    opacity: 0.9;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.language-menu-container {
    position: relative;
}

.header-badge {
    display: inline-block;
    background: #2d3748;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.header-badge:hover {
    background: #1a202c;
}

.language-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: white;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
}

.language-menu-dropdown.show {
    display: block;
}

.language-menu-item {
    display: block;
    padding: 10px 16px;
    color: #4a5568;
    text-decoration: none;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.language-menu-item:hover {
    background-color: #f0f0f0;
    color: #2d3748;
}

.user-menu-container {
    position: relative;
}

.user-display-name {
    font-size: 0.9em;
    color: #4a5568;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.user-display-name:hover {
    background-color: #f0f0f0;
}

.user-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: white;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
}

.user-menu-dropdown.show {
    display: block;
}

.user-menu-item {
    display: block;
    padding: 10px 16px;
    color: #4a5568;
    text-decoration: none;
    font-size: 0.9em;
    white-space: nowrap;
    transition: background-color 0.2s;
}

.user-menu-item:hover {
    background-color: #f0f0f0;
    color: #2d3748;
}

.login-btn {
    padding: 8px 20px;
    background: #f0f0f0;
    color: #4a5568;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s, border-color 0.3s;
}

.login-btn:hover {
    background: #e8e8e8;
    border-color: #d0d0d0;
}

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

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: #2d3748;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background-color: #f0f0f0;
    color: #2d3748;
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    margin: 0 0 20px 0;
    color: #4a5568;
    font-size: 0.95em;
}

.google-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px 20px;
    background: white;
    border: 1px solid #dadce0;
    border-radius: 5px;
    color: #3c4043;
    font-size: 0.95em;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: box-shadow 0.2s, background-color 0.2s;
}

.google-login-btn:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    background-color: #f8f9fa;
}

.google-login-btn:active {
    background-color: #f1f3f4;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .top-bar {
        padding: 15px 20px;
        margin: -10px -10px 20px -10px;
        flex-wrap: wrap;
    }
    
    .top-bar-left {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        width: 100%;
    }
    
    .top-bar-left p {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 1;
        min-width: 0;
    }
    
    .top-bar-right {
        width: 100%;
        justify-content: flex-end;
        margin-top: 10px;
    }
    
    .language-menu-dropdown {
        right: auto;
        left: 0;
        min-width: 200px;
    }
    
    .user-menu-dropdown {
        right: auto;
        left: 0;
    }
    
    .post-card {
        padding: 15px;
    }
    
    .container {
        padding: 0;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.controls {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.form-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: end;
}

.form-field {
    flex: 1;
    min-width: 200px;
}

.form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-field input,
.form-field select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn:hover {
    background: #5568d3;
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #2d3748;
    font-size: 1.2em;
}

.error {
    background: #ff6b6b;
    color: white;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.meta-info {
    background: white;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.meta-info h3 {
    margin-bottom: 10px;
    color: #333;
}

.meta-info pre {
    background: #f5f5f5;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    font-size: 12px;
}

.posts-container {
    display: grid;
    gap: 20px;
}

.post-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

@media (min-width: 769px) {
    .post-card {
        display: grid;
        grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr);
        gap: 15px 20px;
        align-items: start;
    }
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.post-id {
    font-weight: 600;
    color: #667eea;
    font-size: 1.1em;
}

.post-date {
    color: #666;
    font-size: 0.9em;
}

.post-languages {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.language-badge {
    background: #667eea;
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.post-embed {
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    background: #f9f9f9;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

@media (min-width: 769px) {
    .post-embed {
        grid-column: 1;
        margin-bottom: 0;
    }
}

.embed-wrapper {
    width: 100%;
    max-width: 100%;
    min-height: 160px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

.post-embed > div {
    width: 100% !important;
    max-width: 100% !important;
    text-align: center !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    box-sizing: border-box !important;
}

.post-embed iframe {
    border: none;
    display: block;
    margin: 0 auto;
    max-width: 600px !important;
    width: 100% !important;
    box-sizing: border-box;
}

@media (min-width: 769px) {
    .post-embed iframe {
        width: 600px !important;
    }
}

.post-embed > div {
    width: 100% !important;
    text-align: center !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    flex-shrink: 0 !important;
}

.post-embed > div > * {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.post-embed > div blockquote {
    margin: 0 auto !important;
    display: block !important;
}

.post-embed > div .twitter-tweet {
    margin: 0 auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
    display: block !important;
    text-align: left !important;
    width: 100% !important;
    max-width: 550px !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.post-embed > div .twitter-tweet iframe,
.post-embed > div iframe[src*="twitter.com"],
.post-embed > div iframe[src*="platform.twitter.com"] {
    width: 100% !important;
    max-width: 550px !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    display: block !important;
}

@media (min-width: 769px) {
    .post-embed > div .twitter-tweet {
        width: 550px !important;
    }
    
    .post-embed > div .twitter-tweet iframe,
    .post-embed > div iframe[src*="twitter.com"],
    .post-embed > div iframe[src*="platform.twitter.com"] {
        width: 550px !important;
    }
}

.post-embed > div .instagram-media {
    margin: 0 auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
    display: block !important;
    width: 100% !important;
    max-width: 600px !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.post-embed > div .instagram-media iframe {
    width: 100% !important;
    max-width: 600px !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

@media (min-width: 769px) {
    .post-embed > div .instagram-media {
        width: 600px !important;
    }
    
    .post-embed > div .instagram-media iframe {
        width: 600px !important;
    }
}

.post-embed .embed-loading {
    padding: 40px;
    text-align: center;
    color: #666;
    font-size: 0.95em;
    display: block;
}

.post-embed .embed-error {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 0.9em;
}

.post-contribution {
    background: transparent;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

@media (min-width: 769px) {
    .post-contribution {
        grid-column: 2;
        margin-bottom: 0;
        align-self: stretch;
        justify-content: flex-end;
    }
}

.post-contribution h4 {
    margin-bottom: 10px;
    color: #333;
}

.post-contribution .translation {
    font-size: 0.95em;
    font-weight: 400;
    color: #4a5568;
    margin-bottom: 10px;
    white-space: pre-line;
}

.post-contribution .explanation {
    font-size: 0.95em;
    font-weight: 400;
    color: #4a5568;
    white-space: pre-line;
}

.post-contribution .explanation-toggle {
    margin-bottom: 10px;
}

.post-contribution .explanation-toggle summary {
    color: #4a5568;
    cursor: pointer;
    font-style: italic;
    user-select: none;
}

.post-contribution .explanation-toggle[open] summary {
    display: none;
}

.post-engagement {
    display: flex;
    gap: 20px;
    margin-top: 15px;
}

.engagement-item {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: default;
    user-select: none;
    color: #9e9e9e; /* Gray for neutral state */
}

.engagement-item.clickable {
    cursor: pointer;
    transition: opacity 0.2s;
}

.engagement-item.clickable:hover {
    opacity: 0.7;
}

.engagement-item.helpful {
    color: #9e9e9e; /* Gray for neutral state */
}

.engagement-item.confusing {
    color: #9e9e9e; /* Gray for neutral state */
}

/* Active state styling - when user has selected this engagement type */
.engagement-item.helpful.active {
    color: #4caf50; /* Bright green */
    font-weight: 700; /* Bold */
}

.engagement-item.confusing.active {
    color: #ff9800; /* Bright orange */
    font-weight: 700; /* Bold */
}

.post-author {
    color: #666;
    font-size: 0.9em;
}

@media (min-width: 769px) {
    .post-author {
        grid-column: 1 / -1;
    }
}

.pagination {
    text-align: center;
    margin-top: 20px;
}

.pagination button {
    margin: 0 5px;
}

/* Imgur embed blockquote */
.post-embed > div .imgur-embed-pub {
    margin: 0 auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
    display: block !important;
    width: 100% !important;
    max-width: 540px !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.post-embed > div .imgur-embed-pub iframe {
    width: 100% !important;
    max-width: 540px !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

@media (min-width: 769px) {
    .post-embed > div .imgur-embed-pub {
        width: 540px !important;
    }
    
    .post-embed > div .imgur-embed-pub iframe {
        width: 540px !important;
    }
}

.create-page-container {
    padding-bottom: 32px;
}

.create-page-grid {
    display: grid;
    gap: 24px;
}

.create-panel,
.preview-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(44, 62, 80, 0.12);
    padding: 30px;
}

.create-panel-header,
.preview-panel-header {
    margin-bottom: 28px;
}

.eyebrow {
    color: #1f6f78;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.create-panel h2,
.preview-panel h3 {
    color: #1f2937;
    margin-bottom: 8px;
}

.create-intro,
.preview-panel-header p {
    color: #52606d;
    line-height: 1.5;
}

.create-post-form {
    display: grid;
    gap: 24px;
}

.create-field-row {
    display: grid;
    gap: 20px;
}

@media (min-width: 640px) {
    .create-field-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.create-field label {
    display: block;
    color: #1f2937;
    font-weight: 600;
    margin-bottom: 12px;
}

.source-url-input-row {
    display: block;
    width: 100%;
}

.language-summary-field {
    min-width: 0;
}

.language-summary-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.language-summary-row select {
    width: calc(50% - 18px);
    min-width: 0;
    flex: 1 1 0;
}

.language-summary-row span {
    color: #334155;
    font-weight: 500;
    flex: 0 0 auto;
}

.create-field input,
.create-field select,
.create-field textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 12px 14px;
    font: inherit;
    color: #1f2937;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.create-field textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

.create-field input:focus,
.create-field select:focus,
.create-field textarea:focus {
    outline: none;
    border-color: #1f6f78;
    box-shadow: 0 0 0 4px rgba(31, 111, 120, 0.12);
}

.field-help {
    color: #64748b;
    font-size: 0.92rem;
    margin-top: 8px;
}

.field-status {
    min-height: 1.4em;
    font-size: 0.92rem;
    margin-top: 12px;
    color: #64748b;
}

.field-status.is-valid {
    color: #0f766e;
}

.field-status.is-invalid {
    color: #c2410c;
}

.create-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    padding-top: 4px;
}

.create-actions-bottom {
    padding-top: 0;
    margin-top: 8px;
}

.create-error-bottom {
    margin-bottom: 0;
}

.secondary-link {
    color: #475569;
    text-decoration: none;
    font-weight: 500;
}

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

.btn-secondary {
    background: #e2e8f0;
    color: #334155;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.preview-empty {
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    padding: 28px;
    color: #64748b;
    background: #ffffff;
}

.preview-contribution-fields {
    display: grid;
    gap: 18px;
    width: 100%;
}

.post-contribution .preview-contribution-fields .create-field label {
    font-size: 1.05rem;
    margin-bottom: 10px;
}

.post-contribution .preview-contribution-fields .create-field textarea {
    border-radius: 8px;
}

.create-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 12px;
    color: #065f46;
    margin-bottom: 18px;
    padding: 16px;
}

.create-success-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.success-link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
