@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+JP:wght@300;400;500;700&display=swap");

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --line-green: #06c755;
  /* モバイル下部ナビ: 選択中タブ・アクセント */
  --mobile-nav-accent: var(--primary);
  /* 中央 FAB のみブランド青 */
  --mobile-fab-bg: var(--primary);
  --mobile-fab-shadow: rgba(37, 99, 235, 0.4);
  /* PC でも中央に表示するモバイル画面幅 */
  --crm-mobile-width: 430px;
  --crm-mobile-gutter: #cbd5e1;
  /* 下部固定ナビの高さ（pt + 行 + pb） */
  --crm-bottom-nav-height: calc(0.25rem + 3.35rem + max(0.8rem, env(safe-area-inset-bottom, 0px)));
  /* AI人脈検索: 入力欄 + ナビ分のスクロール余白 */
  --crm-ai-chat-composer-stack: calc(var(--crm-bottom-nav-height) + 5rem + 0.35rem);
}

#crm-mobile-bottom-nav {
  background: #ffffff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* 認証画面（ログイン・新規登録など） */
body.crm-auth-page {
  background: var(--crm-mobile-gutter, #cbd5e1);
  min-height: 100vh;
  min-height: 100dvh;
}

.crm-auth-viewport {
  width: 100%;
  max-width: var(--crm-mobile-width, 430px);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #eff6ff 0%, #f8fafc 42%, #f8fafc 100%);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.06),
    0 12px 48px rgba(15, 23, 42, 0.14);
}

.crm-auth-header {
  padding: 2.5rem 1.5rem 1rem;
  text-align: center;
}

.crm-auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
}

.crm-auth-logo i {
  font-size: 1.25rem;
}

.crm-auth-sub {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: #64748b;
}

.crm-auth-main {
  flex: 1;
  padding: 0 1.25rem 2rem;
}

.crm-auth-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
}

.crm-auth-field {
  margin-bottom: 1rem;
}

.crm-auth-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 0.35rem;
}

.crm-auth-field input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: #f8fafc;
}

.crm-auth-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background: #fff;
}

.crm-auth-submit {
  width: 100%;
  padding: 0.85rem;
  border: none;
  border-radius: 0.75rem;
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 0.25rem;
}

.crm-auth-submit:hover {
  background: var(--primary-hover);
}

.crm-auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.crm-auth-links {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.7;
}

.crm-auth-links a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.crm-auth-links a:hover {
  text-decoration: underline;
}

.crm-auth-error {
  margin-bottom: 1rem;
  padding: 0.7rem 0.85rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.65rem;
  font-size: 0.82rem;
  color: #b91c1c;
  line-height: 1.45;
}

.crm-auth-success {
  margin-bottom: 1rem;
  padding: 0.7rem 0.85rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 0.65rem;
  font-size: 0.82rem;
  color: #166534;
  line-height: 1.45;
}

.crm-auth-demo-mail {
  margin-top: 1rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 0.75rem;
  font-size: 0.78rem;
  color: #475569;
  line-height: 1.55;
}

.crm-auth-demo-mail strong {
  display: block;
  font-size: 0.72rem;
  color: #64748b;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.crm-auth-demo-mail a {
  word-break: break-all;
  color: var(--primary);
  font-weight: 600;
}

.crm-auth-footer {
  padding: 1rem 1.25rem 1.5rem;
  text-align: center;
  font-size: 0.7rem;
  color: #94a3b8;
}

/* モバイル専用: 中央フレーム + 左右余白 */
html {
  background: var(--crm-mobile-gutter);
}

body.crm-mobile-only {
  background: var(--crm-mobile-gutter);
}

.crm-mobile-viewport {
  width: 100%;
  max-width: var(--crm-mobile-width);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: #f8fafc;
  position: relative;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.06),
    0 12px 48px rgba(15, 23, 42, 0.14);
  overflow-x: hidden;
}

