/* =====================
   CSS変数
   ===================== */
:root {
  --bg:          #ffffff;
  --bg-sub:      #f5f5f5;
  --bg-card:     #ffffff;
  --border:      #e0e0e0;
  --text:        #222222;
  --text-sub:    #666666;
  --accent:      #7c57c2;
  --accent-dark: #6043a8;
  --accent-pale: #ede8ff;
  --th-bg:       #7c57c2;
  --th-text:     #ffffff;
  --tr-even:     #faf8ff;
  --tr-hover:    #ede8ff;
  --input-bg:    #ffffff;
  --shadow:      rgba(0,0,0,0.08);
  --font:        'M PLUS 1p', sans-serif;
  --font-size:   14px;
}

[data-theme="dark"] {
  --bg:          #111114;
  --bg-sub:      #1a1a20;
  --bg-card:     #1e1e26;
  --border:      #333344;
  --text:        #e8e8f0;
  --text-sub:    #999aaa;
  --accent-pale: #2a2040;
  --th-bg:       #2a2040;
  --th-text:     #c8b8ff;
  --tr-even:     #181820;
  --tr-hover:    #2a2040;
  --input-bg:    #1e1e26;
  --shadow:      rgba(0,0,0,0.4);
}

@font-face {
    font-family: "Hirakaku";
    src: url("https://cdn.jsdelivr.net/gh/shiratama-kotone/assets@main/HiraKakuProN-W4-AlphaNum-01.woff2") format("woff2");
}

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

html { overflow-x: hidden; }

body {
  font-family: "Hirakaku";
  font-size: var(--font-size);
  background: var(--bg);
  color: var(--text);
  padding: 20px;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
}

a { color: var(--accent); }

/* =====================
   レインボー
   ===================== */
@keyframes rainbow { 100% { background-position: 200%; } }
.rainbow {
  background: linear-gradient(to right,#e60000,#f39800,#fff100,#009944,#0068b7,#1d2088,#920783,#e60000) 0/200%;
  animation: rainbow 5s linear infinite;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h1 { font-size: 48px; margin-bottom: 8px; }
p.desc { font-size: 13px; margin-bottom: 14px; line-height: 1.9; color: var(--text-sub); }

/* =====================
   ナビリンク
   ===================== */
.nav-links { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:16px; }
.nav-links a {
  color: var(--accent); text-decoration:none; font-size:13px;
  border:1px solid var(--accent); border-radius:4px; padding:3px 8px;
  transition:background 0.2s, color 0.2s;
}
.nav-links a:hover { background:var(--accent); color:#fff; }

/* =====================
   時計
   ===================== */
#clock {
  position:fixed; top:10px; right:14px;
  font-size:18px; font-family:'Courier New',monospace; font-weight:700;
  color:var(--text-sub); z-index:9500;
  pointer-events: none;
}

/* =====================
   サーバータブ
   ===================== */
.server-tabs { display:flex; gap:6px; margin-bottom:0; }
.server-tabs button {
  padding:7px 18px; border:2px solid var(--accent); border-bottom:none;
  border-radius:6px 6px 0 0; background:var(--bg-sub); color:var(--accent);
  font-family:var(--font); font-size:14px; font-weight:700; cursor:pointer;
  transition:background 0.2s, color 0.2s;
}
.server-tabs button.active { background:var(--accent); color:#fff; }

/* =====================
   フォーム
   ===================== */
#postForm {
  display:flex; flex-direction:column; gap:8px; margin-bottom:16px; max-width:700px;
  background:var(--bg-card); border:1px solid var(--border);
  border-radius:0 8px 8px 8px; padding:14px; box-shadow:0 2px 8px var(--shadow);
}
#content {
  width:100%; min-height:80px; resize:vertical; padding:10px;
  border:1px solid var(--border); border-radius:6px;
  font-family:var(--font); font-size:var(--font-size);
  background:var(--input-bg); color:var(--text); transition:border-color 0.2s;
}
#content:focus { outline:none; border-color:var(--accent); }
.form-row { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.form-row input {
  padding:8px 10px; border:1px solid var(--border); border-radius:6px;
  font-family:var(--font); font-size:var(--font-size); flex:1; min-width:120px;
  background:var(--input-bg); color:var(--text); transition:border-color 0.2s;
}
.form-row input:focus { outline:none; border-color:var(--accent); }
.form-row button[type="submit"] {
  padding:8px 20px; background:var(--accent); color:#fff; border:none;
  border-radius:6px; font-family:var(--font); font-size:var(--font-size);
  font-weight:700; cursor:pointer; transition:background 0.2s; white-space:nowrap;
}
.form-row button[type="submit"]:hover    { background:var(--accent-dark); }
.form-row button[type="submit"]:disabled { background:var(--text-sub); cursor:default; }
#emojiBtn, #settingsBtn {
  padding:7px 12px; background:var(--bg-sub); border:1px solid var(--border);
  border-radius:6px; cursor:pointer; font-size:16px; color:var(--text);
}

/* =====================
   トピック・規制バナー
   ===================== */
#currentTopic { font-size:15px; font-weight:700; margin-bottom:4px; color:var(--text); }
#restrictionBanner {
  display:none; font-size:13px; font-weight:700; color:#cc0000; margin-bottom:8px;
  padding:4px 10px; background:#fff0f0; border-left:3px solid #cc0000; border-radius:3px;
}
[data-theme="dark"] #restrictionBanner { background:#2a1010; color:#ff6666; border-color:#ff4444; }

