#detail-modal .qs-ref-section {
  margin-bottom: 18px;
}

/* システム切替スイッチャー（ヘッダー） */
.system-switcher {
  position: relative;
  display: inline-flex;
}
.system-switcher__btn {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1;
  color: var(--color-base-dark-gray-3, #333);
  background: linear-gradient(180deg, #ffffff 0%, #f6faf7 100%);
  border: 1px solid var(--color-base-light-gray-3, #d7dcd9);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.system-switcher__btn:hover {
  background: var(--color-primary-100, #f2fcf7);
  border-color: var(--color-primary-main, #00cc5b);
  box-shadow: 0 3px 8px rgba(0, 204, 91, 0.14);
}
.system-switcher__btn:active {
  transform: translateY(1px);
}
.system-switcher__btn:focus-visible {
  outline: 2px solid var(--color-primary-main, #00cc5b);
  outline-offset: 2px;
}
.system-switcher__caret {
  color: var(--color-primary-dark, #00ac4c);
  transition: transform 0.18s ease;
  flex: 0 0 auto;
}
.system-switcher__btn[aria-expanded="true"] .system-switcher__caret {
  transform: rotate(180deg);
}
.system-switcher__menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1300;
  min-width: 260px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--color-base-light-gray-3, #d7dcd9);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(17, 24, 39, 0.18);
  animation: system-switcher-in 0.14s ease;
}
@keyframes system-switcher-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.system-switcher__menu.hidden {
  display: none;
}
.system-switcher__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--color-base-dark-gray-3, #333);
  text-decoration: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.system-switcher__item:hover {
  background: var(--color-base-light-gray-1, #f7f9f8);
}
.system-switcher__item.is-active {
  color: var(--color-primary-dark, #00ac4c);
  background: var(--color-primary-100, #f2fcf7);
  font-weight: 700;
  cursor: default;
}
.system-switcher__item.is-active svg {
  color: var(--color-primary-main, #00cc5b);
}
.system-switcher__icon-spacer {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

#detail-modal .qs-ref-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-base-dark-gray-2);
  margin: 0 0 8px 0;
}
#detail-modal .qs-ref-section-body {
  background: #fff;
  border: 1px solid var(--color-base-light-gray-2);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 6px 18px rgba(17,24,39,0.04);
  color: var(--color-base-dark-gray-3);
}
#detail-modal .qs-ref-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 18px;
  height: 100%;
  box-sizing: border-box;
}

/* Narrow summary: keep existing markup but make it compact */
/* Narrow summary: keep existing markup but make it compact
   Also apply same constraints when summary is embedded as plain body */
#detail-modal .qs-ref-summary .qs-ref-section-body,
#detail-modal .qs-ref-summary-body {
  max-height: 160px;
  overflow: auto;
}

/* Checkpoint toggle button */
#detail-modal .qs-checkpoint-toggle-btn {
  background: #f0f0f5;
  border: 1px solid #d0d0d8;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: #333;
  margin-bottom: 8px;
}
#detail-modal .qs-checkpoint-toggle-btn:hover {
  background: #e4e4ec;
}
#detail-modal .qs-ref-checkpoint-body {
  max-height: 200px;
  overflow: auto;
  margin-top: 8px;
}

/* Draft area: larger readable text */
#detail-modal .qs-ref-draft .qs-ref-section-body {
  font-size: 15px;
  line-height: 1.6;
  max-height: 280px;
  overflow: auto;
}

/* Generated answer: emphasize and make scrollable */
#detail-modal .qs-ref-generated .qs-ref-section-body {
  font-size: 15px;
  line-height: 1.7;
  max-height: calc(100vh - 360px);
  overflow: auto;
}

/* AI placeholder styling to match design system and previous modal visual */
.qs-ai-placeholder {
  background: linear-gradient(180deg, var(--color-ai-light) 0%, var(--color-base-white) 100%);
  border: 1px solid var(--color-ai-200);
  border-radius: 16px;
  padding: 20px;
  color: var(--color-base-dark-gray-3);
  box-shadow: 2px 2px 10px 0 rgba(0, 80, 32, 0.10);
}
.qs-ai-title {
  font-weight: 700;
  color: var(--color-base-dark-gray-2);
  margin-bottom: 8px;
}
.qs-ai-note {
  color: var(--color-base-dark-gray-1);
  font-size: 14px;
  line-height: 1.6;
}
.qs-ai-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  color: var(--color-ai-dark);
  font-size: 14px;
  line-height: 1.6;
  background: linear-gradient(180deg, var(--color-ai-light) 0%, var(--color-base-white) 100%);
  border: 1px solid var(--color-ai-200);
  border-radius: 16px;
  box-shadow: 2px 2px 10px 0 rgba(0, 80, 32, 0.10);
}
.qs-ai-answer-content {
  --qs-ai-font-scale: 1;
  --qs-ai-space-scale: 1;
  --qs-ai-line-height: 1.28;
  background: linear-gradient(180deg, rgba(243, 240, 255, 0.55) 0%, var(--color-base-white) 18%, var(--color-base-white) 100%);
  border: 1px solid var(--color-ai-200);
  border-radius: 20px;
  padding: calc(12px * var(--qs-ai-space-scale)) calc(12px * var(--qs-ai-space-scale));
  font-size: calc(16px * var(--qs-ai-font-scale));
  line-height: var(--qs-ai-line-height);
  color: var(--color-base-dark-gray-3);
  box-shadow: 2px 2px 10px 0 rgba(0, 80, 32, 0.10);
  word-break: break-word;
  box-sizing: border-box;
}
.qs-ai-section + .qs-ai-section {
  margin-top: calc(18px * var(--qs-ai-space-scale));
}
.qs-ai-section-main {
  background: transparent;
}
.qs-ai-section-main .qs-ai-section-body {
  font-size: calc(16px * var(--qs-ai-font-scale));
  line-height: var(--qs-ai-line-height);
  padding: 0 2px;
}
.qs-ai-section-main,
.qs-ai-section-evidence,
#detail-modal .qs-ref-viewer-ai-body > .qs-ai-answer-content,
#detail-modal .qs-ref-viewer-ai-body > .qs-ai-section-main {
  width: 100%;
  min-width: 0;
}
.qs-ai-section-evidence {
  background: linear-gradient(180deg, var(--color-base-light-gray-1) 0%, var(--color-base-white) 100%);
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: 16px;
  padding: calc(10px * var(--qs-ai-space-scale)) calc(12px * var(--qs-ai-space-scale));
  box-sizing: border-box;
  overflow: hidden;
}
.qs-ai-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 36px;
  padding: 0 12px;
  margin: 0;
  border-radius: 12px;
  background: var(--color-ai-light);
  color: var(--color-ai-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.qs-ai-section-label::-webkit-details-marker {
  display: none;
}
.qs-ai-section-label-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.qs-ai-section-label-icon {
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.18s ease;
  margin-right: 2px;
}
.qs-ai-section-evidence[open] .qs-ai-section-label {
  margin-bottom: 12px;
}
.qs-ai-section-evidence[open] .qs-ai-section-label-icon {
  transform: rotate(225deg);
}
.qs-ai-section-evidence .qs-ai-section-body {
  color: var(--color-base-dark-gray-2);
  font-size: calc(14px * var(--qs-ai-font-scale));
  line-height: var(--qs-ai-line-height);
  padding: calc(1px * var(--qs-ai-space-scale)) calc(3px * var(--qs-ai-space-scale)) calc(1px * var(--qs-ai-space-scale)) calc(4px * var(--qs-ai-space-scale));
  overflow: hidden;
  word-break: break-word;
  max-width: 100%;
  box-sizing: border-box;
}
.qs-ai-answer-content h3 {
  margin: 0 0 calc(16px * var(--qs-ai-space-scale)) 0;
  padding-bottom: calc(10px * var(--qs-ai-space-scale));
  border-bottom: 1px solid var(--color-ai-200);
  font-size: calc(20px * var(--qs-ai-font-scale));
  font-weight: 700;
  color: var(--color-base-dark-gray-3);
  letter-spacing: 0.01em;
}
.qs-ai-answer-content h3:not(:first-child) {
  margin-top: calc(28px * var(--qs-ai-space-scale));
}
.qs-ai-answer-content p {
  margin: 0 0 calc(18px * var(--qs-ai-space-scale)) 0;
}
.qs-ai-answer-content ul,
.qs-ai-answer-content ol {
  padding-left: 1.5em;
  margin: 0 0 calc(18px * var(--qs-ai-space-scale)) 0;
}
.qs-ai-answer-content li {
  margin-bottom: calc(8px * var(--qs-ai-space-scale));
}
.qs-ai-answer-content strong {
  color: var(--color-base-dark-gray-3);
  font-weight: 700;
}
.qs-ai-answer-content em {
  color: var(--color-ai-dark);
  font-style: normal;
}
.qs-ai-answer-content hr {
  border: none;
  border-top: 1px solid var(--color-base-light-gray-3);
  margin: calc(20px * var(--qs-ai-space-scale)) 0;
}
.qs-ai-answer-content blockquote {
  margin: 0 0 calc(18px * var(--qs-ai-space-scale)) 0;
  padding: calc(10px * var(--qs-ai-space-scale)) calc(14px * var(--qs-ai-space-scale));
  border-left: 4px solid var(--color-ai-main);
  background: var(--color-ai-light);
  color: var(--color-base-dark-gray-2);
  border-radius: 0 12px 12px 0;
}

:root {
  /* === 711 Design System Tokens === */
  /* Primary (Green) */
  --color-primary-main: #00CC5B;
  --color-primary-dark: #00AC4C;
  --color-primary-100: #F2FCF7;
  --color-primary-200: #E0FFEE;
  --color-primary-600: #00CC5B;
  --color-primary-700: #00AC4C;

  /* AI (Purple) */
  --color-ai-main: #7B5AFF;
  --color-ai-dark: #6248CC;
  --color-ai-light: #F3F0FF;
  --color-ai-100: #F3F0FF;
  --color-ai-200: #E0D9FF;
  --color-ai-600: #7B5AFF;
  --color-ai-700: #6248CC;

  /* Error (Red) */
  --color-error-100: #FFE6E3;
  --color-error-600: #ED1C24;

  /* Base (Grayscale) */
  --color-base-white: #FFFFFF;
  --color-base-light-gray-1: #F7F9F8;
  --color-base-light-gray-2: #E8EDEA;
  --color-base-light-gray-3: #D7DCD9;
  --color-base-gray: #C4C4C4;
  --color-base-gray-dark: #949494;
  --color-base-dark-gray-1: #666666;
  --color-base-dark-gray-2: #4D4D4D;
  --color-base-dark-gray-3: #333333;

  /* Elevation shadows (711 Design System) */
  --shadow-level-0: none;
  --shadow-level-1: 2px 2px 10px 0px rgba(0, 80, 32, 0.15);
  --shadow-level-2: 2px 3px 12px 1px rgba(0, 80, 32, 0.15);
  --shadow-level-3: 2px 4px 16px 2px rgba(0, 80, 32, 0.15);
  --shadow-level-4: 2px 5px 20px 3px rgba(0, 80, 32, 0.15);
  --shadow-level-5: 2px 6px 24px 4px rgba(0, 80, 32, 0.15);

  /* Button-specific shadows */
  --shadow-btn-green: 2px 3px 12px 1px rgba(0, 164, 73, 0.25);
  --shadow-btn-danger: 2px 3px 12px 1px rgba(223, 0, 17, 0.25);

  /* Semantic aliases (backward compat) */
  --primary-color: var(--color-primary-main);
  --primary-hover: var(--color-primary-dark);
  --danger-color: var(--color-error-600);
  --bg-color: var(--color-base-light-gray-1);
  --surface-color: var(--color-base-white);
  --text-primary: var(--color-base-dark-gray-3);
  --text-secondary: var(--color-base-dark-gray-1);
  --muted-color: var(--color-base-gray-dark);
  --subtle: var(--color-base-gray);
  --border-color: var(--color-base-light-gray-3);
  --shadow-sm: var(--shadow-level-1);

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-full: 999px;

  /* STT */
  --stt-font-size: 14px;
}

/* === 711 DS Icon utilities === */
.btn-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
/* White icon filter for icons on solid-color (green/red) buttons */
.btn-icon.icon-white,
.btn .icon-white {
  filter: brightness(0) invert(1);
}
/* Disabled icon: gray tone */
.btn:disabled .btn-icon {
  filter: brightness(0) invert(0.6);
}
/* Header outline buttons: icons stay green (no filter needed) */
.app-header .btn .btn-icon {
  filter: none;
}
/* ただしログイン（primary）ボタンのアイコンは白にする */
.app-header .btn.primary .btn-icon,
#connectBtn .btn-icon {
  filter: brightness(0) invert(1);
}
/* Modal close button icon sizing */
.modal-close img {
  display: block;
  width: 24px;
  height: 24px;
}

/* Use border-box globally so padding/border are included in width/height calculations
  This prevents body padding from pushing total height beyond 100vh and causing
  an unwanted vertical scrollbar. */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: "Noto Sans JP", "Roboto", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue",
    sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  margin: 0;
  padding: 8px;
  line-height: 1.6; /* 711 DS: 標準はフォントサイズの1.6倍 */
  display: flex;
  justify-content: center;
  min-height: 100dvh;
  font-size: 14px; /* 711 DS: 本文S = 14px (最小サイズ) */
}

/* Prevent page horizontal overflow which reveals background when panels grow */
html, body { overflow-x: hidden; }

.container {
  width: 100%;
  /* allow layout to span full window width */
  max-width: none;
  margin: 0 auto;
  background-color: var(--surface-color);
  padding: 8px 12px 12px;
  padding-bottom: 12px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-level-1);
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 16px);
  height: calc(100dvh - 16px);
  box-sizing: border-box; /* include padding in width to avoid overflow */
  overflow-x: hidden; /* prevent child overflow from cutting off right edge */
  position: relative;
}

main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

.app-section {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}



/* Make topic keywords and meta-left smaller to improve density */
.topic-keywords,
.topic-card .topic-keywords { font-size: 0.72rem; line-height:1.1; }
.topic-card .topic-keywords .keyword-pill { font-size: 0.65rem; padding: 3px 5px; }

.topic-card-meta-left { font-size: 0.72rem; color: var(--text-secondary); display:flex; gap:6px; align-items:center; }
.topic-card-meta-left .score-pill { font-size: 0.65rem; padding: 3px 5px; }
.topic-card {
  width: 100%;
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--color-base-white);
  box-shadow: var(--shadow-level-1);
  border: 1px solid var(--color-base-light-gray-3);
  display: block;
  box-sizing: border-box;
  font-size: 0.95rem;
  line-height: normal;
}



/* Header search input styling */
.header-search-input {
  height: 32px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--color-base-white);
  min-width: 180px;
  font-size: 14px;
}

.search-widget-trigger-row {
  margin-top: 6px;
}

.search-widget-trigger-input {
  width: 100%;
  height: 36px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--color-base-white);
  font-size: 14px;
}

.search-widget-trigger-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 204, 91, 0.12);
}