/* 広い画面では fixed 要素を中央フレーム内に収める */
@media (min-width: 431px) {
  .crm-mobile-fixed-anchor {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%);
    width: min(100vw, var(--crm-mobile-width)) !important;
    max-width: var(--crm-mobile-width);
  }

  body.crm-mobile-only .crm-mobile-viewport .fixed.inset-0:not(.crm-mobile-fixed-anchor) {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(100vw, var(--crm-mobile-width));
    max-width: var(--crm-mobile-width);
  }

  body.crm-mobile-only .crm-toast,
  body.crm-mobile-only .toast {
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    max-width: calc(var(--crm-mobile-width) - 2rem);
  }

  body.crm-mobile-only .crm-toast.is-visible,
  body.crm-mobile-only .toast.is-visible {
    transform: translateX(-50%) translateY(0);
  }

  body.crm-mobile-only .crm-mobile-viewport > .fixed[class*="right-"],
  body.crm-mobile-only .crm-mobile-viewport .fixed.right-4,
  body.crm-mobile-only .crm-mobile-viewport .fixed.right-6 {
    right: calc(50% - var(--crm-mobile-width) / 2 + 1rem) !important;
    left: auto !important;
    transform: none;
  }
}

/* 戻る: 青い左シェブロン（枠・塗りなし）で統一 */
button.crm-back-btn,
a.crm-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  margin-left: -0.125rem;
  box-sizing: border-box;
  color: var(--primary);
  background: transparent;
  border: 0;
  border-radius: 0.5rem;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease;
}
button.crm-back-btn:hover,
a.crm-back-btn:hover {
  color: var(--primary-hover);
}
button.crm-back-btn:active,
a.crm-back-btn:active {
  color: #1e40af;
}
button.crm-back-btn:focus-visible,
a.crm-back-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
button.crm-back-btn i,
a.crm-back-btn i {
  font-size: 1.125rem;
  line-height: 1;
}

.crm-demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0;
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.2;
  color: #92400e;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1.5px solid #f59e0b;
  border-radius: 9999px;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.28);
}

.crm-demo-badge i {
  font-size: 0.7rem;
  opacity: 0.9;
}

button.crm-demo-badge:hover {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #d97706;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

button.crm-demo-badge:active {
  transform: scale(0.97);
  background: #fde68a;
}

button.crm-demo-badge:focus-visible {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}

/* AI人脈検索: 入力欄を下部メニュー直上に固定 */
.crm-ai-chat-composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--crm-bottom-nav-height);
  z-index: 38;
  padding: 0.5rem 0.5rem 0.5rem;
  background: #f8fafc;
  border-top: 1px solid rgba(226, 232, 240, 0.9);
  box-sizing: border-box;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.05);
}

.crm-ai-chat-composer__inner {
  max-width: min(100%, var(--crm-mobile-width, 430px));
  margin: 0 auto;
}

body.ai-chat-page .ai-chat-page-inner {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

body.ai-chat-page .app-shell > main > .flex-1.overflow-y-auto > div {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 4.25rem);
  padding-bottom: max(1.5rem, var(--crm-ai-chat-composer-stack)) !important;
}

/* インタラクティブ・チュートリアル */
.crm-tutorial {
  position: fixed;
  inset: 0;
  z-index: 95;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.crm-tutorial.is-open {
  pointer-events: none;
  opacity: 1;
  visibility: visible;
}

.crm-tutorial.is-open .crm-tutorial__tooltip {
  pointer-events: auto;
}

.crm-tutorial.is-complete-step {
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.crm-tutorial.is-modal-target {
  z-index: 110;
}

.crm-tutorial.is-modal-target .crm-tutorial__backdrop,
.crm-tutorial.is-modal-target .crm-tutorial__spotlight {
  display: none;
}

.crm-tutorial.is-modal-target .crm-tutorial__tooltip {
  z-index: 111;
}

.crm-tutorial.is-complete-step .crm-tutorial__tooltip {
  position: relative;
  left: auto !important;
  top: auto !important;
  transform: none !important;
  flex-shrink: 0;
}

.crm-tutorial__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(1px);
  pointer-events: none;
}

.crm-tutorial__spotlight {
  position: fixed;
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55);
  background: transparent;
  pointer-events: none;
  transition: top 0.2s ease, left 0.2s ease, width 0.2s ease, height 0.2s ease;
  z-index: 1;
}

