/* ============================================================
   Umatter 統一デザインオーバーレイ (U13: 落ち着いたニンジンオレンジ基調)
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --bg-hover: rgba(15, 23, 42, 0.04);
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #c24b17;
  --primary-hover: #9f3c10;
  --primary-soft: rgba(217, 93, 36, 0.11);
  --carrot: #d95d24;
  --carrot-soft: rgba(217, 93, 36, 0.12);
  --ai-badge-bg: #f1f5f9;
  --ai-badge-text: #334155;
  --link-color: #1d6fa5;
}
[data-theme="dark"] {
  --bg: #0f1419;
  --bg-soft: #171e26;
  --bg-hover: rgba(248, 250, 252, 0.05);
  --border: #2a333d;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #f07b3f;
  --primary-hover: #f5925d;
  --primary-soft: rgba(240, 123, 63, 0.16);
  --carrot: #f07b3f;
  --carrot-soft: rgba(240, 123, 63, 0.16);
  --ai-badge-bg: #1e293b;
  --ai-badge-text: #cbd5e1;
  --link-color: #60a5fa;
}

body {
  font-family: "Inter", "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

/* ---- 背景装飾は控えめに ---- */
body::before { display: none !important; }
.brand-title, .header-title, .widget-title {
  background: none !important;
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
  -webkit-text-fill-color: currentColor !important;
  color: var(--text) !important;
  animation: none !important;
}
.post-card::before, .widget-card::before, .btn-primary::after { display: none !important; }
.post-card.mk-in { animation: none !important; }
.mk-particle { display: none !important; }
.act-btn.mk-pop .act-icon { animation: none !important; }
.sticky-header.mk-scrolled { box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06) !important; }

.mobile-bottom-nav {
  background: color-mix(in srgb, var(--bg) 92%, transparent) !important;
  backdrop-filter: blur(12px);
  box-shadow: none !important;
  border-top: 1px solid var(--border);
}

/* ---- ヘッダー ---- */
.sticky-header {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}
.header-title { font-size: 19px; font-weight: 800; }
.header-subtitle { color: var(--text-muted); }
.brand-sub { color: var(--primary); }

/* ---- 左ナビ ---- */
.nav-item { font-size: 16px; font-weight: 600; }
.nav-item.active {
  color: var(--primary);
  font-weight: 800;
  background: var(--primary-soft);
}
.nav-item:hover { background: var(--bg-hover); }

/* ---- 投稿 ---- */
.post-card { padding: 14px 16px; gap: 12px; }
.post-content { font-size: 15px; line-height: 1.55; }
.author-name { font-size: 15px; font-weight: 700; }
.author-handle, .post-time { font-size: 13px; color: var(--text-muted); }

/* ---- アクションバー ---- */
.act-btn { color: var(--text-muted); font-weight: 500; }
.act-btn:hover { background: var(--bg-hover); color: var(--text); }
.act-btn.repost-btn:hover, .act-btn.repost-btn.active {
  color: #0f766e;
  background: rgba(15, 118, 110, 0.10);
}
[data-theme="dark"] .act-btn.repost-btn:hover,
[data-theme="dark"] .act-btn.repost-btn.active {
  color: #2dd4bf;
  background: rgba(45, 212, 191, 0.14);
}
.act-btn.carrot-btn:hover, .act-btn.carrot-btn.active {
  color: var(--carrot);
  background: var(--carrot-soft);
}

/* ---- 引用カード ---- */
.quote-card { border-radius: 14px; border-color: var(--border); }
.quote-card:hover { border-color: var(--primary); background: var(--bg-hover); }