.search-widget-ghost-trigger {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 600px) {
  /* compact the header search input on mobile to icon-only appearance */
  .header-search-input {
    min-width: 44px !important;
    width: 44px !important;
    padding: 0 !important;
    border-radius: 999px !important;
    font-size: 0 !important;
    background: var(--color-primary-main);
    color: transparent !important;
  }
  .header-search-input::placeholder { color: transparent !important; }
}

/* Responsive: collapse New Session label to icon-only on narrow screens */
@media (max-width: 480px) {
  /* reduce gaps in header to avoid wrapping */
  .app-header .header-content { gap: 6px; }
  .app-header .header-content > .header-left,
  .app-header .header-content > .header-right { gap: 6px; }

  /* Make New Session icon-only to save space */
  #menu-restart-btn {
    width: 40px !important;
    min-width: 40px !important;
    padding: 0 !important;
    border-radius: 999px !important;
  }
  #menu-restart-btn .btn-icon { width: 20px; height: 20px; }
  #menu-restart-btn .btn-label { display: none !important; }

  /* 非常に小さい画面ではログインボタンの余白を少し狭める */
  #connectBtn { padding: 0 10px !important; min-width: 64px; }
}

/* Header single-line + horizontal scroll when overflow */
.app-header {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  position: relative;
  z-index: 1225;
  overflow: visible;
  background: transparent;
  transition: max-height 220ms ease, opacity 180ms ease, transform 220ms ease,
    margin-bottom 180ms ease, padding-bottom 180ms ease, border-color 180ms ease;
  max-height: 120px;
  min-height: 50px;
  flex-shrink: 0;
  opacity: 1;
  transform: translateY(0);
}



.app-header .header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
  padding: 8px 12px;
}

.app-header .header-content > .header-left,
.app-header .header-content > .header-right {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* System title: hide on mobile after connection */
#system-title.hidden-on-mobile {
  display: none;
}

/* Show title on desktop even after connection */
@media (min-width: 769px) {
  #system-title.hidden-on-mobile {
    display: inline;
  }
}

.header-menu-wrapper {
  position: relative;
  display: inline-flex;
}

/* ===== Header menu: bottom-sheet overlay ===== */
/* Background dimmer (mobile only, injected by JS) */
.header-menu-backdrop {
  display: none;
}
@media (max-width: 768px) {
  .header-menu-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9999;
    animation: backdropFadeIn 0.22s ease;
  }
  @keyframes backdropFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}

.header-menu {
  position: fixed;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-level-3);
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 280px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  overflow: auto;
  overscroll-behavior: contain;
  z-index: 10000;
}

/* Mobile: bottom-sheet style */
@media (max-width: 768px) {
  .header-menu {
    /* override JS-set left/top */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    bottom: calc(0px + env(safe-area-inset-bottom)) !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    max-height: 82vh !important;
    border-radius: 16px 16px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 0 0 8px 0;
    gap: 2px;
    animation: sheetSlideUp 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  }
  @keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  /* Drag handle */
  .header-menu::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--color-base-light-gray-3);
    border-radius: 2px;
    margin: 10px auto 6px;
    flex-shrink: 0;
  }
}

.header-menu.hidden { display: none !important; }
.header-menu .menu-item {
  background: transparent;
  color: var(--text-primary);
  border: none;
  text-align: left;
  padding: 10px 16px;
  width: 100%;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  box-sizing: border-box;
}
/* Mobile: larger touch targets */
@media (max-width: 768px) {
  .header-menu .menu-item {
    padding: 14px 20px;
    font-size: 15px;
    min-height: 52px;
  }
  .header-menu .menu-item-sub {
    padding-left: 44px;
  }
  .header-menu .menu-item-toggle {
    padding-right: 68px;
  }
}

/* Menu user label (non-interactive) */
.header-menu .menu-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--color-base-dark-gray-2);
  font-weight: 600;
}
.menu-icon {
  flex-shrink: 0;
  opacity: 0.7;
}
#device-encryption-toggle .menu-icon {
  color: var(--color-primary-main, #00CC5B);
}
.header-menu .menu-item:hover { background: var(--color-base-light-gray-1); }
.header-menu .menu-item.menu-item-danger { color: var(--color-error-600); }
.header-menu .menu-item.menu-item-danger:hover { background: rgba(237, 28, 36, 0.08); }
.header-menu .menu-divider { border: none; border-top: 1px solid var(--color-base-light-gray-3); margin: 4px 8px; }

/* Toggle-type menu items */
.header-menu .menu-item-toggle {
  position: relative;
  padding-right: 60px; /* トグルスイッチ(32px) + 右padding(16px) + 余白 */
}

/* Sub-item indent (翻訳キャプション, ライブ翻訳言語) */
.header-menu .menu-item-sub {
  padding-left: 36px;
}

/* Collapsible sub-group under ライブ翻訳 */
.menu-sub-group {
  display: none;
}
.menu-sub-group.expanded {
  display: block;
}

/* 翻訳出力言語セレクト（スマホでもネイティブピッカーで操作しやすい） */
.menu-lang-select {
  margin-left: auto;
  flex: 0 0 auto;
  min-height: 44px;
  min-width: 96px;
  max-width: 130px;
  padding: 6px 10px;
  border: 1px solid #cfd8dc;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  color: #263238;
}
#menu-live-translate-lang-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
}
#menu-live-translate-lang-row .menu-item-label {
  flex: 0 1 auto;
  white-space: nowrap;
}

/* Toggle switch: 絶対配置で右端に固定、内部の track/thumb の基準点も兼ねる */
.menu-toggle {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 18px;
}
.menu-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--color-base-light-gray-3, #ccc);
  border-radius: 9px;
  transition: background 0.2s;
}
.menu-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.header-menu .menu-item-toggle.active .menu-toggle-track {
  background: var(--color-primary, #00a73c);
}
.header-menu .menu-item-toggle.active .menu-toggle-thumb {
  transform: translateX(14px);
}

.app-header.is-collapsed {
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  min-height: 0;
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  overflow: hidden;
}

#header-reveal-zone {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  z-index: 1235;
  background: transparent;
}
/* Mobile: make reveal zone finger-tappable */
@media (max-width: 768px) {
  #header-reveal-zone {
    height: 44px;
  }
}
/* Make modal selects compact on narrow screens */
@media (max-width: 600px) {
  #modal-stt-lang-select, #modal-summary-lang-select { max-width: 120px; font-size: 0.85rem; }
}

/* Normalize header buttons: consistent height, centering and spacing */
.app-header .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;  /* 8の倍数 */
  min-height: 40px;
  padding: 0 16px;
  gap: 8px;
  font-size: 14px; /* 711 DS: 本文S */
  line-height: 1;
  box-sizing: border-box;
  white-space: nowrap;
  flex: 0 0 auto;
  max-width: none;
  /* 711 DS appbar: header buttons default to outline-green (secondary) */
  background-color: var(--color-base-white);
  color: var(--color-primary-main);
  border: 1.5px solid var(--color-primary-main);
  box-shadow: none;
}
.app-header .btn:hover {
  background-color: var(--color-base-light-gray-1);
  color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}
/* Primary CTA（ログイン）は緑の塗りつぶしを維持する */
.app-header .btn.primary,
#connectBtn {
  background-color: var(--color-primary-main) !important;
  color: var(--color-base-white) !important;
  border-color: var(--color-primary-main) !important;
  box-shadow: var(--shadow-btn-green);
}
.app-header .btn.primary:hover,
#connectBtn:hover {
  background-color: var(--color-primary-dark) !important;
  border-color: var(--color-primary-dark) !important;
}
/* ログアウト状態: danger red */
#connectBtn.btn-disconnect {
  background-color: var(--color-error-600) !important;
  border-color: var(--color-error-600) !important;
  box-shadow: var(--shadow-btn-danger);
}
#connectBtn.btn-disconnect:hover {
  background-color: #C41920 !important;
  border-color: #C41920 !important;
}

/* Icon-only buttons keep a square shape */
.app-header .btn.icon-btn {
  width: 40px;
  min-width: 40px;
  padding: 0;
}

/* Small variant keeps same height but slightly tighter padding */
.app-header .btn.small {
  height: 40px;
  padding: 0 12px;
  min-width: 72px;
  font-size: 14px;
}

/* Specific header buttons that had truncated text: ensure they fit one line */
#micBtn {
  white-space: nowrap;       /* one-line labels */
  min-width: max-content;   /* grow to fit content rather than shrinking */
  padding: 0 14px;          /* slightly more horizontal padding */
  overflow: visible;
}

/* Ensure the new Share System Audio button displays full label */
#shareAudioBtn,
#menu-shareaudio-btn {
  white-space: nowrap;
  min-width: max-content;
  padding: 0 14px;
  overflow: visible;
}

/* Make embedded SVG icons inherit correct color for outline buttons */
.btn.outline-green .btn-icon { color: var(--color-primary-main); }
.btn.outline-green { color: var(--color-primary-main); border-color: var(--color-primary-main); }

/* Memo Archive: solid orange button with white icon to match other solid CTAs */
/* Stronger specificity + important to override outline/btn defaults */
#memo-archive-btn,
.app-header .btn#memo-archive-btn {
  background-color: #FF6600 !important; /* solid orange */
  color: var(--color-base-white) !important; /* white label */
  border-color: #FF6600 !important;
  box-shadow: 2px 3px 12px 1px rgba(255,102,0,0.18) !important;
}
#memo-archive-btn .btn-icon,
.app-header .btn#memo-archive-btn .btn-icon {
  color: var(--color-base-white) !important;
}
#memo-archive-btn:hover,
.app-header .btn#memo-archive-btn:hover {
  background-color: #e65a00 !important; /* slightly darker orange on hover */
  color: var(--color-base-white) !important;
  border-color: #e65a00 !important;
}

/* Pause/Resume share button styling (hidden by default via .hidden) */
#pauseShareBtn {
  white-space: nowrap;
  min-width: max-content;
  padding: 0 12px;
  overflow: visible;
}

/* Add a clear visual separator between header and main content */
.app-header {
  border-bottom: 1px solid var(--color-base-light-gray-3);
  padding-bottom: 8px;
  margin-bottom: 8px;
  background-color: transparent;
}

/* Ensure disabled header buttons look properly inactive */
.app-header .btn:disabled {
  background-color: transparent !important;
  color: var(--color-base-gray) !important;
  border-color: var(--color-base-light-gray-3) !important;
  box-shadow: none !important;
  opacity: 1;
}
#connectBtn:disabled {
  background-color: var(--color-base-gray) !important;
  color: var(--color-base-dark-gray-1) !important;
  border-color: var(--color-base-gray) !important;
}

.status {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: bold;
}

.status.disconnected {
  background-color: var(--color-base-light-gray-2);
  color: var(--color-base-dark-gray-1);
}

.status.connected {
  background-color: var(--color-primary-100);
  color: var(--color-primary-dark);
}

.status.error {
  background-color: var(--color-error-100);
  color: var(--color-error-600);
}

.auth-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
  background: var(--color-base-light-gray-1);
  border-radius: var(--radius-md);
}

.hidden {
  display: none !important;
}

/* Bottom action-bar: hidden off-screen by default, revealed when hovering the bottom hotspot or the bar itself */
#action-bar-hotspot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 14px; /* small hover area at bottom edge */
  z-index: 40;
}
/* Mobile: enlarge hotspot for easier tapping */
@media (max-width: 768px) {
  #action-bar-hotspot {
    height: 56px;
  }
}

.btn {
  padding: 8px 16px; /* 8の倍数 */
  border: none;
  border-radius: var(--radius-md);
  background-color: var(--color-primary-main);
  color: var(--color-base-white);
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  transition: background-color 0.15s, box-shadow 0.15s;
  font-size: 14px; /* 711 DS: 本文S */
  box-shadow: var(--shadow-btn-green);
}

.btn:hover {
  background-color: var(--color-primary-dark);
  box-shadow: var(--shadow-level-2);
}

.btn:disabled {
  background-color: var(--color-base-gray) !important;
  color: var(--color-base-dark-gray-1) !important;
  cursor: not-allowed;
  opacity: 1;
  box-shadow: none !important;
}

/* Ensure danger/primary/icon variants also look disabled when [disabled] attribute present */
.btn.danger:disabled,
.btn.icon-btn.danger:disabled,
.btn.primary:disabled,
.btn.icon-btn:disabled {
  background-color: var(--color-base-gray) !important;
  color: var(--color-base-dark-gray-1) !important;
  border-color: var(--color-base-light-gray-3) !important;
  box-shadow: none !important;
}

.btn.danger {
  background-color: var(--color-error-600);
  box-shadow: var(--shadow-btn-danger);
}

.btn.danger:hover {
  background-color: var(--color-error-600);
}

/* Line button variants (711 DS) */
.btn.outline-green {
  background-color: transparent;
  color: var(--color-primary-main);
  border: 1.5px solid var(--color-primary-main);
  box-shadow: none;
}
.btn.outline-green:hover {
  background-color: var(--color-primary-100);
  color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}
.btn.outline-gray {
  background-color: transparent;
  color: var(--color-base-dark-gray-2);
  border: 1.5px solid var(--color-base-light-gray-3);
  box-shadow: none;
}
.btn.outline-gray:hover {
  background-color: var(--color-base-light-gray-1);
  border-color: var(--color-base-gray);
}

.chat-input {
  display: flex;
  gap: 0.5rem;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  background: var(--color-base-light-gray-1);
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  max-height: 340px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message {
  padding: 0.4rem 0.8rem; /* tighter bubbles */
  border-radius: 10px;
  max-width: 88%;
  word-wrap: break-word;
  font-size: 0.95rem;
}

.message.user {
  align-self: flex-end;
  background-color: var(--primary-color);
  color: white;
  border-bottom-right-radius: 0.25rem;
}

/* Speaking indicator for live user audio (no transcript shown) */
.message.user.speaking-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.message.user.speaking-indicator::before {
  content: '';
  width: 10px;
  height: 10px;
  background: rgba(255,255,255,0.95);
  border-radius: 50%;
  box-shadow: 0 0 0 rgba(255,255,255,0.7);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  50% { transform: scale(1.2); opacity: 0.6; }
  100% { transform: scale(0.9); opacity: 0.9; }
}

.message.gemini {
  align-self: flex-start;
  background-color: var(--color-base-light-gray-2);
  color: var(--text-primary);
  border-bottom-left-radius: 0.25rem;
}

.visual-capture-video {
  position: fixed;
  width: 1px;
  height: 1px;
  left: -10px;
  top: -10px;
  opacity: 0;
  pointer-events: none;
}

.visual-capture-status {
  position: fixed;
  right: 18px;
  bottom: 84px;
  z-index: 1200;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(18, 107, 77, 0.94);
  color: var(--color-base-white);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

.menu-item.disabled,
.menu-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.minutes-body table,
#minutes-markdown table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
  margin: 12px 0 22px;
}

.minutes-body table th,
.minutes-body table td,
#minutes-markdown table th,
#minutes-markdown table td {
  border: 0;
  padding: 8px 10px;
  vertical-align: middle;
}

.minutes-body table th:first-child,
.minutes-body table td:first-child,
#minutes-markdown table th:first-child,
#minutes-markdown table td:first-child {
  width: 76px;
  color: var(--color-base-dark-gray-2);
  font-weight: 700;
  white-space: nowrap;
}

.minutes-body table td:nth-child(2),
#minutes-markdown table td:nth-child(2) {
  background: var(--color-base-light-gray-1);
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: 8px;
}

