:root {
  --line-bg-top: #8cabd8;
  --line-bg-bottom: #b6c8e0;
  --line-green: #06c755;
  --line-green-dark: #05a648;
  --bubble-in-bg: #ffffff;
  --bubble-in-text: #1c1c1e;
  --bubble-out-bg: #8de055;
  --bubble-out-text: #1c1c1e;
  --text-muted: #5a6473;
  --text-strong: #1c1c1e;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --border-subtle: #e5e7eb;
  --radius-card: 12px;
  --radius-bubble: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, var(--line-bg-top) 0%, var(--line-bg-bottom) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--text-strong);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

.detail-container {
  max-width: 720px;
}

/* ===== Page header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  color: #ffffff;
}

.page-title {
  font-size: 20px;
  margin: 0;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.page-count {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
}

.back-link {
  color: #ffffff;
  text-decoration: none;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.back-link:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ===== Search form ===== */
.search-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  background: var(--card-bg);
  padding: 10px;
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
}

.search-input {
  flex: 1;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
}

.search-input:focus {
  outline: none;
  border-color: var(--line-green);
  box-shadow: 0 0 0 2px rgba(6, 199, 85, 0.2);
}

.search-button {
  background: var(--line-green);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.search-button:hover {
  background: var(--line-green-dark);
}

.search-clear {
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  padding: 0 6px;
}

.search-clear:hover {
  text-decoration: underline;
}

/* ===== User list ===== */
.user-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  text-decoration: none;
  color: inherit;
  transition: transform 0.05s ease, box-shadow 0.15s ease;
}

.user-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e5e7eb;
  object-fit: cover;
  flex-shrink: 0;
  font-size: 19px;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-label {
  color: #9aa3b2;
}

.discord-name {
  color: var(--text-muted);
}

/* Discord ID 手動編集（ユーザー詳細のプロフィール内） */
.discord-id-view {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.discord-id-edit-link {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 1px 8px;
  border-radius: 6px;
  background: #f3f4f6;
}

.discord-id-edit-link:hover {
  background: var(--border-subtle);
  color: var(--text-strong);
}

.discord-id-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 2px 0;
}

.discord-id-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-family: inherit;
}

.discord-id-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.discord-id-save {
  font-size: 12px;
  padding: 5px 14px;
  border: none;
  border-radius: 6px;
  background: var(--line-green);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.discord-id-save:hover {
  background: var(--line-green-dark);
}

.discord-id-cancel {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}

.discord-id-cancel:hover {
  color: var(--text-strong);
}

.discord-id-error {
  margin-top: 4px;
  font-size: 12px;
  color: #c0392b;
}

.user-stats {
  text-align: right;
  flex-shrink: 0;
  font-size: 12px;
}

.last-message {
  color: var(--text-muted);
  white-space: nowrap;
}

.message-count {
  margin-top: 4px;
  color: #ffffff;
  background: var(--line-green);
  display: inline-block;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}

.empty {
  text-align: center;
  color: #ffffff;
  padding: 32px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-card);
}

/* ===== User summary (detail page) ===== */
.user-summary {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  margin-bottom: 16px;
}

.summary-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: #e5e7eb;
  flex-shrink: 0;
  font-size: 30px;
}

.summary-info {
  flex: 1;
  min-width: 0;
}

.summary-name {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
}

.summary-list {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 13px;
}

.summary-list dt {
  color: var(--text-muted);
  font-weight: 500;
}

.summary-list dd {
  margin: 0;
  word-break: break-all;
}

.line-id-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.line-id-chip {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
}

.status-badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  background: #e5e7eb;
  color: var(--text-muted);
}

.status-badge.status-active {
  background: rgba(6, 199, 85, 0.15);
  color: var(--line-green-dark);
}

.note {
  white-space: pre-wrap;
}

/* ===== Chat controls ===== */
.chat-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: #ffffff;
  font-size: 13px;
}

.order-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.order-form label {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.order-form select {
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--card-bg);
  font-size: 13px;
  font-family: inherit;
}

.message-total {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* ===== Chat area ===== */
.chat-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 32px;
}

.chat-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.date-divider {
  text-align: center;
  margin: 4px 0 6px;
}

.date-divider span {
  display: inline-block;
  background: rgba(0, 0, 0, 0.35);
  color: #ffffff;
  font-size: 11px;
  padding: 2px 12px;
  border-radius: 999px;
}

.message-row {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}

.message-row.incoming {
  align-self: flex-start;
  align-items: flex-start;
}

.message-row.outgoing {
  align-self: flex-end;
  align-items: flex-end;
}

.bubble {
  padding: 8px 12px;
  border-radius: var(--radius-bubble);
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.message-row.incoming .bubble {
  background: var(--bubble-in-bg);
  color: var(--bubble-in-text);
  border-top-left-radius: 4px;
}

.message-row.outgoing .bubble {
  background: var(--bubble-out-bg);
  color: var(--bubble-out-text);
  border-top-right-radius: 4px;
}

.bubble-placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.timestamp {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 2px;
  padding: 0 4px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* ===== Header nav dropdown groups ===== */
.nav-group {
  position: relative;
}

.nav-group-toggle {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  user-select: none;
  white-space: nowrap;
}

.nav-group-toggle::-webkit-details-marker {
  display: none;
}

.nav-group-toggle:hover {
  background: rgba(6, 199, 85, 0.08);
  color: var(--text-strong);
}

.nav-group.is-active > .nav-group-toggle {
  background: rgba(6, 199, 85, 0.15);
  color: var(--line-green-dark);
}

.nav-group[open] > .nav-group-toggle {
  background: rgba(6, 199, 85, 0.12);
  color: var(--text-strong);
}

.nav-group-caret {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.nav-group[open] > .nav-group-toggle .nav-group-caret {
  transform: rotate(180deg);
}

.nav-group-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 160px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-item {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-strong);
  text-decoration: none;
  white-space: nowrap;
}

.nav-group-item:hover {
  background: #f3f4f6;
}

.nav-group-item.is-current {
  background: rgba(6, 199, 85, 0.15);
  color: var(--line-green-dark);
}

/* ===== Referrers page ===== */
.referrer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.referrer-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  align-items: flex-start;
}

.referrer-main {
  flex: 1;
  min-width: 0;
}

.referrer-name {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.referrer-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.referrer-url {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  background: #f3f4f6;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  word-break: break-all;
}

.referrer-redirect {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  word-break: break-all;
}

.referrer-redirect a {
  color: var(--text-muted);
}

.referrer-stats {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.referrer-stats strong {
  color: var(--text-strong);
}

.referrer-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

/* ===== Analytics page ===== */
.analytics-period-form {
  margin: 0;
}

.analytics-period-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.analytics-custom-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 12px;
}

.analytics-date-input {
  width: 160px;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.analytics-table th,
.analytics-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.analytics-table th {
  color: var(--text-muted);
  font-weight: 600;
  background: #f9fafb;
}

.analytics-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.analytics-total-row {
  background: rgba(6, 199, 85, 0.05);
}

.analytics-chart {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 140px;
  padding: 8px 0;
  overflow-x: auto;
}

.analytics-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 24px;
  gap: 4px;
}

.analytics-bar-wrap {
  width: 16px;
  height: 100px;
  display: flex;
  align-items: flex-end;
}

.analytics-bar {
  width: 100%;
  background: #93c5fd;
  border-radius: 3px 3px 0 0;
  position: relative;
  display: flex;
  align-items: flex-end;
}

.analytics-bar-conv {
  width: 100%;
  background: var(--line-green);
  border-radius: 3px 3px 0 0;
}

.analytics-bar-day {
  font-size: 9px;
  color: var(--text-muted);
  white-space: nowrap;
}

.analytics-legend {
  font-size: 11px;
  color: var(--text-muted);
  margin: 8px 0 0;
}

.analytics-legend-clicks {
  color: #93c5fd;
}

.analytics-legend-conv {
  color: var(--line-green);
  margin-left: 12px;
}

/* ===== Auto tag rules ===== */
.rule-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule-item {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  align-items: flex-start;
}

.rule-main {
  flex: 1;
  min-width: 0;
}

.rule-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rule-keyword {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  background: #f3f4f6;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.rule-arrow {
  color: var(--text-muted);
}

.rule-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.rule-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.rule-name {
  font-weight: 600;
  font-size: 14px;
}

.rule-mode {
  font-size: 11px;
  color: var(--text-muted);
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
}

.rule-reply-preview {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}

/* ===== Login screen ===== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--line-bg-top) 0%, var(--line-bg-bottom) 100%);
  background-attachment: fixed;
}

.login-card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
}

.invite-card {
  max-width: 420px;
}

.login-title {
  font-size: 22px;
  margin: 0 0 4px;
  text-align: center;
  color: var(--text-strong);
}

.login-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-submit {
  margin-top: 4px;
}

.invite-info {
  font-size: 14px;
  margin: 0 0 14px;
  padding: 10px 12px;
  background: rgba(6, 199, 85, 0.08);
  border-radius: 8px;
  color: var(--text-strong);
}

.invite-existing-staff {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border-subtle);
}

.invite-form {
  margin: 8px 0;
}

.invite-or {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin: 8px 0;
}

/* ===== Staff menu (header right) ===== */
.staff-menu {
  position: relative;
  margin-left: 8px;
}

.staff-menu-toggle {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f3f4f6;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  user-select: none;
}

.staff-menu-toggle::-webkit-details-marker {
  display: none;
}

.staff-menu-toggle:hover {
  background: #e5e7eb;
}

.staff-menu-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staff-menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 180px;
  padding: 6px;
}

.staff-menu-id {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
}

.staff-menu-form {
  margin: 0;
}

.staff-menu-item {
  width: 100%;
  background: transparent;
  border: none;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-strong);
}