/* ---- 右レール ---- */
.widget-card { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 16px; }
.widget-title { font-size: 16px; font-weight: 800; }
.search-box-wrap input {
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.search-box-wrap input:focus { background: var(--bg); border-color: var(--primary); }

/* ---- ボタン ---- */
.btn-primary { background: var(--primary); box-shadow: none; color: #ffffff; }
.btn-primary:hover { background: var(--primary-hover); }
[data-theme="dark"] .btn-primary { color: #0f1419; font-weight: 800; }
.btn-outline.following {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* ---- タブ：文字色＋背景ティント＋下線の複数手掛かり ---- */
.tab-btn { font-size: 14.5px; }
.tab-btn.active {
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-soft);
}
.tab-btn.active::after {
  background: var(--primary) !important;
  animation: none !important;
}

/* ---- スレッド段差 ---- */
.mk-thread-node.mk-ind > .post-card {
  border-left: 2px solid color-mix(in srgb, var(--primary) 40%, transparent);
}

/* ============================================================
   DesignBookmark Motion マイクロインタラクション
   ============================================================ */

/* 1. Like / Repost バースト */
.act-btn {
  position: relative;
  overflow: visible;
}
.act-btn.um-pop .act-icon {
  display: inline-block;
  animation: umSpringPop 0.48s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes umSpringPop {
  0% { transform: scale(1) rotate(0deg); }
  35% { transform: scale(1.42) rotate(-10deg); }
  68% { transform: scale(0.92) rotate(4deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.um-burst-particle {
  position: absolute;
  left: 16px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--p-color, var(--carrot));
  pointer-events: none;
  z-index: 5;
  transform: translate(-50%, -50%) scale(0);
  animation: umParticleBurst 0.56s cubic-bezier(0.16, 1, 0.3, 1) var(--delay, 0ms) forwards;
}
@keyframes umParticleBurst {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.5);
  }
  55% {
    opacity: 1;
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1.15);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--tx) * 1.25), calc(-50% + var(--ty) * 1.25)) scale(0.2);
  }
}

/* 2. スライディングタブピル（ホームタブ & 名鑑フィルタ） */
.tab-bar.has-indicator {
  position: relative;
}
.tab-bar.has-indicator .tab-btn {
  position: relative;
  z-index: 1;
  background: transparent !important;
  transition: color 0.2s ease;
}
.tab-bar.has-indicator .tab-btn.active::after {
  display: none !important;
}
.tab-bar.has-indicator .tab-indicator {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  border-radius: 10px;
  background: var(--primary-soft);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: transform 0.36s cubic-bezier(0.34, 1.56, 0.64, 1),
              width 0.36s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.18s ease;
}
.tab-bar.has-indicator .tab-indicator::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 3.5px;
  border-radius: 999px;
  background: var(--primary);
}

.dir-filter-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow-x: auto;
  scrollbar-width: none;
}
.dir-filter-bar::-webkit-scrollbar { display: none; }
.dir-filter-btn {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.2s ease;
}
.dir-filter-btn:hover { color: var(--text); }
.dir-filter-btn.active {
  color: var(--primary);
  font-weight: 800;
}
.dir-filter-bar .tab-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: transform 0.36s cubic-bezier(0.34, 1.56, 0.64, 1),
              width 0.36s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.18s ease;
}