.minutes-body table img,
#minutes-markdown table img,
#minutes-markdown .visual-capture-thumbnail-link img {
  display: block;
  width: min(320px, 100%);
  max-height: 190px;
  border-radius: 8px;
  border: 1px solid var(--color-base-light-gray-3);
  background: var(--color-base-white);
  object-fit: contain;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.visual-capture-thumbnail-link {
  display: inline-block;
  cursor: zoom-in;
}

.visual-capture-thumbnail-link:hover img {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  transform: translateY(-1px);
}

.visual-capture-preview-content {
  position: fixed;
  inset: 5vh 5vw;
  z-index: 1400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px;
  border-radius: 10px;
  background: var(--color-base-white);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

.visual-capture-preview-content img {
  max-width: 100%;
  max-height: calc(90vh - 88px);
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--color-base-light-gray-3);
  background: var(--color-base-light-gray-1);
}

.visual-capture-preview-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--color-base-light-gray-2);
  color: var(--color-base-dark-gray-3);
  font-size: 22px;
  cursor: pointer;
}

.visual-capture-preview-actions a {
  color: var(--color-primary-main);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.visual-capture-card-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 8px;
}

.visual-capture-delete {
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: 6px;
  background: var(--color-base-white);
  color: var(--color-error, #c62828);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
}

.visual-capture-delete:hover {
  background: #fff2f2;
  border-color: #f2b8b8;
}

/* Interim STT debug message */
.message.stt {
  align-self: flex-start; /* interimもfinalも左寄せ */
  background: rgba(0,0,0,0.06);
  color: var(--text-primary);
  font-style: italic;
  max-width: 70%;
}

/* STT panel styles */
.stt-panel {
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: var(--radius-md);
  padding: 4px;
  background: var(--color-base-white);
  min-height: 340px;
  box-sizing: border-box;
}

/* Summary display styles */
.summary-section {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--color-base-white) 0%, var(--color-base-light-gray-1) 100%);
  border: 1px solid var(--color-base-light-gray-3);
}
.summary-heading {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-size: 0.98rem;
}
.summary-list {
  margin: 0 0 6px 18px;
  padding: 0;
  color: var(--text-primary);
}
.summary-list li {
  margin: 4px 0;
}
.summary-paragraph {
  margin: 6px 0;
  color: var(--text-secondary);
  white-space: pre-wrap;
}
.summary-topic {
  margin-top: 6px;
  font-weight: 600;
  color: var(--color-primary-dark);
}
.stt-panel h3 { margin-top: 0; }

/* Temporarily hide memo/section labels inside the STT panel to maximize transcript space */
.stt-panel h3,
.stt-panel .msg-role,
.stt-panel .topic-title {
  display: none !important;
}
.stt-content {
  margin-top: 0;
  min-height: 260px;
  display: flex;
  align-items: stretch;
  padding: 0;
  background: var(--color-base-light-gray-1);
  border: 1px dashed var(--color-base-light-gray-3);
  border-radius: var(--radius-md);
  word-break: break-word;
}

/* Slightly smaller font for memo area to improve density */
.stt-content,
.stt-content .stt-history,
.stt-content .stt-interim,
.stt-content .message {
  font-size: var(--stt-font-size, 13px);
  line-height: 1.5;
}

/* Gemini panel: vertical stacked results with vertical scrolling */
#gemini-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  padding: 8px;
  max-height: 260px;
}
#gemini-content .message {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* STT history (final transcripts) and interim area */
.stt-content .stt-history {
  flex: 1 1 auto;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--color-base-white);
  border: 1px solid var(--color-base-light-gray-3);
}

.stt-content .stt-interim {
  flex: 0 0 40%;
  min-width: 220px;
  margin-right: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--color-primary-100);
  border: 1px solid var(--color-primary-200);
  display: flex;
  /* allow multi-line content and vertical growth */
  align-items: flex-start;
  justify-content: flex-start;
  min-height: 120px;
  max-height: 60vh;
  overflow-y: auto;
  white-space: normal;
}

.stt-content .stt-interim .message.stt.interim {
  width: 100%;
  background: transparent;
  font-style: italic;
  color: var(--color-base-dark-gray-2);
  padding: 6px 8px;
  box-sizing: border-box;
  text-align: left;
  white-space: normal;
}

/* Smooth interim updates: subtle opacity/transform for less jarring repaint */
.stt-content .stt-interim .message.stt.interim {
  transition: opacity 120ms linear, transform 120ms ease;
  will-change: opacity, transform;
}

.stt-history .message.stt.final {
  background: var(--color-primary-100);
  border: 1px solid var(--color-primary-200);
  color: var(--text-primary);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  max-width: 100%;
  align-self: flex-start;
}

/* 復元されたSTT項目：やや薄い表示で区別 */
.stt-history .message.stt.final.restored {
  opacity: 0.7;
}

/* 復元バナー */
.stt-restore-banner {
  font-size: 0.75rem;
  color: var(--color-base-dark-gray-1, #888);
  text-align: center;
  padding: 4px 0 8px;
  border-bottom: 1px dashed var(--color-base-light-gray-3, #ccc);
  margin-bottom: 6px;
}

.stt-interim .message.stt.interim {
  background: transparent;
  font-style: italic;
  color: var(--color-base-dark-gray-2);
}

.message.keywords {
  align-self: center;
  background: var(--color-primary-100);
  border: 1px solid var(--color-base-light-gray-3);
  padding: 12px 16px;
  max-width: 95%;
}

.keywords-content { display: flex; flex-direction: column; gap: 0.5rem; }
.keywords-summary { font-weight: 600; color: var(--text-primary); }
.keywords-list { 
  display: 'flex';
  flex-direction: 'column';
  flex-wrap: 'nowrap';
  gap: '4px';
  max-height: '200px';
  overflow-y: 'auto';
  margin-top: '8px';
}
.keyword-pill { background: var(--color-base-white); border: 1px solid var(--color-base-light-gray-3); padding: 4px 8px; border-radius: 12px; font-size: 12px; }

/* Topic rows and cards for per-topic search results */
.topic-row {
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-bottom: 10px;
  background: var(--color-base-white);
}
.topic-header { display: none !important; }
.topic-title { font-weight:700; color:var(--text-primary); }
.topic-keywords { display:flex; gap:6px; align-items:center; margin-top:8px; }
.topic-card .topic-keywords { margin-top:8px; }
.content-columns {
  display: flex;
  gap: 16px;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}
.left-column {
  flex: 2 1 0%;
  /* ensure left column fills the content-columns height and can layout its children vertically */
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0; /* allow flex children to shrink instead of overflowing */
}
.right-column {
  flex: 1 1 0%;
  /* ensure right column matches parent height and can stretch its internal panels */
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0; /* allow flex children to shrink instead of overflowing */
}

.column-resizer {
  flex: 0 0 10px;
  width: 10px;
  cursor: col-resize;
  position: relative;
  user-select: none;
  touch-action: none;
  align-self: stretch;
  border-radius: 999px;
}

.column-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
}

.column-resizer:hover::before,
.content-columns.resizing .column-resizer::before {
  background: var(--primary-color);
}

.content-columns.resizing,
.content-columns.resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.left-column .fullwidth-stt {
  flex: 7 1 0%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.left-column .fullwidth-stt .stt-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.left-column #quick-summary {
  flex: 3 1 0%;
  min-height: 0;
  overflow: auto;
}
.topic-cards { display:flex; flex-direction:column; gap:12px; overflow-y:auto; max-height:60vh; padding-bottom:6px; }
.topic-rows { display:flex; flex-direction:column; gap:12px; }
.topic-card-title { font-weight:700; margin-bottom:4px; font-size:15px; color:var(--text-primary); }
.topic-card-summary {
  color: var(--color-base-dark-gray-2);
  font-size: 14px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4; /* standard property for line clamping */
  overflow: hidden;
}
.topic-card-meta { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-top:4px; }
.topic-card-meta-left { display:flex; gap:6px; align-items:center; }
.topic-card-meta-right { font-size:12px; color:var(--color-base-gray-dark); }
.topic-card-date { color:var(--color-base-gray-dark); font-size:12px; }
.score-pill { background:#f3f6ff; color:#1f3b9c; padding:4px 8px; border-radius:999px; font-size:12px; border:1px solid rgba(31,59,156,0.06); }
.topic-card-link { display:inline-block; margin-bottom:0; color:var(--primary-color); font-weight:600; text-decoration: none; }
.topic-card-meta-right { font-size:12px; color:var(--color-base-gray-dark); display:flex; gap:8px; align-items:center; }

/* Right column: make reference pane tall and scrollable so it reaches down */
.right-column .search-panel {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.right-column .search-panel .carousel-wrap {
  flex: 1 1 auto;
  min-height: 0; /* allow child to scroll */
  overflow: auto;
}
.right-column .topic-rows {
  height: 100%;
  overflow: auto;
  padding-right: 6px;
}


.msg-role {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  opacity: 0.8;
}

.msg-text {
  white-space: pre-wrap;
}

input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--color-primary-main);
  box-shadow: 0 0 0 2px rgba(0, 204, 91, 0.12);
}

/* 711 DS: Select / Pulldown styling */
select {
  padding: 8px 12px;
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background-color: var(--color-base-white);
  line-height: 1.6;
  cursor: pointer;
  appearance: auto;
}
select:focus {
  outline: none;
  border-color: var(--color-primary-main);
  box-shadow: 0 0 0 2px rgba(0, 204, 91, 0.12);
}
select.small {
  padding: 6px 10px;
  font-size: 14px;
}

/* 711 DS: Label styling */
label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-base-dark-gray-2);
  display: block;
  margin: 8px 0 4px;
}

.note {
  font-size: 12px;
  color: var(--color-base-dark-gray-1);
}

.session-end-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px;
  background: var(--color-base-light-gray-1);
  border-radius: var(--radius-md);
  text-align: center;
  animation: fadeIn 0.5s ease-in-out;
}

.link-btn {
  display: inline-block;
  padding: 12px 24px;
  background-color: var(--color-base-white);
  color: var(--color-primary-main);
  border: 1.5px solid var(--color-primary-main);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.2s;
}

.link-btn:hover {
  background-color: var(--color-primary-100);
}

/* Header memo toggle small styling */
/* #toggle-memo-btn はメニュー内アイテムのため .menu-item の padding を使用 */

/* Gain slider styling */
#gain-slider { width: 120px; vertical-align: middle; }
#gain-value { font-weight:600; color: var(--color-base-dark-gray-2); margin-left:6px; }


@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}



.search-panel { width: 100%; max-width: 100%; box-sizing: border-box; }

.extraction-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Make the Gemini panel size adapt to its content: when used as a fullwidth gemini area
   allow the panel to shrink/grow based on the inner content size, and don't cap the
   gemini content with an artificial max-height. Keep vertical scrolling if content
   becomes very long by allowing overflow-y:auto on the inner container. */
.fullwidth-gemini {
  min-height: auto !important;
}
.fullwidth-gemini #gemini-content {
  max-height: none; /* allow gemini content to define height */
  overflow-y: auto; /* keep scrolling when very large */
}
.search-meta {
  font-size: 12px;
  color: var(--color-base-dark-gray-1);
}

.search-raw {
  background: var(--color-base-light-gray-1);
  border:1px solid var(--color-base-light-gray-3);
  padding:8px;
  margin-top:8px;
  font-size:12px;
  overflow:auto;
  max-height:200px;
  white-space: pre-wrap;
}

.search-keywords { display:flex; gap:0.5rem; flex-wrap:wrap; margin-bottom:0.5rem; }
.search-question { font-size:14px; color:var(--text-primary); margin-bottom:8px; white-space:pre-wrap; font-weight:600 }
.toggle-btn { margin-top:8px; background:var(--color-base-white); border:1px solid var(--color-base-light-gray-3); padding:6px 12px; border-radius:var(--radius-md); cursor:pointer; font-size:14px; font-family:inherit; }

.search-details { margin-top:8px; display:flex; flex-direction:column; gap:8px }
.search-created { font-size:12px; color:var(--color-base-dark-gray-1) }
.search-summary { font-size:14px; color:var(--text-primary); }
.search-answer { font-size:14px; color:var(--text-primary); background:var(--color-base-light-gray-1); padding:8px; border-radius:var(--radius-md); border:1px solid var(--color-base-light-gray-3) }
.search-url { font-size:0.85rem; color:var(--primary-color); text-decoration:underline; }
.search-scores { display:flex; gap:0.5rem; margin-top:0.25rem }
.score-pill { background:#f1f3f4; padding:0.25rem 0.5rem; border-radius:6px; font-size:0.8rem; color:#222 }
.keyword-pill.small { padding:0.25rem 0.5rem; font-size:0.8rem }

.assistant-msg { transition: box-shadow 0.12s, transform 0.08s; }
.assistant-msg.selected { box-shadow: 0 6px 18px rgba(26,115,232,0.08); transform: translateY(-1px); }
/* Highlight assistant messages that have an extraction ready */
.assistant-msg.has-extraction { background: var(--color-ai-100); }

.search-panel {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--color-base-white);
  min-height: 160px;
  max-height: 420px;
  overflow-y: auto;
  h3 { cursor: move; user-select: none; }
}

/* Ensure the search panel fills the right column instead of forcing a centered
   half-width. Removing the 50% forced width avoids layout conflicts with the
   left/right column flex ratios. */
.search-panel {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  position: relative !important;
  left: auto !important;
  top: auto !important;
  right: auto !important;
  transform: none !important;
}

@media (max-width: 900px) {
  .search-panel { width: 100% !important; max-width: 100% !important; }
}

/* Quick-summary header controls: keep timestamp and buttons fixed to the right */
/* Ensure the quick-summary container is the positioning context; place controls at top-right */
#quick-summary {
  position: relative;
  padding-top: 8px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}
.quick-summary-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%; /* Ensure full width */
  min-width: 0;
}
/* High-specificity rule to override inline or conflicting styles and force right-alignment */
#quick-summary .quick-summary-header .quick-summary-controls {
  display: flex !important;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
  margin-left: auto !important;
  z-index: 30;
}

#quick-summary-updated {
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}

#quick-summary-clear {
  flex: 0 0 auto;
  white-space: nowrap;
}
.quick-summary-header h3 {
  margin: 0;
}
@media (max-width: 640px) {
  #quick-summary .quick-summary-header .quick-summary-controls { position: static; }
}

/* Bottom strip layout: show cards horizontally in a fixed bottom bar. */

/* Place search panel inline under Extraction by default and allow vertical resize */
.search-panel {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  background: transparent; /* keep panel background transparent */
  max-height: 420px;
  overflow: auto;
  /* Prevent user from manually resizing this panel to avoid layout breakage */
  resize: none !important;
  display: flex;
  flex-direction: column;
  box-sizing: border-box; /* keep padding inside width */
  width: 100%; /* full width of the right column */
  min-width: 0; /* avoid auto-expanding in flex layouts */
}

/* If we want the search panel to sit outside the `.app-grid` and span the page,
   add the `outside-grid` modifier class to the element. This forces it to
   occupy the full grid width and ignore any inline/drag positioning. */
.search-panel.outside-grid {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 0 1rem 0 !important;
  position: relative !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
}

