/* =========================================================
   ChartView Trade - Shared Global Menu / Board UI
   ========================================================= */

:root {
  --cv-ui-panel: var(--bg-panel, #131722);
  --cv-ui-panel-2: var(--bg-panel-header, #1c2030);
  --cv-ui-border: var(--border-color, #2a2e39);
  --cv-ui-text: var(--text-primary, #fff);
  --cv-ui-muted: var(--text-secondary, #b2b5be);
  --cv-ui-accent: var(--accent, #2962ff);
}

#top-menu-bar {
  gap: 10px;
  justify-content: flex-start;
}

#top-menu-brand {
  flex: 0 0 auto;
  white-space: nowrap;
}

#top-menu-spacer {
  flex: 1 1 auto;
  min-width: 18px;
}

#top-menu-items {
  flex: 0 0 auto;
  padding: 0;
  overflow: visible;
}

#top-menu-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

#top-menu-items > button,
#top-menu-controls button,
#global-settings-btn {
  border: 1px solid var(--cv-ui-border);
  background: color-mix(in srgb, var(--cv-ui-panel) 88%, transparent);
  color: var(--cv-ui-text);
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  min-height: 34px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

#top-menu-items > button:hover,
#top-menu-controls button:hover,
#global-settings-btn:hover {
  background: color-mix(in srgb, var(--cv-ui-panel-2) 82%, transparent);
  border-color: var(--cv-ui-accent);
}

#top-menu-items > button:active,
#top-menu-controls button:active,
#global-settings-btn:active {
  transform: translateY(1px);
}

#auth-box { margin-right: 0 !important; }
#auth-guest-view, #auth-user-view { display: inline-flex; align-items: center; gap: 6px; }
#auth-user-nickname {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 3px;
  white-space: nowrap;
  font-weight: 700;
}

#theme-toggle-btn {
  width: 34px;
  min-width: 34px;
  padding: 5px !important;
  font-size: 16px !important;
  line-height: 1;
}

#global-settings-wrap { position: relative; }
#global-settings-btn { width: 34px; min-width: 34px; padding: 5px !important; }

#global-settings-popup {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100050;
  width: 168px;
  padding: 8px;
  border: 1px solid var(--cv-ui-border);
  border-radius: 9px;
  background: var(--cv-ui-panel-2);
  box-shadow: 0 14px 32px rgba(0,0,0,.28);
}

#global-settings-popup[hidden] { display: none !important; }
#global-settings-popup .cv-setting-label { padding: 6px 8px 5px; color: var(--cv-ui-muted); font-size: 11px; }
#global-settings-popup button { display: block; width: 100%; margin: 2px 0; text-align: left; border: 0; background: transparent; color: var(--cv-ui-text); border-radius: 6px; padding: 8px 9px; cursor: pointer; }
#global-settings-popup button:hover,
#global-settings-popup button.active { background: rgba(90,162,255,.12); }

/* Board typography / spacing */
#board-section .cv-board-head {
  gap: 18px;
  margin-bottom: 18px;
}

#board-section .cv-board-head h2 {
  font-size: clamp(21px, 2vw, 28px);
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin: 0;
}

#board-section .cv-board-head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.cv-action-btn,
.cv-primary-btn {
  min-height: 34px;
  border-radius: 7px;
  font-size: 12px;
}

.cv-post-card,
.cv-detail-card {
  border-radius: 10px;
}

.cv-post-card {
  padding: 16px 18px;
}

.cv-post-title-btn,
.cv-detail-card h2 {
  font-size: clamp(17px, 1.55vw, 21px);
  line-height: 1.48;
  letter-spacing: -0.01em;
}

.cv-post-preview,
.cv-detail-body,
.cv-comment-body {
  font-size: 14px;
  line-height: 1.72;
}

.cv-post-meta,
.cv-comment-meta {
  font-size: 12px;
  line-height: 1.5;
}

/* Post editor toolbar */
.cv-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 7px;
}