.staff-menu-item:hover {
  background: #f3f4f6;
}

/* ===== Staff list (admin) ===== */
.staff-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.staff-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  align-items: flex-start;
}

.staff-main {
  flex: 1;
  min-width: 0;
}

.staff-name {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.staff-badge-admin {
  background: rgba(6, 199, 85, 0.15);
  color: var(--line-green-dark);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
}

.staff-badge-self {
  background: #fef3c7;
  color: #92400e;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
}

.staff-username {
  font-size: 12px;
  color: var(--text-muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.staff-perms {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.staff-perm-badge {
  background: #e5e7eb;
  color: #374151;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}

.staff-perm-editor {
  background: rgba(6, 199, 85, 0.15);
  color: var(--line-green-dark);
}

.staff-perm-viewer {
  background: rgba(59, 130, 246, 0.12);
  color: #1e40af;
}

.staff-perm-empty {
  font-size: 11px;
  color: var(--text-muted);
}

.staff-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.staff-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.staff-perm-form-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.staff-perm-form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.staff-perm-form-account {
  flex: 1;
  font-size: 13px;
}

.staff-perm-form-select {
  width: 120px;
}

.invitation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.invitation-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.invitation-main {
  flex: 1;
  min-width: 0;
}

.invitation-target {
  font-size: 13px;
  font-weight: 600;
}

.invitation-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.invitation-status {
  font-weight: 600;
}

.status-active {
  color: var(--line-green-dark);
}

.status-used {
  color: var(--text-muted);
}

.status-expired {
  color: #991b1b;
}

.invite-url-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.invite-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 8px;
}

/* ===== Account switcher ===== */
.account-switcher {
  position: relative;
  margin-left: auto;
}

.account-switcher-toggle {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f3f4f6;
  font-size: 13px;
  color: var(--text-strong);
  user-select: none;
  max-width: 200px;
}

.account-switcher-toggle::-webkit-details-marker {
  display: none;
}

.account-switcher-toggle:hover {
  background: #e5e7eb;
}

.account-switcher-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.account-switcher-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.account-switcher-caret {
  font-size: 10px;
  color: var(--text-muted);
}

.account-switcher-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 220px;
  max-width: 320px;
}

.account-switcher-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.account-switcher-form {
  margin: 0;
}

.account-switcher-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  color: var(--text-strong);
}

.account-switcher-item:hover {
  background: #f3f4f6;
}

.account-switcher-item.is-current {
  background: rgba(6, 199, 85, 0.1);
}

.account-switcher-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-switcher-check {
  color: var(--line-green-dark);
  font-weight: 700;
}

.account-switcher-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 8px 10px;
}

.account-switcher-manage {
  font-size: 12px;
  color: var(--line-green-dark);
  text-decoration: none;
  font-weight: 600;
}

.account-switcher-manage:hover {
  text-decoration: underline;
}

/* ===== Accounts admin list ===== */
.account-admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.account-admin-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

.account-admin-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.account-admin-main {
  flex: 1;
  min-width: 0;
}

.account-admin-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-strong);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.account-admin-current {
  background: rgba(6, 199, 85, 0.15);
  color: var(--line-green-dark);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}

.account-admin-channel {
  display: block;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
  word-break: break-all;
}

.account-admin-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.account-admin-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

/* ===== App header (nav) ===== */
.app-header {
  background: var(--card-bg);
  border-bottom: 3px solid var(--line-green);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-brand {
  font-weight: 700;
  color: var(--line-green-dark);
  text-decoration: none;
  font-size: 16px;
  flex-shrink: 0;
}

.app-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

/* ===== Send area (user detail) ===== */
.send-area {
  position: sticky;
  bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--border-subtle);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  padding: 12px;
  margin-top: 16px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

.send-error {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  word-break: break-all;
}

.send-disabled {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 12px;
}

.send-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.send-textarea {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 56px;
}

.send-textarea:focus {
  outline: none;
  border-color: var(--line-green);
  box-shadow: 0 0 0 2px rgba(6, 199, 85, 0.2);
}

.send-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.send-template {
  flex: 1;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  min-width: 0;
}

.send-button {
  background: var(--line-green);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}

.send-button:hover {
  background: var(--line-green-dark);
}

/* ===== Generic card / form (templates & settings) ===== */
.flash {
  background: rgba(6, 199, 85, 0.15);
  color: var(--line-green-dark);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.template-form-card,
.template-list-card,
.settings-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text-strong);
}

.template-form,
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.form-input,
.form-textarea {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-strong);
  width: 100%;
}