/* Bottom action bar for NextAction buttons */
.action-bar {
  position: fixed;
  left: 50%;
  bottom: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  --action-btn-height: 44px;
  --action-stack-gap: 8px;
  transform: translate(-50%, 120%); /* hidden below viewport by default */
  transition: transform 180ms ease, opacity 180ms ease;
  opacity: 0;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 10px;
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  overflow-y: hidden;
  z-index: 1400;
  pointer-events: auto;
  padding-top: 5px; /* ホバー時のtransformで上部が途切れないように余白を追加 */
}

/* Keep selected action buttons vertically stacked inside action bar */
.action-stack {
  display: inline-flex;
  flex-direction: column;
  gap: var(--action-stack-gap);
  align-items: stretch;
  justify-content: flex-start;
  flex: 0 0 auto;
}

/* single-lower: no longer needs padding-top; flex-end on action-bar handles bottom alignment */
/* Lock toggle label width to OFF-state (wider label) so button never resizes on toggle */
#auto-translation-toggle-btn .btn-label {
  display: inline-block;
  min-width: 7em;
  text-align: center;
}
#auto-punctuate-toggle-btn .btn-label {
  display: inline-block;
  min-width: 7em;
  text-align: center;
}
#auto-question-toggle-btn .btn-label {
  display: inline-block;
  min-width: 9em;
  text-align: center;
}
/* Pill-style green buttons for action bar */
#action-bar .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: var(--action-btn-height);
  white-space: nowrap;
  min-width: fit-content;
  padding: 10px 18px;
  border-radius: 999px;
  color: var(--color-base-white);
  /* 711 DS: solid primary green (same as header primary CTA) */
  background: var(--color-primary-main);
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: var(--shadow-btn-green);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.1;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.15s ease;
}
#action-bar .btn.small { min-width: fit-content; padding: 8px 16px; }
#action-bar .btn .btn-label { white-space: nowrap; }
#action-bar .btn:hover {
  transform: translateY(-3px);
  background: var(--color-primary-dark);
  box-shadow: var(--shadow-level-3);
}
#action-bar .btn:active { transform: translateY(-1px); }
#action-bar .btn:focus { outline: 3px solid rgba(0,204,91,0.18); outline-offset: 2px; }

/* ===== 自動●●トグルボタン: 通常ボタンと差別化した小型ピルスタイル ===== */
#action-bar .btn.toggle {
  min-height: 28px;
  padding: 4px 13px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--color-base-light-gray-2);
  color: var(--color-base-dark-gray-1);
  border: 1.5px solid var(--color-base-light-gray-3);
  box-shadow: none;
  transform: none !important;
}

/* 自動トグル: デフォルト非表示、ホバーでフェードイン */
#action-bar .btn.auto-toggle {
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
#action-bar .btn.auto-toggle.auto-toggle-visible {
  display: flex;
  opacity: 1;
}

/* OFF状態: 非活性感をわかりやすく */
#action-bar .btn.toggle[aria-pressed="false"] {
  background: var(--color-base-light-gray-2);
  color: var(--color-base-gray-dark);
  border-color: var(--color-base-light-gray-3);
  box-shadow: none;
}
#action-bar .btn.toggle[aria-pressed="false"]:hover {
  background: var(--color-base-light-gray-3);
  filter: none;
  transform: none !important;
}

/* ON状態: アクティブを明確に */
#action-bar .btn.toggle[aria-pressed="true"] {
  background: var(--color-primary-dark);
  color: var(--color-base-white);
  border-color: rgba(0,0,0,0.1);
  box-shadow: var(--shadow-btn-green);
}
#action-bar .btn.toggle[aria-pressed="true"]:hover {
  background: var(--color-primary-main);
  filter: none;
  transform: none !important;
}

/* ===== メモクリアボタン: 危険操作を示す赤系スタイル (711 DS: 削除ボタン) ===== */
#action-bar .btn.danger {
  background: var(--color-error-600);
  border-color: rgba(0,0,0,0.08);
  box-shadow: var(--shadow-btn-danger);
}
#action-bar .btn.danger:hover {
  background: #C41920;
}

/* Ensure consistent vertical spacing between the quick summary and reference/search panel */
#quick-summary {
  margin-bottom: 1rem; /* give breathing room below the summary block */
}

/* Additional guard to ensure the search panel keeps a gap when placed directly after the summary */
#quick-summary + .search-panel,
#quick-summary + .search-panel.outside-grid {
  margin-top: 1rem !important;
}

/* Gemini panel full-width wrapper when placed above the grid */
.fullwidth-gemini {
    grid-column: 1 / -1;
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-elev);
    padding: 12px;
    border-radius: 8px;
}

/* Reveal and responsive behavior */
#action-bar-hotspot:hover + .action-bar,
.action-bar:hover {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* Visible class used by JS to keep the bar shown after mouseleave for a short time */
.action-bar.visible {
  transform: translate(-50%, 0) !important;
  opacity: 1 !important;
}

/* Responsive: on mobile/tablet (≤768px), show compact circular icon-only buttons in the action bar */
@media (max-width: 768px) {
  .action-bar {
    left: 8px;
    right: 8px;
    max-width: calc(100vw - 16px);
    gap: 8px;
    transform: translateY(120%);
    justify-content: center;
    flex-wrap: wrap;
  }
  #action-bar-hotspot:hover + .action-bar,
  .action-bar:hover,
  .action-bar.visible {
    transform: translateY(0) !important;
  }
  /* Icon-only: hide label text, keep SVG icon */
  #action-bar .btn.small {
    min-width: 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 999px;
    font-size: 0;
    position: relative;
  }
  #action-bar .btn.small .btn-label { display: none; }
  #action-bar .btn.small span { display: none; }
  #action-bar .btn.small .btn-icon {
    display: block !important;
    margin: auto;
  }
}

@media (max-width: 600px) {

  /* Keep header button size/label consistent across viewport widths */
  header { padding-left: 8px; padding-right: 8px; }
  /* disabled header buttons */
  header .btn:disabled, header .btn.small:disabled {
    background: transparent;
    color: var(--color-base-gray);
    box-shadow: none;
    border-color: var(--color-base-light-gray-3);
    cursor: not-allowed;
  }
  /* recording state for mic button (711 DS: error red) */
  header .btn.small.recording {
    background: var(--color-error-600) !important;
    color: var(--color-base-white) !important;
    border-color: var(--color-error-600) !important;
    box-shadow: var(--shadow-btn-danger);
  }
  /* memo toggle active state: primary dark green */
  header .btn.small.active {
    background: var(--color-primary-dark);
    color: var(--color-base-white);
    border-color: var(--color-primary-dark);
    box-shadow: var(--shadow-btn-green);
  }

  /* タッチデバイス: 自動トグルを常時表示 */
  #action-bar .btn.auto-toggle {
    display: flex !important;
    opacity: 1 !important;
  }
}

/* ===== Mobile: Header buttons icon-only ===== */
@media (max-width: 600px) {
  /* Shrink header buttons to icon-only circles */
  .app-header .btn.small {
    min-width: 44px !important;
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    border-radius: var(--radius-full) !important;
    font-size: 0;
    gap: 0 !important;
    white-space: nowrap;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  /* hidden class must win over the display:inline-flex !important above */
  .app-header .btn.small.hidden { display: none !important; }
  .app-header .btn.small .btn-label { display: none; }
  .app-header .btn.small span:not(.btn-icon) { display: none; }
  .app-header .btn.small .btn-icon {
    display: block !important;
    margin: 0;
  }
  /* Menu button: icon only, no text */
  #header-menu-btn { font-size: 0; }
  /* Header gaps tighter */
  .app-header .header-content { gap: 6px; }
  .header-right { gap: 4px !important; }
  /* Ensure the header doesn't scroll horizontally */
  .app-header .header-content { overflow-x: visible; }
  /* Single-column layout on mobile */
  .content-columns { flex-direction: column; gap: 8px; }
  .content-columns .left-column,
  .content-columns .right-column { flex: none; width: 100%; }
  .column-resizer { display: none; }
  /* Action bar: wrap buttons */
  .action-bar { flex-wrap: wrap; justify-content: center; }
}

.search-results {
  /* Stack cards vertically (one per row) and allow them to stretch to available width */
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px 4px;
  align-items: stretch;
  overflow-y: auto;
}

/* Live STT caption shown near the bottom of the screen (above action bar) */
.stt-caption {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 72px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 1450;
  background: rgba(51, 51, 51, 0.85);
  color: var(--color-base-white);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 15px; /* use explicit px to avoid fractional em clipping */
  line-height: 18px; /* explicit line-height in px */
  box-sizing: border-box;
  /* 2 lines (2 * 18px) + vertical padding (8px top + 8px bottom) = 52px total */
  max-height: calc((2 * 18px) + 16px);
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
  text-align: center;
  box-shadow: var(--shadow-level-4);
  pointer-events: none;
}
.live-translate-caption {
  /* 翻訳キャプションは4行まで表示（案A: 高さ緩和） */
  max-height: calc((4 * 18px) + 20px) !important;
  text-align: left !important;
  padding: 10px 16px !important;
  bottom: 136px;
  bottom: calc(136px + env(safe-area-inset-bottom));
}
/* 翻訳キャプション内の各エントリ */
.translate-caption-entry {
  display: block;
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.translate-caption-entry:last-child {
  border-bottom: none;
}
.stt-caption.hidden { display: none !important; }
.stt-caption .msg-text, .stt-caption { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; display:block; }

/* hide scrollbars but keep scrolling behavior so we can scroll to bottom programmatically */
.stt-caption {
  -ms-overflow-style: none; /* IE/Edge */
  scrollbar-width: none; /* Firefox */
}
.stt-caption::-webkit-scrollbar { display: none; }

/* Pending (interim) STT item shown in history */
.stt-history .message.stt.pending,
.stt-history .message.stt.interim {
  opacity: 0.85;
  font-style: italic;
  background: var(--color-primary-100);
  border-left: 3px solid var(--color-primary-main);
  padding: 8px 12px;
  margin: 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #e0e7ff; /* interim用の目立つ薄い青系背景 */
  border: 1px dashed #7b8cff;
  color: var(--color-base-dark-gray-2);
  font-style: italic;
  align-self: flex-start;
}
.stt-history .message.stt.pending .msg-text { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.stt-history .message.stt.interim .msg-text { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.stt-history .stt-spinner {
  width: 12px; height: 12px; border: 2px solid rgba(0,0,0,0.12); border-top-color: var(--color-primary-main); border-radius: 50%;
  animation: stt-spin .8s linear infinite; display:inline-block; flex: 0 0 auto;
}
@keyframes stt-spin { to { transform: rotate(360deg); } }

/* Fullscreen modal for minutes (議事録) */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  box-sizing: border-box;
  transition: padding-top 220ms ease;
}
.modal.hidden { display: none !important; }
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}
.modal-content {
  position: relative;
  background: var(--color-base-white);
  border-radius: var(--radius-md);
  max-width: 1100px;
  width: calc(100% - 48px);
  max-height: calc(100% - 48px);
  overflow: auto;
  box-shadow: var(--shadow-level-5);
  z-index: 1210;
}

#translationModal .modal-content {
  width: calc(100vw - 256px);
  max-width: calc(100vw - 256px);
}

/* 論点整理など汎用 detail-modal は画面いっぱいに広げる */
#detail-modal .modal-content {
  width: calc(100vw - 32px);
  max-width: calc(100vw - 32px);
  height: calc(100% - 32px);
  max-height: calc(100% - 32px);
}
.modal-content.fullscreen {
  /* Use A4 portrait aspect ratio so content prints nicely later */
  width: min(90vw, 1100px);
  aspect-ratio: 210 / 297; /* A4 portrait */
  max-width: 1100px;
  max-height: 95vh;
  height: auto;
  border-radius: 8px; /* slight rounding for nicer UI */
  padding: 18px 22px 24px 22px; /* top padding so close button isn't clipped */
  box-sizing: border-box;
}

/* Minutes modal: keep the frame fixed and scroll only the minutes body. */
#minutes-modal .modal-content.fullscreen {
  display: block;
  width: min(94vw, 1100px);
  height: 92vh;
  max-height: 92vh;
  aspect-ratio: auto;
  overflow: hidden;
  padding: 20px;
}
#minutes-modal .modal-body {
  box-sizing: border-box;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
#minutes-modal .minutes-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
#minutes-modal .minutes-toolbar { display:flex; gap:8px; align-items:center; }
#minutes-modal .minutes-toolbar .btn.small { padding:6px 10px; }

@media (max-width: 600px) {
  #minutes-modal .minutes-toolbar .btn-label { display: none; }
  #minutes-modal .minutes-toolbar .btn.small { padding: 6px 8px; min-width: 36px; justify-content: center; }
}
#minutes-modal .minutes-body {
  flex: 1 1 auto;
  min-height: 0 !important;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  overscroll-behavior: contain;
}
#minutes-modal #minutes-markdown { background: var(--color-base-white); padding: 12px; border-radius: var(--radius-md); border:1px solid var(--color-base-light-gray-3); }
#minutes-modal #minutes-editor { box-sizing:border-box; }
#minutes-modal .minutes-editor-wrap {
  position: relative;
  margin-top: 12px;
}
#minutes-modal .minutes-editor-mirror {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  box-sizing: border-box;
  overflow: hidden;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--color-base-dark-gray-3);
  font-size: 14px;
  line-height: 1.6;
  font-family: inherit;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  pointer-events: none;
  visibility: hidden;
}
#minutes-modal .minutes-editor-mirror mark {
  padding: 0;
  color: inherit;
  background: #fff0a6;
  border-radius: 2px;
}
#minutes-modal .minutes-editor-mirror mark.current {
  background: #ffbf47;
  outline: 1px solid #d88a00;
}
#minutes-modal #minutes-editor {
  position: relative;
  z-index: 1;
  display: block;
  height: clamp(360px, 55vh, 620px);
  margin: 0;
  resize: vertical;
}
#minutes-modal #minutes-editor.search-highlighting {
  background: transparent;
  color: transparent;
  caret-color: var(--color-base-dark-gray-3);
  -webkit-text-fill-color: transparent;
}
#minutes-modal .minutes-replace-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
#minutes-modal .minutes-replace-bar input {
  flex: 1 1 180px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: var(--radius-md);
  font: inherit;
}
#minutes-modal .minutes-replace-bar .note {
  flex: 1 0 100%;
  min-height: 1.2em;
}
@media (max-width: 600px), (max-height: 700px) {
  #minutes-modal #minutes-editor {
    height: clamp(260px, 48vh, 420px);
  }
}
#minutes-modal .minutes-footer { padding-top:8px; border-top: 1px solid rgba(0,0,0,0.04); }
#minutes-modal .minutes-footer .btn { padding:8px 14px; }

/* Make action buttons at top-right smaller and secondary-looking */
#minutes-modal .minutes-toolbar .btn { background: var(--color-primary-main); color: var(--color-base-white); }
#minutes-modal .minutes-toolbar .btn.small { font-size: 14px; }

/* Ensure close button sits above content */
#minutes-modal .modal-close { z-index: 1250; }
#memo-password-modal {
  z-index: 1400;
}
.memo-password-modal-content {
  width: min(420px, calc(100vw - 32px));
  max-width: 420px;
  padding: 0;
}
.memo-password-body {
  padding: 24px;
}
.memo-password-title {
  margin: 0 40px 18px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.memo-password-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}
