  :root {
    --primary-color: #4285f4;
    --bg-color: #f1f3f4;
    --card-bg: #ffffff;
    --white-key: #ffffff;
    --black-key: #212529;
    --playing-highlight: #ff1744;
    --reset-color: #dc3545;
    --toggle-on: #34a853;
    --bass-color: #fbbc04;
  }
  body { 
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; 
    background-color: var(--bg-color); 
    margin: 0; 
    /*padding: 10px;*/ 
    color: #333; 
    padding-bottom: 70px;
  }
  
  h1 { margin: 0; font-size: 1.25em; color: #444; }

  .add-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  }
  .add-btn:disabled { background: #ccc; cursor: not-allowed; }

  .app-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-start;
  }

  .analyzer-instance {
    position: relative;
    flex: 0 1 auto;
    width: 245px;
    background: var(--card-bg);
    padding: 5px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border: 3px solid transparent;
    transition: border-color 0.2s;
  }
  .analyzer-instance.is-active {
    border-color: var(--primary-color);
  }

  .instance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }
  .instance-title { font-size: 0.85em; font-weight: bold; color: #777; }
  .remove-btn {
    background: none; border: none; color: #bbb; cursor: pointer; font-size: 18px; line-height: 1;
  }
  .remove-btn:hover { color: var(--reset-color); }

  .piano-wrapper { position: relative; margin-bottom: 10px; }
  .piano-container {
    display: flex;
    justify-content: center;
    padding: 5px 0 20px 0;
    background: #333;
    border-radius: 4px;
    user-select: none;
  }

    /* ベース音セレクター（横並びボタン） */
  .bass-selector-container {
    display: flex;
    justify-content: center;
    background: #222;
    padding: 2px;
    border-radius: 0 0 4px 4px;
    gap: 1px;
  }
  .bass-btn {
    flex: 1;
    height: 18px; /* メインの1/5程度 */
    border: none;
    cursor: pointer;
    font-size: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    transition: all 0.1s;
  }

    .bass-btn.white { background: #eee; }
  .bass-btn.black { background: #444; color: #aaa; }
  .bass-btn.active { 
    background: var(--bass-color) !important; 
    color: #000 !important; 
    font-weight: bold;
    box-shadow: inset 0 0 4px rgba(0,0,0,0.3);
  }

  .key {
    position: relative;
    cursor: pointer;
    box-sizing: border-box;
    border: 1px solid #ccc;
  }

  .white-key {
    width: 26px; height: 90px;
    background: var(--white-key);
    border-radius: 0 0 2px 2px;
    z-index: 1;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
    padding-bottom: 5px; font-size: 16px; font-weight: bold;
  }

  .black-key {
    width: 18px; height: 55px;
    background: var(--black-key); color: white;
    border: 1px solid #000; border-radius: 0 0 2px 2px;
    margin-left: -9px; margin-right: -9px;
    z-index: 3;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
    padding-bottom: 4px; font-size: 16px;
  }

  .white-key.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }
  .black-key.active { background: #1a73e8; border-color: #1a73e8; }

  .key.playing-pulse { animation: playing-glow 0.8s ease-out forwards; }
  @keyframes playing-glow {
    0% { box-shadow: 0 0 15px 5px var(--playing-highlight); }
    100% { box-shadow: 0 0 0 0 transparent; }
  }

  .controls { 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-top: -12px; 
    margin-bottom: 8px; 
  }
  
  .toggle-container {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 16px;
    color: #666;
    font-weight: bold;
  }

  .omit-toggle {
    background: #ddd;
    border: none;
    padding: 3px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
  }
  .omit-toggle.on {
    background: var(--toggle-on);
    color: white;
  }

  .reset-btn {
    background: #eee; border: none; padding: 3px 8px;
    border-radius: 4px; font-size: 16px; cursor: pointer; color: #666;
  }

  .result-container {
    width:225px;
    background: #fdfdfd; border-radius: 6px; padding: 8px;
    border: 1px solid #eee; min-height: 60px;
  }

  .section-title { font-size: 0.65em; color: #aaa; margin-bottom: 5px; text-transform: uppercase; font-weight: bold; }
  .chord-list { display: flex; flex-wrap: wrap; gap: 4px; }

  .chord-badge {
    padding: 4px 8px; border-radius: 4px; font-size: 16px; font-weight: bold;
    cursor: pointer; border: 1px solid transparent; white-space: nowrap;
    transition: transform 0.1s;
  }
  .chord-badge:hover { transform: scale(1.05); }
  .chord-badge.omit-style { background: #f0f0f0; color: #888; }

  #global-history-container {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 2px solid #ddd;
    padding: 15px 25px;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
    z-index: 2000;
  }
  .history-list {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 10px;
    padding: 5px 0;
  }
  .history-badge {
    position: relative;
    background: #e8f0fe;
    color: var(--primary-color);
    border: 1px solid #c2d7fa;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
    cursor: default;
    animation: slide-in 0.3s ease-out;
    white-space: nowrap;
    text-align: center;
  }
  .history-badge:hover { background: #d2e3fc; }
  .history-key-hint {
    position: absolute;
    top: -8px;
    right: -5px;
    background: #333;
    color: #fff;
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 4px;
    opacity: 0.8;
  }
  @keyframes slide-in {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
  }

  .no-selection { color: #ccc; font-style: italic; font-size: 0.8em; }