/* ==================================================================
   神衞堂 Shineido — 統一スタイル
   Reddit風三カラムレイアウト × KHF様式（深黒・燐光金色）
   ================================================================== */

:root {
  /* カラーパレット：Reddit の落ち着いた暗色 + KHF 金・深紅 */
  --bg:           #0b0f14;
  --bg-alt:       #11161d;
  --surface:      #161c24;
  --surface-2:    #1c232d;
  --border:       #2a323e;
  --border-hi:    #3a4454;
  --text:         #e6edf3;
  --text-mute:    #9aa4b2;
  --text-dim:     #6b7684;
  --accent:       #b8962e;         /* KHF金（板ごとに上書き） */
  --accent-hi:    #d4af60;
  --link:         #6ba8ff;
  --ok:           #22c55e;
  --warn:         #f59e0b;
  --danger:       #ef4444;
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 1px 0 rgba(255,255,255,.03) inset, 0 2px 8px rgba(0,0,0,.25);
  --mono:         'Share Tech Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --serif:        'Noto Serif JP', serif;
  --sans:         'Noto Sans JP', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ------------------------- Reset ------------------------- */
*,*::before,*::after { box-sizing: border-box; }
html,body { margin:0; padding:0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
img, svg { max-width: 100%; height: auto; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 0; padding: .5rem 1rem; background: var(--accent); color: #000; z-index: 10000; }

/* ==================================================================
   ヘッダー
   ================================================================== */
.site-hd {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(120%) blur(8px);
}
.hd-inner {
  max-width: 1240px; margin: 0 auto;
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 1rem; align-items: center;
  padding: .55rem 1rem;
}
.logo {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--text); text-decoration: none; font-weight: 700;
}
.logo-mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px;
  font-family: var(--serif); font-size: 1.1rem;
  background: linear-gradient(135deg, #b8962e, #6e5a1b);
  color: #0b0f14;
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 2px 6px rgba(0,0,0,.3);
  letter-spacing: -0.05em;
}
.logo-name {
  font-family: var(--serif); font-size: 1.15rem; line-height: 1;
  display: flex; flex-direction: column; gap: 2px;
}
.logo-name small {
  font-family: var(--mono); font-size: .65rem;
  color: var(--text-dim); letter-spacing: .15em;
}

.hd-nav {
  display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none;
}
.hd-nav::-webkit-scrollbar { display: none; }
.hd-board {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .35rem .65rem; border-radius: 999px;
  color: var(--text-mute); font-size: .85rem;
  border: 1px solid transparent;
  white-space: nowrap;
}
.hd-board:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  text-decoration: none;
}
.hd-board-icon {
  font-family: var(--serif);
  color: var(--accent);
  font-weight: 700;
}

.hd-search input {
  padding: .5rem .8rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .9rem;
  min-width: 180px;
}
.hd-search input:focus {
  outline: 0; border-color: var(--accent); background: var(--surface-2);
}

/* ==================================================================
   メインレイアウト　Reddit風3カラム（サイドバー左）→レスポンシブで1列
   ================================================================== */
.layout {
  max-width: 1240px; margin: 0 auto; padding: 1rem;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
}

.sidebar { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 64px; }
@media (max-width: 860px) { .sidebar { position: static; } }

/* ==================================================================
   パネル
   ================================================================== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  position: relative;
}
.panel::before {
  content: ''; position: absolute; top:0; left:0; right:0; height:3px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-top-left-radius: var(--radius); border-top-right-radius: var(--radius);
}
.panel h2 {
  margin: 0 0 .75rem; font-family: var(--serif); font-size: 1.02rem;
  color: var(--accent-hi); font-weight: 600;
  border-bottom: 1px solid var(--border); padding-bottom: .5rem;
}
.panel h4 { margin:0 0 .5rem; font-size: .9rem; color: var(--accent-hi); }
.panel p  { margin: .35rem 0; color: var(--text-mute); font-size: .88rem; }
.panel ul, .panel ol { margin:.35rem 0; padding-left: 1.1rem; color: var(--text-mute); font-size: .88rem; }
.panel li { margin: .2rem 0; }
.panel-meta { font-family: var(--mono); font-size: .75rem; color: var(--text-dim); }

.board-list { list-style: none; padding: 0; margin: 0; }
.board-list li + li { margin-top: 4px; }
.board-list a {
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  padding: .5rem .6rem; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none;
  border: 1px solid transparent;
}
.board-list a:hover { background: var(--surface-2); border-color: var(--border); text-decoration: none; }
.b-icon {
  grid-row: 1 / span 2;
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 6px;
  font-family: var(--serif); font-weight: 700;
  background: var(--surface-2); color: var(--accent);
  border: 1px solid var(--border);
}
.b-name { font-weight: 600; font-size: .9rem; }
.b-desc { font-size: .75rem; color: var(--text-dim); grid-column: 2; }

.board-add { margin-top: .8rem; padding-top: .8rem; border-top: 1px dashed var(--border); }
.board-add summary { cursor: pointer; color: var(--accent-hi); font-size: .85rem; font-weight: 600; padding: .25rem 0; list-style: none; }
.board-add summary::-webkit-details-marker { display: none; }
.board-add summary:hover { color: var(--text); }
.board-add[open] summary { margin-bottom: .5rem; }
.form-tight { gap: .5rem; }
.form-tight input { padding: .45rem .6rem; font-size: .85rem; }
.form-tight button { margin-top: .3rem; }
.form-note { color: var(--text-dim); font-size: .72rem; }

.panel-recent .recent-list { list-style: none; padding: 0; margin: 0; }
.panel-recent .recent-list li {
  display: grid; grid-template-columns: 1fr auto; gap: .6rem;
  align-items: baseline;
  padding: .55rem .2rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.panel-recent .recent-list li:last-child { border-bottom: 0; }
.panel-recent .recent-list a { display: flex; gap: .6rem; align-items: baseline; min-width: 0; color: var(--text); text-decoration: none; }
.panel-recent .recent-list a:hover .r-title { color: var(--accent-hi); }
.panel-recent .r-board { color: var(--accent); font-size: .78rem; flex-shrink: 0; font-family: var(--serif); font-weight: 600; }
.panel-recent .r-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-recent time { color: var(--text-dim); font-size: .75rem; flex-shrink: 0; }

.board-hero {
  display: grid; grid-template-columns: 52px 1fr; gap: .8rem; align-items: center;
  margin-bottom: .5rem;
}
.board-hero-icon {
  width: 52px; height: 52px; border-radius: 10px;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 1.6rem; font-weight: 700;
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 55%, #000), #0b0f14);
  color: #0b0f14;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.board-hero h2 { margin: 0; border: 0; padding: 0; }
.board-hero p  { margin: .25rem 0 0; }

.btn-new {
  display: block; text-align: center;
  margin-top: .8rem; padding: .65rem 1rem;
  background: var(--accent); color: #0b0f14;
  border-radius: var(--radius-sm); font-weight: 700;
  text-decoration: none;
}
.btn-new:hover { background: var(--accent-hi); text-decoration: none; }

/* ==================================================================
   フィード・並べ替えタブ
   ================================================================== */
.feed { display: flex; flex-direction: column; gap: .8rem; min-width: 0; }
.feed-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .2rem .2rem .2rem 0;
}
.feed-title {
  margin: 0; font-family: var(--serif); font-size: 1.25rem;
  color: var(--text);
}
.sort-tabs {
  display: inline-flex; gap: .25rem; padding: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
.sort-tabs a {
  padding: .35rem .85rem; border-radius: 999px;
  font-size: .8rem; color: var(--text-mute); text-decoration: none;
}
.sort-tabs a:hover { color: var(--text); }
.sort-tabs a.active { background: var(--accent); color: #0b0f14; font-weight: 700; }

/* ==================================================================
   カード（スレッド一覧）— Reddit風
   ================================================================== */
.card {
  display: grid; grid-template-columns: 48px 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .12s;
  position: relative;
}
.card::before {
  content: ''; position: absolute; top:0; left:0; bottom:0; width:3px;
  background: var(--accent);
}
.card:hover { border-color: var(--border-hi); }

.vote {
  display: flex; flex-direction: column; align-items: center;
  padding: .65rem .3rem;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border-right: 1px solid var(--border);
  gap: .3rem;
}
.vote button {
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: .85rem;
  transition: all .1s;
}
.vote button:hover { background: var(--surface-2); color: var(--text); }
.vote-up.on    { color: var(--accent); }
.vote-down.on  { color: var(--danger); }
.vote-score {
  font-family: var(--mono);
  font-size: .78rem; font-weight: 700;
  color: var(--text);
}
.vote-sm button { width: 22px; height: 22px; font-size: .7rem; }
.vote-sm { padding: .4rem .25rem; }

.card-body { padding: .75rem 1rem; min-width: 0; }
.card-meta {
  display: flex; flex-wrap: wrap; gap: .4rem;
  font-size: .78rem; color: var(--text-dim);
  align-items: center; margin-bottom: .35rem;
}
.card-meta .sep { color: var(--border-hi); }
.card-board {
  color: var(--accent-hi); font-weight: 700; text-decoration: none;
}
.card-board:hover { text-decoration: underline; }
.card-author { color: var(--text-mute); font-weight: 600; }
.card-id { font-family: var(--mono); color: var(--text-dim); font-size: .72rem; }
.pin, .lock { font-size: .75rem; color: var(--warn); }

.card-title {
  margin: 0 0 .4rem; font-family: var(--serif); font-weight: 600;
  font-size: 1.1rem; line-height: 1.4;
}
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--accent-hi); }

