/* 2ch.tw 樣式 - 簡潔實用風格 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", "微軟正黑體", sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

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

/* Header */
header {
    background: #fff;
    padding: 30px;
    margin-bottom: 20px;
    border-bottom: 3px solid #333;
}

header h1 {
    font-size: 2.5em;
    font-weight: 700;
    color: #000;
    margin-bottom: 5px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 968px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Boards List (左側) */
.boards-list {
    background: #fff;
    padding: 20px;
    border: 1px solid #ddd;
}

.boards-list h2 {
    font-size: 1.3em;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #333;
}

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

.board-link {
    display: block;
    padding: 12px 15px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-left: 3px solid #666;
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
}

.board-link:hover {
    background: #f0f0f0;
    border-left-color: #000;
    transform: translateX(2px);
}

.board-name {
    display: block;
    font-weight: 600;
    font-size: 1.05em;
    margin-bottom: 3px;
}

.board-desc {
    display: block;
    font-size: 0.85em;
    color: #666;
}

/* Rules Content (右側) */
.rules-content {
    background: #fff;
    padding: 30px;
    border: 1px solid #ddd;
}

.rules h2 {
    font-size: 1.8em;
    margin-bottom: 10px;
}

.rules-subtitle {
    color: #666;
    font-size: 0.95em;
    margin-bottom: 20px;
}

.rules hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 25px 0;
}

.intro {
    background: #f9f9f9;
    padding: 20px;
    border-left: 4px solid #333;
    margin-bottom: 20px;
}

.intro p {
    margin-bottom: 12px;
}

.intro p:last-child {
    margin-bottom: 0;
}

.rule-section {
    margin-bottom: 25px;
}

.rule-section h3 {
    font-size: 1.3em;
    margin-bottom: 12px;
    color: #000;
}

.rule-section ol,
.rule-section ul {
    margin-left: 25px;
    margin-bottom: 12px;
}

.rule-section li {
    margin-bottom: 8px;
}

.rule-section ul ul {
    margin-top: 8px;
}

.rule-section p {
    margin-bottom: 10px;
}

.warning {
    background: #fff3cd;
    padding: 12px 15px;
    border-left: 4px solid #ff9800;
    margin-top: 12px;
    font-weight: 500;
}

.rule-section strong {
    font-weight: 600;
}

/* Footer */
footer {
    background: #fff;
    padding: 20px;
    text-align: center;
    border-top: 1px solid #ddd;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .rules-content {
        padding: 20px 15px;
    }

    .rules h2 {
        font-size: 1.5em;
    }

    .rule-section h3 {
        font-size: 1.15em;
    }
}

/* ================================================
   Board Page Styles
   ================================================ */

.board-page {
    /* No max-width needed - it's part of grid layout */
}

/* Board Header */
.board-header {
    background: #fff;
    padding: 25px 30px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-left: 4px solid #333;
}

.board-header h2 {
    font-size: 1.8em;
    margin-bottom: 8px;
}

.board-description {
    color: #666;
    font-size: 1.05em;
}

/* Post Form Container */
.post-form-container {
    background: #fff;
    padding: 25px 30px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
}

.post-form-container h3 {
    font-size: 1.3em;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

#post-form input[type="text"],
#post-form textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1em;
    margin-bottom: 10px;
}

#post-form textarea {
    line-height: 1.6;
    resize: vertical;
}

#post-form input[type="text"]:focus,
#post-form textarea:focus {
    outline: none;
    border-color: #333;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-count {
    color: #999;
    font-size: 0.9em;
}

#post-form button {
    background: #333;
    color: #fff;
    border: none;
    padding: 10px 30px;
    font-size: 1em;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

#post-form button:hover:not(:disabled) {
    background: #000;
}

#post-form button:disabled {
    background: #999;
    cursor: not-allowed;
}

.message {
    margin-top: 12px;
    padding: 10px 15px;
    border-radius: 4px;
    font-size: 0.95em;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Threads Container */
.threads-container {
    background: #fff;
    padding: 25px 30px;
    border: 1px solid #ddd;
}

.threads-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
}

.threads-header h3 {
    font-size: 1.3em;
}

.refresh-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    padding: 6px 16px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9em;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: #e0e0e0;
}

/* Threads List */
.threads-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.thread-item {
    border: 1px solid #e0e0e0;
    border-left: 3px solid #999;
    padding: 15px;
    background: #fafafa;
    transition: all 0.2s;
}

.thread-item:hover {
    background: #f5f5f5;
    border-left-color: #333;
}

.thread-content {
    margin-bottom: 10px;
}

.thread-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #000;
    margin-bottom: 5px;
}

.thread-author,
.post-author,
.reply-author {
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
}

.thread-content p {
    color: #333;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.thread-meta {
    display: flex;
    gap: 15px;
    align-items: center;
    font-size: 0.9em;
    color: #666;
}

.thread-id {
    font-weight: 600;
    color: #999;
}

.thread-time {
    color: #999;
}

.thread-replies {
    color: #666;
}

.thread-link {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    margin-left: auto;
    padding: 4px 12px;
    border: 1px solid #ddd;
    border-radius: 3px;
    transition: all 0.2s;
}

