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

body {
    font-family: 'Courier New', monospace;
    background: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.6;
}

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

header {
    border-bottom: 2px solid #333;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

header h1 {
    font-size: 20px;
    margin-bottom: 12px;
    color: #fff;
}

.server-config {
    display: flex;
    gap: 10px;
    align-items: center;
}

.server-config input {
    padding: 8px 12px;
    background: #2a2a2a;
    border: 1px solid #444;
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.server-config input:focus {
    outline: none;
    border-color: #666;
}

.server-config button {
    padding: 8px 20px;
    background: #444;
    border: 1px solid #555;
    color: #fff;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.server-config button:hover {
    background: #555;
}

.main-content {
    display: flex;
    gap: 20px;
    min-height: 600px;
}

.sidebar {
    width: 300px;
    flex-shrink: 0;
    border-right: 1px solid #333;
    padding-right: 20px;
}

.sidebar h2 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #fff;
}

.group-search {
    width: 100%;
    padding: 6px 10px;
    margin-bottom: 10px;
    background: #2a2a2a;
    border: 1px solid #444;
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.group-search:focus {
    outline: none;
    border-color: #666;
}

.groups-list {
    max-height: 700px;
    overflow-y: auto;
}

.group-item {
    padding: 6px 8px;
    margin-bottom: 3px;
    background: #2a2a2a;
    border: 1px solid #333;
    cursor: pointer;
    transition: background 0.2s;
}

.group-item:hover {
    background: #333;
}

.group-item.active {
    background: #444;
    border-color: #666;
}

.group-name {
    font-weight: bold;
    color: #fff;
    margin-bottom: 2px;
    font-size: 12px;
}

.group-info {
    font-size: 10px;
    color: #999;
}

.content {
    flex: 1;
    min-width: 0;
}

.welcome {
    padding: 40px;
    text-align: center;
    color: #666;
}

.articles-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

#articles-panel h2 {
    font-size: 14px;
    margin: 0;
    color: #fff;
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.articles-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.loading-more {
    text-align: center;
    padding: 15px;
    color: #999;
    font-style: italic;
}

.article-item {
    padding: 8px 10px;
    background: #2a2a2a;
    border: 1px solid #333;
    cursor: pointer;
    transition: background 0.2s;
}

.article-item:hover {
    background: #333;
}

.article-subject {
    font-weight: bold;
    color: #fff;
    margin-bottom: 3px;
    font-size: 12px;
}

.article-meta {
    font-size: 10px;
    color: #999;
    display: flex;
    gap: 12px;
}

#article-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.article-header {
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
    margin-bottom: 12px;
}

.article-header button {
    padding: 6px 12px;
    background: #444;
    border: 1px solid #555;
    color: #fff;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    margin-bottom: 10px;
}

.article-header button:hover {
    background: #555;
}

.article-header h3 {
    font-size: 14px;
    color: #fff;
    margin-bottom: 8px;
}

.article-header .article-meta {
    font-size: 10px;
    color: #999;
    display: flex;
    gap: 12px;
}

.article-body {
    white-space: pre-wrap;
    font-size: 12px;
    line-height: 1.6;
    color: #e0e0e0;
    padding: 12px;
    background: #2a2a2a;
    border: 1px solid #333;
    max-height: 600px;
    overflow-y: auto;
}

.loading, .error {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    z-index: 1000;
}

.error {
    background: #3a1a1a;
    border-color: #a44;
    color: #faa;
}

.info {
    color: #666;
    font-style: italic;
    padding: 20px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #444;
}

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

/* Mobile Optimizations */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        max-width: 100%;
    }

    header {
        padding-bottom: 15px;
        margin-bottom: 15px;
    }

    header h1 {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .server-config {
        flex-wrap: wrap;
        gap: 8px;
    }

    .server-config input {
        flex: 1 1 auto;
        min-width: 120px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }

    .server-config input[type="number"] {
        min-width: 80px;
        flex: 0 0 80px;
    }

    .server-config button {
        flex: 1 1 100%;
        padding: 12px 20px;
        font-size: 16px;
        min-height: 44px; /* Minimum touch target */
    }

    .main-content {
        flex-direction: column;
        gap: 15px;
        min-height: auto;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #333;
        padding-right: 0;
        padding-bottom: 15px;
        margin-bottom: 15px;
    }

    .groups-list {
        max-height: 300px;
    }

    .group-item {
        padding: 12px;
        min-height: 44px; /* Minimum touch target */
    }

    .group-name {
        font-size: 13px;
    }

    .group-info {
        font-size: 11px;
    }

    .content {
        width: 100%;
    }

    .articles-header {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 12px;
    }

    #articles-panel h2 {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .post-btn {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
    }

    .article-item {
        padding: 12px;
        min-height: 60px; /* Larger touch target */
    }

    .article-subject {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .article-meta {
        font-size: 11px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .article-header {
        padding-bottom: 12px;
        margin-bottom: 15px;
    }

    .article-header > div {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .article-header button {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
        margin-bottom: 12px;
        width: 100%;
    }

    .article-header h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .article-body {
        font-size: 13px;
        line-height: 1.7;
        padding: 15px;
        max-height: none;
        overflow-y: visible;
    }

    /* Modal optimizations for mobile */
    .modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 95vh;
        margin: 10px;
    }

    .modal-header {
        padding: 15px;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .modal-body {
        padding: 15px;
    }

    .form-group input,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }

    .form-group textarea {
        min-height: 200px;
    }

    .modal-actions {
        flex-direction: column-reverse;
        gap: 10px;
    }

    .cancel-btn,
    .submit-btn {
        width: 100%;
        padding: 14px;
        font-size: 16px;
        min-height: 44px;
    }

    .loading, .error {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        padding: 12px 15px;
        font-size: 14px;
    }

    .welcome {
        padding: 30px 20px;
        font-size: 14px;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }

    header h1 {
        font-size: 16px;
    }

    .server-config input {
        font-size: 16px;
        padding: 14px;
    }

    .group-search {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }

    .groups-list {
        max-height: 250px;
    }

    .article-body {
        font-size: 12px;
        padding: 12px;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets for touch devices */
    button, .group-item, .article-item {
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    }

    .group-item:active,
    .article-item:active {
        background: #3a3a3a;
    }

    button:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* Prevent text selection on buttons (better UX) */
button, .post-btn, .close-btn {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Improve scrolling on mobile */
.groups-list,
.articles-list,
.article-body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Post/Reply buttons */
.post-btn {
    padding: 8px 16px;
    background: #555;
    border: 1px solid #666;
    color: #fff;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.post-btn:hover {
    background: #666;
}

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

.modal-content {
    background: #2a2a2a;
    border: 1px solid #444;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h2 {
    margin: 0;
    color: #fff;
    font-size: 20px;
}

.close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 30px;
}

.close-btn:hover {
    color: #faa;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #fff;
    font-weight: bold;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #666;
}

.form-group textarea {
    resize: vertical;
    min-height: 200px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.cancel-btn,
.submit-btn {
    padding: 10px 20px;
    border: 1px solid #555;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.cancel-btn {
    background: #444;
    color: #fff;
}

.cancel-btn:hover {
    background: #555;
}

.submit-btn {
    background: #555;
    color: #fff;
}

.submit-btn:hover {
    background: #666;
}

