/*
 * Community pages (community.php, community/thread.php, community/new.php).
 * Referenced with ?v=COMMUNITY_CSS_VERSION (community/_common.php): bump that
 * constant whenever this file changes.
 */
.cm-page {
    --cm-ink: #1c2530;
    --cm-ink-soft: #4a5663;
    --cm-muted: #7a8794;
    --cm-line: #e4e8ed;
    --cm-line-soft: #eef1f4;
    --cm-surface: #ffffff;
    --cm-tint: #f6f8f9;
    --cm-accent: #28a745;
    --cm-accent-ink: #1c7a33;
    --cm-accent-soft: #e9f6ec;
    --cm-warn: #b45309;
    --cm-warn-soft: #fff7e6;
    --cm-danger: #c0392b;
    --cm-radius: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "PingFang SC", "Hiragino Sans", "Noto Sans", sans-serif;
    color: var(--cm-ink);
    font-size: 15px;
    line-height: 1.6;
    padding: 6px 0 56px;
}
.cm-page *, .cm-overlay *, .cm-toasts * { box-sizing: border-box; }
.cm-page a { color: inherit; }
.cm-page h1, .cm-page h2, .cm-page h3, .cm-page h4 { font-family: inherit; }

/* ---- hero / crumbs ---- */
.cm-hero { padding: 6px 0 18px; border-bottom: 1px solid var(--cm-line); margin-bottom: 20px; }
.cm-hero h1 { margin: 0; font-size: 30px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.cm-hero-sub { margin: 6px 0 0; color: var(--cm-ink-soft); max-width: 62ch; }
.cm-crumb { margin: 0 0 10px; font-size: 13px; color: var(--cm-muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cm-crumb a { color: var(--cm-accent-ink); text-decoration: none; font-weight: 600; }
.cm-crumb a:hover { text-decoration: underline; }

/* ---- layout ---- */
.cm-layout { display: grid; grid-template-columns: minmax(0, 1fr) 272px; gap: 28px; align-items: start; }
.cm-main { min-width: 0; }
.cm-side { display: grid; gap: 16px; position: sticky; top: 88px; }
.cm-card { background: var(--cm-surface); border: 1px solid var(--cm-line); border-radius: var(--cm-radius); padding: 18px 20px; }
.cm-card-title { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--cm-muted); }

/* ---- buttons ---- */
.cm-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 14px; border: 1px solid var(--cm-line); border-radius: 8px;
    background: var(--cm-surface); color: var(--cm-ink) !important; font: inherit; font-size: 14px; font-weight: 600;
    line-height: 1.2; text-decoration: none !important; cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.cm-btn:hover { background: var(--cm-tint); border-color: #cfd6dd; }
.cm-btn:focus-visible, .cm-act:focus-visible, .cm-tabs a:focus-visible, .cm-nodes a:focus-visible {
    outline: 2px solid var(--cm-accent); outline-offset: 2px;
}
.cm-btn:disabled { opacity: .55; cursor: not-allowed; }
.cm-btn-primary { background: var(--cm-accent); border-color: var(--cm-accent); color: #fff !important; }
.cm-btn-primary:hover { background: var(--cm-accent-ink); border-color: var(--cm-accent-ink); }
.cm-btn-danger { background: var(--cm-danger); border-color: var(--cm-danger); color: #fff !important; }
.cm-btn-danger:hover { background: #a02d21; border-color: #a02d21; }
.cm-btn-block { display: flex; width: 100%; }

/* ---- toolbar / tabs ---- */
.cm-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.cm-tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--cm-tint); border-radius: 9px; }
.cm-tabs a { padding: 6px 14px; border-radius: 7px; font-size: 14px; font-weight: 600; color: var(--cm-ink-soft); text-decoration: none; }
.cm-tabs a:hover { color: var(--cm-ink); }
.cm-tabs a.is-active { background: var(--cm-surface); color: var(--cm-ink); box-shadow: 0 1px 2px rgba(20, 32, 25, .12); }

/* ---- thread list ---- */
.cm-threads { list-style: none; margin: 0; padding: 0; }
.cm-thread { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--cm-line-soft); }
.cm-thread.is-pinned { background: linear-gradient(90deg, var(--cm-accent-soft), transparent 60%); border-radius: 8px; padding-left: 10px; padding-right: 10px; }
.cm-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--cm-tint); flex: 0 0 auto; }
.cm-byline .cm-avatar { width: 32px; height: 32px; }
.cm-avatar-sm, .cm-byline .cm-avatar-sm { width: 24px; height: 24px; }
.cm-thread-title { margin: 0; font-size: 16px; font-weight: 650; line-height: 1.4; letter-spacing: -.005em; }
.cm-thread-title a { text-decoration: none; color: var(--cm-ink); }
.cm-thread-title a:hover { color: var(--cm-accent-ink); }
.cm-thread-title a:visited { color: var(--cm-ink-soft); }
.cm-flag-icon { color: var(--cm-accent); font-size: .8em; margin-right: 6px; }
.cm-thread-meta { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 13px; color: var(--cm-muted); }
.cm-user { color: var(--cm-ink-soft) !important; font-weight: 600; text-decoration: none; }
.cm-user:hover { color: var(--cm-accent-ink) !important; }
.cm-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--cm-tint); color: var(--cm-ink-soft) !important; font-size: 12px; font-weight: 600; text-decoration: none; }
a.cm-chip:hover { background: var(--cm-accent-soft); color: var(--cm-accent-ink) !important; }
.cm-chip-op { background: var(--cm-accent-soft); color: var(--cm-accent-ink) !important; }
.cm-type { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--cm-line); color: var(--cm-ink-soft); }
.cm-type-question { border-color: #c7dcf5; color: #1f5fa8; background: #f1f7fe; }
.cm-type-share { border-color: #f1ddb4; color: #8a5a00; background: #fff9ec; }
.cm-type-show { border-color: #d9cdf3; color: #5b3aa8; background: #f6f2fd; }
.cm-thread-stats { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--cm-muted); }
.cm-replies { min-width: 38px; padding: 3px 10px; border-radius: 999px; background: var(--cm-accent-soft); color: var(--cm-accent-ink) !important; font-weight: 700; text-align: center; text-decoration: none; font-variant-numeric: tabular-nums; }
.cm-replies.is-zero { background: var(--cm-tint); color: var(--cm-muted) !important; }
.cm-count { font-size: 12px; font-weight: 700; color: var(--cm-muted); font-variant-numeric: tabular-nums; }
.cm-muted { color: var(--cm-muted) !important; font-size: 13px; text-decoration: none; }

.cm-empty { text-align: center; padding: 56px 16px; color: var(--cm-muted); border: 1px dashed var(--cm-line); border-radius: var(--cm-radius); margin-top: 12px; }
.cm-empty i { font-size: 34px; margin-bottom: 10px; color: #c2cad2; }
.cm-empty p { margin: 0 0 14px; }
.cm-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 22px; }
.cm-pager-pos { font-size: 14px; color: var(--cm-ink-soft); font-variant-numeric: tabular-nums; }

/* ---- sidebar ---- */
.cm-me-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cm-me-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-me-guest { margin: 0 0 12px; color: var(--cm-ink-soft); }
.cm-me-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; }
/* Number first, label under it: the two numbers stay level even when a label wraps. */
.cm-me-stats div { display: flex; flex-direction: column-reverse; justify-content: flex-end; background: var(--cm-tint); border-radius: 8px; padding: 9px 10px; min-width: 0; }
.cm-me-stats dt { margin: 2px 0 0; font-size: 12px; font-weight: 600; line-height: 1.3; color: var(--cm-muted); }
.cm-me-stats dd { margin: 0; font-size: 20px; font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; }
.cm-me-links { display: flex; flex-direction: column; gap: 2px; margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--cm-line); }
.cm-me-links a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 0 -8px; border-radius: 7px; font-size: 14px; font-weight: 600; color: var(--cm-ink-soft); text-decoration: none; }
.cm-me-links a:hover, .cm-me-links a.is-active { background: var(--cm-tint); color: var(--cm-ink); }
.cm-me-links i { width: 16px; text-align: center; color: var(--cm-muted); }
.cm-state { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 4px; background: #fff4d6; color: #8a5a00; }
.cm-state-hidden { background: #fde8e8; color: #b42318; }
.cm-mine-excerpt { margin: 0; font-size: 15px; line-height: 1.5; color: var(--cm-ink); overflow-wrap: anywhere; }
.cm-mine-excerpt a { color: inherit; text-decoration: none; }
.cm-mine-excerpt a:hover { color: var(--cm-accent-ink); }
.cm-thread-stats .cm-act { white-space: nowrap; }
.cm-level { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--cm-tint); color: var(--cm-ink-soft); white-space: nowrap; }
.cm-level-1 { background: #eaf3fd; color: #1f5fa8; }
.cm-level-2 { background: var(--cm-accent-soft); color: var(--cm-accent-ink); }
.cm-level-3 { background: #1c2530; color: #fff; }
.cm-nodes ul, .cm-rules ul { list-style: none; margin: 0; padding: 0; }
.cm-nodes a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; margin: 0 -10px; border-radius: 7px; text-decoration: none; color: var(--cm-ink-soft); font-weight: 600; font-size: 14px; }
.cm-nodes a:hover { background: var(--cm-tint); color: var(--cm-ink); }
.cm-nodes a.is-active { background: var(--cm-accent-soft); color: var(--cm-accent-ink); }
.cm-rules li { position: relative; padding: 4px 0 4px 16px; font-size: 13px; color: var(--cm-ink-soft); }
.cm-rules li::before { content: ""; position: absolute; left: 2px; top: 13px; width: 5px; height: 5px; border-radius: 50%; background: var(--cm-accent); }

.cm-note { margin: 0 0 12px; padding: 9px 12px; border-radius: 8px; background: var(--cm-tint); color: var(--cm-ink-soft); font-size: 13px; }
.cm-note-warn { background: var(--cm-warn-soft); color: var(--cm-warn); }
.cm-side .cm-note:last-child { margin-bottom: 0; }

/* ---- thread page ---- */
.cm-post { margin-bottom: 14px; }
.cm-op { padding: 24px 26px; }
.cm-op-head h1 { margin: 0 0 10px; font-size: 26px; font-weight: 750; line-height: 1.3; letter-spacing: -.015em; overflow-wrap: anywhere; }
.cm-byline { margin: 0 0 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; }
.cm-link-card { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--cm-line); border-radius: 8px; background: var(--cm-tint); color: var(--cm-accent-ink) !important; font-weight: 600; text-decoration: none; overflow: hidden; }
.cm-link-card span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-link-card:hover { border-color: var(--cm-accent); }
.cm-content { font-size: 15.5px; line-height: 1.7; overflow-wrap: anywhere; }
.cm-content > :first-child { margin-top: 0; }
.cm-content > :last-child { margin-bottom: 0; }
.cm-content p { margin: 0 0 12px; }
.cm-content a { color: var(--cm-accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.cm-content h3 { font-size: 18px; margin: 20px 0 8px; font-weight: 700; }
.cm-content h4 { font-size: 16px; margin: 16px 0 6px; font-weight: 700; }
.cm-content ul, .cm-content ol { margin: 0 0 12px; padding-left: 24px; }
.cm-content blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--cm-line); color: var(--cm-ink-soft); font-size: inherit; }
.cm-content pre { margin: 0 0 12px; padding: 12px 14px; background: #f4f6f8; border: 1px solid var(--cm-line-soft); border-radius: 8px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; }
.cm-content code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.cm-content :not(pre) > code { background: #f1f3f5; padding: 1px 5px; border-radius: 4px; color: inherit; }
.cm-content-reply { font-size: 14.5px; }

.cm-actions { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 12px; margin-left: -8px; }
.cm-act { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border: 0; border-radius: 6px; background: none; color: var(--cm-muted) !important; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.cm-act:hover { background: var(--cm-tint); color: var(--cm-ink) !important; }
.cm-act:disabled { opacity: .5; cursor: default; background: none; }
.cm-act.is-on { color: var(--cm-accent-ink) !important; }
.cm-act-like.is-on { color: #d6336c !important; }
.cm-act-mod { color: var(--cm-warn) !important; }
.cm-like-count { font-variant-numeric: tabular-nums; }

.cm-section-title { margin: 26px 0 12px; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.cm-no-responses { margin: 0 0 14px; }
.cm-response { padding: 16px 20px; }
.cm-replies-list { margin-top: 4px; }
.cm-replies-list:empty { display: none; }
.cm-reply { margin-top: 12px; padding: 12px 0 0 16px; border-top: 1px solid var(--cm-line-soft); border-left: 2px solid var(--cm-line-soft); margin-left: 4px; }
.cm-reply .cm-byline { margin-bottom: 6px; }
.cm-reply .cm-actions { margin-top: 6px; }
.cm-reply-form { margin: 12px 0 0 4px; padding: 12px 0 0 16px; border-left: 2px solid var(--cm-accent); }

/* ---- forms ---- */
.cm-compose-title { margin: 0 0 18px; font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
.cm-field { margin: 0 0 16px; min-width: 0; border: 0; padding: 0; }
.cm-field-row { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 20px; }
.cm-label { display: block; margin: 0 0 6px; padding: 0; border: 0; font-size: 13px; font-weight: 700; color: var(--cm-ink-soft); width: auto; }
.cm-page .cm-input { width: 100%; padding: 9px 12px; border: 1px solid #cfd6dd; border-radius: 8px; background: #fff; color: var(--cm-ink); font: inherit; font-size: 15px; line-height: 1.4; }
.cm-page .cm-input:hover { background: #fff; }
/* One ring on focus: the border turns green with a soft halo, no second outline. */
.cm-page .cm-input:focus, .cm-page .cm-input:focus-visible { outline: none; border-color: var(--cm-accent); box-shadow: 0 0 0 3px rgba(40, 167, 69, .18); }
.cm-page input.cm-input, .cm-page select.cm-input { height: 40px; padding-top: 0; padding-bottom: 0; }
.cm-page select.cm-input {
    -webkit-appearance: none; appearance: none; padding-right: 34px; cursor: pointer;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235b6672' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.cm-overlay .cm-input { width: 100%; padding: 9px 12px; border: 1px solid #cfd6dd; border-radius: 8px; background: #fff; color: #1c2530; font: inherit; font-size: 15px; }
.cm-textarea { resize: vertical; min-height: 84px; }
.cm-static { margin: 0; height: 40px; line-height: 40px; font-weight: 600; }
.cm-types { display: block; }
.cm-type-list { display: flex; flex-wrap: wrap; gap: 8px; }
.cm-type-option { margin: 0; cursor: pointer; }
.cm-type-option input { position: absolute; opacity: 0; pointer-events: none; }
.cm-type-option span { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border: 1px solid #cfd6dd; border-radius: 999px; font-size: 14px; font-weight: 600; line-height: 1; color: var(--cm-ink-soft); background: #fff; transition: border-color .12s, background-color .12s; }
.cm-type-option:hover span { border-color: #aab4be; }
.cm-type-option input:checked + span { border-color: var(--cm-accent); background: var(--cm-accent-soft); color: var(--cm-accent-ink); }
.cm-type-option input:focus-visible + span { outline: 2px solid var(--cm-accent); outline-offset: 2px; }
.cm-form-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.cm-form-status { flex: 1 1 200px; margin: 0; font-size: 13px; color: var(--cm-accent-ink); }
.cm-form-status.is-error { color: var(--cm-danger); }
.cm-compose .tox-tinymce { border-radius: 8px; border-color: #cfd6dd; }

/* ---- dialog ---- */
body.cm-dialog-open { overflow: hidden; }
.cm-overlay { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(18, 26, 34, .5); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
.cm-dialog { width: 100%; max-width: 440px; padding: 22px 24px; border-radius: 12px; background: #fff; color: #1c2530; box-shadow: 0 24px 60px rgba(18, 26, 34, .28); }
.cm-dialog-title { margin: 0 0 8px; font-size: 18px; font-weight: 750; font-family: inherit; }
.cm-dialog-message { margin: 0 0 6px; color: #4a5663; font-size: 15px; line-height: 1.55; }
.cm-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.cm-overlay .cm-btn { display: inline-flex; align-items: center; padding: 8px 14px; border: 1px solid #e4e8ed; border-radius: 8px; background: #fff; color: #1c2530; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.cm-overlay .cm-btn:hover { background: #f6f8f9; }
.cm-overlay .cm-btn-primary { background: #28a745; border-color: #28a745; color: #fff; }
.cm-overlay .cm-btn-primary:hover { background: #1c7a33; }
.cm-overlay .cm-btn-danger { background: #c0392b; border-color: #c0392b; color: #fff; }
.cm-overlay .cm-btn-danger:hover { background: #a02d21; }
.cm-overlay .cm-btn:focus-visible, .cm-overlay .cm-input:focus-visible { outline: 2px solid #28a745; outline-offset: 2px; }

/* ---- toast ---- */
.cm-toasts { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 2100; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.cm-toast { padding: 10px 16px; border-radius: 8px; background: #1c2530; color: #fff; font: 600 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; box-shadow: 0 10px 30px rgba(18, 26, 34, .25); transition: opacity .25s, transform .25s; max-width: min(92vw, 520px); }
.cm-toast.is-error { background: #c0392b; }
.cm-toast.is-leaving { opacity: 0; transform: translateY(6px); }

/* ---- responsive ---- */
@media (max-width: 991px) {
    .cm-layout { grid-template-columns: minmax(0, 1fr); }
    .cm-side { position: static; order: -1; }
    .cm-side .cm-rules { display: none; }
    .cm-nodes ul { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
    .cm-nodes li { flex: 0 0 auto; }
    .cm-nodes a { margin: 0; padding: 6px 12px; border: 1px solid var(--cm-line); border-radius: 999px; white-space: nowrap; }
    .cm-nodes .cm-count { display: none; }
}
@media (max-width: 600px) {
    .cm-hero h1 { font-size: 24px; }
    .cm-op { padding: 18px 16px; }
    .cm-op-head h1 { font-size: 21px; }
    .cm-card { padding: 14px 16px; }
    .cm-thread { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; }
    .cm-thread.cm-mine { grid-template-columns: minmax(0, 1fr) auto; }
    .cm-thread .cm-avatar { width: 32px; height: 32px; }
    .cm-last { display: none; }
    .cm-field-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .cm-btn, .cm-toast { transition: none; }
}
.cm-thread.cm-mine { grid-template-columns: minmax(0, 1fr) auto; }