.crm-tutorial-target {
  position: relative;
  z-index: 100 !important;
  pointer-events: auto !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.85), 0 0 0 6px rgba(37, 99, 235, 0.25);
  border-radius: 12px;
  animation: crm-tutorial-pulse 1.6s ease-in-out infinite;
}

@keyframes crm-tutorial-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.85), 0 0 0 6px rgba(37, 99, 235, 0.2);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 1), 0 0 0 10px rgba(37, 99, 235, 0.12);
  }
}

.crm-tutorial__tooltip {
  position: fixed;
  z-index: 110;
  max-width: min(22rem, calc(100vw - 24px));
  max-height: min(70vh, calc(100dvh - 24px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border-radius: 1.15rem;
  padding: 1rem 1rem 0.85rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
  border: 1px solid #e2e8f0;
  pointer-events: auto;
}

.crm-tutorial__tooltip.is-complete {
  width: min(calc(100vw - 24px), var(--crm-mobile-width, 430px));
  max-width: min(calc(100vw - 24px), var(--crm-mobile-width, 430px));
  box-sizing: border-box;
}

.crm-tutorial__eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #2563eb;
}

.crm-tutorial__title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.35;
}

.crm-tutorial__body {
  font-size: 0.8125rem;
  line-height: 1.65;
  color: #475569;
}

.crm-tutorial__body strong {
  color: #0f172a;
  font-weight: 700;
}

.crm-tutorial__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f1f5f9;
}

.crm-tutorial__skip {
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem 0.25rem;
}

.crm-tutorial__skip:hover {
  color: #64748b;
}

.crm-tutorial__next {
  margin-left: auto;
  border: 0;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 0.55rem 1.1rem;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
}

.crm-tutorial__next.hidden {
  display: none;
}

.crm-tutorial__next.is-finish {
  width: 100%;
  padding: 0.7rem 1rem;
}

.crm-tutorial__skip.hidden {
  display: none;
}

body.crm-tutorial-active {
  overflow: hidden;
}

body.crm-tutorial-active .crm-tutorial-elevated {
  z-index: 96 !important;
}

#crm-mobile-bottom-nav .crm-tutorial-target {
  z-index: 101 !important;
}

a.crm-mobile-fab.crm-tutorial-target {
  border-radius: 9999px !important;
}

/* 初回デモ説明ポップアップ */
.crm-demo-welcome {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.crm-demo-welcome.is-open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.crm-demo-welcome__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  cursor: pointer;
}

.crm-demo-welcome__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 22rem;
  max-height: min(88vh, 36rem);
  overflow-y: auto;
  background: #fff;
  border-radius: 1.35rem;
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
  border: 1px solid #e2e8f0;
}

.crm-demo-welcome__badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 9999px;
  margin-bottom: 0.65rem;
}

.crm-demo-welcome__title {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
}

.crm-demo-welcome__body {
  font-size: 0.8125rem;
  line-height: 1.65;
  color: #475569;
}

.crm-demo-welcome__body p {
  margin: 0 0 0.75rem;
}

.crm-demo-welcome__body strong {
  color: #0f172a;
  font-weight: 700;
}

.crm-demo-welcome__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  border-radius: 0.75rem;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
}

.crm-demo-welcome__link:hover {
  filter: brightness(1.05);
}

.crm-demo-welcome__pwa {
  padding: 0.85rem 0.9rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.9rem;
}