.form-textarea {
  resize: vertical;
  min-height: 96px;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--line-green);
  box-shadow: 0 0 0 2px rgba(6, 199, 85, 0.2);
}

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.primary-button {
  background: var(--line-green);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.primary-button:hover {
  background: var(--line-green-dark);
}

.primary-button:disabled,
.primary-button[disabled] {
  background: #d1d5db;
  color: #6b7280;
  cursor: not-allowed;
}

.primary-button:disabled:hover,
.primary-button[disabled]:hover {
  background: #d1d5db;
}

.danger-button {
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.danger-button:hover {
  background: #dc2626;
}

.secondary-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f3f4f6;
}

.secondary-link:hover {
  background: #e5e7eb;
}

/* <a> と <button> の両方で同じ見た目にする */
button.secondary-link {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: normal;
}

.inline-form {
  display: inline;
  margin: 0;
}

.empty-inline {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 12px;
}

.template-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-item {
  display: flex;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  align-items: flex-start;
}

.template-main {
  flex: 1;
  min-width: 0;
}

.template-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-strong);
}

.template-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-meta {
  font-size: 11px;
  color: #9aa3b2;
  margin-top: 4px;
}

.template-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
}

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--line-green);
  cursor: pointer;
}

.toggle-label {
  color: var(--text-strong);
}

.settings-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 4px 28px;
}

/* ===== Broadcast page ===== */
.broadcast-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.4);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.broadcast-tab {
  flex: 1;
  text-align: center;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.broadcast-tab:hover {
  background: rgba(255, 255, 255, 0.6);
}

.broadcast-tab.is-active {
  background: var(--card-bg);
  color: var(--line-green-dark);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.broadcast-form-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.broadcast-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.broadcast-target-fieldset {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 0;
}

.broadcast-target-fieldset legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
}

.target-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 4px 0;
  cursor: pointer;
}

.target-checkbox input[type='checkbox'] {
  accent-color: var(--line-green);
}

.target-tags-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-subtle);
}

/* schema_v19: オーディエンス除外 */
.broadcast-exclude-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-subtle);
}

.exclude-input-wrap {
  margin-top: 8px;
  padding-left: 22px;
}

.broadcast-exclude-label {
  font-size: 12px;
  color: var(--text-muted, #888);
  margin-right: 6px;
}

.preview-count-note {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted, #888);
  margin-left: 6px;
}

.target-mode-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.target-mode-label {
  color: var(--text-muted);
}

.mode-radio {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 13px;
}

.mode-radio input[type='radio'] {
  accent-color: var(--line-green);
}

.target-tag-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.broadcast-content-row {
  display: flex;
  gap: 8px;
}

.broadcast-template-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Preview page */
.preview-warning {
  background: #fef3c7;
  color: #92400e;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}

.preview-warning-dup {
  background: #fee2e2;
  color: #991b1b;
}

.preview-list {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 6px 12px;
  margin: 0 0 14px;
}

.preview-list dt {
  color: var(--text-muted);
  font-size: 13px;
}

.preview-list dd {
  margin: 0;
  font-size: 14px;
}

.preview-count {
  font-weight: 700;
  font-size: 18px;
  color: var(--line-green-dark);
}

.preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.preview-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}

.broadcast-content-full {
  background: #f9fafb;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-strong);
}

/* History */
.broadcast-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.broadcast-history-item {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
}

.broadcast-history-item > details {
  padding: 0;
}

.broadcast-history-summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 14px;
  user-select: none;
}

.broadcast-history-summary::-webkit-details-marker {
  display: none;
}

.broadcast-history-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.broadcast-date {
  font-weight: 600;
  color: var(--text-strong);
}

.broadcast-target {
  background: #f3f4f6;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
}

.broadcast-counts {
  margin-left: auto;
}

.count-bad {
  color: #ef4444;
  font-weight: 700;
}

.broadcast-preview-text {
  font-size: 13px;
  color: var(--text-strong);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.broadcast-history-body {
  padding: 4px 14px 14px;
  border-top: 1px solid var(--border-subtle);
}

.broadcast-detail-list {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 6px 10px;
  margin: 10px 0;
  font-size: 13px;
}

.broadcast-detail-list dt {
  color: var(--text-muted);
}

.broadcast-detail-list dd {
  margin: 0;
}

.broadcast-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.broadcast-failure-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}

.broadcast-failure-list li {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  flex-wrap: wrap;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border-subtle);
}

.failure-user {
  font-weight: 600;
  color: var(--text-strong);
}

.failure-line-id {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.failure-error {
  color: #991b1b;
  font-size: 11px;
  word-break: break-all;
  flex: 1 1 100%;
}

.broadcast-actions-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 10px;
}

.broadcast-actions-row button.secondary-link {
  background: #f3f4f6;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}

/* ===== Broadcast status badges & schedule ===== */
.broadcast-status-pending {
  background: rgba(59, 130, 246, 0.15);
  color: #1e40af;
}

.broadcast-status-sent {
  background: rgba(6, 199, 85, 0.15);
  color: var(--line-green-dark);
}

.broadcast-status-failed {
  background: rgba(239, 68, 68, 0.15);
  color: #991b1b;
}

.broadcast-status-cancelled {
  background: #e5e7eb;
  color: var(--text-muted);
}

.broadcast-scheduled {
  background: rgba(59, 130, 246, 0.1);
  color: #1e40af;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
}

.broadcast-schedule-fieldset {
  margin-top: 0;
}

.schedule-input-wrap {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-subtle);
}

.schedule-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

/* ===== Unread badges & states ===== */
.unread-badge {
  display: inline-block;
  background: #ef4444;
  color: #ffffff;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.2;
  min-width: 22px;
  text-align: center;
}

.nav-unread-badge {
  display: inline-block;
  background: #ef4444;
  color: #ffffff;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  line-height: 1.2;
  margin-left: 6px;
  vertical-align: middle;
}

.user-stats-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  margin-top: 4px;
}

.user-stats-badges .message-count {
  margin-top: 0;
}

/* 未読の受信メッセージ吹き出し */
.message-row.message-unread .bubble {
  background: #e0f2fe;
}

/* 並び順ピル + 未読フィルタ */
.user-sort-row {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  font-size: 13px;
}

.user-sort-toggle {
  display: inline-flex;
  gap: 4px;
  background: #f3f4f6;
  border-radius: 999px;
  padding: 2px;
}

.sort-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}

.sort-pill input[type='radio'] {
  display: none;
}

.sort-pill.is-active {
  background: var(--card-bg);
  color: var(--line-green-dark);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.unread-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
}

.unread-filter-toggle input[type='checkbox'] {
  accent-color: var(--line-green);
  cursor: pointer;
}

/* 「未読に戻す」ボタン */
.mark-unread-form {
  margin: 10px 0 0;
}

.mark-unread-button {
  background: transparent;
  border: 1px solid #d1d5db;
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.mark-unread-button:hover {
  background: #f3f4f6;
  color: var(--text-strong);
}

/* ===== Search highlight ===== */
mark {
  background: #fff3a0;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* ===== Search page ===== */
.search-section {
  margin-bottom: 16px;
}

.search-section .card-title {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  margin-bottom: 8px;
}

.search-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  text-decoration: none;
  color: inherit;
}

.search-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.search-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e5e7eb;
  object-fit: cover;
  flex-shrink: 0;
  font-size: 16px;
}

.search-main {
  flex: 1;
  min-width: 0;
}

.search-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.search-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
}

.search-discord {
  font-size: 12px;
  color: var(--text-muted);
}

.direction-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.direction-badge.direction-in {
  background: #e5e7eb;
  color: #374151;
}

.direction-badge.direction-out {
  background: rgba(6, 199, 85, 0.18);
  color: var(--line-green-dark);
}

.search-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-strong);
  word-break: break-word;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.search-user-fields {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 2px 8px;
  margin: 4px 0 0;
  font-size: 12px;
}