/* 3. 文字数制限 円形SVGゲージ */
.char-gauge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.char-gauge-svg {
  transform: rotate(-90deg);
  overflow: visible;
  flex-shrink: 0;
}
.char-gauge-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 2.6;
}
.char-gauge-fill {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 69.115;
  stroke-dashoffset: 69.115;
  transition: stroke-dashoffset 0.18s ease-out, stroke 0.25s ease;
}
.char-gauge-num {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 24px;
  text-align: right;
  transition: color 0.25s ease;
}
.char-gauge.near-limit .char-gauge-fill { stroke: var(--primary); }
.char-gauge.near-limit .char-gauge-num { color: var(--primary); font-weight: 800; }
.char-gauge.at-limit .char-gauge-fill { stroke: #dc2626; }
.char-gauge.at-limit .char-gauge-num { color: #dc2626; font-weight: 800; }
[data-theme="dark"] .char-gauge.at-limit .char-gauge-fill { stroke: #f87171; }
[data-theme="dark"] .char-gauge.at-limit .char-gauge-num { color: #f87171; }
.char-gauge.pulse {
  animation: umGaugePulse 1s ease-in-out infinite;
}
@keyframes umGaugePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* 4. 送信ボタン Loading -> Success 遷移 */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.18s ease, transform 0.12s ease, opacity 0.15s ease;
}
.btn-primary.btn-block {
  display: flex;
  width: 100%;
}
.btn-primary.is-loading {
  pointer-events: none;
  opacity: 0.9;
}
.btn-primary.is-success {
  background: #059669 !important;
  color: #ffffff !important;
  pointer-events: none;
}
[data-theme="dark"] .btn-primary.is-success {
  background: #10b981 !important;
  color: #0f1419 !important;
}
.btn-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: umSpin 0.65s linear infinite;
}
@keyframes umSpin {
  to { transform: rotate(360deg); }
}
.btn-check-svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  animation: umCheckDraw 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes umCheckDraw {
  to { stroke-dashoffset: 0; }
}

/* 5. 通知ベル物理振動 & 新着ポスト Morph Island ピル */
.notif-header-btn.bell-ringing svg,
.nav-item.bell-ringing .nav-icon svg {
  transform-origin: 50% 4px;
  animation: umBellRing 0.9s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
.notif-header-btn.has-unread:hover svg,
.nav-item.has-unread:hover .nav-icon svg {
  transform-origin: 50% 4px;
  animation: umBellRing 0.8s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes umBellRing {
  0% { transform: rotate(0deg); }
  14% { transform: rotate(17deg); }
  28% { transform: rotate(-15deg); }
  42% { transform: rotate(11deg); }
  56% { transform: rotate(-8deg); }
  70% { transform: rotate(5deg); }
  84% { transform: rotate(-2deg); }
  100% { transform: rotate(0deg); }
}
.notif-header-btn.has-unread .notif-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--carrot);
  opacity: 0;
  animation: umDotPing 2.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes umDotPing {
  0% { transform: scale(0.8); opacity: 0.8; }
  70%, 100% { transform: scale(2.1); opacity: 0; }
}

.new-posts-banner {
  position: sticky;
  top: 108px;
  z-index: 19;
  align-self: center;
  width: fit-content;
  max-width: calc(100% - 24px);
  margin: 10px auto 2px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.15s ease;
}
.new-posts-banner:hover {
  background: var(--primary-hover);
  transform: translateY(-1px) scale(1.02);
}
[data-theme="dark"] .new-posts-banner {
  color: #0f1419;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.new-posts-banner.morph-in {
  animation: umMorphIslandIn 0.44s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes umMorphIslandIn {
  0% {
    opacity: 0;
    transform: translateY(-16px) scale(0.68);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 6. スプリングドロップダウン / モーダル / 引用スムーズ展開 */
.post-more-menu:not(.hidden) {
  transform-origin: bottom right;
  animation: umMenuSpringIn 0.24s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.post-more-menu.open-down:not(.hidden) {
  transform-origin: top right;
  animation-name: umMenuSpringInDown;
}
.post-more-menu.is-closing {
  animation: umMenuSpringOut 0.14s ease forwards !important;
  pointer-events: none;
}
@keyframes umMenuSpringIn {
  0% { opacity: 0; transform: scale(0.86) translateY(6px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes umMenuSpringInDown {
  0% { opacity: 0; transform: scale(0.86) translateY(-6px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes umMenuSpringOut {
  to { opacity: 0; transform: scale(0.92) translateY(4px); }
}

.modal-overlay:not(.hidden) {
  animation: umOverlayFadeIn 0.2s ease both;
}
.modal-overlay:not(.hidden) .modal-card {
  animation: umModalSpringIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.modal-overlay.is-closing {
  animation: umOverlayFadeOut 0.16s ease forwards !important;
  pointer-events: none;
}
.modal-overlay.is-closing .modal-card {
  animation: umModalSpringOut 0.16s ease forwards !important;
}
@keyframes umOverlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes umOverlayFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes umModalSpringIn {
  0% { opacity: 0; transform: scale(0.92) translateY(14px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes umModalSpringOut {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to { opacity: 0; transform: scale(0.95) translateY(8px); }
}

.quote-collapsible .quote-content {
  transition: max-height 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

/* モバイルタッチターゲット確保 (44x44px) */
@media (max-width: 820px) {
  .dir-filter-btn,
  .new-posts-banner {
    min-height: 44px;
    min-width: 44px;
  }
  .new-posts-banner {
    top: 138px;
    display: inline-flex;
    align-items: center;
  }
}

/* Reduced Motion 対応 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .um-burst-particle {
    display: none !important;
  }
}
