:root{
    --bg:#0b1020;
    --fg:#111827;
    --muted:#6b7280;
    --card:#ffffff;
    --line:#e5e7eb;
    --brand:#4f46e5;
    --brand-weak:#eef2ff;
    --danger:#ef4444;
  }
  
  *{box-sizing:border-box}
  html,body{margin:0;padding:0}
  body{font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;background:#f7f7fb;color:var(--fg)}
  .site-header{background:var(--bg);color:#fff;padding:16px 20px}
  .site-header h1{margin:0;font-size:22px;font-weight:700;letter-spacing:.3px}
  
  .stack{display:flex;flex-direction:column;gap:16px;padding:16px;max-width:1100px;margin:0 auto}
  
  .card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:16px}
  .card-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
  .card h2{margin:0 0 8px 0}
  .card h3{margin:12px 0 8px 0}
  
  .grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
  .field{display:flex;flex-direction:column;gap:6px}
  .field--full{grid-column:1 / -1}
  .row{display:flex;gap:8px;align-items:center}
  
  input,textarea{width:100%;padding:10px;border:1px solid var(--line);border-radius:10px;background:#fff;font-size:14px}
  textarea{resize:vertical;min-height:72px}
  /* voice セレクトの見た目をリッチに */
select{
    width:100%;
    padding:10px;
    border:1px solid var(--line);
    border-radius:10px;
    background:#fff;
    font-size:14px;
    cursor:pointer;
  
    /* ネイティブ矢印を消してカスタム矢印を表示 */
    appearance:none;
    -webkit-appearance:none;
    -moz-appearance:none;
  
    /* 右側に▼アイコン風のグラデーションを描画 */
    background-image:
      linear-gradient(45deg, transparent 50%, var(--muted) 50%),
      linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
      calc(100% - 18px) 50%,
      calc(100% - 12px) 50%;
    background-size:6px 6px, 6px 6px;
    background-repeat:no-repeat;
    padding-right:32px; /* 矢印分の余白 */
  }
  
  select:focus{
    outline:none;
    border-color:var(--brand);
    box-shadow:0 0 0 2px rgba(79,70,229,0.18);
  }
  
  button{padding:10px 14px;border:1px solid var(--line);border-radius:10px;background:#fff;cursor:pointer}
  button.primary{background:var(--brand);border-color:var(--brand);color:#fff}
  button.danger{background:var(--danger);border-color:var(--danger);color:#fff}
  button.ghost{background:#fff}
  button:disabled{opacity:.6;cursor:not-allowed}

  /* =========================
   更新ボタンスピナー
   ========================= */

.spinner {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-top-color: var(--brand, #4f46e5); /* brand 色がなければデフォルト */
    animation: spin 0.7s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-left: 8px;
  }
  
  /* 実際には JS で display:none を切り替えるが、念のため */
  .spinner[hidden] {
    display: none;
  }
  
  @keyframes spin {
    to {
      transform: rotate(360deg);
    }
  }
  
  .hint{color:var(--muted);margin:8px 0 0 0;font-size:13px}
  .muted{color:var(--muted);font-size:14px}
  .pill{background:var(--brand-weak);color:#3730a3;border-radius:999px;padding:6px 10px;font-size:12px}
  
  .list{display:flex;flex-direction:column;gap:8px}
  .item{border:1px solid var(--line);border-radius:10px;padding:10px;background:#fbfbfe;cursor:pointer}
  .item:hover{background:#f4f6ff}
  .item.selected{border-color:var(--brand);background:#eef2ff}
  .item .top{display:flex;align-items:center;gap:10px;justify-content:space-between}
  .item .cid{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:70%}
  .item .status{padding:2px 8px;border-radius:999px;background:#eef2ff;color:#3730a3;font-size:12px}
  .item .time{color:var(--muted);font-size:12px}
  
  .log{background:#0b1020;color:#c7d2fe;border-radius:10px;padding:12px;max-height:46vh;overflow:auto;border:1px solid #1f2937}

  .instructions-container {
    background: #fff8e1;
    border: 1px solid #f5d48c;
    padding: 16px;
    margin-bottom: 20px;
    border-radius: 8px;
  }
  
  .instructions-container h2 {
    margin-top: 0;
  }
  
  .instructions-container ol {
    padding-left: 20px;
    margin: 8px 0;
  }

   /* 既存のスタイルの末尾などに追記 */
  .list--past .list-item {
    opacity: 0.85;
  }
  .list--past .list-item .meta {
    color: #666;
  }

  #past-calls-section .card-head .row {
    gap: 8px;
    align-items: center;
  }

  #toggle-past {
    cursor: pointer;
  }

  /* active選択の可視性（必要なら） */
  .list-item.active {
    outline: 2px solid #4a90e2;
  }
  
  
  /* タブUI */
  .tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--line);
    margin-bottom: 16px;
  }

  .tab {
    padding: 10px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
  }

  .tab:hover {
    color: var(--fg);
    background: rgba(79, 70, 229, 0.05);
  }

  .tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
  }

  .tab-content {
    display: none;
  }

  .tab-content.active {
    display: block;
  }

  /* 電話番号管理タブ */
  .phone-tab-content {
    display: none;
  }

  .phone-tab-content.active {
    display: block;
  }

  /* FAQ管理 */
  .faq-tab-content {
    display: none;
  }

  .faq-tab-content.active {
    display: block;
  }

  .faq-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
  }

  .faq-filters .field {
    flex: 1;
    min-width: 150px;
  }

  .faq-filters button {
    height: 42px;
  }

  .faq-list {
    max-height: 500px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .faq-item {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    background: #fbfbfe;
  }

  .faq-item:hover {
    background: #f4f6ff;
  }

  .faq-item-question {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--fg);
  }

  .faq-item-answer {
    color: var(--muted);
    font-size: 13px;
    white-space: pre-wrap;
    line-height: 1.5;
  }

  .faq-item-answer--collapsed {
    max-height: 4.5em;
    overflow: hidden;
    position: relative;
  }

  .faq-item-answer--collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1.5em;
    background: linear-gradient(transparent, #fbfbfe);
    pointer-events: none;
  }

  .faq-item-answer--expanded {
    max-height: none;
    overflow: visible;
  }

  .faq-toggle-btn {
    margin-top: 6px;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--brand);
    border: none;
    background: transparent;
    cursor: pointer;
  }

  .faq-toggle-btn:hover {
    text-decoration: underline;
  }

  .faq-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
  }

  .faq-category-badge {
    background: var(--brand);
    color: #fff;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
  }

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

  .faq-item-actions button {
    padding: 5px 10px;
    font-size: 12px;
  }

  /* モーダル */
  .modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
  }

  .modal-content {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
  }

  .modal-header h3 {
    margin: 0;
  }

  .modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--muted);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .modal-close:hover {
    color: var(--fg);
  }

  .modal-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    margin-top: 8px;
  }

  .modal-actions button {
    min-width: 100px;
    white-space: nowrap;
  }

  button.secondary {
    background: #f5f5f5;
    border-color: var(--line);
    color: var(--fg);
  }

  button.secondary:hover {
    background: #e8e8e8;
  }

  /* トースト通知 */
  .toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b; color: #fff;
    padding: 12px 24px; border-radius: 8px; font-size: 14px;
    z-index: 9999; opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
  }
  .toast.show {
    transform: translateX(-50%) translateY(0); opacity: 1;
  }

  /* プロバイダーバッジ */
  .provider-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
  }

  .provider-badge--openai {
    background: #e8f5e9;
    color: #2e7d32;
  }

  .provider-badge--gemini {
    background: #e3f2fd;
    color: #1565c0;
  }

  /* 選択中電話番号のプロバイダーインジケーター */
  .provider-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-top: 10px;
    background: #f8f9ff;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
  }

  .provider-indicator-text {
    color: var(--muted);
  }

  /* 通話一覧のプロバイダータグ */
  .list-item .provider-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 6px;
  }

  .list-item .provider-tag--openai {
    background: #e8f5e9;
    color: #2e7d32;
  }

  .list-item .provider-tag--gemini {
    background: #e3f2fd;
    color: #1565c0;
  }

  /* レスポンシブ */
  @media(min-width:1000px){
    /* 上：設定、下：２列（左：一覧 右：操作）のような表示にしたい場合は以下を有効化
    .stack{display:grid;grid-template-columns:1fr;gap:16px}
    #calls-list, #call-actions{display:grid;grid-template-columns:1fr 1fr;gap:16px}
    */
  }
  