.crm-demo-welcome__pwa-title {
  margin: 0 0 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.crm-demo-welcome__steps {
  margin: 0 0 0.55rem;
  padding-left: 1.15rem;
  font-size: 0.75rem;
  color: #475569;
  line-height: 1.55;
}

.crm-demo-welcome__steps li + li {
  margin-top: 0.25rem;
}

.crm-demo-welcome__pwa-note {
  margin: 0;
  font-size: 0.6875rem;
  color: #64748b;
  line-height: 1.5;
}

.crm-demo-welcome__ok {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: #334155;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.crm-demo-welcome__ok:hover {
  background: #e2e8f0;
}

.crm-demo-welcome__tutorial {
  display: block;
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}

.crm-demo-welcome__tutorial:hover {
  background: #dbeafe;
}

.crm-demo-welcome__ok:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* フォント統一（Tailwind font-sans と併用） */
body.app-body {
  font-family: "Inter", "Noto Sans JP", system-ui, sans-serif;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

body.app-body::-webkit-scrollbar {
  display: none;
}

/* 全ページ: 表示上のスクロールバーを非表示（スクロールは可能） */
* {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  display: none;
}

.sidebar-item.active {
  background-color: #eff6ff;
  color: var(--primary);
  border-right: 4px solid var(--primary);
}

.glass-card {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.line-preview {
  background-color: #7494c0;
  border-radius: 20px;
  padding: 20px;
  max-width: 400px;
  margin: 0 auto;
}

.bubble {
  background: #fff;
  border-radius: 15px;
  padding: 10px 15px;
  position: relative;
  margin-bottom: 15px;
  font-size: 0.9rem;
  line-height: 1.5;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.bubble::after {
  content: "";
  position: absolute;
  left: -8px;
  top: 10px;
  border-width: 8px 10px 8px 0;
  border-style: solid;
  border-color: transparent #fff transparent transparent;
}

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.contact-card:hover {
  transform: translateY(-2px);
  transition: all 0.2s ease;
}

/* トースト（JS で .is-visible） */
.crm-toast {
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.crm-toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

/* モバイル下部タブバー: 横スクロール時にスクロールバーを隠す */
.crm-bottom-nav-scroll {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.crm-bottom-nav-scroll::-webkit-scrollbar {
  display: none;
}

.crm-mobile-tab-active {
  color: var(--mobile-nav-accent);
}

.crm-mobile-fab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 9999px;
  background: var(--mobile-fab-bg);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  box-shadow: 0 10px 28px var(--mobile-fab-shadow);
  transform: translateY(-0.65rem);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.crm-mobile-fab:hover {
  filter: brightness(1.05);
}
.crm-mobile-fab:active {
  transform: translateY(-0.55rem) scale(0.98);
}
.crm-mobile-fab.is-current {
  box-shadow: 0 10px 32px var(--mobile-fab-shadow), 0 0 0 3px rgba(255, 255, 255, 0.95);
}

.crm-mobile-fab .crm-mobile-fab-icon {
  font-size: 1.15rem;
  line-height: 1;
  margin-bottom: 0.2rem;
}

/* 「その他」ボトムシート */
.crm-mobile-more-sheet {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.crm-mobile-more-sheet.is-open {
  opacity: 1;
  pointer-events: auto;
}
.crm-mobile-more-sheet .crm-mobile-more-backdrop {
  opacity: 0;
  transition: opacity 0.2s ease;
}
.crm-mobile-more-sheet.is-open .crm-mobile-more-backdrop {
  opacity: 1;
}
.crm-mobile-more-panel {
  transform: translateY(105%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
.crm-mobile-more-sheet.is-open .crm-mobile-more-panel {
  transform: translateY(0);
}

/* チュートリアル選択シート（ヘッダー ? ボタン） */
.crm-tutorial-picker-sheet {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.crm-tutorial-picker-sheet.is-open {
  opacity: 1;
  pointer-events: auto;
}
.crm-tutorial-picker-sheet .crm-tutorial-picker-backdrop {
  opacity: 0;
  transition: opacity 0.2s ease;
}
.crm-tutorial-picker-sheet.is-open .crm-tutorial-picker-backdrop {
  opacity: 1;
}
.crm-tutorial-picker-panel {
  transform: translateY(105%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
.crm-tutorial-picker-sheet.is-open .crm-tutorial-picker-panel {
  transform: translateY(0);
}

/* 連絡先 登録/編集画面のモバイル最適化 */
body.contact-form-page .contact-editor-form {
    gap: 0.9rem;
  }

  body.contact-form-page .contact-mode-switch {
    position: sticky;
    top: 3.5rem;
    z-index: 15;
    background: rgba(248, 250, 252, 0.94);
    backdrop-filter: blur(6px);
    border: 1px solid #e5e7eb;
    border-radius: 0.9rem;
    padding: 0.6rem;
    margin-bottom: 0.9rem;
  }

  body.contact-form-page #contact-basic-card,
  body.contact-form-page #contact-reminder-card {
    border-radius: 1rem;
    padding: 0;
    overflow: hidden;
    border-color: #e5e7eb;
  }

  body.contact-form-page #contact-basic-card h2,
  body.contact-form-page #contact-reminder-card h2 {
    margin: 0;
    padding: 0.9rem 1rem;
    font-size: 0.92rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
  }

  body.contact-form-page #contact-reminder-card > p {
    margin: 0;
    padding: 0.65rem 1rem 0.85rem;
    font-size: 0.76rem;
    border-bottom: 1px solid #e5e7eb;
  }

  body.contact-form-page #contact-basic-fields {
    max-width: none;
    margin: 0;
  }

  body.contact-form-page #contact-basic-fields > div {
    padding: 0.55rem 1rem;
    border-bottom: 0;
  }

  body.contact-form-page #contact-basic-fields label {
    margin-bottom: 0.35rem;
    font-size: 0.75rem;
    color: #6b7280;
  }

  body.contact-form-page #contact-basic-fields input,
  body.contact-form-page #contact-basic-fields select,
  body.contact-form-page #contact-basic-fields textarea {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 0.75rem;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    color: #111827;
    line-height: 1.4;
    box-shadow: none;
  }

  body.contact-form-page #contact-basic-fields textarea {
    min-height: 4.4rem;
    resize: vertical;
  }

  body.contact-form-page #contact-basic-fields input:focus,
  body.contact-form-page #contact-basic-fields select:focus,
  body.contact-form-page #contact-basic-fields textarea:focus {
    outline: none;
    box-shadow: none;
  }

  body.contact-form-page #contact-reminder-card {
    padding-bottom: 0.9rem;
  }

  body.contact-form-page #contact-reminder-card #reminderRows,
  body.contact-form-page #contact-reminder-card #addReminder {
    margin-left: 1rem;
    margin-right: 1rem;
  }

  body.contact-form-page #contact-form-actions {
    position: sticky;
    bottom: calc(4.6rem + env(safe-area-inset-bottom, 0px));
    z-index: 10;
    background: linear-gradient(to top, rgba(248, 250, 252, 1), rgba(248, 250, 252, 0.85));
    padding: 0.7rem 0 0.35rem;
    margin-top: 0.2rem;
    margin-bottom: 0;
  }

