/* 勝手にCNP TIMES - 高機能版スタイル */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1b1f27;
  --text-dim: #6b7280;
  --accent: #e8732c;
  --accent-2: #4a6cf7;
  --up: #16a34a;
  --up-bg: rgba(22, 163, 74, 0.10);
  --down: #dc2626;
  --down-bg: rgba(220, 38, 38, 0.10);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 6px 20px rgba(0,0,0,0.04);
  --radius: 16px;
}
[data-theme="dark"] {
  --bg: #0e1016;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2a2f3a;
  --text: #e8eaed;
  --text-dim: #9aa3b2;
  --accent: #ff8a4c;
  --accent-2: #6f8bff;
  --up: #34d399;
  --up-bg: rgba(52, 211, 153, 0.12);
  --down: #f87171;
  --down-bg: rgba(248, 113, 113, 0.12);
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 8px 28px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 16px 64px; }

/* ===== Top bar ===== */
.topbar {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 46px; height: 46px; object-fit: contain; }
.brand h1 { font-size: 21px; margin: 0; letter-spacing: .02em; }
.brand .sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.spacer { flex: 1; }
.topbar .meta { text-align: right; font-size: 12px; color: var(--text-dim); }
.topbar .meta .issue { font-weight: 700; color: var(--accent); font-size: 13px; }