.search-user-fields dt {
  color: var(--text-muted);
}

.search-user-fields dd {
  margin: 0;
  color: var(--text-strong);
  word-break: break-word;
}

/* ===== Detail page: in-user search bar ===== */
.detail-search-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-search-input {
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--card-bg);
  min-width: 0;
  width: 140px;
}

.detail-search-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(6, 199, 85, 0.35);
}

.detail-search-button {
  background: var(--line-green);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.detail-search-button:hover {
  background: var(--line-green-dark);
}

.chat-controls {
  flex-wrap: wrap;
  gap: 8px;
}

/* ===== Note section ===== */
.note-section {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 12px 16px;
  margin-bottom: 12px;
}

.note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.note-header .card-title {
  margin: 0;
}

.note-edit-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 3px 10px;
  border-radius: 6px;
  background: #f3f4f6;
}

.note-edit-link:hover {
  background: #e5e7eb;
  color: var(--text-strong);
}

.note-display {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  color: var(--text-strong);
  line-height: 1.6;
}

.note-empty {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.note-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note-textarea {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-strong);
  resize: vertical;
  min-height: 120px;
}

.note-textarea:focus {
  outline: none;
  border-color: var(--line-green);
  box-shadow: 0 0 0 2px rgba(6, 199, 85, 0.2);
}

/* ===== 成約情報の記録 ===== */
.contract-section {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 12px 16px;
  margin-bottom: 12px;
}

.contract-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contract-broker-radios {
  display: flex;
  gap: 16px;
  align-items: center;
}

.contract-broker-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-strong);
  cursor: pointer;
}

.contract-broker-radio input {
  cursor: pointer;
}

/* ===== Tag badge ===== */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e5e7eb;
  color: #374151;
  border-radius: 999px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  max-width: 100%;
}

.tag-badge-sm {
  font-size: 11px;
  padding: 3px 8px;
}

.tag-badge-md {
  font-size: 13px;
  padding: 5px 10px;
}

.tag-badge-removable {
  padding-right: 2px;
}

.tag-badge-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-badge-remove-form {
  display: inline;
  margin: 0;
}

.tag-badge-remove {
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 999px;
  opacity: 0.6;
  font-family: inherit;
}

.tag-badge-removable:hover .tag-badge-remove {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

.tag-badge-remove:hover {
  color: #991b1b;
}

/* ===== User detail: tag section ===== */
.user-tags-section {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 12px 16px;
  margin-bottom: 12px;
}

.user-tags-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.user-tags-empty {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Tag picker (user detail) ===== */
.tag-picker {
  position: relative;
}

.tag-picker-toggle {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--line-green-dark);
  background: rgba(6, 199, 85, 0.08);
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 500;
  user-select: none;
}

.tag-picker-toggle::-webkit-details-marker {
  display: none;
}

.tag-picker-toggle:hover {
  background: rgba(6, 199, 85, 0.15);
}

.tag-picker-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 8px;
  min-width: 220px;
  max-width: 320px;
}

.tag-picker-empty {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 8px 8px;
}

.tag-picker-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}

.tag-picker-form {
  display: inline;
  margin: 0;
}

.tag-picker-item {
  background: #f3f4f6;
  border: 1px solid var(--border-subtle);
  color: #374151;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.tag-picker-item:hover {
  background: var(--line-green);
  color: #fff;
  border-color: var(--line-green);
}

.tag-picker-new {
  display: flex;
  gap: 4px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}

.tag-picker-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
}

.tag-picker-input:focus {
  outline: none;
  border-color: var(--line-green);
}

.tag-picker-create {
  background: var(--line-green);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.tag-picker-create:hover {
  background: var(--line-green-dark);
}

/* ===== Tag filter (user list) ===== */
.tag-filter {
  flex-basis: 100%;
  margin-top: 4px;
}

.tag-filter-summary {
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 0;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tag-filter-summary::-webkit-details-marker {
  display: none;
}

.tag-filter-summary::before {
  content: '▸ ';
  color: var(--text-muted);
}

.tag-filter[open] .tag-filter-summary::before {
  content: '▾ ';
}

.tag-filter-count {
  background: var(--line-green);
  color: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}

.tag-filter-panel {
  padding: 8px 0 4px;
}

.tag-filter-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.tag-filter-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-filter-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
}

.tag-filter-item input[type='checkbox'] {
  accent-color: var(--line-green);
  cursor: pointer;
}

.tag-filter-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ===== User list inline tags ===== */
.user-tags-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

/* ===== Unified search: hit location display ===== */
.user-hits {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 6px;
}

.user-hit-tag {
  align-self: flex-start;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
  background: #f1f5f9;
  border-radius: 4px;
  padding: 1px 6px;
}

.user-hit-snippet {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-strong);
  /* 抜粋は折り返して全文を見せる（メッセージ・メモは複数行になり得る） */
  word-break: break-word;
}

.user-hit-icon {
  color: var(--text-muted);
  white-space: nowrap;
}

/* ===== Tag admin list ===== */
.tag-admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tag-admin-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

.tag-admin-meta {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.tag-admin-count {
  font-size: 12px;
  color: var(--text-strong);
  font-weight: 500;
}

.tag-admin-date {
  font-size: 11px;
  color: var(--text-muted);
}

.tag-admin-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .container {
    padding: 12px;
  }

  .user-summary {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .summary-list {
    grid-template-columns: 64px 1fr;
    text-align: left;
  }

  .user-stats {
    font-size: 11px;
  }

  .last-message {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .message-row {
    max-width: 85%;
  }

  .app-header-inner {
    padding: 8px 12px;
    gap: 8px;
  }

  .nav-group-toggle {
    padding: 6px 8px;
    font-size: 13px;
  }

  .nav-group-panel {
    min-width: 140px;
  }

  .template-item {
    flex-direction: column;
  }

  .template-actions {
    align-self: flex-end;
  }
}

/* ===== シナリオ（ステップ配信） ===== */

.page-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
}

.scenario-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scenario-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

.scenario-main {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scenario-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.scenario-name {
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
  text-decoration: none;
}

.scenario-name:hover {
  text-decoration: underline;
}

.scenario-trigger-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
}

.scenario-desc {
  color: #4b5563;
  font-size: 13px;
  white-space: pre-wrap;
}

.scenario-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: #6b7280;
}

.scenario-stats-meta {
  margin-left: auto;
}

.scenario-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* シナリオ編集ページ */

.scenario-form .template-form-card + .template-form-card {
  margin-top: 16px;
}

.scenario-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.scenario-step-item {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px 12px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scenario-step-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scenario-step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #4f46e5;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
}

.scenario-step-label {
  font-weight: 600;
  color: #1f2937;
}

.scenario-step-controls {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.scenario-step-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scenario-delay-row {
  display: flex;
  gap: 6px;
}

.scenario-delay-value {
  flex: 0 1 100px;
}

.scenario-delay-unit {
  flex: 0 1 120px;
}

.trigger-detail-block {
  padding: 8px 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  margin: 8px 0;
}

/* 進行管理ページ */

.scenario-progress-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 8px 0 12px;
  flex-wrap: wrap;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bulk-actions {
  display: flex;
  gap: 6px;
}

.scenario-progress-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scenario-progress-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  flex-wrap: wrap;
}

.scenario-progress-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.scenario-progress-user:hover .progress-user-name {
  text-decoration: underline;
}

.progress-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f3f4f6;
  font-size: 13px;
}