/* =====================
   テーブル
   ===================== */
.table-wrap {
  width:100%; overflow-x:auto;
  border:1px solid var(--border); border-radius:0 8px 8px 8px;
  box-shadow:0 2px 8px var(--shadow);
}
#postsTable { width:100%; border-collapse:collapse; table-layout:fixed; }
#postsTable col.col-no      { width:48px; }
#postsTable col.col-info    { width:150px; }
#postsTable col.col-content { width:auto; }
#postsTable th {
  background:var(--th-bg); color:var(--th-text); padding:8px 10px;
  font-size:13px; text-align:left; font-weight:700;
}
#postsTable td {
  border-bottom:1px solid var(--border); padding:8px 10px; vertical-align:top;
  font-size:var(--font-size); word-break:break-word; background:var(--bg-card);
  transition:background 0.15s;
}
#postsTable tr:nth-child(even) td { background:var(--tr-even); }
#postsTable tr:hover td           { background:var(--tr-hover); }

/* アンカーハイライト */
@keyframes highlight-flash {
  0%,100% { background: var(--bg-card); }
  50%      { background: #ffe066; }
}
.anchor-highlight td { animation: highlight-flash 1.5s ease; }
[data-theme="dark"] .anchor-highlight td { animation: none; background: #3a3010 !important; }

.post-content { white-space:pre-wrap; }
.post-no-link { color:var(--text-sub); text-decoration:none; font-size:12px; }
.anchor-link  { color:#789922; text-decoration:none; font-weight:bold; }

/* 名前・ID */
.info-name { font-weight:700; font-size:13px; }
.info-id   { font-size:11px; margin-top:2px; }
.info-add  { font-size:11px; color:magenta; }
.dm-link   { font-size:11px; text-decoration:none; opacity:0.6; transition:opacity 0.2s; margin-left:4px; }
.dm-link:hover { opacity:1; }

/* 権限色 */
.role-admin   { color:red; }
.role-summit  { color:darkcyan; }
.role-manager { color:red; }
.role-speaker { color:darkorange; }
.role-blue    { color:#1a6fcf; }

/* 画像 */
.emoji { width:20px; height:20px; vertical-align:middle; }
.post-img { max-height:100px; max-width:100%; vertical-align:middle; cursor:zoom-in; border-radius:4px; }

/* 埋め込みメディア */
.embed-wrap { margin: 4px 0; }
.embed-wrap iframe { display: block; }

/* 画像モーダル */
#img-modal {
  display:none; position:fixed; inset:0;
  background:rgba(0,0,0,0.88); z-index:20000;
  align-items:center; justify-content:center; cursor:zoom-out;
}
#img-modal.open { display:flex; }
#img-modal-img  { max-width:92vw; max-height:92vh; border-radius:8px; box-shadow:0 4px 32px rgba(0,0,0,0.6); }
#img-modal-close {
  position:absolute; top:14px; right:18px;
  background:rgba(0,0,0,0.5); color:#fff; border:none;
  font-size:30px; width:42px; height:42px; border-radius:50%;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
}

/* 絵文字パネル */
#emoji-panel {
  display:none; position:fixed; background:var(--bg-card); border:1px solid var(--border);
  border-radius:8px; padding:8px; max-width:360px; max-height:260px; overflow-y:auto;
  box-shadow:0 4px 16px var(--shadow); z-index:5000;
  grid-template-columns:repeat(auto-fill, minmax(32px,1fr)); gap:4px;
}
#emoji-panel button { border:none; background:none; padding:4px; cursor:pointer; border-radius:4px; }
#emoji-panel button:hover { background:var(--accent-pale); }

/* =====================
   設定パネル
   ===================== */
.settings-header {
  display:flex; justify-content:space-between; align-items:center;
  padding:14px 16px; border-bottom:1px solid var(--border);
  font-weight:700; font-size:15px; position:sticky; top:0;
  background:var(--bg-card); z-index:1;
}
#settings-close {
  background:none; border:none; font-size:22px; cursor:pointer; color:var(--text-sub);
}
.settings-body { padding:16px; display:flex; flex-direction:column; gap:10px; }
.settings-label { font-size:12px; font-weight:700; color:var(--text-sub); margin-bottom:2px; display:block; }
.settings-row   { display:flex; justify-content:space-between; align-items:center; font-size:13px; }
.settings-body select,
.settings-body input[type="range"] {
  width:100%; padding:6px 8px; border:1px solid var(--border); border-radius:6px;
  background:var(--input-bg); color:var(--text); font-size:13px;
  font-family:var(--font);
}
.settings-body input[type="color"] {
  width:44px; height:32px; border:1px solid var(--border); border-radius:6px;
  cursor:pointer; padding:2px; background:var(--input-bg);
}
.settings-body input[type="checkbox"] { width:18px; height:18px; cursor:pointer; accent-color:var(--accent); }
.settings-body input[type="range"]    { padding:0; accent-color:var(--accent); }