.btn {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 999px; padding: 8px 14px;
  font-size: 13px; cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ghost { background: transparent; }
a.btn { text-decoration: none; }

/* ===== Section ===== */
.section { margin-top: 30px; }
.section > h2 {
  font-size: 15px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px;
  color: var(--text);
}
.section > h2::before { content: ""; width: 4px; height: 16px; background: var(--accent); border-radius: 2px; }
.section .hint { font-size: 12px; color: var(--text-dim); font-weight: 400; }

/* ===== Cards ===== */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.card .k { font-size: 12px; color: var(--text-dim); margin-bottom: 7px; }
.card .v { font-size: 21px; font-weight: 700; letter-spacing: .01em; line-height: 1.25; white-space: nowrap; }
.card .v .unit { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.card .v small { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-top: 3px; }

/* CNP情報カードと参考レートの区切り */
.cards-divider { display: flex; align-items: center; gap: 12px; margin: 18px 2px 12px; color: var(--text-dim); font-size: 12px; }
.cards-divider::before, .cards-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.card .d { font-size: 12px; margin-top: 5px; font-weight: 600; display: inline-block;
  padding: 1px 8px; border-radius: 999px; }
.d.up { color: var(--up); background: var(--up-bg); }
.d.down { color: var(--down); background: var(--down-bg); }
.d.flat { color: var(--text-dim); background: var(--surface-2); }

/* ===== Controls ===== */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.controls .grp { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.controls label { font-size: 12px; color: var(--text-dim); }
input[type="date"], select {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; font-family: inherit;
}
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; overflow-x: auto;
}
.note {
  font-size: 12px; color: var(--text-dim); background: var(--surface-2);
  border-radius: 10px; padding: 9px 12px; margin-bottom: 14px;
}
.note.warn { color: var(--accent); }

/* ===== Table ===== */
table.t { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 460px; }
table.t caption { text-align: left; font-weight: 700; padding: 6px 2px 10px; font-size: 12.5px; }
table.t caption .cap-sub { font-size: 11px; font-weight: 500; color: var(--text-dim); margin-left: 4px; }
table.t th, table.t td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: right; }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t thead th { color: var(--text-dim); font-weight: 600; font-size: 11.5px; border-bottom: 2px solid var(--border); }
table.t tbody tr:hover { background: var(--surface-2); }
table.t .seclabel { font-weight: 700; color: var(--accent-2); background: var(--surface-2); }
.charcell { display: flex; align-items: center; gap: 8px; }
.charcell img { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; }
.up { color: var(--up); } .down { color: var(--down); }
.mono { font-variant-numeric: tabular-nums; }

/* ===== Sales detail ===== */
.sales-head { font-weight: 700; font-size: 14px; margin-bottom: 12px; }
.sales-list { display: flex; flex-direction: column; gap: 10px; }
.sale { display: flex; gap: 12px; align-items: center; padding: 10px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.sale-img { position: relative; width: 56px; height: 56px; flex: 0 0 56px; border-radius: 10px;
  overflow: hidden; display: block; background: var(--surface); }
.sale-img img { width: 100%; height: 100%; object-fit: cover; }
.sale-tok { position: absolute; bottom: 0; left: 0; right: 0; font-size: 10px; text-align: center;
  background: rgba(0,0,0,.6); color: #fff; padding: 1px 0; }
.sale-main { flex: 1; min-width: 0; }
.sale-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sale-char { font-weight: 700; }
.sale-time { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.sale-price { font-size: 16px; font-weight: 700; margin: 2px 0; }
.sale-price .unit { font-size: 11px; color: var(--text-dim); font-weight: 600; }
.sale-price small { color: var(--text-dim); font-weight: 600; font-size: 12px; margin-left: 6px; }
.sale-addr { font-size: 12px; font-family: ui-monospace, Menlo, monospace; display: flex; gap: 6px;
  align-items: center; flex-wrap: wrap; }
.sale-addr a { color: var(--accent-2); text-decoration: none; }
.sale-addr a:hover { text-decoration: underline; }
.sale-addr .waddr { color: var(--text-dim); font-weight: 400; }
.sale-addr .arrow { color: var(--text-dim); }
.sale-cnp { background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 0 7px; font-size: 11px; color: var(--accent); font-weight: 700; }
.sale-tx { margin-left: auto; color: var(--accent) !important; }

/* ===== Chart ===== */
.chart-box { position: relative; height: 360px; }
@media (max-width: 600px) {
  .brand h1 { font-size: 18px; }
  .card .v { font-size: 19px; }
  .chart-box { height: 280px; }
}

/* ===== Loader ===== */
.loader { text-align: center; padding: 60px 0; color: var(--text-dim); }
.spin { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: sp 0.8s linear infinite; margin: 0 auto 14px; }
@keyframes sp { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.footer { margin-top: 44px; font-size: 12px; color: var(--text-dim); }
.footer .creator { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center;
  padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.footer .creator > span { font-weight: 700; color: var(--text); }
.footer .notes { max-width: 760px; margin: 0 auto; }
.footer .notes ul { margin: 6px 0 0; padding-left: 18px; }
.footer .notes li { margin: 4px 0; line-height: 1.6; }
.footer .notes b { color: var(--text); }
.footer a { color: var(--accent); }

/* クリプトニンジャ・ニュース埋め込み */
.news-head { font-weight: 700; margin: 2px 0 10px; }
.news-embeds { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.news-embeds .twitter-tweet { margin: 0 !important; }
#news-panel:empty { display: none; }
#sales-panel:empty { display: none; }

/* CNP Owner限定: ヘッダーのログインUI（トップバー右端） */
.cnp-auth-header { display: flex; align-items: center; gap: 8px; font-size: 12px; flex-wrap: wrap; }
.cnp-header-status { color: var(--down); font-size: 11.5px; max-width: 220px; text-align: right; }
.cnp-header-name { color: var(--text-dim); font-weight: 700; white-space: nowrap; }
.cnp-login-btn, .cnp-logout-btn { white-space: nowrap; }

/* Discord公式風ログインボタン（blurple #5865F2 + ロゴマーク） */
.cnp-discord-login-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: #5865F2; color: #fff;
  border: none; border-radius: 10px;
  padding: 9px 18px;
  font-size: 13.5px; font-weight: 700; white-space: nowrap;
  cursor: pointer;
  transition: background .15s ease;
}
.cnp-discord-login-btn:hover { background: #4752C4; }
.cnp-discord-mark { width: 20px; height: 15px; display: block; }

/* editor限定: 表示モード切替セレクタ（あくまで表示のシミュレーション） */
.cnp-view-mode-select { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.cnp-view-mode-select label {
  font-size: 11.5px; font-weight: 700; color: var(--text-dim);
}
.cnp-view-mode-select select {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 10px; font-size: 12px; cursor: pointer;
}
.cnp-view-mode-select select:hover { border-color: var(--accent); }

/* CNP Owner限定: 日次分析コメントセクション本体 */
.cnp-exclusive-section { margin-top: 16px; }
.cnp-exclusive-section h2 {
  display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700;
  color: var(--text); margin-bottom: 10px;
}
.cnp-exclusive-section h2::before { content: ""; width: 4px; height: 16px; background: var(--accent); border-radius: 2px; }
.cnp-exclusive-body { font-size: 14px; line-height: 1.6; }
.cnp-exclusive-msg { color: var(--text-dim); margin-bottom: 14px; }
.cnp-exclusive-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.cnp-owner-badge { font-size: 13px; font-weight: 700; color: var(--up); }
.cnp-exclusive-title { font-size: 16px; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.cnp-exclusive-updated { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }
.cnp-exclusive-block { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.cnp-exclusive-block h4 { font-size: 14px; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.cnp-exclusive-block p { margin: 0; color: var(--text); }

/* CNP Owner限定: 最安リスト トップ10セクション本体 */
.cnp-listings-section { margin-top: 16px; }
.cnp-listings-section h2 {
  display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700;
  color: var(--text); margin-bottom: 10px;
}
.cnp-listings-section h2::before { content: ""; width: 4px; height: 16px; background: var(--accent); border-radius: 2px; }
.cnp-listings-body { font-size: 13px; line-height: 1.6; }
.cnp-listings-summary { font-weight: 700; margin: 0 0 12px; color: var(--text); }
.cnp-listings-table-wrap { overflow-x: auto; }
table.cnp-listings-table { min-width: 720px; }
table.cnp-listings-table th, table.cnp-listings-table td { vertical-align: middle; }
.cnp-listings-nft .charcell img {
  width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--surface-2);
}
.cnp-listings-nft .charcell { text-align: left; }
.cnp-listings-jpy { color: var(--text-dim); font-size: 11.5px; }
.cnp-listings-scope-note { color: var(--text-dim); font-size: 11px; }

/* v2: 日次分析コメントCMS（日付セレクタ・記事表示・エディタ） */
.cnp-editor-toggle-btn {
  border: none; border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 700;
  cursor: pointer; color: #fff; background: var(--up); transition: opacity .15s ease;
}
.cnp-editor-toggle-btn:hover { opacity: .85; }

.cnp-date-selector { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cnp-date-selector label { font-size: 13px; font-weight: 700; color: var(--text-dim); }
.cnp-date-selector select {
  font-size: 13px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); max-width: 100%;
}

.cnp-entry-body { font-size: 14px; line-height: 1.8; color: var(--text); }
.cnp-entry-body img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.cnp-entry-body h1, .cnp-entry-body h2, .cnp-entry-body h3 { margin: 14px 0 6px; }
.cnp-entry-body p { margin: 0 0 10px; }
.cnp-entry-plain { white-space: pre-wrap; font-size: 14px; line-height: 1.7; color: var(--text); }

.cnp-entry-editor { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--border); }
.cnp-editor-row { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.cnp-editor-row label { font-size: 13px; font-weight: 700; color: var(--text-dim); }
.cnp-editor-hint { font-size: 11.5px; color: var(--text-dim); margin: 4px 0 0; }
.cnp-editor-header-actions { display: flex; align-items: center; gap: 8px; }
.cnp-editor-row input[type="date"],
.cnp-editor-row input[type="text"],
.cnp-editor-row textarea {
  font-size: 13px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); width: 100%; font-family: inherit;
}
.cnp-editor-row textarea { resize: vertical; line-height: 1.6; }

.cnp-editor-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cnp-image-upload-btn, .cnp-preview-toggle-btn {
  display: inline-block; font-size: 13px; font-weight: 700; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); padding: 7px 14px;
  border-radius: 999px; cursor: pointer; transition: background .15s ease;
}
.cnp-image-upload-btn:hover, .cnp-preview-toggle-btn:hover { background: var(--surface-2); }

.cnp-editor-preview {
  margin-bottom: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2);
}

.cnp-editor-status { font-size: 12px; color: var(--text-dim); min-height: 16px; margin-bottom: 10px; }

.cnp-editor-actions { display: flex; gap: 10px; }
.cnp-save-btn, .cnp-delete-btn {
  border: none; border-radius: 999px; padding: 9px 18px; font-size: 13px; font-weight: 700;
  cursor: pointer; color: #fff; transition: opacity .15s ease;
}
.cnp-save-btn { background: var(--accent-2); }
.cnp-delete-btn { background: var(--down); }
.cnp-save-btn:hover, .cnp-delete-btn:hover { opacity: .85; }

/* 日付ナビをスクロール追従（このセクションを見ている間、上部に固定） */
#date-controls {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  margin: 0 -6px 12px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 10px -8px rgba(0,0,0,.4);
}