.progress-user-name {
  font-weight: 500;
  color: #1f2937;
}

.scenario-progress-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: #6b7280;
  align-items: center;
}

.progress-stop-reason {
  color: #b45309;
}

.scenario-progress-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

/* ユーザー詳細ページのシナリオ */

.scenario-user-section {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
}

.user-scenario-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-scenario-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  flex-wrap: wrap;
}

.user-scenario-main {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-scenario-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.user-scenario-name {
  font-weight: 600;
  color: #1f2937;
  text-decoration: none;
}

.user-scenario-name:hover {
  text-decoration: underline;
}

.user-scenario-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: #6b7280;
}

.user-scenario-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.user-scenario-start-form {
  margin-top: 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.user-scenario-start-form .form-label {
  flex: 1 1 200px;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  background: #fff;
  color: #1f2937;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.secondary-button:hover {
  background: #f3f4f6;
}

/* ===== 送信タブ（テキスト/リッチメッセージ切替） ===== */

.send-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.send-tab {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #4b5563;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 13px;
}

.send-tab.is-active {
  background: #fff;
  color: #06c755;
  font-weight: 600;
  border-bottom: 2px solid #06c755;
}

.send-controls-bottom {
  margin-top: 8px;
  justify-content: flex-end;
}

/* ===== リッチメッセージ一覧 ===== */

.rich-message-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rich-message-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: #fff;
  flex-wrap: wrap;
}