.cv-editor-tool {
  border: 1px solid var(--cv-community-border);
  background: var(--cv-community-card);
  color: var(--cv-community-text);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
}

.cv-editor-tool:hover {
  border-color: var(--cv-community-accent);
}

.cv-editor-emoji {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 7px;
  margin-bottom: 8px;
  border: 1px solid var(--cv-community-border);
  border-radius: 8px;
  background: var(--cv-community-card);
}

.cv-editor-emoji.open { display: flex; }
.cv-editor-emoji[hidden] { display: none !important; }
.cv-editor-emoji button { border: 0; background: transparent; font-size: 18px; cursor: pointer; padding: 3px; }

.cv-editor-hint {
  margin: 5px 0 0;
  color: var(--cv-community-muted);
  font-size: 11px;
  line-height: 1.45;
}

@media (max-width: 700px) {
  #top-menu-bar { padding: 0 10px; gap: 7px; }
  #top-menu-items { padding: 0 3px; }
  #top-menu-controls { gap: 5px !important; }
  #auth-guest-view { gap: 4px !important; }
  #auth-guest-view button { padding-left: 8px !important; padding-right: 8px !important; }
  #global-settings-popup { right: -4px; }
  #board-section .cv-board-head-actions { width: 100%; justify-content: stretch; }
  #board-section .cv-board-head-actions > * { flex: 1 1 auto; }
}

/* Post content media generated by the lightweight Markdown-like editor. */
.cv-post-image {
  display: block;
  max-width: min(100%, 760px);
  max-height: 680px;
  margin: 10px 0;
  border-radius: 8px;
  object-fit: contain;
}

#home-board-stream a,
#board-app a {
  color: var(--cv-community-accent, #5aa2ff);
}

#home-post-content,
#post-content {
  line-height: 1.7;
  resize: vertical;
}


/* Unified community/editor sizing */
#board-section,
#promo-space,
#market-section,
#home-board-summary,
#board-section .cv-board-app,
#board-section .cv-board-head,
#board-section .cv-board-stream-head,
#board-section .cv-post-card,
#board-section .cv-detail-card {
  width: 100%;
}

#board-section { max-width: 1440px; margin-left:auto; margin-right:auto; }
#promo-space { max-width: 1440px; margin-left:auto; margin-right:auto; }

#board-section .cv-board-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
}
#board-section .cv-board-head h2 {
  margin:0;
  white-space:nowrap;
  font-size:clamp(19px,1.8vw,25px);
  line-height:1.2;
  letter-spacing:-0.02em;
}