.memo-password-input-wrap {
  position: relative;
  display: block;
}
.memo-password-field input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: var(--radius-sm);
  padding: 10px 42px 10px 12px;
  font: inherit;
  color: var(--text-primary);
  background: var(--color-base-white);
}
.memo-password-field input:focus {
  outline: 2px solid rgba(0, 117, 92, 0.18);
  border-color: var(--color-primary-main);
}
.memo-password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.memo-password-toggle:hover {
  background: var(--color-base-light-gray-1);
}
.memo-password-toggle img {
  width: 20px;
  height: 20px;
  opacity: 0.78;
}
.memo-password-error {
  min-height: 18px;
  margin: 2px 0 14px;
  color: #b91c1c;
  font-size: 13px;
}
.memo-password-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
#memo-success-modal {
  z-index: 1400;
}
.memo-success-modal-content {
  width: min(400px, calc(100vw - 32px));
  max-width: 400px;
  padding: 0;
}
.memo-success-body {
  padding: 32px 24px 24px;
  text-align: center;
}
.memo-success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: rgba(0, 204, 91, 0.12);
  color: var(--color-primary-main);
  font-size: 28px;
  font-weight: 700;
}
.memo-success-title {
  margin: 0 0 10px;
  color: var(--text-primary);
  font-size: 20px;
}
.memo-success-message {
  margin: 0 0 22px;
  color: var(--text-secondary);
  line-height: 1.6;
}
#memo-success-modal-ok {
  min-width: 120px;
}
.modal-close {
  position: absolute;
  right: 18px;
  top: 14px;
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  z-index: 1230; /* above modal content */
  padding: 6px 10px;
  border-radius: 6px;
}

.modal-close:hover { background: rgba(0,0,0,0.04); }
#minutes-markdown {
  padding: 12px 6px;
}

/* Loading / spinner styles for '生成中' */
.minutes-loading { display:flex; gap:12px; align-items:center; padding:18px; }
.loader {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 4px solid rgba(0,0,0,0.08);
  border-top-color: var(--color-primary-main);
  animation: spin 1s linear infinite;
}
.loading-text { font-size: 16px; color: var(--text-secondary); }
.loading-dots::after { content: '...'; display:inline-block; animation: dots 1s steps(4, end) infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dots { 0% { content: ''; } 33% { content: '.'; } 66% { content: '..'; } 100% { content: '...'; } }

/* Markdown content styles inside modal */
#minutes-markdown h1, #minutes-markdown h2, #minutes-markdown h3 { color: var(--text-primary); }
#minutes-markdown pre { background:#f6f8fa; padding:10px; border-radius:6px; overflow:auto; }
#minutes-markdown code { background:#f3f4f6; padding:2px 6px; border-radius:4px; }
#minutes-markdown ul, #minutes-markdown ol { padding-left:1.15rem; }
#minutes-markdown p { margin:0 0 0.8rem 0; }

/* Carousel variant: horizontal scroll with snap and nav buttons */
.search-results.carousel {
  display: flex !important;
  flex-direction: row;
  gap: 12px;
  padding: 12px 8px;
  overflow-x: auto !important;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  position: relative;
}
.search-results.carousel .search-result {
  flex: 0 0 300px !important; /* slightly wider cards */
  min-width: 300px !important;
  scroll-snap-align: start;
  margin: 0;
}
.carousel-nav-hidden { display: none !important; }

/* subtle fade edges to suggest horizontal scroll */
.search-results.carousel::before,
.search-results.carousel::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 48px;
  pointer-events: none;
}
.search-results.carousel::before { left: 0; background: linear-gradient(to right, rgba(245,246,248,1), rgba(245,246,248,0)); }
.search-results.carousel::after { right: 0; background: linear-gradient(to left, rgba(245,246,248,1), rgba(245,246,248,0)); }

/* carousel wrapper and overlay nav buttons */
.carousel-wrap {
  position: relative;
  /* allow carousel to take more horizontal space so side gutters are smaller */
  max-width: 95%;
  margin: 0 auto;
  padding: 0 8px; /* small horizontal padding so items don't touch edges */
}
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-base-white);
  color: var(--color-base-dark-gray-3);
  border: 1px solid rgba(16,24,40,0.06);
  box-shadow: 0 8px 20px rgba(23,35,70,0.08);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.carousel-btn.prev { left: -18px; }
.carousel-btn.next { right: -18px; }
.carousel-btn:disabled { opacity: 0.45; cursor: default; }

@media (max-width: 900px) {
  .search-results.carousel .search-result { flex: 0 0 260px !important; min-width: 260px !important; }
  .carousel-btn { width:40px; height:40px; }
  .carousel-wrap { max-width: 100%; padding: 0 6px; }
}

/* Centered carousel variant: snap items to center and highlight active */
.search-results.carousel.center-snap {
  justify-content: center;
  scroll-snap-type: x mandatory;
}
.search-results.carousel.center-snap .search-result {
  scroll-snap-align: center;
  transition: transform 240ms ease, box-shadow 240ms ease;
  transform-origin: center center;
  opacity: 0.92;
}
.search-results.carousel.center-snap .search-result.active {
  transform: scale(1.02);
  box-shadow: 0 12px 30px rgba(23,35,70,0.12);
  opacity: 1;
}

/* Indicators (dots) */
.search-indicators { display: none; }

.search-panel > .btn { padding: 6px 10px; }

/* Add a subtle shadow and rounded edges for the carousel track */
.search-results.carousel { border-radius: 8px; background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.0)); padding-bottom:12px; }

/* Make scrollbar minimal but visible on supported browsers */
.search-results.carousel::-webkit-scrollbar { height: 8px; }
.search-results.carousel::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 8px; }

.search-result {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow: visible; /* allow children (detail button, long text) to be visible */
  display: flex;
  flex-direction: column;
  /* uniform card height to keep layout tidy */
  min-height: 220px;
  height: 220px;
}

/* Prevent long/continuous text from forcing a wider card */
.search-result, .search-result * {
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Ensure title and main text area truncate with ellipsis when overflowing */
.search-result .search-title {
  font-weight: 600;
  margin-bottom: 8px;
  /* allow up to two lines for title without cutting */
  display: -webkit-box;
  /* standardized property for line clamping (keeps linter happy) */
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Hide the title visually but keep it in the DOM (data retained) */
.search-title {
  display: none !important;
}

/* Add internal spacing to make cards look less cramped */
.search-result {
  padding: 12px 14px;
  gap: 8px;
}

/* Clamp multiline text areas (snippet / question / summary / answer) */
.search-card-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 6px; /* spacing for scrollbar */
}

.search-result .search-snippet,
.search-result .search-question,
.search-result .search-summary,
.search-result .search-answer {
  /* let the card body scroll rather than clipping text with line-clamp */
  overflow: visible;
  display: block;
}

/* Push the toggle button to the bottom of the card */
.search-result .toggle-btn {
  margin-top: 8px;
  align-self: center;
  padding: 6px 10px;
  font-size: 0.875rem;
  border-radius: 6px;
}

/* Ensure small elements (keyword pills etc.) have breathing room */
.search-result .search-keywords {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.search-result .keyword-pill {
  padding: 4px 8px;
  font-size: 0.85rem;
}

/* metadata sits below the toggle */
.search-result .search-meta {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* make the panel background transparent so underlying page shows through */
.search-panel, .search-results {
  background: transparent;
}

/* cards should have a light gray background so they stand out */
.search-result {
  background: var(--color-base-light-gray-1);
  border: 1px solid var(--color-base-light-gray-3);
}

@media (max-width: 900px) {
  /* On narrower screens make cards full-width of the panel */
  .search-result { width: 100%; min-width: 0; }
}

@media (max-width: 520px) {
  .search-result { width: 100%; min-width: 0; }
}

.chat-log {
  flex-grow: 1;
  max-height: 400px;
}

/* Modal styles for full detail view */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
.modal:not(.hidden) {
  display: flex;
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}
.modal-content {
  position: relative;
  background: var(--color-base-white);
  width: min(920px, 94%);
  max-height: 84vh;
  overflow-y: auto;
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-level-5);
  z-index: 1200;
}
.modal-close {
  position: absolute;
  right: 12px;
  top: 8px;
  border: none;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
}
.modal-body { display:flex; flex-direction:column; gap:12px; }

/* User dictionary editor */
.user-dictionary-modal-content {
  width: min(1120px, 94vw);
  max-height: 90vh;
}
.user-dictionary-modal-body {
  padding: 20px;
  min-height: 0;
}
.user-dictionary-modal-body h3 { margin: 0; }
.user-dictionary-toolbar,
.user-dictionary-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-dictionary-toolbar { justify-content: space-between; }
.user-dictionary-actions {
  position: sticky;
  z-index: 3;
  bottom: 0;
  justify-content: flex-end;
  margin: 0;
  padding: 12px 0 0;
  background: var(--color-base-white, #fff);
}
.user-dictionary-actions::before {
  content: "";
  position: absolute;
  /* Cover the body (20px) and modal (24px) padding below the sticky actions. */
  inset: 0 -20px -44px;
  z-index: -1;
  background: var(--color-base-white, #fff);
  pointer-events: none;
}
.user-dictionary-tabs,
.dictionary-scope-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-base-light-gray-3);
}
.user-dictionary-tab,
.dictionary-scope-tab {
  padding: 9px 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: inherit;
  font-weight: 600;
  cursor: pointer;
}
.user-dictionary-tab.active,
.dictionary-scope-tab.active {
  border-bottom-color: var(--color-primary, #1565c0);
  color: var(--color-primary, #1565c0);
}
.dictionary-scope-tabs { gap: 8px; }
.dictionary-scope-tab {
  flex: 1;
  border: 1px solid var(--color-base-light-gray-3);
  border-bottom-width: 3px;
  border-radius: 8px 8px 0 0;
  background: var(--color-base-light-gray-1);
}
.dictionary-scope-tab.active { background: var(--color-base-white, #fff); }
.dictionary-scope-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 32px;
}
.dictionary-scope-heading strong { font-size: 1rem; }
#dictionary-department-name { margin-left: 0; }
#dictionary-permission-note { margin-left: auto; }
.dictionary-permission-denied {
  color: var(--color-functional-red, #c62828);
  font-weight: 700;
}
.user-dictionary-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
}
.user-dictionary-panel.hidden { display: none; }
.user-dictionary-panel .note { margin: 0; }
.user-dictionary-content {
  box-sizing: border-box;
  width: 100%;
  height: clamp(220px, 32vh, 300px);
  min-height: 180px;
  max-height: 45vh;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: 8px;
  background: var(--color-base-white, #fff);
  color: inherit;
  font: 0.9rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.user-terms-table-wrap {
  max-height: 390px;
  overflow: auto;
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: 8px;
}
.user-terms-table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.user-terms-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px;
  text-align: left;
  background: var(--color-base-light-gray-1);
}
.user-terms-table td {
  padding: 6px;
  border-top: 1px solid var(--color-base-light-gray-3);
}
.user-terms-table input {
  box-sizing: border-box;
  width: 100%;
  min-width: 130px;
  padding: 7px 8px;
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: 5px;
  background: var(--color-base-white, #fff);
  color: inherit;
}
.user-terms-table input[data-field="description"] { min-width: 210px; }
.user-terms-delete-btn {
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--color-functional-red, #c62828);
  cursor: pointer;
}
.user-terms-delete-btn:hover { background: rgba(198, 40, 40, 0.08); }

/* 論点整理モーダル：本文を読みやすいサイズに */
#detail-modal .modal-content {
  --detail-modal-font-scale: 2.25;
  font-size: calc(1.18rem * var(--detail-modal-font-scale));
  padding: 16px 20px;
}
#detail-modal .modal-content h2 { font-size: calc(1.45rem * var(--detail-modal-font-scale)); border: none; padding-bottom: 0; }
#detail-modal .modal-content h3,
#detail-modal .modal-content h4 { font-size: calc(1.25rem * var(--detail-modal-font-scale)); margin: 0.8em 0 0.3em; }
#detail-modal .modal-content p,
#detail-modal .modal-content li { font-size: calc(1.12rem * var(--detail-modal-font-scale)); line-height: 1.85; }
/* Override modal-content rules inside AI answer so auto-fit CSS variables take effect */
#detail-modal .modal-content .qs-ai-answer-content h3,
#detail-modal .modal-content .qs-ai-answer-content h4 {
  font-size: calc(20px * var(--qs-ai-font-scale) * var(--detail-modal-font-scale, 1));
  line-height: var(--qs-ai-line-height);
  margin: 0 0 calc(16px * var(--qs-ai-space-scale)) 0;
}
#detail-modal .modal-content .qs-ai-answer-content p,
#detail-modal .modal-content .qs-ai-answer-content li {
  font-size: calc(16px * var(--qs-ai-font-scale) * var(--detail-modal-font-scale, 1));
  line-height: var(--qs-ai-line-height);
}
#detail-modal .modal-body { gap: 4px; }
.ellipsis { opacity: 0.9 }

/* Ensure the search panel inside the right column fills the column height
   and lets its internal content scroll when necessary. Use a selector
   scoped to the content grid to avoid disturbing global .search-panel
   rules elsewhere. */
.content-columns .right-column > .search-panel {
  flex: 1 1 auto;      /* allow the panel to grow within the right column */
  height: 100%;        /* match the parent's computed height */
  max-height: 100%;    /* avoid earlier max-height caps interfering */
  min-height: 0;       /* allow children with overflow to scroll */
  overflow: auto;      /* enable internal scrolling when content overflows */
}

/* Make common inner wrappers honor flex-based shrinking when used
   inside the right column (helps with nested carousel or topic-rows). */
.content-columns .right-column .carousel-wrap,
.content-columns .right-column .topic-rows {
  flex: 1 1 auto;
  min-height: 0;
}

/* Split left column vertically: memo (fullwidth-stt) and quick-summary.
   Use flex ratios so they always stay in 5:5 (half/half) proportion based
   on the left-column height. */
.content-columns .left-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.content-columns .left-column > .fullwidth-stt {
  flex: 7 1 0%;
  min-height: 0; /* allow inner scroll when needed */
  overflow: auto;
}
.content-columns .left-column > #quick-summary {
  flex: 3 1 0%;
  min-height: 0;
  overflow: auto;
}

/* Ensure quick-summary expands to fill the entire right column when placed there */
.content-columns .right-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.content-columns .right-column > #quick-summary {
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  overflow: auto;
}

/* Match spacing and box-sizing of left-column .fullwidth-stt so heights align visually */
.content-columns .right-column > #quick-summary {
  box-sizing: border-box !important;
  margin-bottom: 8px !important;
  padding: 12px !important;
}

/* Make the stt-panel itself use flex layout so it doesn't create its own
   scrollbar; let .stt-content take available space and scroll internally
   when needed. This prevents the outer panel from showing a vertical
   scrollbar while keeping content accessible. */
.stt-panel {
  display: flex;
  flex-direction: column;
  /* prevent the panel itself from scrolling; inner .stt-content will handle overflow */
  overflow: hidden;
  height: 100%;
  box-sizing: border-box; /* include padding in height calculations */
}

.stt-panel .stt-content {
  /* occupy remaining vertical space inside .stt-panel */
  flex: 1 1 auto;
  min-height: 0; /* allow children to shrink and inner scrolling to work */
  overflow-y: auto; /* inner scrolling only */
}

/* Ensure history area doesn't enforce its old max-height which caused
   nested scrollbars; allow it to grow inside .stt-content and scroll
   there if necessary. */
.stt-content .stt-history {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
}

/* Strong overrides to prevent outer-panel vertical scrollbar caused by
   legacy min-heights / margins. These use !important selectively because
   some inline styles set margin-bottom on .fullwidth-stt. */
.stt-panel {
  min-height: 0 !important;
}

.content-columns .left-column > .fullwidth-stt {
  margin-bottom: 8px !important; /* reserve space equal to quick-summary offset */
  box-sizing: border-box;      /* ensure padding included in height */
}

.content-columns { box-sizing: border-box; }

/* When left column is hidden, allow right-column to expand to full width */
.content-columns.left-hidden .right-column {
  flex: 1 1 100% !important;
  width: 100% !important;
  max-width: 100% !important;
  padding-right: 8px !important;
}

.content-columns.left-hidden .column-resizer {
  display: none !important;
}

/* When right column is hidden, allow left-column to expand to full width (symmetry) */
.content-columns.right-hidden .left-column {
  flex: 1 1 100% !important;
  width: 100% !important;
  max-width: 100% !important;
}

.content-columns.right-hidden .column-resizer {
  display: none !important;
}

/* Ensure content-columns never exceeds the app-section width; place this
   near the end to override earlier rules that set fixed heights/widths. */
.app-section .content-columns {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

.content-columns > * {
  min-width: 0 !important;
}

/* Prevent right-column children from drawing outside the container edge.
   Add small right padding and ensure box sizing includes borders so the
   visible vertical line isn't clipped. */
.content-columns .right-column {
  box-sizing: border-box !important;
  padding-right: 8px !important;
}
.content-columns .right-column > .search-panel {
  box-sizing: border-box !important;
  padding-right: 8px !important;
}

/* Modal footer styling for detail modal confirm/cancel */
.modal-content .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 12px;
}

#memo-list-modal .modal-content {
  overflow: hidden;
}