.rich-message-main {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rich-message-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rich-message-name {
  font-weight: 600;
  color: #1f2937;
}

.rich-timer-badge {
  font-size: 11px;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.rich-message-desc {
  font-size: 13px;
  color: #4b5563;
}

.rich-message-meta {
  font-size: 12px;
  color: #6b7280;
}

.rich-message-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ===== リッチメッセージプレビュー（LINE風） ===== */

.rich-preview-wrap {
  padding: 12px;
  background: linear-gradient(180deg, #8cabd8 0%, #b6c8e0 100%);
  border-radius: 12px;
  margin: 8px 0;
}

.rich-preview-alt {
  font-size: 12px;
  color: #fff;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 10px;
}

.rich-preview-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  width: 240px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
}

.rich-preview-image-wrap {
  width: 100%;
  aspect-ratio: 1.51 / 1;
  background: #e5e7eb;
  overflow: hidden;
}

.rich-preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rich-preview-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rich-preview-title {
  font-weight: 600;
  font-size: 14px;
  color: #1f2937;
}

.rich-preview-text {
  font-size: 13px;
  color: #374151;
  white-space: pre-wrap;
  word-break: break-word;
}

.rich-preview-actions {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rich-preview-action {
  padding: 8px;
  border-top: 1px solid #f1f5f9;
  text-align: center;
  font-size: 13px;
  color: #06c755;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.rich-preview-action-label {
  font-weight: 500;
}

.rich-preview-action-meta {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.rich-preview-action-postback {
  color: #b45309;
}

.rich-preview-action-expiry {
  font-size: 10px;
  color: #b45309;
  white-space: nowrap;
}

/* ===== リッチメッセージ編集: postback 期限制御 ===== */

.rm-postback-pane {
  border-left: 3px solid #fde68a;
  padding-left: 10px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rm-duration-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.rm-duration-row .form-input[type="number"] {
  max-width: 120px;
}

.rm-duration-row .form-input:not([type="number"]) {
  max-width: 100px;
}

.rich-preview-empty {
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
  padding: 4px;
}

.rich-preview-carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.rich-preview-carousel .rich-preview-card {
  flex: 0 0 auto;
}

.rich-preview-error {
  background: #fee2e2;
  color: #991b1b;
  padding: 8px 10px;
  border-radius: 6px;
}

/* ===== リッチメッセージ プレビューモーダル ===== */

.rich-preview-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: flex-start;
  padding: 30px 12px;
  overflow-y: auto;
}

.rich-preview-modal.is-open {
  display: flex;
}

.rich-preview-modal-inner {
  background: #fff;
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rich-preview-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rich-preview-modal-title {
  font-weight: 600;
}

.rich-preview-modal-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  padding: 4px 8px;
  color: #6b7280;
}

/* ===== リッチメッセージ編集フォーム ===== */

.rm-type-fieldset,
.rm-image-section,
.reply-mode-fieldset,
.bc-content-fieldset {
  margin: 8px 0;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.rm-type-fieldset legend,
.rm-image-section legend,
.reply-mode-fieldset legend,
.bc-content-fieldset legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.rm-columns {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rm-column {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  background: #f9fafb;
}

.rm-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.rm-image-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.rm-image-tabs .secondary-button.is-active {
  background: #06c755;
  color: #fff;
  border-color: #06c755;
}

.rm-actions-wrap {
  margin-top: 8px;
}

.rm-actions-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.rm-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rm-action {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.rm-action-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.rm-action-index {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  background: #06c755;
  color: #fff;
  border-radius: 50%;
  padding: 2px 6px;
  font-size: 12px;
}

/* ===== 画像一覧ページ ===== */

.image-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.image-item {
  display: flex;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: #fff;
  align-items: flex-start;
  flex-wrap: wrap;
}

.image-thumb-link {
  display: block;
  width: 80px;
  height: 80px;
  flex: 0 0 80px;
  background: #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}

.image-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-info {
  flex: 1 1 240px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.image-name {
  font-weight: 600;
  color: #1f2937;
  word-break: break-all;
}

.image-meta {
  font-size: 12px;
  color: #6b7280;
}

.image-url-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.image-url {
  background: #f3f4f6;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 12px;
  word-break: break-all;
  flex: 1 1 200px;
  min-width: 0;
}

.image-actions {
  display: flex;
  gap: 6px;
}

.scenario-step-controls .secondary-button,
.rm-actions-head .secondary-button {
  padding: 4px 8px;
  font-size: 12px;
}

/* ===== Account groups (schema_v15) ===== */
.account-group-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.account-group-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.account-group-main {
  flex: 1;
  min-width: 0;
}

.account-group-name {
  font-weight: 600;
  font-size: 15px;
  color: #111827;
}

.account-group-desc {
  margin-top: 4px;
  font-size: 13px;
  color: #4b5563;
  white-space: pre-wrap;
}

.account-group-meta {
  margin-top: 6px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #6b7280;
}

.account-group-count {
  font-weight: 500;
  color: #374151;
}

.account-group-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.account-group-actions .danger-button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* アカウント一覧でのグループ表示 */
.account-admin-meta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.account-admin-group {
  color: #374151;
  font-weight: 500;
}

/* 編集モーダルのチェックボックスグリッド */
.form-fieldset {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 6px 0;
}

.form-fieldset legend {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  padding: 0 6px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.checkbox-label .hint-text {
  font-size: 11px;
  color: #9ca3af;
  margin-left: 4px;
}

.page-description {
  margin: -4px 0 12px;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.55;
}

/* ===== A2: テンプレショートカット ===== */

.shortcut-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.shortcut-prefix {
  color: #6b7280;
  font-weight: 600;
  font-size: 14px;
  padding-left: 4px;
}

.shortcut-input {
  flex: 1;
}

.shortcut-badge {
  display: inline-block;
  background: #eef2ff;
  color: #4338ca;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* 送信フォーム textarea とポップアップの相対配置用ラッパー */
.send-textarea-wrap {
  position: relative;
}

.shortcut-popup {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 4px;
  width: 100%;
  max-width: 360px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  z-index: 50;
}

.shortcut-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
}

.shortcut-item:last-child {
  border-bottom: none;
}

.shortcut-item.is-active,
.shortcut-item:hover {
  background: #eef2ff;
}

.shortcut-item-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: #4338ca;
}

.shortcut-item-preview {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== C2: トークプレビュー（ユーザー一覧ホバー） ===== */

.user-preview-popup {
  position: absolute;
  width: 300px;
  max-height: 380px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  padding: 10px;
  pointer-events: auto;
  font-size: 12px;
}

.preview-header {
  font-size: 11px;
  color: #6b7280;
  border-bottom: 1px solid #f3f4f6;
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.preview-loading,
.preview-empty {
  color: #9ca3af;
  text-align: center;
  padding: 12px 0;
}

.preview-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
  max-width: 100%;
}

.preview-in {
  align-items: flex-start;
}

.preview-out {
  align-items: flex-end;
}

.preview-bubble {
  max-width: 85%;
  padding: 6px 10px;
  border-radius: 12px;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.4;
}

.preview-in .preview-bubble {
  background: #f3f4f6;
  color: #111827;
  border-bottom-left-radius: 2px;
}

.preview-out .preview-bubble {
  background: #06c755;
  color: #fff;
  border-bottom-right-radius: 2px;
}

.preview-time {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 2px;
}

/* ===== 新UI(/chat): ユーザー一覧ホバープレビュー =====
   旧UI .user-preview-popup は position:absolute（ページスクロール前提）。
   新UIは全画面固定レイアウトのため position:fixed 版を別途用意する。
   内側の .preview-* クラス（header/row/bubble/in/out/time/loading/empty）は
   旧UIと共通流用するため、ここでは外枠コンテナのみ定義する。 */
.chatui-user-preview-popup {
  position: fixed;
  width: 300px;
  max-height: 380px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 2000;
  padding: 10px;
  pointer-events: auto;
  font-size: 12px;
}

/* ===== schema_v18: シンプル画像メッセージ用フォーム部品 ===== */
.image-field {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  background: #fafafa;
  margin-top: 4px;
}

.image-field-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.image-field-tab {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  cursor: pointer;
}

.image-field-tab.is-active {
  background: #06c755;
  border-color: #06c755;
  color: #fff;
}

.image-field-pane {
  margin-bottom: 8px;
}

.image-field-file {
  display: inline-block;
  margin-right: 6px;
  font-size: 13px;
}

.image-field-status {
  font-size: 12px;
  color: #6b7280;
  margin-left: 6px;
}

.image-field-preview {
  margin: 8px 0;
}

.image-field-preview img {
  max-width: 160px;
  max-height: 160px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  display: block;
  margin-bottom: 4px;
}

.image-field-clear {
  font-size: 12px;
  padding: 2px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #b91c1c;
  cursor: pointer;
}

.image-field-order {
  border: none;
  padding: 6px 0 0;
  margin: 0;
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.image-field-order legend {
  font-size: 12px;
  color: #6b7280;
  padding: 0;
}

.image-field-order-opt {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* 個別送信の画像添付ブロック */
.send-image-attach {
  margin-top: 8px;
}

.send-image-label {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

/* トーク内の画像バブル */
.bubble-image {
  max-width: 220px;
  max-height: 220px;
  border-radius: 8px;
  display: block;
}

.bubble-image-link {
  display: inline-block;
}

/* 配信プレビューの画像 */
.broadcast-preview-image img {
  max-width: 240px;
  max-height: 240px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  display: block;
  margin-top: 6px;
}

/* ===== リッチメニュー ===== */

/* プレビュー: 画像の上に各タップ領域の枠と番号を重ねる */
.rm-preview-frame {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.rm-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rm-preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 14px;
}

.rm-preview-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.rm-area-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid rgba(37, 99, 235, 0.9);
  background: rgba(37, 99, 235, 0.12);
}

.rm-area-box-num {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 10px;
  background: #2563eb;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}

/* タップ領域のアクション設定 */
.rm-areas {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rm-area-row {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  background: #fafafa;
}

.rm-area-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 600;
}

.rm-area-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
}

/* 各マス個別画像 + アクション設定（自動合成方式） */
.rm-cells {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rm-cell {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  background: #fafafa;
}

.rm-cell-body {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.rm-cell-thumb {
  position: relative;
  flex: 0 0 140px;
  width: 140px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}

.rm-cell-img {
  width: 100%;
  height: 100%;
  object-fit: fill; /* マスサイズへ強制リサイズ（合成と同じ見え方） */
  display: block;
}

.rm-cell-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 12px;
  text-align: center;
  padding: 4px;
}

.rm-cell-controls {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rm-cell-clear {
  align-self: flex-start;
}

/* 全体プレビューに各マス画像を敷く（合成イメージ） */
.rm-preview-overlay-fill .rm-area-box {
  background: transparent;
  border-color: rgba(37, 99, 235, 0.5);
}

.rm-area-box-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

/* ===== Flex Message（テキスト装飾メッセージ） ===== */

/* 編集ページ: 左フォーム + 右ライブプレビューの2カラム */
.flex-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .flex-editor-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}
.flex-preview-panel {
  position: sticky;
  top: 16px;
}

/* テキストブロック編集 */
.flex-blocks {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.flex-block {
  border: 1px solid var(--border, #d8dee4);
  border-radius: 8px;
  padding: 12px;
  background: #fafbfc;
}
.flex-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 600;
}
.flex-block-index {
  display: inline-block;
  min-width: 20px;
  text-align: center;
}
.flex-block-controls {
  display: flex;
  gap: 6px;
}
.flex-block-type-label {
  font-weight: 600;
}
.flex-block-controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
/* 種類別の左ボーダーで一目で分かるように */
.flex-block[data-block-type='image'] {
  border-left: 3px solid #0066cc;
}
.flex-block[data-block-type='video'] {
  border-left: 3px solid #b5179e;
}
/* ブロック追加ボタン群 */
.flex-add-actions {
  flex-wrap: wrap;
  gap: 8px;
}
/* 動画ブロックの編集UI */
.flex-video-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.flex-video-hint {
  font-size: 12px;
  color: #6b7280;
  margin: 0;
}
.flex-video-thumb-wrap {
  width: 100%;
}
.flex-video-thumb {
  display: block;
  max-width: 240px;
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border, #d8dee4);
}
.flex-block-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.flex-block-col {
  flex: 1 1 100px;
  min-width: 90px;
}

/* 色プリセット + カスタムカラー */
.flex-color-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.flex-color-preset {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  padding: 0;
}
.flex-color-preset:hover {
  transform: scale(1.1);
}
.flex-color-input {
  width: 48px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border, #d8dee4);
  border-radius: 6px;
  cursor: pointer;
  background: none;
}
.flex-bg-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

/* LINE 風プレビュー（一覧モーダル / 編集ライブ / 配信プレビュー共通） */
.flex-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #7494c0;
  padding: 16px;
  border-radius: 8px;
}
.flex-preview-bubble {
  width: 100%;
  max-width: 300px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  background: #fff;
}
.flex-preview-hero img {
  display: block;
  width: 100%;
  height: auto;
}
/* 動画ブロックのプレビュー（プレビュー画像 + 再生アイコン） */
.flex-preview-video {
  position: relative;
  background: #000;
  min-height: 80px;
}
.flex-preview-video img {
  display: block;
  width: 100%;
  height: auto;
}
.flex-preview-video-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  color: #cfd6e0;
  font-size: 13px;
  background: #2b2f36;
}
.flex-preview-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  padding-left: 3px;
  pointer-events: none;
}
/* 画像ブロックのプレビュー（body 内） */
.flex-preview-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 2px;
}
.flex-preview-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.flex-preview-text {
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}
.flex-preview-empty {
  color: #999;
  font-size: 13px;
  margin: 0;
}
.flex-preview-footer {
  padding: 10px 14px 14px;
}
.flex-preview-button {
  display: block;
  text-align: center;
  background: #06c755;
  color: #fff;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
}
/* 通知・トーク一覧での表示（alt_text）プレビュー */
.flex-notify {
  width: 100%;
  max-width: 300px;
}
.flex-notify-label {
  font-size: 12px;
  font-weight: 600;
  color: #e8eefb;
  margin-bottom: 6px;
}
.flex-notify-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f5f6f8;
  border-radius: 10px;
  padding: 10px 12px;
}
.flex-notify-avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: #06c755;
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-notify-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.flex-notify-avatar-fallback {
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
}
.flex-notify-content {
  min-width: 0;
  flex: 1 1 auto;
}
.flex-notify-name {
  font-weight: 700;
  font-size: 14px;
  color: #1f2328;
  margin-bottom: 2px;
}
.flex-notify-text {
  font-size: 13px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== 自動応答: 連続返信ブロック（schema_v29） ===== */
.ar-blocks-section {
  margin-top: 12px;
}

#ar-blocks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.ar-block-card {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ar-block-card.is-dragging {
  opacity: 0.5;
  border-style: dashed;
  border-color: #2563eb;
}

.ar-block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #eef0f3;
  background: #f9fafb;
  border-radius: 8px 8px 0 0;
}

.ar-block-handle {
  cursor: grab;
  color: #9ca3af;
  font-size: 16px;
  line-height: 1;
  user-select: none;
  padding: 0 2px;
}

.ar-block-handle:active {
  cursor: grabbing;
}

.ar-block-label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}

.ar-block-del {
  margin-left: auto;
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.ar-block-del:hover {
  background: #fee2e2;
  color: #dc2626;
}

.ar-block-body {
  padding: 10px;
}

.ar-add-block-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.ar-add-block-label {
  font-size: 12px;
  color: #6b7280;
}

.ar-convert-btn {
  margin-top: 10px;
}

/* =====================================================================
   新UI: LINE公式マネージャー風 3カラム (/chat) — フェーズ1
   すべて chatui- プレフィックス。既存クラスとの衝突を避けるため
   .chat-area / .chat-group など既存名は使わない（吹き出しの .message-row /
   .bubble / .date-divider / .timestamp / .tag-badge は見た目共通で流用）。
   ===================================================================== */
.chatui-body {
  height: 100vh;
  overflow: hidden;
}

.chatui-root {
  --chatui-left-w: 220px;
  --chatui-mid-w: 340px;
  --chatui-right-w: 320px;
  display: flex;
  height: 100vh;
  width: 100vw;
  background: #f3f4f6;
}

.chatui-col {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chatui-col-nav {
  width: var(--chatui-left-w);
  flex: none;
  background: #1f2937;
  color: #e5e7eb;
}

.chatui-col-list {
  width: var(--chatui-mid-w);
  flex: none;
  background: #ffffff;
  border-right: 1px solid var(--border-subtle);
}

.chatui-col-chat {
  flex: 1 1 0;
  min-width: 0;
  background: linear-gradient(180deg, var(--line-bg-top) 0%, var(--line-bg-bottom) 100%);
}

.chatui-resizer {
  flex: none;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
}

.chatui-resizer:hover {
  background: rgba(6, 199, 85, 0.35);
}

/* ===== 右情報パネル（フェーズ3） ===== */
.chatui-col-right {
  width: var(--chatui-right-w);
  flex: none;
  background: #ffffff;
  border-left: 1px solid var(--border-subtle);
}

/* 折りたたみ時: 右パネルとその左のリサイザを隠す */
.chatui-root.right-collapsed .chatui-col-right,
.chatui-root.right-collapsed .chatui-resizer[data-resize='right'] {
  display: none;
}

/* 再オープン用の細いバー（既定は非表示、折りたたみ時のみ表示） */
.chatui-right-reopen {
  display: none;
  flex: none;
  width: 18px;
  border: none;
  border-left: 1px solid var(--border-subtle);
  background: #f3f4f6;
  color: #6b7280;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.chatui-right-reopen:hover {
  background: #e5e7eb;
  color: #111827;
}
.chatui-root.right-collapsed .chatui-right-reopen {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12px;
}

.chatui-right {
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chatui-right-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  background: #fafafa;
}
.chatui-right-title {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}
.chatui-right-collapse {
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.chatui-right-collapse:hover {
  background: #e5e7eb;
  color: #111827;
}

.chatui-right-body {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 12px;
}

.chatui-right-empty {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 13px;
}

.chatui-right-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.chatui-right-section:last-child {
  border-bottom: none;
}
.chatui-right-section-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: none;
}

/* ===== 過去アカウントと統合（master_id 統合）===== */
.merge-help {
  margin: 0 0 8px;
  font-size: 11px;
  line-height: 1.5;
  color: #6b7280;
}
.merge-search-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.merge-search-row .discord-id-input {
  flex: 1 1 auto;
  min-width: 0;
}
.merge-results {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.merge-empty {
  margin: 0;
  font-size: 12px;
  color: #9ca3af;
}
.merge-candidate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}
.merge-candidate-info {
  min-width: 0;
}
.merge-candidate-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.merge-candidate-meta {
  font-size: 11px;
  color: #6b7280;
}
.merge-pick-btn {
  flex: 0 0 auto;
  font-size: 12px;
  padding: 4px 8px;
}
.merge-candidate-merged {
  flex: 0 0 auto;
  font-size: 11px;
  color: #9ca3af;
}
.merge-warning {
  color: #b91c1c;
  font-weight: 600;
}
.merge-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.merge-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.merge-modal-box {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 32px));
  background: #ffffff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}
.merge-modal-title {
  margin: 0 0 8px;
  font-size: 15px;
}
.merge-modal-desc {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.6;
}
.merge-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== 左ナビ ===== */
.chatui-nav {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chatui-nav-brand {
  display: block;
  padding: 16px;
  font-weight: 700;
  font-size: 16px;
  color: #ffffff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chatui-nav-scroll {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 8px 0;
}

.chatui-nav-group {
  margin-bottom: 8px;
}

.chatui-nav-group-label {
  padding: 6px 16px 2px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #9ca3af;
  text-transform: uppercase;
}

.chatui-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px;
  color: #e5e7eb;
  text-decoration: none;
  font-size: 14px;
}

.chatui-nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chatui-nav-badge {
  background: var(--line-green);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}

.chatui-nav-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 16px;
}

.chatui-nav-staff {
  font-size: 13px;
  color: #d1d5db;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chatui-nav-logout-form {
  margin: 0;
}

.chatui-nav-logout {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e5e7eb;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.chatui-nav-logout:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ===== 中央 ユーザー一覧 ===== */
.chatui-userlist {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chatui-userlist-head {
  flex: none;
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.chatui-search-form {
  margin: 0;
}

.chatui-search-row {
  display: flex;
  gap: 6px;
}

.chatui-search-input {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 14px;
}

.chatui-search-input:focus {
  outline: none;
  border-color: var(--line-green);
}

.chatui-search-button {
  flex: none;
  background: var(--line-green);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 13px;
  cursor: pointer;
}

.chatui-search-button:hover {
  background: var(--line-green-dark);
}

.chatui-search-clear {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.chatui-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.chatui-sort-toggle {
  display: inline-flex;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.chatui-sort-pill {
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--text-muted);
}

.chatui-sort-pill.is-active {
  background: var(--line-green);
  color: #ffffff;
}

.chatui-sort-pill input {
  display: none;
}

.chatui-unread-toggle {
  font-size: 12px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.chatui-tag-filter {
  margin-top: 8px;
}

.chatui-tag-filter-summary {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatui-tag-filter-count {
  background: var(--line-green);
  color: #ffffff;
  border-radius: 999px;
  font-size: 11px;
  padding: 0 6px;
}

.chatui-tag-filter-panel {
  padding-top: 8px;
}

.chatui-tag-filter-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chatui-tag-filter-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.chatui-tag-filter-apply {
  margin-top: 8px;
  background: var(--line-green);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}

.chatui-userlist-scroll {
  flex: 1 1 0;
  overflow-y: auto;
}

.chatui-userlist-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.chatui-userlist-count {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
}

.chatui-user-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chatui-user-row {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid #f1f2f4;
}

.chatui-user-row:hover {
  background: #f8f9fa;
}

.chatui-user-row.is-selected {
  background: #e8f8ee;
}

.chatui-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: #e5e7eb;
  font-size: 18px;
}

.chatui-user-main {
  flex: 1 1 0;
  min-width: 0;
}

.chatui-user-line1 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.chatui-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chatui-user-time {
  flex: none;
  font-size: 11px;
  color: var(--text-muted);
}

.chatui-user-line2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.chatui-user-excerpt {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 0;
  min-width: 0;
}

.chatui-user-unread {
  flex: none;
  background: var(--line-green);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}

.chatui-user-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.chatui-user-tags-more {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== 右 チャット ===== */
.chatui-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chatui-chat-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-subtle);
}

.chatui-chat-userinfo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chatui-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: #e5e7eb;
  font-size: 13px;
}

.chatui-chat-username {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chatui-chat-detaillink {
  flex: none;
  font-size: 12px;
  color: var(--line-green-dark);
  text-decoration: none;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px 8px;
}

.chatui-chat-detaillink:hover {
  background: #f3f4f6;
}

.chatui-chat-empty {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
}

.chatui-messages {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chatui-messages-empty {
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
}

.chatui-send {
  flex: none;
  padding: 10px 16px;
  background: #ffffff;
  border-top: 1px solid var(--border-subtle);
}

.chatui-send-error {
  color: #dc2626;
  font-size: 13px;
  margin-bottom: 8px;
}

.chatui-send-disabled {
  color: var(--text-muted);
  font-size: 13px;
  padding: 6px 0;
}

.chatui-send-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

/* テキストエリア＋送信ボタンの行（フェーズ2でツールバーを下に追加したため行で分離） */
.chatui-send-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chatui-send-textarea {
  flex: 1 1 0;
  min-width: 0;
  resize: vertical;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}

.chatui-send-textarea:focus {
  outline: none;
  border-color: var(--line-green);
}

.chatui-send-button {
  flex: none;
  background: var(--line-green);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.chatui-send-button:hover {
  background: var(--line-green-dark);
}

/* ===== 送信欄下の4ツール（画像 / テンプレ / リッチ / Flex）・フェーズ2 ===== */
.chatui-send-tools {
  display: flex;
  gap: 4px;
  align-items: center;
}

.chatui-send-tool {
  position: relative;
}

/* summary（アイコン）。details のデフォルト三角マーカーは隠す。 */
.chatui-send-tool-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  color: var(--text-muted);
}

.chatui-send-tool-toggle::-webkit-details-marker {
  display: none;
}

.chatui-send-tool-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
}

.chatui-send-tool[open] > .chatui-send-tool-toggle {
  background: rgba(0, 0, 0, 0.08);
}

.chatui-send-tool-icon {
  font-size: 18px;
  line-height: 1;
}

/* ドロップダウンパネル。送信欄の上方向に開く（下は画面端のため）。 */
.chatui-send-pop {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 30;
  width: 320px;
  max-width: 80vw;
  max-height: 50vh;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 10px;
}

.chatui-send-pop-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.chatui-send-pop-empty {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.chatui-send-pop-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chatui-send-pop-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-family: inherit;
}

.chatui-send-pop-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.chatui-send-pop-item-title {
  font-size: 14px;
  color: var(--text-primary, #111827);
  font-weight: 500;
}

.chatui-send-pop-item-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== チャット内アカウント切替（/chat 専用・return_to 付き） ===== */
.chatui-acct {
  position: relative;
  flex: none;
}

.chatui-acct-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
}

.chatui-acct-toggle::-webkit-details-marker {
  display: none;
}

.chatui-acct-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 親 .chatui-col が overflow:hidden のため position:absolute だとパネルが
   チャット列の幅でクリップされ見切れる。position:fixed で切り抜けコンテキストを
   抜け、画面右上に固定表示する（トグルは常に画面右上にあるので top/right 固定で整合）。 */
.chatui-acct-panel {
  position: fixed;
  right: 16px;
  top: 52px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 100;
  min-width: 220px;
  max-height: 60vh;
  overflow-y: auto;
}

.chatui-acct-list {
  list-style: none;
  margin: 0;
  padding: 4px;
}

.chatui-acct-form {
  margin: 0;
}

.chatui-acct-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.chatui-acct-item:hover {
  background: #f3f4f6;
}

.chatui-acct-item.is-current {
  font-weight: 600;
}

.chatui-acct-item-name {
  flex: 1 1 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chatui-acct-check {
  color: var(--line-green);
}

/* 狭い画面では一旦横スクロールで凌ぐ（モバイル最適化はフェーズ2以降） */
@media (max-width: 640px) {
  .chatui-root {
    min-width: 720px;
  }
  .chatui-body {
    overflow: auto;
  }
}

/* CSS アバター（プロフィール画像の代替）。
   サイズ/レイアウトは各 .*-avatar クラス側が指定する（width/height/border-radius/flex/font-size）。
   ここでは中央寄せ・白文字・背景色のみを担当する。 */
.avatar-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
  overflow: hidden;
}
/* 名前ハッシュで決まる10色。.avatar-circle と二重指定で既存 background を確実に上書きする。 */
.avatar-circle.avatar-circle--color-0 { background: #e53935; } /* 赤 */
.avatar-circle.avatar-circle--color-1 { background: #1e88e5; } /* 青 */
.avatar-circle.avatar-circle--color-2 { background: #43a047; } /* 緑 */
.avatar-circle.avatar-circle--color-3 { background: #fb8c00; } /* 橙 */
.avatar-circle.avatar-circle--color-4 { background: #8e24aa; } /* 紫 */
.avatar-circle.avatar-circle--color-5 { background: #d81b60; } /* ピンク */
.avatar-circle.avatar-circle--color-6 { background: #00897b; } /* 青緑 */
.avatar-circle.avatar-circle--color-7 { background: #6d4c41; } /* 茶 */
.avatar-circle.avatar-circle--color-8 { background: #3949ab; } /* 藍 */
.avatar-circle.avatar-circle--color-9 { background: #757575; } /* 灰 */
