/* =============================================
   study-tools.css — ツールバー + サイドバー + アノテーション
   ============================================= */

/* ツールバー */
.study-toolbar {
  position: sticky;
  top: 40px; /* site-headerの高さ分下 */
  z-index: 90;
  background: #3a3028;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1.5px solid transparent;
  border-radius: 5px;
  color: #bbb;
  font-size: 12px;
  font-family: inherit;
  padding: 4px 9px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.tool-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.tool-btn.active { background: rgba(255,255,255,0.15); border-color: #6a9fd8; color: #fff; }
.tool-btn svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }

.tool-sep { width: 1px; background: #555; height: 20px; margin: 0 4px; }

/* 色選択 */
.color-picker-wrap { display: flex; align-items: center; gap: 3px; margin-left: 4px; }
.color-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.1s, transform 0.1s;
}
.color-dot:hover { transform: scale(1.2); }
.color-dot.selected { border-color: #fff; }

.toolbar-right { margin-left: auto; }

/* =============================================
   サイドバー
   ============================================= */
.study-sidebar {
  position: fixed;
  top: 0;
  left: -260px;
  width: 260px;
  height: 100vh;
  background: #2c2416;
  z-index: 200;
  transition: left 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 3px 0 16px rgba(0,0,0,0.4);
}
.study-sidebar.open { left: 0; }

/* サイドバーを開くタブ */
.sidebar-tab {
  position: fixed;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  z-index: 201;
  background: #3a3028;
  border: none;
  border-radius: 0 6px 6px 0;
  color: #aaa;
  cursor: pointer;
  padding: 12px 5px;
  font-size: 11px;
  writing-mode: vertical-rl;
  letter-spacing: 1px;
  transition: background 0.15s, color 0.15s, left 0.25s ease;
  box-shadow: 2px 0 6px rgba(0,0,0,0.3);
}
.sidebar-tab:hover { background: #4a3a28; color: #fff; }
.sidebar-tab.shifted { left: 260px; }

.sidebar-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header .title { color: #eee; font-size: 13px; font-weight: 700; }
.sidebar-close {
  background: none; border: none; color: #888; cursor: pointer; font-size: 18px; line-height: 1;
}
.sidebar-close:hover { color: #fff; }

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

/* 科目アコーディオン */
.subject-item { }
.subject-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: none; border: none;
  color: #ccc; font-size: 12px; font-family: inherit; font-weight: 700;
  padding: 8px 14px; cursor: pointer; text-align: left;
  transition: background 0.1s;
}
.subject-toggle:hover { background: rgba(255,255,255,0.05); color: #fff; }
.subject-toggle .arrow { font-size: 10px; transition: transform 0.2s; color: #666; }
.subject-toggle.expanded .arrow { transform: rotate(90deg); }

.chapter-list-nav { display: none; padding: 0 0 4px 0; }
.chapter-list-nav.open { display: block; }
.chapter-link {
  display: block; text-decoration: none;
  color: #999; font-size: 11.5px;
  padding: 5px 14px 5px 26px;
  transition: background 0.1s, color 0.1s;
  border-left: 2px solid transparent;
  margin-left: 12px;
}
.chapter-link:hover { color: #fff; background: rgba(255,255,255,0.04); }
.chapter-link.current { color: #6a9fd8; border-left-color: #6a9fd8; background: rgba(106,159,216,0.08); }
.chapter-link.disabled { color: #555; pointer-events: none; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 199;
  background: rgba(0,0,0,0.4);
}
.sidebar-overlay.show { display: block; }

/* =============================================
   アノテーション共通
   ============================================= */

/* ハイライト */
.st-highlight {
  border-radius: 2px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.st-highlight:hover { opacity: 0.7; }
.st-highlight[data-color="yellow"] { background: rgba(255,230,0,0.45); }
.st-highlight[data-color="red"]    { background: rgba(255,100,100,0.35); }
.st-highlight[data-color="blue"]   { background: rgba(100,160,255,0.35); }
.st-highlight[data-color="green"]  { background: rgba(80,200,120,0.35); }

/* 付箋コンテナ（ノート上に重ねる絶対配置レイヤー） */
#sticky-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* 付箋 */
.st-sticky {
  position: absolute;
  width: 160px;
  min-height: 60px;
  border-radius: 3px;
  padding: 6px 8px;
  font-size: 11px;
  font-family: inherit;
  line-height: 1.5;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.25);
  cursor: move;
  pointer-events: all;
  resize: none;
  border: none;
  outline: none;
}
.st-sticky[data-color="yellow"] { background: #fff9a3; }
.st-sticky[data-color="red"]    { background: #ffd5d5; }
.st-sticky[data-color="blue"]   { background: #d5eaff; }
.st-sticky[data-color="green"]  { background: #d5f5e3; }

.sticky-delete {
  position: absolute;
  top: 2px; right: 3px;
  background: none; border: none;
  color: #999; font-size: 13px;
  cursor: pointer; line-height: 1;
  pointer-events: all;
}
.sticky-delete:hover { color: #c0392b; }

/* 手書きキャンバス */
#drawing-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9;
  touch-action: none;
}
#drawing-canvas.active { pointer-events: all; cursor: crosshair; }
#drawing-canvas.eraser-active { pointer-events: all; cursor: cell; }

/* 消しゴム範囲選択ボックス */
#erase-rect {
  position: absolute;
  border: 1.5px dashed #c0392b;
  background: rgba(192,57,43,0.08);
  pointer-events: none;
  z-index: 12;
  display: none;
}

/* ノートのラッパーを relative に */
.notebook-wrap {
  position: relative;
}

/* ツール非アクティブ時はノート本文が選択可能 */
body.tool-highlight .nb-inner { cursor: text; user-select: text; }
body.tool-sticky    .nb-inner { cursor: cell; }
body.tool-draw      .nb-inner { cursor: crosshair; user-select: none; }
body.tool-eraser    .nb-inner { cursor: cell; }

/* 消しゴムモード中のハイライト */
body.tool-eraser .st-highlight { outline: 1.5px dashed #c0392b; }
body.tool-eraser .st-sticky    { outline: 1.5px dashed #c0392b; }