.cv-editor-attachments {
  margin-top: 10px;
  border: 1px solid var(--cv-community-border);
  background: var(--cv-community-card);
  border-radius: 8px;
  padding: 9px;
}
.cv-editor-file-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:6px 0;
  border-bottom:1px solid color-mix(in srgb, var(--cv-community-border) 70%, transparent);
  font-size:12px;
}
.cv-editor-file-row:last-child { border-bottom:0; }
.cv-editor-file-name { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cv-editor-file-meta { flex:0 0 auto; color:var(--cv-community-muted); }
.cv-editor-remove-file { border:0; background:transparent; color:var(--cv-community-muted); cursor:pointer; }
.cv-editor-total { margin-top:7px; color:var(--cv-community-muted); font-size:11px; }

.cv-post-attachments {
  margin-top: 14px;
  display:flex;
  flex-direction:column;
  gap:7px;
}
.cv-post-attachment {
  display:flex;
  align-items:center;
  gap:9px;
  padding:8px 10px;
  border:1px solid var(--cv-community-border);
  border-radius:8px;
  background:var(--cv-community-card);
}
.cv-post-attachment img {
  max-width:100%;
  width:auto;
  max-height:460px;
  border-radius:7px;
  object-fit:contain;
}
.cv-post-file-link { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.cv-post-editor-toolbar { margin-top: 4px; }

@media (max-width:700px) {
  #top-menu-bar { height:50px; padding:0 8px; gap:5px; flex-wrap:nowrap; }
  #top-menu-brand { font-size:11px; }
  #top-menu-spacer { min-width:6px; }
  #top-menu-items > button,
  #top-menu-controls button,
  #global-settings-btn { min-height:30px; padding:5px 7px; font-size:10px; border-radius:7px; }
  #theme-toggle-btn, #global-settings-btn { width:30px; min-width:30px; padding:4px !important; font-size:14px !important; }
  #auth-guest-view, #auth-user-view { gap:3px; }
  #auth-user-nickname { min-height:30px; font-size:10px; max-width:90px; overflow:hidden; text-overflow:ellipsis; }
  #top-menu-controls { gap:4px; }
  #board-section .cv-board-head { gap:7px; align-items:center; }
  #board-section .cv-board-head h2 { font-size:18px; }
  #board-section .cv-board-head-actions { gap:5px; flex-wrap:nowrap; }
  #board-section .cv-board-head-actions > * { flex:0 1 auto; }
}


/* =========================================================
   Header refinements
   ========================================================= */
#top-menu-brand a {
  color: var(--cv-ui-text) !important;
  text-decoration: none;
}
#top-menu-brand a:hover,
#top-menu-brand a:visited,
#top-menu-brand a:active {
  color: var(--cv-ui-text) !important;
}
body.light-mode #top-menu-bar {
  background: #edf0f3;
  border-color: #d7dce2;
}
body.light-mode #top-menu-items > button,
body.light-mode #top-menu-controls button,
body.light-mode #global-settings-btn {
  background: #e2e6ea;
  color: #3b434d;
  border-color: #c8cfd6;
}
body.light-mode #top-menu-items > button:hover,
body.light-mode #top-menu-controls button:hover,
body.light-mode #global-settings-btn:hover {
  background: #d9dee3;
  border-color: #b8c0c8;
}

/* Board spacing / readability */
#board-section .cv-board-head {
  padding: 8px 10px 0;
}
#board-section .cv-board-head h2 {
  padding-left: 4px;
}
#board-section .cv-board-stream-head {
  padding: 0 10px 4px;
}
#board-section .cv-board-head-actions {
  padding-top: 2px;
}
#board-section .cv-post-card,
#board-section .cv-detail-card {
  margin-left: 8px;
  margin-right: 8px;
}
#board-section .cv-post-title-btn,
#board-section .cv-detail-card h2 {
  letter-spacing: -0.015em;
}
#board-section .cv-post-preview,
#board-section .cv-detail-body,
#board-section .cv-comment-body {
  line-height: 1.8;
}
.cv-table-wrap { width:100%; overflow:auto; margin:12px 0; }
.cv-post-table { width:100%; border-collapse:collapse; min-width:420px; }
.cv-post-table th,
.cv-post-table td { border:1px solid var(--cv-community-border); padding:8px 10px; text-align:left; }
.cv-post-table th { font-weight:700; background:rgba(128,150,180,.10); }

@media (max-width:700px) {
  #top-menu-bar { flex-wrap: nowrap; }
  #top-menu-brand { min-width: 0; }
  #top-menu-brand a { font-size: clamp(12px, 3.1vw, 16px); }
  #top-menu-spacer { flex: 1 1 8px; min-width: 4px; }
  #top-menu-items > button,
  #top-menu-controls button,
  #global-settings-btn { white-space: nowrap; }
  #auth-user-nickname { max-width: 72px; }
  #top-menu-items > button,
  #top-menu-controls button { padding-left: 6px; padding-right: 6px; }
  #board-section .cv-board-head { padding-left: 7px; padding-right: 7px; }
  #board-section .cv-board-head h2 { padding-left: 2px; }
  #board-section .cv-post-card,
  #board-section .cv-detail-card { margin-left: 4px; margin-right: 4px; }
}