#memo-list-modal .modal-body {
  box-sizing: border-box;
  max-height: calc(84vh - 48px);
  min-height: 0;
}

.memo-list-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.memo-list-item {
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--color-base-white);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memo-list-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.memo-list-item-title {
  font-weight: 600;
  color: var(--text-primary);
}

.memo-list-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.memo-list-item-preview {
  white-space: pre-wrap;
  color: var(--text-primary);
  font-size: 13px;
}

.memo-list-footer {
  flex: 0 0 auto;
  padding-top: 12px;
  background: var(--color-base-white);
}

.memo-list-footer .btn {
  width: 100%;
}

/* ===== 過去議事録モーダル ===== */
.past-sessions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.past-sessions-header h3 {
  margin: 0;
}

.past-sessions-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

#past-sessions-modal .past-sessions-header .modal-close {
  position: static;
}

#past-sessions-modal .modal-content {
  overflow: hidden;
}

#past-sessions-modal .modal-body {
  box-sizing: border-box;
  max-height: calc(84vh - 48px);
  min-height: 0;
}

#past-sessions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.past-sessions-footer {
  flex: 0 0 auto;
  padding-top: 12px;
  background: var(--color-base-white);
}

.past-sessions-footer .btn {
  width: 100%;
}

.past-session-card {
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--color-base-white);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.past-session-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.past-session-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.past-session-minutes-date {
  font-size: 11px;
  color: var(--text-secondary, #888);
}

.past-session-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.past-session-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.past-session-actions .btn {
  flex: 1 1 auto;
  min-width: 64px;
  text-align: center;
  justify-content: center;
}

.past-session-audio-player {
  margin-top: 10px;
}

.past-session-audio-player audio {
  display: block;
  width: 100%;
}

.past-session-audio-error {
  font-size: 12px;
  color: #dc2626;
}

.btn.danger {
  background: #dc2626;
  color: #fff;
  border: none;
}
.btn.danger:hover:not(:disabled) {
  background: #b91c1c;
}
.btn.danger:disabled {
  background: #f87171;
  cursor: not-allowed;
}

.past-session-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-audio {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-transcript {
  background: #d1fae5;
  color: #065f46;
}

.badge-text {
  background: #fef9c3;
  color: #713f12;
}

.badge-minutes {
  background: #ede9fe;
  color: #5b21b6;
}

/* ===== 議事録バックグラウンド生成トースト ===== */
.minutes-toast {
  position: fixed;
  bottom: 96px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-base-dark-gray-3, #333);
  color: #fff;
  padding: 10px 16px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 19000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  font-size: 13px;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
}
.minutes-toast.hidden { display: none; }
.minutes-toast.toast-error { background: #b91c1c; }
.minutes-toast-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}

/* Preview styling: wrapping, max height and scroll */
.summarize-preview pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 8px;
  background: var(--color-base-white);
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: var(--radius-md);
}

/* ===== 論点整理モーダル デザイン強化 ===== */

/* Compact action buttons (top-right, absolute) */
#detail-modal .qs-actions-bar {
  position: absolute;
  top: 10px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 2px;
  z-index: 1240;
  box-sizing: border-box;
  overflow: hidden; /* container manages internal scroll */
}
#detail-modal .qs-actions-test-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--color-primary-100);
  color: var(--color-primary-dark);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
#detail-modal .qs-actions-bar button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 5px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s;
}
#detail-modal .qs-actions-bar button:hover {
  opacity: 1;
  background: rgba(0,0,0,0.05);
}

/* Status bar */
#detail-modal [data-question-summary-status="1"] {
  font-size: 13px;
  color: var(--color-base-gray-dark);
  flex: 1 1 auto;
  min-height: 0; /* required so children can scroll inside flex container */
  width: 100%;
  padding: 8px 0 4px;
}

/* Section cards */
#detail-modal .qs-section-card {
  position: relative;
  background: var(--color-base-light-gray-1);
  border: 1px solid var(--color-base-light-gray-2);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 12px;
}
#detail-modal .qs-section-card h3,
#detail-modal .qs-section-card h4 {
  font-size: calc(1.1rem * var(--detail-modal-font-scale, 1.12));
  font-weight: 700;
  color: var(--color-ai-dark);
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--color-ai-200);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#detail-modal .qs-section-card h3::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--color-ai-main);
  border-radius: 2px;
  flex-shrink: 0;
}
#detail-modal .qs-section-card ol {
  margin: 0;
  padding-left: 1.5em;
}
#detail-modal .qs-section-card ul {
  margin: 0;
  padding-left: 1.5em;
}
#detail-modal .qs-section-card.qs-check-card ul {
  margin: 0;
  padding-left: 1.3em;
}
#detail-modal .qs-section-card.qs-check-card ul li {
  margin-bottom: 2px;
  line-height: 1.5;
}
#detail-modal .qs-section-card ol li {
  margin-bottom: 6px;
  line-height: 1.65;
}
#detail-modal .qs-section-card ol li strong {
  color: var(--color-base-dark-gray-3);
}
#detail-modal .qs-section-card p {
  margin: 0;
  line-height: 1.7;
  color: var(--color-base-dark-gray-2);
}

/* Summary section: slightly different accent */
#detail-modal .qs-section-card.qs-summary {
  background: var(--color-base-white);
  border-left: 4px solid var(--color-ai-main);
}
#detail-modal .qs-section-card.qs-summary h3::before {
  display: none;
}

/* Respondent badges — inline next to heading text */
#detail-modal .qs-respondent-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
#detail-modal .qs-respondent {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  appearance: none;
  background: var(--color-primary-200, #E0FFEE);
  border: 1.5px solid var(--color-primary-main, #00CC5B);
  border-radius: var(--radius-sm, 6px);
  padding: 2px 10px;
  font-family: inherit;
  font-size: calc(0.78rem * var(--detail-modal-font-scale, 1.12));
  font-weight: 700;
  color: var(--color-primary-dark, #00AC4C);
  white-space: nowrap;
  cursor: pointer;
}
#detail-modal .qs-respondent:focus-visible {
  outline: 2px solid var(--color-primary-main, #00CC5B);
  outline-offset: 2px;
}
#detail-modal .qs-respondent.is-hidden {
  display: none;
}
#detail-modal .qs-respondent-all-toggle {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}
#detail-modal .qs-respondent-all-toggle:focus-visible {
  outline: 2px solid var(--color-primary-main, #00CC5B);
  outline-offset: 3px;
}
#detail-modal .qs-respondent-all-toggle:disabled {
  color: inherit;
  opacity: 1;
  cursor: default;
}
#detail-modal .qs-respondent::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 12c2.7 0 4.8-2.1 4.8-4.8S14.7 2.4 12 2.4 7.2 4.5 7.2 7.2 9.3 12 12 12zm0 2.4c-3.2 0-9.6 1.6-9.6 4.8v2.4h19.2v-2.4c0-3.2-6.4-4.8-9.6-4.8z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 12c2.7 0 4.8-2.1 4.8-4.8S14.7 2.4 12 2.4 7.2 4.5 7.2 7.2 9.3 12 12 12zm0 2.4c-3.2 0-9.6 1.6-9.6 4.8v2.4h19.2v-2.4c0-3.2-6.4-4.8-9.6-4.8z'/%3E%3C/svg%3E") center/contain no-repeat;
  flex-shrink: 0;
}

/* ── Reference materials / answer drafts panel ── */
#detail-modal .qs-ref-panel {
  margin-top: 4px;
  border-top: 1px solid var(--color-base-light-gray-2);
  padding-top: 10px;
}
#detail-modal .qs-ref-panel-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: calc(0.92rem * var(--detail-modal-font-scale, 1.12));
  font-weight: 700;
  color: var(--color-base-dark-gray-2);
  margin: 0 0 8px;
  cursor: pointer;
  user-select: none;
}
#detail-modal .qs-ref-panel-heading::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12.04 6.79c-.05-.09-.13-.19-.2-.29h7.41c.77 0 1.75.86 1.75 1.75v7c0 .89-.63 1.75-1.4 1.75H19v-5.25c0-.83-.47-1.52-.96-1.96-.49-.44-1.19-.79-1.91-.79h-2.59l-1.5-2.21zM15.7 5.5H7v-.77C7 3.84 7.78 3 8.56 3h5.06c.47 0 .78.38 1.03.83l1.05 1.67zM16.5 20.5h-12C3.67 20.5 3 19.64 3 18.75V10h13.12c.83 0 1.88.86 1.88 1.75v7c0 .89-.67 1.75-1.5 1.75zM12.32 9H3v-.77C3 7.34 3.83 6.5 4.67 6.5h5.42c.5 0 .83.38 1.11.83L12.33 9h-.01z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12.04 6.79c-.05-.09-.13-.19-.2-.29h7.41c.77 0 1.75.86 1.75 1.75v7c0 .89-.63 1.75-1.4 1.75H19v-5.25c0-.83-.47-1.52-.96-1.96-.49-.44-1.19-.79-1.91-.79h-2.59l-1.5-2.21zM15.7 5.5H7v-.77C7 3.84 7.78 3 8.56 3h5.06c.47 0 .78.38 1.03.83l1.05 1.67zM16.5 20.5h-12C3.67 20.5 3 19.64 3 18.75V10h13.12c.83 0 1.88.86 1.88 1.75v7c0 .89-.67 1.75-1.5 1.75zM12.32 9H3v-.77C3 7.34 3.83 6.5 4.67 6.5h5.42c.5 0 .83.38 1.11.83L12.33 9h-.01z'/%3E%3C/svg%3E") center/contain no-repeat;
  flex-shrink: 0;
}
#detail-modal .qs-ref-panel-heading .qs-ref-toggle {
  margin-left: 4px;
  font-size: 0.85em;
  color: var(--color-base-gray-dark);
  transition: transform 0.2s;
}
#detail-modal .qs-ref-panel-heading.collapsed .qs-ref-toggle {
  transform: rotate(-90deg);
}
#detail-modal .qs-ref-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#detail-modal .qs-ref-list.collapsed {
  display: none;
}

/* Group per check point */
#detail-modal .qs-ref-group {
  margin-bottom: 6px;
}
#detail-modal .qs-ref-group-label {
  font-size: 0.82em;
  font-weight: 600;
  color: var(--color-base-gray-dark);
  padding: 6px 0 4px;
  border-bottom: 1px solid var(--color-base-light-gray-2);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
#detail-modal .qs-ref-group-label::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 1em;
  background: var(--color-primary-main, #00CC5B);
  border-radius: 2px;
  flex-shrink: 0;
}

/* Individual reference card */
#detail-modal .qs-ref-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--color-base-white);
  border: 1px solid var(--color-base-light-gray-2);
  border-radius: var(--radius-sm, 6px);
  padding: 10px 14px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