body.contact-form-page #contact-form-actions > * {
  flex: 1 1 100%;
  width: 100%;
  justify-content: center;
}

/* 連絡先一覧: 交換月ラベル */
body.contact-list-page .contacts-month-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #9ca3af;
  line-height: 1.3;
  padding: 0.35rem 0.25rem 0.15rem;
}

body.contact-list-page .contacts-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
}

body.contact-list-page .contact-row-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0.95rem 0.25rem;
  border-bottom: 1px solid #e5e7eb;
}

body.contact-list-page .contact-row-card:last-child {
  border-bottom: 0;
}

body.contact-list-page .contact-row-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

body.contact-list-page .contact-row-name-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

body.contact-list-page .contact-row-name {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 1.04rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.25;
}

body.contact-list-page .contact-referrer {
  flex: 0 0 auto;
  max-width: 46%;
  text-align: right;
  font-size: 0.78rem;
  font-weight: 500;
  color: #6b7280;
  line-height: 1.25;
  white-space: nowrap;
}

body.contact-list-page .contact-row-job {
  margin-top: 0.25rem;
  font-size: 0.9rem;
  color: #4b5563;
  line-height: 1.35;
}

/* 連絡先一覧のモバイルUI */
body.contact-list-page #contacts-mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 22;
    background: rgba(248, 250, 252, 0.98);
    padding-top: 0.25rem;
  }

  body.contact-list-page #contacts-mobile-search-wrap {
    position: relative;
    background: rgba(248, 250, 252, 0.96);
    padding-top: 0.35rem;
    padding-bottom: 0.45rem;
    margin-bottom: 0.2rem;
  }

  body.contact-list-page #contacts-mobile-search-wrap input {
    background: #f3f4f6;
    border-color: #e5e7eb;
    box-shadow: none;
  }

  body.contact-list-page #contacts-mobile-tabs {
    display: flex;
    position: relative;
    align-items: center;
    gap: 0.9rem;
    border-bottom: 1px solid #dbe2ea;
    margin-bottom: 0.55rem;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    white-space: nowrap;
    background: rgba(248, 250, 252, 0.98);
  }

  body.contact-list-page #contacts-mobile-tabs button {
    border: 0;
    background: transparent;
    color: #6b7280;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.35rem 0.05rem 0.55rem;
    flex-shrink: 0;
  }

  body.contact-list-page #contacts-mobile-tabs button.is-active {
    color: #111827;
    border-bottom: 2px solid var(--primary);
    margin-bottom: -1px;
  }

  body.contact-list-page #contacts-mobile-tabs button.contacts-manage-tab {
    margin-left: auto;
    color: #1d4ed8;
    font-weight: 700;
  }

  body.contact-list-page #contacts-total-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.55rem;
    height: 1.1rem;
    padding: 0 0.32rem;
    border-radius: 999px;
    background: #1d4ed8;
    color: #fff;
    font-size: 0.67rem;
    margin-left: 0.22rem;
  }

  body.contact-list-page #contacts-mobile-sortbar {
    display: none;
  }

  body.contact-list-page #contacts-mobile-sortbar button {
    border: 0;
    background: transparent;
    color: #6b7280;
    font-size: 0.8rem;
    padding: 0.18rem 0.35rem;
  }

  body.contact-list-page #contacts-mobile-sortbar button.is-active {
    color: #1d4ed8;
    font-weight: 700;
  }

  body.contact-list-page .contacts-month-label {
    padding: 0.85rem 0.2rem 0.35rem;
    background: #fff;
  }

  body.contact-list-page .contacts-month-label:first-child {
    padding-top: 0.55rem;
  }

  body.contact-list-page .contact-row-card {
    padding: 0.95rem 0.2rem;
  }

  body.contact-list-page .contact-row-main {
    align-items: center;
  }

  body.contact-list-page .contact-card-thumb {
    width: 5.85rem;
    height: 3.45rem;
    border: 1px solid #d1d5db;
    border-radius: 0.2rem;
    background: #fff;
    overflow: hidden;
  }

  body.contact-list-page .contact-card-thumb-inner {
    width: 100%;
    height: 100%;
    background: linear-gradient(130deg, #f3f4f6 0%, #ffffff 55%, #eef2ff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
  }

body.contact-list-page .contact-card-thumb-initial {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  background: #1d4ed8;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.contact-form-page main > header.sticky {
  display: none !important;
}

/* 連絡先編集画面: 下部アクションは上部バーで代替するため非表示 */
body.contact-form-page #contact-form-actions {
  display: none !important;
}

/* 連絡先編集画面: ヘッダー非表示時の上部余白 */
body.contact-form-page .app-shell {
  padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
}

/* 通知ベル・下部ナビなどの未対応件数バッジ */
.crm-notify-count-badge {
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background-color: #2563eb;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px #fff;
  pointer-events: none;
}