/* Guest credentials and editor controls */
.cv-guest-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin:10px 0; }
.cv-guest-fields[hidden] { display:none !important; }
.cv-form-input { width:100%; min-height:38px; padding:8px 10px; border:1px solid var(--cv-community-border,#303946); border-radius:7px; background:var(--cv-community-card,#151c25); color:var(--cv-community-text,#e6edf3); box-sizing:border-box; }
.cv-editor-toolbar { align-items:center; }
.cv-editor-size-wrap { display:inline-flex; align-items:center; gap:5px; min-height:32px; padding:4px 7px; border:1px solid var(--cv-community-border,#303946); border-radius:6px; background:var(--cv-community-card,#151c25); color:var(--cv-community-text,#e6edf3); font-size:12px; }
.cv-editor-size { border:0; outline:0; background:transparent; color:inherit; font-size:12px; cursor:pointer; }
.cv-editor-color-group { display:inline-flex; align-items:center; gap:3px; min-height:32px; padding:3px 5px; border:1px solid var(--cv-community-border,#303946); border-radius:6px; background:var(--cv-community-card,#151c25); }
.cv-editor-color-icon { font-weight:800; font-size:13px; margin:0 2px; }
.cv-editor-color-swatch { width:20px; height:20px; min-width:20px; border-radius:50%; border:2px solid rgba(255,255,255,.7); background:var(--swatch); padding:0; cursor:pointer; }
.cv-editor-color-swatch:hover { transform:scale(1.08); }
.cv-editor-custom-color { width:23px; height:23px; padding:0; border:0; background:transparent; cursor:pointer; }
.cv-attachment-actions { display:flex; gap:6px; flex-wrap:wrap; margin:7px 0; }
.cv-post-size-small { font-size:.85em; }
.cv-post-size-normal { font-size:1em; }
.cv-post-size-large { font-size:1.25em; }
.cv-post-size-xlarge { font-size:1.55em; }
@media (max-width:700px){ .cv-guest-fields{grid-template-columns:1fr;} .cv-editor-toolbar{gap:4px;} .cv-editor-size-wrap,.cv-editor-color-group{min-height:30px;} }


/* WYSIWYG editor */
.cv-editor-content {
  min-height: 190px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--cv-community-border, #303946);
  border-radius: 8px;
  background: var(--cv-community-card, #151c25);
  color: var(--cv-community-text, #e6edf3);
  outline: none;
  line-height: 1.8;
  font-size: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cv-editor-content:focus {
  border-color: var(--cv-community-accent, #5aa2ff);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--cv-community-accent, #5aa2ff) 16%, transparent);
}
.cv-editor-content.is-empty::before {
  content: attr(data-placeholder);
  color: var(--cv-community-muted, #8d99a8);
  pointer-events: none;
}
.cv-editor-content img { max-width: 100%; height: auto; border-radius: 8px; vertical-align: middle; }
.cv-editor-content a { color: var(--cv-community-accent, #5aa2ff); }
.cv-editor-color-wrap { position: relative; }
.cv-editor-color-palette { position:absolute; top:calc(100% + 5px); left:0; z-index:50; min-width:170px; padding:9px; border:1px solid var(--cv-community-border,#303946); border-radius:9px; background:var(--cv-community-card,#151c25); box-shadow:0 12px 30px rgba(0,0,0,.25); }
.cv-editor-color-palette[hidden] { display:none !important; }
.cv-editor-color-title { display:block; margin-bottom:7px; font-size:11px; color:var(--cv-community-muted,#8d99a8); }
.cv-editor-color-grid { display:grid; grid-template-columns:repeat(5, 1fr); gap:6px; }
.cv-editor-color-swatch { width:24px; height:24px; min-width:24px; padding:0; border-radius:50%; border:2px solid rgba(255,255,255,.72); background:var(--swatch); cursor:pointer; }
.cv-editor-color-swatch:hover { transform:scale(1.08); }

.cv-editor-toolbar .cv-editor-color-swatch { background: var(--swatch) !important; color: transparent !important; border: 2px solid rgba(0,0,0,.22) !important; }