/* =====================
   通知・ダークボタン
   ===================== */
#notif-container {
  position:fixed; bottom:20px; right:20px; z-index:10000; pointer-events:none;
  display:flex; flex-direction:column-reverse; gap:8px;
}
.notification {
  padding:12px 36px 12px 16px; border-radius:8px; min-width:240px; max-width:340px;
  box-shadow:0 4px 12px rgba(0,0,0,0.25); font-size:14px; position:relative;
  transform:translateX(120%); opacity:0; transition:transform 0.3s, opacity 0.3s;
  pointer-events:auto; word-wrap:break-word; font-family:var(--font);
}
.notification-success { background:#3a9e5c; color:#fff; }
.notification-error   { background:#d94040; color:#fff; }
.notification-show    { transform:translateX(0); opacity:1; }
.notification-close {
  position:absolute; top:8px; right:8px; background:none; border:none;
  color:#fff; font-size:18px; cursor:pointer; padding:0; line-height:1;
}

#overlay    { display:none; }
#toggleBtn, #settingsBtn {
  position: fixed !important;
  bottom: 16px;
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--bg-card); color: var(--text);
  font-size: 20px; cursor: pointer; z-index: 9500;
  box-shadow: 0 2px 8px var(--shadow); transition: background 0.2s;
  display: flex; align-items: center; justify-content: center;
}
#toggleBtn  { right: 68px; }
#settingsBtn { right: 16px; }
#toggleBtn:hover, #settingsBtn:hover { background: var(--accent-pale); }

/* 設定パネルの横スクロール漏れ防止 */
#settings-panel {
  position: fixed !important;
  top: 0; right: -340px; bottom: 0;
  width: 320px; overflow-y: auto; overflow-x: hidden;
  background: var(--bg-card); border-left: 1px solid var(--border);
  box-shadow: -4px 0 16px var(--shadow);
  z-index: 9200;
  transition: right 0.3s ease;
}
#settings-panel.open { right: 0; }

.emergency-ticker {
  background-color: #000; /* 黒背景 */
  overflow: hidden;
  white-space: nowrap;
  padding: 10px 0;
  width: 100%;
}

.ticker-text {
  display: inline-block;
  padding-left: 100%; /* 右端から開始 */
  color: #ff0; /* 黄色文字 */
  font-weight: bold;
  font-size: 1.2rem;
  animation: scroll-left 25s linear infinite;
}

.spoiler {
  background: #2a2a2a;
  color: #2a2a2a;
  border-radius: 3px;
  padding: 0 3px;
  cursor: pointer;
  transition: color 0.2s;
}
.spoiler.revealed {
  color: #e8e8e8;
}

pre.code-block, code.code-inline {
  font-family: monospace;
  font-size: var(--font-size);
}

@keyframes scroll-left {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* =====================
   スマホ対応
   ===================== */
@media (max-width:600px) {
  body { padding:10px; }
  h1   { font-size:30px; }
  #clock { font-size:13px; top:6px; right:8px; }
  .nav-links a { font-size:12px; padding:2px 6px; }
  .server-tabs button { padding:6px 12px; font-size:13px; }
  #postForm { max-width:100%; padding:10px; }
  .form-row { flex-direction:column; align-items:stretch; }
  .form-row input,
  .form-row button[type="submit"],
  #emojiBtn, #settingsBtn-inline { width:100%; min-width:unset; }
  #postsTable col.col-no   { width:32px; }
  #postsTable col.col-info { width:80px; }
  #postsTable th,
  #postsTable td { padding:6px; font-size:12px; }
  .info-name { font-size:12px; }
  .info-id   { font-size:10px; }
  #emoji-panel { left:4px !important; max-width:calc(100vw - 8px); width:calc(100vw - 8px); }
  #toggleBtn  { bottom:10px; right:58px; width:38px; height:38px; font-size:16px; }
  #settingsBtn { bottom:10px; right:10px; width:38px; height:38px; font-size:16px; }
  #settings-panel { width:100%; right:-100%; }
}