.thread-link:hover {
    background: #333;
    color: #fff;
    border-color: #333;
}

/* Empty/Loading/Error States */
.loading,
.empty,
.error {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 1.05em;
}

.error {
    color: #d9534f;
}

/* Responsive */
@media (max-width: 768px) {
    .board-page {
        max-width: 100%;
    }

    .board-header,
    .post-form-container,
    .threads-container {
        padding: 20px 15px;
    }

    .board-header h2 {
        font-size: 1.5em;
    }

    .thread-meta {
        flex-wrap: wrap;
        gap: 10px;
    }

    .thread-link {
        margin-left: 0;
        flex-basis: 100%;
        text-align: center;
    }
}

/* ================================================
   Syntax Help Tooltip
   ================================================ */

/* Textarea wrapper for positioning help icon */
.textarea-wrapper {
    position: relative;
}

.textarea-wrapper textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1em;
    margin-bottom: 10px;
    line-height: 1.6;
    resize: vertical;
}

.textarea-wrapper textarea:focus {
    outline: none;
    border-color: #333;
}

/* Help icon */
.syntax-help {
    position: absolute;
    top: 8px;
    right: 8px;
    cursor: help;
}

.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #e0e0e0;
    color: #666;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.syntax-help:hover .help-icon,
.syntax-help:focus .help-icon {
    background: #333;
    color: #fff;
}

/* Help tooltip */
.help-tooltip {
    display: none;
    position: absolute;
    top: 28px;
    right: 0;
    width: 420px;
    max-width: 90vw;
    background: #fff;
    border: 1px solid #999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    padding: 16px;
    font-size: 0.9em;
    line-height: 1.5;
}

.syntax-help:hover .help-tooltip,
.syntax-help:focus .help-tooltip,
.syntax-help.active .help-tooltip {
    display: block;
}

.help-title {
    font-weight: 600;
    font-size: 1em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.help-section {
    margin-bottom: 12px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-label {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.help-tooltip code {
    display: block;
    background: #f5f5f5;
    padding: 6px 8px;
    border: 1px solid #ddd;
    font-family: "SF Mono", "Consolas", "Monaco", monospace;
    font-size: 0.9em;
    color: #333;
    margin: 4px 0;
    white-space: pre-wrap;
    word-break: break-all;
}

.help-note {
    color: #666;
    font-size: 0.9em;
    margin: 2px 0;
    padding-left: 4px;
}

.help-footer {
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
}

/* Mobile: tap to toggle */
@media (max-width: 768px) {
    .help-tooltip {
        right: -8px;
        width: calc(100vw - 60px);
        max-width: 360px;
    }
}

/* Ensure textarea doesn't overlap with form styles */
#post-form .textarea-wrapper textarea,
#reply-form .textarea-wrapper textarea {
    margin-bottom: 10px;
}

/* ================================================
   Thread Detail Page Styles
   ================================================ */

/* Navigation */
.thread-navigation {
    margin-bottom: 20px;
}

.back-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.95em;
    transition: all 0.2s;
}

.back-btn:hover {
    background: #e0e0e0;
}

/* Thread Detail Container */
.thread-detail {
    background: #fff;
    padding: 25px 30px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
}

/* Original Post */
.op-post {
    border-left: 4px solid #333;
    padding-left: 20px;
}

.op-post .thread-title {
    font-size: 1.5em;
    font-weight: 700;
    color: #000;
    margin-bottom: 12px;
}

.post-header,
.reply-header {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.9em;
    color: #666;
}

.post-id,
.reply-id {
    font-weight: 600;
    color: #000;
}

.post-time,
.reply-time {
    color: #999;
}

.post-board {
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 500;
}

.post-content,
.reply-content {
    margin-bottom: 12px;
}

.post-content p,
.reply-content p {
    color: #333;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.post-meta {
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
    font-size: 0.9em;
    color: #666;
}

.reply-count {
    font-weight: 500;
}

/* Reply Form */
.reply-form-container {
    background: #fff;
    padding: 25px 30px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
}

.reply-form-container h3 {
    font-size: 1.3em;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

#reply-form input[type="text"],
#reply-form textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1em;
    margin-bottom: 10px;
}

#reply-form textarea {
    line-height: 1.6;
    resize: vertical;
}

#reply-form input[type="text"]:focus,
#reply-form textarea:focus {
    outline: none;
    border-color: #333;
}

/* Replies Container */
.replies-container {
    background: #fff;
    padding: 25px 30px;
    border: 1px solid #ddd;
}

.replies-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
}

.replies-header h3 {
    font-size: 1.3em;
}

/* Replies List */
.replies-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.reply-item {
    border: 1px solid #e0e0e0;
    border-left: 3px solid #999;
    padding: 15px;
    background: #fafafa;
}

.reply-number {
    background: #e0e0e0;
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 0.85em;
}

/* Thread Detail Responsive */
@media (max-width: 768px) {
    .thread-detail,
    .reply-form-container,
    .replies-container {
        padding: 20px 15px;
    }

    .post-header,
    .reply-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .op-post {
        padding-left: 15px;
    }
}