.card-excerpt {
  margin: 0 0 .6rem; color: var(--text-mute); font-size: .9rem;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}

.card-actions, .post-actions {
  display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem;
}
.act {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .35rem .6rem; border-radius: 999px;
  color: var(--text-mute); font-size: .78rem; background: transparent;
  border: 1px solid transparent; text-decoration: none;
}
.act:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.act .ico { font-size: .9rem; }

.empty {
  padding: 2rem; text-align: center; color: var(--text-dim);
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ==================================================================
   スレッド詳細ページ
   ================================================================== */
.crumbs { font-size: .8rem; color: var(--text-dim); padding: .2rem 0 .4rem; }
.crumbs a { color: var(--text-mute); }

.card-op { grid-template-columns: 48px 1fr; }
.op-title { font-size: 1.4rem; line-height: 1.35; margin-bottom: .6rem; }
.card-text {
  color: var(--text); line-height: 1.75; font-size: .98rem;
  white-space: pre-wrap; word-break: break-word;
}
.card-text .quote {
  display: inline; color: var(--ok);
  border-left: 3px solid var(--ok); padding-left: .4rem; margin-left: .1rem;
}
.card-text .ref { font-family: var(--mono); color: var(--accent-hi); }
.card-text a { color: var(--link); }
.card-text a:hover { color: var(--accent-hi); }

.replies-head {
  font-family: var(--serif); font-size: 1rem;
  margin: .3rem .2rem; padding-bottom: .4rem;
  border-bottom: 1px solid var(--border); color: var(--text-mute);
}

.post {
  display: grid; grid-template-columns: 40px 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.post + .post { margin-top: .5rem; }
.post-body { padding: .6rem .85rem; min-width: 0; }
.post-meta {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
  font-size: .75rem; color: var(--text-dim);
  margin-bottom: .3rem;
}
.post-num { font-family: var(--mono); color: var(--accent); font-weight: 700; }
.permalink { margin-left: auto; color: var(--text-dim); font-family: var(--mono); }
.post-text {
  color: var(--text); white-space: pre-wrap; word-break: break-word; font-size: .93rem;
}
.post-text .quote { color: var(--ok); }
.post-text .ref { color: var(--accent-hi); font-family: var(--mono); }

/* ==================================================================
   引用（Citation）の表示
   ================================================================== */
.cites {
  margin-top: .8rem;
  padding: .65rem .8rem;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}
.cites h3 {
  margin: 0 0 .4rem; font-size: .85rem; font-family: var(--serif);
  color: var(--accent-hi); font-weight: 600; letter-spacing: .05em;
}
.cite-list-display {
  list-style: decimal; padding-left: 1.4rem; margin: 0;
  color: var(--text-mute); font-size: .85rem; line-height: 1.6;
}
.cite-list-display .cite { margin: .3rem 0; }
.cite-badge {
  display: inline-block;
  padding: 1px 6px;
  margin-right: 4px;
  font-size: .7rem; font-family: var(--mono);
  border-radius: 4px; vertical-align: baseline;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim);
}
.cite-paper { color: #6ba8ff; border-color: #2a4668; }
.cite-book  { color: #e0b878; border-color: #5a4a1a; }
.cite-web   { color: #9aa4b2; }
.cite-news  { color: #e07a7a; border-color: #5a2a2a; }
.cite-law   { color: #c9a0ff; border-color: #3a2a5a; }
.cite-other { color: #9aa4b2; }
.cite em { color: var(--text); font-style: italic; }
.cite-note { font-size: .78rem; color: var(--text-dim); margin-top: 2px; }
.cite-meta { font-size: .78rem; margin-top: 2px; }
.cite-meta a { color: var(--link); }

/* ==================================================================
   共有パネル
   ================================================================== */
.panel-share .share-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.btn-share {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .55rem .7rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: .8rem; text-decoration: none;
  transition: all .1s;
}
.btn-share:hover { border-color: var(--accent); color: var(--accent-hi); text-decoration: none; }
.embed { margin-top: .8rem; }
.embed summary { cursor: pointer; color: var(--text-mute); font-size: .8rem; }
.embed-code {
  width: 100%; margin-top: .4rem;
  background: var(--bg); color: var(--text-mute);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .5rem; font-family: var(--mono); font-size: .75rem;
  resize: vertical;
}

/* ==================================================================
   フォーム
   ================================================================== */
.form { display: flex; flex-direction: column; gap: .75rem; }
.form label {
  display: flex; flex-direction: column; gap: .3rem;
  font-size: .82rem; color: var(--text-mute);
}
.form input[type="text"],
.form input[type="url"],
.form input[type="search"],
.form textarea,
.form select {
  padding: .6rem .75rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: .95rem;
}
.form textarea {
  font-family: var(--mono); font-size: .9rem; line-height: 1.55;
  min-height: 120px; resize: vertical;
}
.form input:focus, .form textarea:focus, .form select:focus {
  outline: 0; border-color: var(--accent); background: var(--surface);
}
.form-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.form-foot small { color: var(--text-dim); font-size: .75rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .6rem 1.2rem; border-radius: var(--radius-sm);
  font-weight: 700; cursor: pointer;
  border: 1px solid transparent;
  transition: all .1s;
}
.btn-primary {
  background: var(--accent); color: #0b0f14;
}
.btn-primary:hover { background: var(--accent-hi); }
.btn-ghost {
  background: transparent; color: var(--text-mute);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-hi); }

/* ==================================================================
   引用フォーム（citations_form.php）
   ================================================================== */
.cite-form {
  margin: .25rem 0; padding: .7rem .85rem;
  background: var(--surface-2);
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
}
.cite-form legend {
  display: inline-flex; gap: .6rem; align-items: center;
  padding: 0 .4rem;
}
.cite-form legend small { color: var(--text-dim); font-size: .72rem; }
.cite-toggle {
  color: var(--accent-hi); font-weight: 700; font-size: .85rem;
  padding: .2rem .5rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface);
}
.cite-toggle:hover { border-color: var(--accent); }

.cite-list { display: flex; flex-direction: column; gap: .5rem; margin: .6rem 0; }
.cite-row {
  position: relative;
  padding: .6rem .7rem .5rem;
  background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.cite-grid {
  display: grid; gap: .4rem .6rem;
  grid-template-columns: repeat(6, 1fr);
}
.cite-grid label { font-size: .72rem; color: var(--text-dim); }
.cite-grid input, .cite-grid select { padding: .4rem .5rem; font-size: .85rem; }
.g-type    { grid-column: span 2; }
.g-title   { grid-column: span 4; }
.g-authors { grid-column: span 3; }
.g-year    { grid-column: span 1; }
.g-source  { grid-column: span 2; }
.g-doi     { grid-column: span 3; }
.g-url     { grid-column: span 3; }
.g-note    { grid-column: span 6; }
@media (max-width: 640px) { .cite-grid > label { grid-column: 1 / -1 !important; } }

.cite-remove {
  position: absolute; top: 6px; right: 6px;
  color: var(--danger); font-size: .7rem;
  padding: 2px 6px; border-radius: 4px;
}
.cite-remove:hover { background: color-mix(in oklab, var(--danger) 25%, #000); color: #fff; }

/* ==================================================================
   フッター
   ================================================================== */
.site-ft {
  margin-top: 3rem;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
}
.ft-inner {
  max-width: 1240px; margin: 0 auto;
  padding: 1.8rem 1rem 1rem;
  display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2rem;
}
@media (max-width: 640px) { .ft-inner { grid-template-columns: 1fr; } }
.ft-col ul { list-style: none; padding: 0; margin: 0; }
.ft-col li { padding: 2px 0; font-size: .85rem; }
.ft-col h4 { font-family: var(--serif); color: var(--accent-hi); margin: 0 0 .4rem; }
.ft-col p small, .ft-col li { color: var(--text-mute); }
.ft-bottom {
  border-top: 1px solid var(--border);
  padding: .8rem 1rem;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--mono);
}

/* ==================================================================
   走査線効果（控えめ）
   ================================================================== */
body::after {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(184, 150, 46, 0.012) 3px,
    rgba(184, 150, 46, 0.012) 4px
  );
  pointer-events: none; z-index: 9999;
}

/* ==================================================================
   トースト
   ================================================================== */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text);
  padding: .7rem 1.2rem; border: 1px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  z-index: 10001; font-size: .9rem;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