#detail-modal .qs-ref-card:hover {
  border-color: var(--color-ai-200);
  box-shadow: var(--shadow-level-1);
}
/* Multi-selection checkbox */
#detail-modal .qs-ref-card .qs-ref-checkbox {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-top: 4px;
  cursor: pointer;
}
#detail-modal .qs-ref-card .qs-ref-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-ai-main, #7B5AFF);
  cursor: pointer;
}
/* Selected card highlight */
#detail-modal .qs-ref-card.qs-ref-selected {
  border-color: var(--color-ai-main, #7B5AFF);
  background: var(--color-ai-50, #f5f2ff);
  box-shadow: 0 0 0 2px var(--color-ai-100, #e8e0ff);
}
/* Selection action bar */
#detail-modal .qs-ref-selection-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--color-base-white);
  border-top: 1px solid var(--color-base-light-gray-2);
  border-radius: 0 0 var(--radius-sm, 6px) var(--radius-sm, 6px);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  z-index: 10;
}
#detail-modal .qs-ref-selection-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-ai-main, #7B5AFF);
}
#detail-modal .qs-ref-selection-bar .btn {
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: 4px;
}
#detail-modal .qs-ref-selection-open {
  background: var(--color-base-white);
  color: var(--color-ai-dark);
  border: 1px solid var(--color-ai-200);
}
#detail-modal .qs-ref-selection-open:hover {
  background: var(--color-ai-light);
}
#detail-modal .qs-ref-selection-preview {
  background: var(--color-ai-main, #7B5AFF);
  color: var(--color-base-white);
  border: none;
}
#detail-modal .qs-ref-selection-preview:hover {
  opacity: 0.85;
}
#detail-modal .qs-ref-selection-clear {
  background: transparent;
  color: var(--color-base-gray-dark);
  border: 1px solid var(--color-base-light-gray-2);
}
/* Multi-viewer navigation */
#detail-modal .qs-ref-multi-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: 0.85rem;
}
#detail-modal .qs-ref-nav-btn {
  background: var(--color-base-light-gray-1, #f0f0f0);
  border: 1px solid var(--color-base-light-gray-2);
  border-radius: 3px;
  padding: 1px 5px;
  cursor: pointer;
  font-size: 0.68rem;
  line-height: 1.2;
}
#detail-modal .qs-ref-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
#detail-modal .qs-ref-nav-btn:not(:disabled):hover {
  background: var(--color-ai-100, #e8e0ff);
  border-color: var(--color-ai-200);
}
#detail-modal .qs-ref-nav-pos {
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--color-base-dark-gray-2);
}
#detail-modal .qs-ref-card.qs-ref-clickable {
  cursor: default;
}
#detail-modal .qs-ref-card.qs-ref-clickable .qs-ref-title {
  color: var(--color-ai-main, #7B5AFF);
  cursor: pointer;
}
#detail-modal .qs-ref-card.qs-ref-clickable .qs-ref-title:hover {
  text-decoration: underline;
}
#detail-modal .qs-ref-card .qs-ref-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-base-white);
}
#detail-modal .qs-ref-card .qs-ref-icon.answer   { background: var(--color-ai-main); }
#detail-modal .qs-ref-card .qs-ref-icon.document  { background: var(--color-primary-main); }
#detail-modal .qs-ref-card .qs-ref-icon.engine-createdqa { background: #1570ef; }
#detail-modal .qs-ref-card .qs-ref-icon.engine-hd { background: transparent; }
#detail-modal .qs-ref-card .qs-ref-icon.engine-ref { background: #00a35c; }
#detail-modal .qs-ref-card .qs-ref-icon.engine-qa { background: #7b5aff; }
#detail-modal .qs-ref-card .qs-ref-icon.engine-createdqa {
  width: 36px;
  font-size: 10px;
  letter-spacing: 0.04em;
}
#detail-modal .qs-ref-card .qs-ref-icon .qs-ref-icon-img {
  width: 22px;
  height: 22px;
  display: block;
}
#detail-modal .qs-ref-card .qs-ref-body {
  flex: 1;
  min-width: 0;
}
#detail-modal .qs-ref-card .qs-ref-title {
  font-size: calc(0.88rem * var(--detail-modal-font-scale, 1.12));
  font-weight: 700;
  color: var(--color-base-dark-gray-3);
  margin: 0;
  flex: 1;
  min-width: 0;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
}
#detail-modal .qs-ref-card .qs-ref-snippet {
  font-size: calc(0.8rem * var(--detail-modal-font-scale, 1.12));
  color: var(--color-base-dark-gray-1);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#detail-modal .qs-ref-card .qs-ref-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  font-size: calc(0.72rem * var(--detail-modal-font-scale, 1.12));
  color: var(--color-base-gray-dark);
}
#detail-modal .qs-ref-card .qs-ref-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.85em;
  font-weight: 600;
}
#detail-modal .qs-ref-card .qs-ref-badge.answer   { background: var(--color-ai-100); color: var(--color-ai-dark); }
#detail-modal .qs-ref-card .qs-ref-badge.document  { background: var(--color-primary-100); color: var(--color-primary-dark); }
#detail-modal .qs-ref-card .qs-ref-source {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  overflow-wrap: anywhere;
  opacity: 0.7;
}

/* Loading placeholder for ref panel */
#detail-modal .qs-ref-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  font-size: calc(0.82rem * var(--detail-modal-font-scale, 1.12));
  color: var(--color-base-gray-dark);
}
#detail-modal .qs-ref-loading .qs-ref-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-base-light-gray-3);
  border-top-color: var(--color-ai-main);
  border-radius: 50%;
  animation: qs-spin 0.7s linear infinite;
}
@keyframes qs-spin {
  to { transform: rotate(360deg); }
}

/* ── Ref Viewer (in-modal PDF viewer) ── */
#detail-modal .qs-ref-viewer {
  display: none;
  flex-direction: column;
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--color-base-white);
  z-index: 10;
  border-radius: inherit;
  box-sizing: border-box;
}
#detail-modal .qs-ref-viewer.active {
  display: flex;
}
#detail-modal .qs-ref-viewer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--color-base-light-gray-2);
  flex-shrink: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}
#detail-modal .qs-ref-viewer-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: 1;
  min-width: 0;
}
#detail-modal .qs-ref-viewer-header-right > span.qs-ref-viewer-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  color: var(--color-base-gray-dark);
  margin: 0;
}
#detail-modal .qs-ref-viewer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s;
  flex-shrink: 0;
}
#detail-modal .qs-ref-viewer-close:hover {
  background: rgba(0, 0, 0, 0.04);
}
#detail-modal .qs-ref-viewer-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  font-size: 0.875rem;
  line-height: 1;
  background: var(--color-base-white);
  border: 1.5px solid var(--color-primary-main);
  border-radius: 999px;
  cursor: pointer;
  color: var(--color-primary-main);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
#detail-modal .qs-ref-viewer-back:hover {
  background: var(--color-primary-100);
  color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}
#detail-modal .qs-left-toggle-btn,
#detail-modal .qs-checkpoint-toggle-btn {
  background: var(--color-base-white);
  border: 1.5px solid var(--color-primary-main);
  border-radius: 999px;
  padding: 0 12px;
  height: 32px;
  font-size: 0.875rem;
  line-height: 1;
  margin-bottom: 0;
  cursor: pointer;
  color: var(--color-primary-main);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
#detail-modal .qs-left-toggle-btn:hover,
#detail-modal .qs-checkpoint-toggle-btn:hover {
  background: var(--color-primary-100);
  color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}
#detail-modal .qs-ref-viewer-title {
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--color-base-dark-gray-2);
  margin-left: auto;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
#detail-modal .qs-ref-viewer-body {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
#detail-modal .qs-ref-viewer.preview-only .qs-ref-viewer-header {
  padding: 4px 10px;
}
#detail-modal .qs-ref-viewer-preview {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#detail-modal .qs-ref-viewer-preview-panels {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
}
#detail-modal .qs-ref-viewer.preview-only .qs-ref-multi-panel {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
#detail-modal .qs-ref-viewer.preview-only .qs-ref-viewer-body {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
#detail-modal .qs-ref-preview-answer-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px;
  box-sizing: border-box;
  height: 100%;
  overflow: auto;
  background: linear-gradient(180deg, var(--color-base-light-gray-1) 0%, var(--color-base-white) 100%);
}
#detail-modal .qs-ref-preview-answer-body {
  max-width: 960px;
  font-size: 16px;
  line-height: 1.7;
}
/* Split layout: left (preview) + right (AI response) */
#detail-modal .qs-ref-viewer-split {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#detail-modal .qs-ref-viewer-left {
  flex: none;
  width: 50%;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  border-right: none;
}
#detail-modal .qs-ref-viewer.qs-left-hidden .qs-ref-viewer-left {
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
#detail-modal .qs-ref-viewer.qs-left-hidden .qs-ref-split-handle {
  display: none;
}
#detail-modal .qs-ref-viewer.qs-left-hidden .qs-ref-viewer-right {
  min-width: 0;
}
#detail-modal .qs-ref-viewer.qs-left-hidden .qs-ref-viewer-split {
  gap: 0;
}
#detail-modal .qs-ref-split-handle {
  width: 6px;
  cursor: col-resize;
  background: var(--color-base-light-gray-2);
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s;
  touch-action: none;
  /* Widen grab area without visual change */
  margin: 0 -4px;
  padding: 0 4px;
  background-clip: content-box;
}
#detail-modal .qs-ref-split-handle:hover,
#detail-modal .qs-ref-split-handle.dragging {
  background: var(--color-primary-main, #00CC5B);
}
#detail-modal .qs-ref-split-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 32px;
  border-radius: 1px;
  background: rgba(0,0,0,0.2);
}
#detail-modal .qs-ref-viewer-left-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 3px 10px;
  border-bottom: 1px solid var(--color-base-light-gray-2);
  background: var(--color-base-light-gray-1, #fafafa);
  flex-shrink: 0;
  font-size: 0.72rem;
}
#detail-modal .qs-ref-viewer-left .qs-ref-viewer-body {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
#detail-modal .qs-ref-viewer-left .qs-ref-viewer-panels {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
}
#detail-modal .qs-ref-viewer-left .qs-ref-multi-panel {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
#detail-modal .qs-ref-viewer-right {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(243, 240, 255, 0.45) 0%, rgba(255, 255, 255, 0.96) 22%, var(--color-base-light-gray-1) 100%);
}
#detail-modal .qs-ref-viewer-ai-header {
  display: none;
}
#detail-modal .qs-ref-viewer-ai-body {
  flex: 1;
  overflow: auto;
  padding: 4px;
  min-height: 0;
  scrollbar-gutter: stable;
}
#detail-modal .qs-ref-viewer-ai-body > * {
  margin: 0 auto;
}
#detail-modal .qs-ref-viewer-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Answer draft visual style (centered card inside modal) */
#detail-modal .qs-ref-viewer.answer .qs-ref-viewer-body {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px;
  box-sizing: border-box;
}
#detail-modal .qs-ref-viewer.answer .qs-ref-viewer-body .qs-ref-viewer-answer {
  width: 100%;
  max-width: 920px;
  background: linear-gradient(180deg, var(--color-base-white) 0%, #fbfdff 100%);
  border: 1px solid var(--color-base-light-gray-2);
  box-shadow: 0 8px 24px rgba(17,24,39,0.06);
  border-radius: 12px;
  padding: 20px 22px;
}
#detail-modal .qs-ref-viewer.answer .qs-ref-viewer-title {
  color: var(--color-base-dark-gray-2);
  font-size: 1rem;
}
#detail-modal .qs-ref-viewer.answer .qs-ref-viewer-answer h1,
#detail-modal .qs-ref-viewer.answer .qs-ref-viewer-answer h2 {
  margin: 0 0 10px 0;
}
#detail-modal .qs-ref-viewer.answer .qs-ref-viewer-answer p,
#detail-modal .qs-ref-viewer.answer .qs-ref-viewer-answer div {
  color: var(--color-base-dark-gray-3);
  font-size: 15px;
  line-height: 1.7;
}

/* Scaling wrapper to allow zooming content inside the modal without clipping */
#detail-modal .qs-ref-scale-outer {
  width: 100%;
  overflow: auto;
  box-sizing: border-box;
  outline: none;
}
#detail-modal .qs-ref-scale-wrap {
  --qs-scale: 1;
  transform: scale(var(--qs-scale));
  transform-origin: top left;
  transition: transform 0.12s ease;
  box-sizing: border-box;
}

/* Zoom controls in header */
#detail-modal .qs-ref-viewer-zoom {
  margin-left: 12px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
#detail-modal .qs-zoom-btn {
  border: 1px solid var(--color-base-light-gray-3);
  background: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
}
#detail-modal .qs-zoom-btn:active { transform: translateY(1px); }

/* Ensure section containers can shrink within flex layouts */
#detail-modal .qs-ref-sections {
  min-height: 0;
}

/* Small action bar inside the answer view */
#detail-modal .qs-ref-viewer.answer .qs-ref-viewer-header {
  background: linear-gradient(90deg, rgba(250,250,253,0.6), rgba(255,255,255,0.6));
}
#detail-modal .qs-ref-viewer.answer .qs-ref-viewer-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
/* copy buttons removed per user request */

/* Hide reCAPTCHA badge injected by IAP / external services */
.grecaptcha-badge,
.rc-anchor-invisible {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  position: fixed !important;
  right: -9999px !important;
}

/* ==============================
   Agent Radial FAB Menu
   ============================== */
.agent-radial {
  position: fixed;
  bottom: 32px;
  bottom: calc(32px + env(safe-area-inset-bottom));
  right: 32px;
  z-index: 9000;
}

/* Main FAB button */
.agent-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--color-ai-main);
  cursor: pointer;
  background: var(--color-base-white);
  color: var(--color-base-white);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-level-3);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 2;
}
.agent-fab:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-level-5);
}
.agent-fab:active {
  transform: scale(0.95);
}
.agent-fab-icon {
  pointer-events: none;
  border-radius: 50%;
  object-fit: cover;
  width: 100%;
  height: 100%;
}

/* ライブ翻訳ON状態ドット（こめ粒ちゃんFAB上） */
.agent-fab-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-ai-main, #00a040);
  border: 2px solid var(--color-base-white, #fff);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.12);
  z-index: 3;
  pointer-events: none;
}
.agent-fab-dot.hidden { display: none; }

/* ライブ翻訳 設定ポップオーバー */
.lt-popover {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: 300px;
  max-width: calc(100vw - 40px);
  background: var(--color-base-white, #fff);
  border: 1px solid var(--color-base-light-gray-3, #d7dcd9);
  border-radius: 16px;
  box-shadow: var(--shadow-level-5);
  padding: 8px;
  z-index: 1200;
}
.lt-popover.hidden { display: none; }
.lt-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 12px;
  border-bottom: 1px solid var(--color-base-light-gray-3, #d7dcd9);
  margin-bottom: 6px;
}
.lt-popover-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--color-base-dark-gray-3, #333);
}
.lt-popover-close {
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--color-base-dark-gray-1, #666);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: background 0.15s;
}
.lt-popover-close:hover { background: var(--color-base-light-gray-1, #f7f9f8); }

/* ポップオーバー内の項目を行スタイルに整える */
.lt-popover .menu-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 12px 56px 12px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-base-dark-gray-3, #333);
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
  min-height: 48px;
}
.lt-popover .menu-item:hover { background: var(--color-base-light-gray-1, #f7f9f8); }
.lt-popover .menu-item-label { flex: 1 1 auto; }
.lt-popover .menu-item-toggle.active .menu-toggle-track {
  background: var(--color-primary-main, #00cc5b);
}
.lt-popover .menu-item-toggle.active .menu-toggle-thumb {
  transform: translateX(14px);
}
.lt-popover .menu-item-sub { padding-left: 24px; }
.lt-popover #menu-live-translate-lang-row {
  padding-right: 12px;
  min-height: 48px;
}
.lt-popover .menu-lang-select { min-width: 110px; }

/* Opened state — rotate FAB */
.agent-radial.open .agent-fab {
  border-color: var(--color-ai-dark);
}
.agent-radial.open .agent-fab:hover {
  transform: scale(1.08);
}

/* Radial items container */
.agent-radial-items {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Individual radial item */
.agent-radial-item {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--color-ai-main);
  background: var(--color-base-white);
  color: var(--color-ai-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-level-2);
  opacity: 0;
  transform: scale(0.3);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.25s ease,
              background 0.2s ease,
              color 0.2s ease;
  pointer-events: none;
}
.agent-radial-item:hover {
  background: var(--color-ai-light);
  border-color: var(--color-ai-dark);
  transform: translate(var(--tx), var(--ty)) scale(1.12) !important;
}
.agent-radial-item:active {
  background: var(--color-ai-200);
}
.agent-radial-item .agent-radial-icon {
  pointer-events: none;
  line-height: 1;
}

/* Radial item label (tooltip on hover — positioned upper-left) */
.agent-radial-label {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 50%;
  white-space: nowrap;
  background: var(--color-base-dark-gray-3);
  color: var(--color-base-white);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  font-family: 'Noto Sans JP', sans-serif;
}
.agent-radial-item:hover .agent-radial-label {
  opacity: 1;
}

/* Open state — fan items outward (arc from ~180° to ~270°, i.e. upper-left quadrant) */
.agent-radial.open .agent-radial-item {
  opacity: 1;
  pointer-events: auto;
}
.agent-radial.open .agent-radial-item:nth-child(1) {
  --tx: -10px; --ty: -70px;
  transform: translate(-10px, -70px) scale(1);
  transition-delay: 0.04s;
}
.agent-radial.open .agent-radial-item:nth-child(2) {
  --tx: -50px; --ty: -52px;
  transform: translate(-50px, -52px) scale(1);
  transition-delay: 0.08s;
}
.agent-radial.open .agent-radial-item:nth-child(3) {
  --tx: -72px; --ty: -24px;
  transform: translate(-72px, -24px) scale(1);
  transition-delay: 0.12s;
}
.agent-radial.open .agent-radial-item:nth-child(4) {
  --tx: -78px; --ty: 8px;
  transform: translate(-78px, 8px) scale(1);
  transition-delay: 0.16s;
}

/* Backdrop overlay when menu is open */
.agent-radial-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 8999;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.agent-radial-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Pulse animation for attention */
@keyframes agent-fab-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(123, 90, 255, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(123, 90, 255, 0); }
}
.agent-fab.pulse {
  animation: agent-fab-pulse 2s ease-in-out 3;
}

/* Speech bubble message from こめ粒ちゃん */
.agent-bubble {
  position: absolute;
  bottom: 72px;
  right: 0;
  background: var(--color-base-white);
  color: var(--color-base-dark-gray-3);
  font-size: 14px;
  font-family: 'Noto Sans JP', sans-serif;
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid var(--color-ai-main);
  box-shadow: var(--shadow-level-2);
  white-space: nowrap;
  z-index: 9001;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.agent-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--color-ai-main);
}
.agent-bubble.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ========== QS Display Settings Modal ========== */
.qs-settings-title {
  margin: 0 0 16px 0;
  font-size: 24px;
  line-height: 1.45;
  font-weight: 700;
  color: var(--color-base-dark-gray-3);
  letter-spacing: 0.01em;
  word-break: keep-all;
}
.qs-settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.qs-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.qs-settings-row:hover {
  background: var(--color-base-light-gray-1, #f9f9f9);
}
.qs-settings-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-base-dark-gray-2);
}
.qs-settings-help {
  margin: 12px 2px 0;
  color: var(--color-base-dark-gray-1);
  font-size: 12px;
  line-height: 1.6;
}
/* Toggle switch styling */
.qs-settings-toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--color-base-light-gray-3, #ccc);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.qs-settings-toggle:checked {
  background: var(--color-primary, #00a040);
}
.qs-settings-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}
.qs-settings-toggle:checked::after {
  transform: translateX(20px);
}

.qs-test-input-body {
  gap: 12px;
}
.qs-test-input-note {
  margin: 0;
  color: var(--color-base-dark-gray-1);
  font-size: 14px;
  line-height: 1.7;
}
.qs-test-input-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-base-dark-gray-2);
}
.qs-test-input-textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 14px 16px;
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: 12px;
  background: var(--color-base-white);
  color: var(--color-base-dark-gray-3);
  font: inherit;
  line-height: 1.7;
}
.qs-test-input-textarea:focus {
  outline: none;
  border-color: var(--color-primary-main);
  box-shadow: 0 0 0 3px rgba(0, 204, 91, 0.12);
}
.qs-test-input-meta {
  min-height: 22px;
  color: var(--color-base-dark-gray-1);
  font-size: 13px;
}
.qs-test-input-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ========== 論点整理モーダル ダークモード ========== */
#detail-modal.qs-darkmode .modal-content {
  background: #1a1a1a;
  color: #ffe600;
}
#detail-modal.qs-darkmode .modal-content h2,
#detail-modal.qs-darkmode .modal-content h3,
#detail-modal.qs-darkmode .modal-content h4,
#detail-modal.qs-darkmode .modal-content p,
#detail-modal.qs-darkmode .modal-content li,
#detail-modal.qs-darkmode .modal-content span,
#detail-modal.qs-darkmode .modal-content strong {
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-respondent {
  color: var(--color-primary-dark, #00AC4C);
}
#detail-modal.qs-darkmode .modal-content .qs-respondent,
#detail-modal.qs-darkmode .qs-section-card .qs-respondent {
  color: var(--color-primary-dark, #00AC4C);
}
#detail-modal.qs-darkmode .qs-section-card {
  background: #222;
  border-color: #444;
}
#detail-modal.qs-darkmode .qs-section-card h3,
#detail-modal.qs-darkmode .qs-section-card h4 {
  color: #ffe600;
  border-bottom-color: #555;
}
#detail-modal.qs-darkmode .qs-section-card h3::before {
  background: #ffe600;
}
#detail-modal.qs-darkmode .qs-section-card p {
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-section-card ol li strong {
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-section-card.qs-summary {
  background: #1e1e1e;
  border-left-color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ref-panel {
  border-top-color: #444;
}
#detail-modal.qs-darkmode .qs-ref-panel-heading {
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ref-section-body {
  background: #222;
  border-color: #444;
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ref-section-title {
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ref-card {
  background: #222;
  border-color: #444;
}
#detail-modal.qs-darkmode .qs-ref-card-title {
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ref-badge {
  color: #1a1a1a;
  background: #ffe600;
}
#detail-modal.qs-darkmode .modal-close img {
  filter: brightness(0) saturate(100%) invert(88%) sepia(60%) saturate(500%) hue-rotate(5deg);
}
#detail-modal.qs-darkmode .qs-ref-viewer-right {
  background: #1a1a1a;
}
#detail-modal.qs-darkmode .qs-ref-viewer-ai-body {
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ref-viewer-ai-body * {
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ref-viewer-header {
  background: #1a1a1a;
  border-bottom-color: #444;
}
#detail-modal.qs-darkmode .qs-ref-viewer-title {
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ref-viewer-header-right > span.qs-ref-viewer-title {
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ref-viewer-back {
  color: #ffe600;
  border-color: #ffe600;
  background: #1f1f1f;
}
#detail-modal.qs-darkmode .qs-ref-viewer-back:hover {
  background: #2a2a2a;
  color: #ffe600;
  border-color: #ffe600;
}
#detail-modal.qs-darkmode .qs-left-toggle-btn {
  background: #1f1f1f;
  border-color: #ffe600;
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-left-toggle-btn:hover {
  background: #2a2a2a;
  border-color: #ffe600;
}
#detail-modal.qs-darkmode .qs-checkpoint-toggle-btn {
  background: #1f1f1f;
  border-color: #ffe600;
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-checkpoint-toggle-btn:hover {
  background: #2a2a2a;
  border-color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ref-viewer-close {
  background: transparent;
}
#detail-modal.qs-darkmode .qs-ref-viewer-close:hover {
  background: rgba(255, 230, 0, 0.1);
}
#detail-modal.qs-darkmode .qs-ref-viewer-left {
  background: #111;
}
#detail-modal.qs-darkmode .qs-ref-viewer-left-nav {
  background: #1a1a1a;
  border-bottom-color: #444;
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ref-viewer-left .qs-ref-viewer-body,
#detail-modal.qs-darkmode .qs-ref-scale-outer,
#detail-modal.qs-darkmode .qs-ref-scale-wrap,
#detail-modal.qs-darkmode .qs-ref-sections,
#detail-modal.qs-darkmode .qs-ref-multi-panel {
  background: #111;
}
#detail-modal.qs-darkmode .qs-ref-viewer.answer .qs-ref-viewer-body .qs-ref-viewer-answer {
  background: #222;
  border-color: #444;
}
#detail-modal.qs-darkmode .qs-ref-split-handle {
  background: #444;
}
#detail-modal.qs-darkmode .qs-ai-loading {
  background: #111;
  border-color: #444;
  color: #ffe600;
  box-shadow: none;
}
#detail-modal.qs-darkmode .qs-ai-answer-content {
  background: #111;
  border-color: #444;
  color: #ffe600;
  box-shadow: none;
}
#detail-modal.qs-darkmode .qs-ai-answer-content h1,
#detail-modal.qs-darkmode .qs-ai-answer-content h2,
#detail-modal.qs-darkmode .qs-ai-answer-content h3,
#detail-modal.qs-darkmode .qs-ai-answer-content h4,
#detail-modal.qs-darkmode .qs-ai-answer-content p,
#detail-modal.qs-darkmode .qs-ai-answer-content li,
#detail-modal.qs-darkmode .qs-ai-answer-content strong,
#detail-modal.qs-darkmode .qs-ai-answer-content span {
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ai-answer-content h3 {
  border-bottom-color: #444;
}
#detail-modal.qs-darkmode .qs-ai-section-evidence {
  background: #111;
  border-color: #444;
}
#detail-modal.qs-darkmode .qs-ai-section-label {
  background: #1f1f1f;
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ai-section-evidence .qs-ai-section-body {
  color: #ffe600;
}
#detail-modal.qs-darkmode .qs-ref-viewer-checkpoint {
  background: #111;
  border-bottom: 1px solid #444 !important;
}
#detail-modal.qs-darkmode .qs-zoom-btn {
  background: #1f1f1f;
  border-color: #444;
  color: #ffe600;
}

#originalTextContent {
  --original-modal-font-size: 14px;
  font-size: var(--original-modal-font-size);
}

#translatedTextContent {
  --translation-modal-font-size: 14px;
  font-size: var(--translation-modal-font-size);
}

/* ===== デバイス選択モーダル ===== */

/* モーダル本体サイズ */
.modal-content.device-modal {
  max-width: 480px;
}

/* モーダル本体のパディング */
.device-modal-body {
  padding: 28px 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* タイトル */
.device-modal-title {
  margin: 0 0 24px 0;
  font-size: 20px;
  font-weight: bold;
  color: var(--color-base-dark-gray-3);
  line-height: 1.4;
}

/* セクション間の余白 */
.device-section {
  margin-bottom: 28px;
}
.device-section:last-child {
  margin-bottom: 0;
}
/* セクションラベル（h3） */
.device-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: bold;
  color: var(--color-base-dark-gray-2);
  line-height: 1.4;
}
.device-section-icon {
  opacity: 0.6;
  flex-shrink: 0;
}

/* 補足テキスト */
.device-section-note {
  margin: -4px 0 10px 0;
  font-size: 12px;
  color: var(--color-base-gray-dark);
  line-height: 1.5;
}

/* デバイスリストコンテナ */
.device-list {
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: 10px;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--color-base-white);
}

/* ローディングテキスト */
.device-list-loading {
  padding: 16px;
  margin: 0;
  color: var(--color-base-gray-dark);
  font-size: 14px;
}

/* 各デバイスボタン（JSで生成） */
.device-list-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: none;
  border-bottom: 1px solid var(--color-base-light-gray-2);
  background: var(--color-base-white);
  color: var(--color-base-dark-gray-3);
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
  transition: background 0.15s ease;
  box-sizing: border-box;
}
.device-list-item:last-child {
  border-bottom: none;
}
.device-list-item:hover {
  background: var(--color-primary-100);
}
.device-list-item.selected {
  background: var(--color-primary-200);
  color: var(--color-primary-dark);
  font-weight: bold;
}
.device-list-item.selected::after {
  content: " ✓";
  font-weight: bold;
}

/* 選択中バッジ */
.device-selected-badge {
  margin: 8px 0 0 2px;
  font-size: 12px;
  color: var(--color-base-dark-gray-1);
  min-height: 18px;
}
.device-selected-badge span {
  font-weight: bold;
}

/* ===== ライブ翻訳ログパネル（サイドパネル） ===== */

.live-translate-log-panel {
  position: fixed;
  top: 52px; /* ヘッダー下 */
  right: 0;
  bottom: 0;
  width: 50vw;
  max-width: 600px;
  min-width: 300px;
  background: var(--color-base-white);
  border-left: 1px solid var(--color-base-light-gray-3);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}
.live-translate-log-panel.open {
  transform: translateX(0);
}

@media (max-width: 640px) {
  .live-translate-log-panel {
    width: 92vw;
    max-width: none;
    min-width: 0;
  }
}

.live-translate-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-base-light-gray-3);
  background: rgba(20, 90, 180, 0.05);
  flex-shrink: 0;
}
.live-translate-log-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: bold;
  color: #14529c;
}
.live-translate-log-title img {
  opacity: 0.75;
}
.live-translate-log-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s;
}
.live-translate-log-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

.live-translate-log-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 80px; /* 下部はアクションバーに隠れないよう余白 */
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-base-light-gray-3) transparent;
}

.translate-log-entry {
  font-size: 13px;
  line-height: 1.65;
  color: var(--color-base-dark-gray-3);
  padding: 8px 10px;
  background: rgba(20, 90, 180, 0.04);
  border-radius: 6px;
  border-left: 3px solid rgba(20, 90, 180, 0.28);
  word-break: break-word;
  animation: log-entry-in 0.2s ease;
}
.translate-log-status {
  font-size: 12px;
  line-height: 1.5;
  color: #14529c;
  padding: 7px 10px;
  background: rgba(20, 90, 180, 0.08);
  border-left: 3px solid #14529c;
  border-radius: 4px;
}
.translate-log-status.error {
  color: var(--color-error-600);
  background: var(--color-error-100);
  border-left-color: var(--color-error-600);
}
@keyframes log-entry-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.translate-log-empty {
  font-size: 13px;
  color: var(--color-base-gray-dark);
  text-align: center;
  padding: 32px 0 0;
  margin: 0;
}

/* ===== 会話メモの話者一括編集モーダル ===== */
.speaker-edit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 55vh;
  overflow-y: auto;
}

.speaker-edit-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.speaker-edit-orig {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 0 0 34%;
  min-width: 0;
}

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

.speaker-edit-count {
  font-size: 12px;
  color: var(--color-base-dark-gray-2);
  white-space: nowrap;
}

.speaker-edit-arrow {
  color: var(--color-base-light-gray-3);
  flex: 0 0 auto;
}

.speaker-edit-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

/* 文字起こしの選択範囲に紐づくメモ */
.transcript-annotation {
  background: #fff1a8;
  border-bottom: 2px solid #e4a400;
  border-radius: 2px;
  color: inherit;
  cursor: pointer;
  padding: 0 1px;
}
.transcript-annotation:focus-visible {
  outline: 2px solid var(--color-primary, #00853f);
  outline-offset: 2px;
}
.annotation-tooltip {
  position: fixed;
  z-index: 10022;
  width: max-content;
  max-width: min(360px, calc(100vw - 16px));
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid #000;
  border-radius: 8px;
  background: #fff;
  color: #000;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  pointer-events: none;
  box-shadow: 0 5px 18px rgba(0,0,0,.25);
}
.annotation-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: #000;
}
.annotation-tooltip.below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #000;
}
.annotation-add-button {
  position: fixed;
  z-index: 10020;
  border: 0;
  border-radius: 18px;
  padding: 7px 13px;
  color: #fff;
  background: var(--color-primary, #00853f);
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
  cursor: pointer;
  font-weight: 700;
}
.annotation-composer {
  position: fixed;
  z-index: 10021;
  width: 310px;
  box-sizing: border-box;
  padding: 14px;
  border: 1px solid var(--color-base-light-gray-3);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(0,0,0,.22);
}
.annotation-composer label { display:block; margin-bottom:8px; font-weight:700; }
.annotation-composer textarea { width:100%; box-sizing:border-box; resize:vertical; padding:8px; border:1px solid #aaa; border-radius:6px; font:inherit; }
.annotation-composer-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:10px; }
