@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Hiragino Sans', sans-serif;
  background: #e8f4f0;
  color: #1a2e28;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== Sky gradient bg ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 100% 60% at 50% 0%, #b8eaff 0%, transparent 70%),
    radial-gradient(ellipse 80% 80% at 0% 100%, #c8f5e0 0%, transparent 60%),
    radial-gradient(ellipse 60% 60% at 100% 80%, #d0e8ff 0%, transparent 60%),
    linear-gradient(160deg, #f0fbf7 0%, #e4f5ff 50%, #edfff5 100%);
  pointer-events: none;
  z-index: 0;
}

/* Floating orbs */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle 300px at 15% 25%, rgba(100,220,180,0.18) 0%, transparent 70%),
    radial-gradient(circle 400px at 85% 15%, rgba(80,180,255,0.15) 0%, transparent 70%),
    radial-gradient(circle 250px at 70% 80%, rgba(120,220,160,0.12) 0%, transparent 70%),
    radial-gradient(circle 200px at 30% 75%, rgba(60,160,255,0.1) 0%, transparent 70%);
  animation: floatOrbs 16s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes floatOrbs {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(20px, -15px) scale(1.03); }
  100% { transform: translate(-10px, 10px) scale(0.98); }
}

/* ===== Header ===== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 10px 20px;
  background: rgba(240, 252, 248, 0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid rgba(100,200,160,0.2);
  box-shadow: 0 2px 24px rgba(0,160,120,0.08);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, #00a878, #0080d0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

/* ===== Nav pills — floating ===== */
.header-nav { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }

.nav-btn {
  background: rgba(255,255,255,0.7);
  color: #3a7a6a;
  border: 1.5px solid rgba(100,200,160,0.3);
  padding: 7px 18px;
  border-radius: 100px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,160,120,0.1), 0 1px 3px rgba(0,0,0,0.05);
  backdrop-filter: blur(8px);
}

.nav-btn:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 8px 24px rgba(0,160,120,0.18), 0 2px 6px rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.9);
}

.nav-btn.active {
  background: linear-gradient(135deg, #00c896, #0090e0);
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(0,180,140,0.35), 0 2px 6px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

.auth-area {
  display: flex;
  gap: 6px;
  align-items: center;
}

.auth-btn {
  background: rgba(255,255,255,0.72);
  color: #11616b;
  border: 1.5px solid rgba(0,215,255,0.28);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,160,120,0.1);
  transition: transform 0.2s, box-shadow 0.2s;
}

.auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,160,120,0.16);
}

/* ===== Account chip (ログイン後のアカウント欄) ===== */
.account-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.82);
  border: 1.5px solid rgba(0,200,160,0.35);
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,160,120,0.12);
  transition: transform 0.2s, box-shadow 0.2s;
}

.account-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,160,120,0.18);
}

.account-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #00c896, #0090e0);
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

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

.account-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #11616b;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Layout ===== */
.layout {
  display: flex;
  width: min(100%, 1280px);
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(14px, 2vw, 24px);
  gap: clamp(14px, 2vw, 24px);
  align-items: flex-start;
  position: relative;
  z-index: 1;
}

/* ===== Sidebar — bubble canvas ===== */
.sidebar {
  width: 340px;
  flex-shrink: 0;
  position: sticky;
  top: 72px;
}

/* 3D Carousel — shell holds visual styling; canvas holds only perspective
   Separating them fixes iOS Safari: backdrop-filter/mask on an ancestor
   flattens preserve-3d children, making the carousel invisible. */
.bubble-shell {
  position: relative;
  width: 340px;
  height: calc(100vh - 100px);
  max-height: 640px;
  min-height: 430px;
  border-radius: 24px;
  background: rgba(255,255,255,0.42);
  border: 1.5px solid rgba(100,200,160,0.22);
  box-shadow: 0 8px 32px rgba(0,160,120,0.1), 0 2px 8px rgba(0,0,0,0.06);
}

#bubbleCanvas {
  position: absolute;
  inset: 0;
  cursor: grab;
  user-select: none;
  touch-action: none;
  perspective: 420px;
  perspective-origin: 50% 50%;
}

#bubbleCanvas:active { cursor: grabbing; }

/* Sibling overlay for top/bottom fade — avoids mask-image on 3D ancestor */
.bubble-fade-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0.92) 0%,
    transparent 19%,
    transparent 81%,
    rgba(255,255,255,0.92) 100%
  );
  pointer-events: none;
  z-index: 10;
  border-radius: 24px;
}

#bubbleInner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  transform: rotateX(0deg);
}

.subject-bubble {
  position: absolute;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  background: rgba(255,255,255,0.94);
  border: 2px solid rgba(100,200,160,0.3);
  box-shadow:
    0 5px 18px rgba(0,160,120,0.13),
    0 1px 4px rgba(0,0,0,0.07),
    inset 0 1px 0 rgba(255,255,255,0.9);
  overflow: hidden;
  will-change: transform, opacity;
  transition: opacity 0.08s linear, box-shadow 0.15s;
}

.subject-bubble.active {
  background: linear-gradient(145deg, rgba(0,210,155,0.92), rgba(0,148,228,0.92));
  border-color: rgba(0,230,185,0.45);
  box-shadow:
    0 10px 32px rgba(0,180,140,0.4),
    0 0 0 3px rgba(0,210,170,0.22),
    inset 0 1px 0 rgba(255,255,255,0.3);
  color: white;
}

.bubble-icon { font-size: 1.4rem; line-height: 1; }
.bubble-label { font-size: 0.58rem; font-weight: 700; margin-top: 3px; text-align: center; color: #2a5a4a; line-height: 1.2; }
.subject-bubble.active .bubble-label { color: rgba(255,255,255,0.95); }

/* Apple Watch-style pannable subject picker */
.bubble-shell {
  overflow: hidden;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255,255,255,0.72), rgba(255,255,255,0.36) 58%, rgba(225,246,239,0.4)),
    rgba(255,255,255,0.42);
}

#bubbleCanvas {
  overflow: hidden;
  perspective: none;
}

.bubble-fade-overlay {
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 50%, transparent 42%, rgba(255,255,255,0.3) 75%, rgba(255,255,255,0.86) 100%),
    linear-gradient(
      to bottom,
      rgba(255,255,255,0.68) 0%,
      transparent 18%,
      transparent 82%,
      rgba(255,255,255,0.68) 100%
    );
  box-shadow:
    inset 0 20px 34px rgba(255,255,255,0.45),
    inset 0 -20px 34px rgba(255,255,255,0.45);
}

.bubble-shell::after {
  content: "ドラッグして教科を選択";
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 11;
  transform: translateX(-50%);
  padding: 5px 12px;
  border-radius: 100px;
  background: rgba(255,255,255,0.64);
  color: rgba(42,90,74,0.64);
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0,120,90,0.08);
}

#bubbleInner {
  inset: 0;
  width: auto;
  height: auto;
  transform-style: flat;
  transform: none;
}

.subject-bubble {
  top: 50%;
  left: 50%;
  animation: none !important;
  background:
    radial-gradient(circle at 35% 25%, rgba(255,255,255,0.98), rgba(255,255,255,0.82) 48%, rgba(225,248,240,0.9) 100%);
  box-shadow:
    0 9px 22px rgba(0,160,120,0.16),
    0 2px 7px rgba(0,0,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.95);
  transition:
    opacity 0.12s linear,
    box-shadow 0.18s,
    background 0.18s,
    border-color 0.18s;
  -webkit-tap-highlight-color: transparent;
}

.subject-bubble.node-converging {
  transition:
    transform 0.58s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.42s ease,
    box-shadow 0.42s ease,
    filter 0.42s ease;
  filter: saturate(1.25) brightness(1.08);
}

.subject-bubble::before {
  content: "";
  position: absolute;
  inset: 8px 10px auto;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.72), transparent);
  pointer-events: none;
}

.subject-bubble.active {
  background: radial-gradient(circle at 35% 25%, rgba(95,255,213,0.98), rgba(0,210,155,0.92) 48%, rgba(0,148,228,0.92));
}

.bubble-icon { font-size: 1.45rem; }
.bubble-label {
  max-width: 90%;
  font-size: 0.56rem;
  font-weight: 800;
  line-height: 1.15;
}

/* ===== Main ===== */
.main { flex: 1; min-width: 0; width: 100%; }

/* ===== Glass card base ===== */
.glass-card {
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1.5px solid rgba(100,200,160,0.2);
  border-radius: 24px;
  box-shadow: 0 8px 32px rgba(0,160,120,0.08), 0 2px 8px rgba(0,0,0,0.05);
}

/* ===== Welcome ===== */
.welcome {
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(20px);
  border: 1.5px solid rgba(100,200,160,0.2);
  border-radius: 28px;
  padding: 70px 24px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,160,120,0.1);
}

.welcome-icon { font-size: 3.5rem; margin-bottom: 18px; filter: drop-shadow(0 4px 12px rgba(0,160,120,0.3)); }
.welcome h2 { font-size: 1.4rem; margin-bottom: 10px; color: #00a878; font-weight: 600; }
.welcome p { color: rgba(60,120,100,0.6); }

/* ===== Breadcrumb ===== */
.breadcrumb { font-size: 0.82rem; color: rgba(60,120,100,0.5); margin-bottom: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.breadcrumb span { cursor: pointer; transition: color 0.15s; }
.breadcrumb span:hover { color: #00a878; }
.breadcrumb .sep { color: rgba(0,180,140,0.3); }
.breadcrumb .current { color: #2a6a5a; font-weight: 500; cursor: default; }

/* ===== Unit Grid — floating cards ===== */
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

.unit-card {
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(16px);
  border: 1.5px solid rgba(100,200,160,0.2);
  border-radius: 20px;
  padding: 20px 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 16px rgba(0,160,120,0.08), 0 1px 4px rgba(0,0,0,0.04);
}

.unit-card:hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 16px 40px rgba(0,160,120,0.18), 0 4px 12px rgba(0,0,0,0.08);
  border-color: rgba(0,200,160,0.4);
  background: rgba(255,255,255,0.88);
}

.unit-card h3 { font-size: 0.92rem; margin-bottom: 5px; color: #1a4a3a; font-weight: 500; }
.unit-card p { font-size: 0.72rem; color: rgba(60,120,100,0.5); }

/* ===== Topic chips ===== */
.topic-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.topic-chip {
  background: rgba(255,255,255,0.7);
  border: 1.5px solid rgba(100,200,160,0.25);
  border-radius: 100px;
  padding: 5px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  color: #3a7a6a;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 8px rgba(0,160,120,0.08);
  backdrop-filter: blur(8px);
}

.topic-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,160,120,0.15);
  border-color: rgba(0,200,160,0.5);
}

.topic-chip.active {
  background: linear-gradient(135deg, #00c896, #0090e0);
  border-color: transparent;
  color: white;
  box-shadow: 0 6px 18px rgba(0,180,140,0.3);
  transform: translateY(-2px);
}

/* ===== Search bar ===== */
.search-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }

.search-bar input {
  flex: 1;
  min-width: 160px;
  padding: 11px 18px;
  background: rgba(255,255,255,0.75);
  border: 1.5px solid rgba(100,200,160,0.25);
  border-radius: 100px;
  font-size: 0.9rem;
  color: #1a3a2a;
  outline: none;
  transition: all 0.25s;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(0,160,120,0.08);
}

.search-bar input::placeholder { color: rgba(80,140,120,0.4); }
.search-bar input:focus {
  border-color: rgba(0,200,160,0.5);
  box-shadow: 0 4px 20px rgba(0,180,140,0.15);
  background: rgba(255,255,255,0.92);
}

.search-bar select {
  padding: 11px 14px;
  background: rgba(255,255,255,0.75);
  border: 1.5px solid rgba(100,200,160,0.25);
  border-radius: 100px;
  font-size: 0.83rem;
  color: #3a7a6a;
  cursor: pointer;
  outline: none;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(0,160,120,0.08);
  transition: all 0.25s;
}

.search-bar button {
  background: linear-gradient(135deg, #00c896, #0090e0);
  color: white;
  border: none;
  padding: 11px 22px;
  border-radius: 100px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0,180,140,0.3), 0 2px 6px rgba(0,0,0,0.08);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.search-bar button:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 10px 30px rgba(0,180,140,0.4), 0 4px 10px rgba(0,0,0,0.1);
}

/* ===== API Alert ===== */
.api-alert { background: rgba(255,250,220,0.8); border: 1.5px solid rgba(200,180,50,0.3); border-radius: 14px; padding: 12px 16px; margin-bottom: 14px; font-size: 0.88rem; color: #7a6020; backdrop-filter: blur(8px); }
.api-alert a { color: #0080c0; }

/* ===== Video Grid ===== */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 16px; }

.video-card {
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(16px);
  border: 1.5px solid rgba(100,200,160,0.18);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 20px rgba(0,160,120,0.08), 0 1px 4px rgba(0,0,0,0.04);
}

.video-card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 16px 48px rgba(0,160,120,0.16), 0 4px 12px rgba(0,0,0,0.08);
  border-color: rgba(0,200,160,0.35);
}

.video-thumb { position: relative; padding-top: 56.25%; background: #d4eee6; cursor: pointer; overflow: hidden; }
.video-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.video-card:hover .video-thumb img { transform: scale(1.04); }

.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.25);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 3rem;
  color: white;
  text-shadow: 0 2px 12px rgba(0,120,100,0.4);
}
.video-thumb:hover .play-overlay { opacity: 1; }

.video-iframe-wrap { position: relative; padding-top: 56.25%; }
.video-iframe-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }

.video-info { padding: 12px 14px; }
.video-title { font-size: 0.87rem; font-weight: 500; margin-bottom: 4px; line-height: 1.4; color: #1a3a2a; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-channel { font-size: 0.76rem; color: rgba(60,120,100,0.5); margin-bottom: 8px; }

.video-note-preview { font-size: 0.76rem; color: #7a6020; background: rgba(255,240,180,0.5); border: 1px solid rgba(200,180,50,0.2); border-radius: 8px; padding: 4px 8px; margin-bottom: 8px; line-height: 1.4; }

.thumb-note-preview {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(4, 22, 28, 0.68);
  color: #dffff6;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
  box-shadow: 0 0 18px rgba(0,215,255,0.18);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

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

.btn-action {
  flex: 1;
  padding: 7px 4px;
  border-radius: 100px;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1.5px solid transparent;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.btn-memo { background: rgba(255,248,200,0.8); border-color: rgba(200,180,50,0.25); color: #8a7020; }
.btn-memo:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(180,160,0,0.15); }

.btn-list { background: rgba(200,240,255,0.8); border-color: rgba(0,180,220,0.25); color: #0060a0; }
.btn-list:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,160,220,0.15); }

.btn-ai {
  background: linear-gradient(135deg, rgba(15,205,163,0.92), rgba(0,151,224,0.92));
  border-color: rgba(84,255,218,0.46);
  color: white;
  box-shadow: 0 5px 16px rgba(0,170,190,0.2);
}
.btn-ai:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,160,200,0.3); }

/* ===== Spinner ===== */
.spinner { text-align: center; padding: 48px; color: rgba(0,160,120,0.5); font-size: 0.9rem; letter-spacing: 0.5px; }
.spinner::before { content: "🌿 読み込み中..."; }

/* ===== Page header ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-header h2 { font-size: 1.15rem; font-weight: 600; color: #00a878; }
.page-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-header-actions select { padding: 7px 14px; background: rgba(255,255,255,0.7); border: 1.5px solid rgba(100,200,160,0.25); border-radius: 100px; font-size: 0.82rem; color: #3a7a6a; outline: none; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }

/* ===== History ===== */
.history-group { padding: 4px 0 10px; }
.history-date { font-size: 0.75rem; color: rgba(0,160,120,0.6); font-weight: 600; padding: 4px 0; border-bottom: 1px solid rgba(0,200,160,0.15); margin-bottom: 2px; letter-spacing: 0.5px; }

/* ===== Lists ===== */
.list-section { background: rgba(255,255,255,0.6); backdrop-filter: blur(16px); border: 1.5px solid rgba(100,200,160,0.18); border-radius: 22px; padding: 18px; margin-bottom: 20px; box-shadow: 0 4px 20px rgba(0,160,120,0.07); }
.list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.list-header h3 { font-size: 1rem; font-weight: 500; color: #1a5a4a; }
.list-header-actions { display: flex; align-items: center; gap: 8px; }
.list-count { font-size: 0.78rem; color: rgba(60,120,100,0.45); }
.list-option { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(0,200,160,0.1); font-size: 0.9rem; color: #2a5a4a; }
.list-option:last-child { border-bottom: none; }

.list-video-grid {
  align-items: start;
}

.list-video-card {
  touch-action: manipulation;
}

.list-video-card.dragging {
  opacity: 0.62;
  transform: scale(0.98);
  box-shadow: 0 0 0 2px rgba(0,215,255,0.42), 0 18px 48px rgba(0,92,120,0.24);
}

.list-drag-handle {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  min-width: 48px;
  height: 28px;
  border: 1px solid rgba(143,255,232,0.58);
  border-radius: 999px;
  background: rgba(4, 24, 30, 0.68);
  color: #dffff7;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: grab;
  touch-action: none;
  box-shadow: 0 0 18px rgba(0,215,255,0.24);
  backdrop-filter: blur(10px);
}

.list-drag-handle:active {
  cursor: grabbing;
}

/* ===== Buttons ===== */
.btn-primary-sm {
  background: linear-gradient(135deg, #00c896, #0090e0);
  color: white; border: none; padding: 8px 18px; border-radius: 100px; cursor: pointer; font-size: 0.83rem; font-weight: 600;
  box-shadow: 0 6px 18px rgba(0,180,140,0.28), 0 2px 4px rgba(0,0,0,0.08);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-primary-sm:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 10px 28px rgba(0,180,140,0.38); }

.btn-danger-sm { background: rgba(255,220,220,0.7); color: #c03030; border: 1.5px solid rgba(200,80,80,0.2); padding: 6px 14px; border-radius: 100px; cursor: pointer; font-size: 0.8rem; font-weight: 500; transition: all 0.2s; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.btn-danger-sm:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(200,0,0,0.1); }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; background: rgba(200,240,230,0.3); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; }

.modal-box {
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(24px);
  border: 1.5px solid rgba(0,200,160,0.25);
  border-radius: 28px;
  padding: 28px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 24px 80px rgba(0,160,120,0.18), 0 4px 12px rgba(0,0,0,0.08);
}

.modal-box h3 { margin-bottom: 14px; font-size: 1.1rem; font-weight: 600; color: #00a878; }
.modal-box p { font-size: 0.88rem; color: rgba(40,100,80,0.7); margin-bottom: 14px; line-height: 1.7; }

.modal-box input, .modal-box textarea {
  width: 100%; padding: 10px 16px;
  background: rgba(240,252,248,0.8);
  border: 1.5px solid rgba(100,200,160,0.3);
  border-radius: 14px; font-size: 0.9rem; color: #1a3a2a; margin-bottom: 14px; outline: none; font-family: inherit; resize: vertical; transition: all 0.2s;
}
.modal-box input:focus, .modal-box textarea:focus { border-color: rgba(0,200,160,0.6); box-shadow: 0 0 0 3px rgba(0,200,160,0.1); }
.modal-box input::placeholder, .modal-box textarea::placeholder { color: rgba(80,140,120,0.4); }

.memo-video-info { display: flex; align-items: center; margin-bottom: 12px; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; }

.auth-modal-box {
  max-width: 480px;
}

.auth-wide-btn {
  width: 100%;
  margin-bottom: 12px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  color: rgba(40,100,80,0.5);
  font-size: 0.78rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(0,200,160,0.14);
}

.auth-help {
  margin-top: 12px;
  margin-bottom: 0 !important;
  font-size: 0.74rem !important;
  color: rgba(40,100,80,0.5) !important;
}

.auth-link-btn {
  display: block;
  width: fit-content;
  margin: 12px auto 0;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: #008ab8;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
}

.auth-link-btn:hover {
  color: #00a878;
  text-decoration: underline;
}

.auth-btn.is-syncing {
  color: #007f85;
  border-color: rgba(0,215,255,0.45);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.5), 0 0 18px rgba(0,215,255,0.18);
}

.auth-btn.is-disabled,
.auth-modal-box button:disabled {
  opacity: 0.62;
  cursor: wait;
  transform: none;
}

.btn-primary { background: linear-gradient(135deg, #00c896, #0090e0); color: white; border: none; padding: 9px 24px; border-radius: 100px; cursor: pointer; font-weight: 600; font-size: 0.88rem; box-shadow: 0 6px 18px rgba(0,180,140,0.3); transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,180,140,0.4); }

.btn-secondary { background: rgba(240,252,248,0.9); color: #3a7a6a; border: 1.5px solid rgba(100,200,160,0.25); padding: 9px 24px; border-radius: 100px; cursor: pointer; font-weight: 500; font-size: 0.88rem; transition: all 0.2s; }
.btn-secondary:hover { background: rgba(220,248,240,0.95); transform: translateY(-1px); }

.btn-ai-secondary {
  background: rgba(224,250,247,0.92);
  color: #007b85;
  border: 1.5px solid rgba(0,190,190,0.3);
  padding: 9px 18px;
  border-radius: 100px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.84rem;
  transition: all 0.2s;
}
.btn-ai-secondary:hover { background: rgba(205,247,244,0.98); transform: translateY(-1px); }

/* ===== AI復習セット ===== */
.ai-review-modal-box {
  max-width: 760px;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ai-review-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.ai-review-header h3 {
  margin: 3px 0 0;
  color: #103f43;
  font-size: 1.25rem;
  line-height: 1.35;
}

.ai-review-kicker,
.ai-review-focus {
  display: inline-flex;
  width: fit-content;
  padding: 4px 10px;
  border: 1px solid rgba(0,190,190,0.24);
  border-radius: 100px;
  background: rgba(221,251,245,0.82);
  color: #008f82;
  font-size: 0.7rem;
  font-weight: 800;
}

.ai-review-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(0,160,150,0.18);
  border-radius: 50%;
  background: rgba(245,255,252,0.9);
  color: #36706a;
  cursor: pointer;
  font-size: 0.88rem;
}

.ai-review-source {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 16px;
  border-bottom: 1px solid rgba(0,170,155,0.14);
}

.ai-review-source img {
  flex: 0 0 auto;
  width: 104px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: #d8eee8;
}

.ai-review-source div {
  min-width: 0;
}

.ai-review-source strong {
  display: -webkit-box;
  overflow: hidden;
  color: #153f3a;
  font-size: 0.86rem;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ai-review-source span {
  display: block;
  margin-top: 5px;
  color: rgba(31,91,82,0.58);
  font-size: 0.72rem;
}

.ai-review-inputs {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  padding: 16px 0 4px;
}

.ai-review-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
  color: #315f58;
  font-size: 0.76rem;
  font-weight: 700;
}

.ai-review-field select,
.ai-review-field textarea {
  margin: 0;
}

.ai-review-field small {
  align-self: flex-end;
  color: rgba(40,100,80,0.46);
  font-size: 0.66rem;
  font-weight: 500;
}

.ai-review-disclosure {
  margin: 8px 0 10px !important;
  padding-left: 10px;
  border-left: 2px solid rgba(0,177,176,0.28);
  color: rgba(37,90,82,0.58) !important;
  font-size: 0.72rem !important;
  line-height: 1.55 !important;
}

.ai-review-status {
  min-height: 42px;
  margin: 10px 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(0,160,150,0.16);
  border-radius: 8px;
  background: rgba(239,252,248,0.78);
  color: #42736b;
  font-size: 0.76rem;
  line-height: 1.5;
}

.ai-review-status.is-loading {
  background: rgba(226,250,249,0.92);
  color: #007c89;
}

.ai-review-status.is-loading::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border: 2px solid rgba(0,150,170,0.2);
  border-top-color: #00a9b5;
  border-radius: 50%;
  animation: ai-spin 0.7s linear infinite;
}

.ai-review-status.is-success,
.ai-review-status.is-cached {
  border-color: rgba(0,175,125,0.2);
  background: rgba(231,252,242,0.9);
  color: #087451;
}

.ai-review-status.is-warning,
.ai-review-status.is-error {
  border-color: rgba(215,140,50,0.24);
  background: rgba(255,248,229,0.9);
  color: #865a20;
}

.ai-review-result {
  padding: 4px 0 6px;
}

.ai-review-result h4 {
  margin: 10px 0;
  color: #174d48;
  font-size: 0.92rem;
}

.ai-review-summary {
  padding: 4px 0 14px;
  border-bottom: 1px solid rgba(0,160,145,0.14);
}

.ai-review-summary ol {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 22px;
  color: #275a53;
  font-size: 0.82rem;
  line-height: 1.55;
}

.ai-review-section {
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,160,145,0.14);
}

.ai-question-list {
  display: grid;
  gap: 8px;
}

.ai-question {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 9px;
  padding: 11px;
  border: 1px solid rgba(0,160,150,0.14);
  border-radius: 8px;
  background: rgba(248,255,252,0.72);
}

.ai-question-number {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ccaa2, #079bd4);
  color: white;
  font-size: 0.72rem;
  font-weight: 800;
}

.ai-question-body {
  min-width: 0;
}

.ai-question-text {
  margin: 2px 0 7px !important;
  color: #163f3b !important;
  font-size: 0.83rem !important;
  font-weight: 700;
  line-height: 1.55 !important;
}

.ai-question-hint {
  margin: 0 0 8px !important;
  color: #53786f !important;
  font-size: 0.74rem !important;
  line-height: 1.5 !important;
}

.ai-question details {
  padding-top: 7px;
  border-top: 1px dashed rgba(0,150,140,0.18);
}

.ai-question summary {
  width: fit-content;
  color: #008b91;
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 800;
}

.ai-question details strong {
  display: block;
  margin-top: 9px;
  color: #12654f;
  font-size: 0.82rem;
  line-height: 1.55;
}

.ai-question details p {
  margin: 6px 0 0 !important;
  color: #486e66 !important;
  font-size: 0.75rem !important;
  line-height: 1.55 !important;
}

.ai-review-insights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 0 2px;
}

.ai-review-insights section {
  padding: 11px 12px;
  border: 1px solid rgba(0,160,150,0.14);
  border-radius: 8px;
  background: rgba(240,253,249,0.72);
}

.ai-review-insights span {
  color: #008b79;
  font-size: 0.68rem;
  font-weight: 800;
}

.ai-review-insights p {
  margin: 5px 0 0 !important;
  color: #315f58 !important;
  font-size: 0.75rem !important;
  line-height: 1.55 !important;
}

.ai-review-actions {
  position: sticky;
  bottom: -28px;
  z-index: 2;
  margin: 12px -28px -28px;
  padding: 14px 28px 18px;
  border-top: 1px solid rgba(0,170,150,0.12);
  background: rgba(250,255,253,0.94);
  backdrop-filter: blur(18px);
}

.ai-review-actions button:disabled {
  opacity: 0.58;
  cursor: wait;
  transform: none;
}

@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

/* ===== ご意見モーダル ===== */
.modal-box select {
  width: 100%;
  padding: 10px 16px;
  background: rgba(240,252,248,0.8);
  border: 1.5px solid rgba(100,200,160,0.3);
  border-radius: 14px;
  font-size: 0.9rem;
  color: #1a3a2a;
  margin-bottom: 12px;
  outline: none;
  font-family: inherit;
  cursor: pointer;
}

.feedback-status {
  font-size: 0.82rem;
  margin-bottom: 10px;
  color: #00a878;
}

.feedback-status.is-error { color: #c03030; }

/* ===== 受信箱（開発者用） ===== */
.inbox-box {
  max-width: 560px;
  max-height: 82vh;
  overflow-y: auto;
}

.inbox-item {
  background: rgba(240,252,248,0.75);
  border: 1.5px solid rgba(100,200,160,0.25);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.inbox-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 0.72rem;
  color: rgba(60,120,100,0.65);
  margin-bottom: 6px;
}

.inbox-cat {
  background: linear-gradient(135deg, #00c896, #0090e0);
  color: white;
  padding: 2px 10px;
  border-radius: 100px;
  font-weight: 700;
}

.inbox-text {
  font-size: 0.88rem;
  color: #1a3a2a;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 8px;
}

/* ===== ホーム画面追加バナー (A2HS) ===== */
.a2hs-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1.5px solid rgba(0,200,160,0.35);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0,120,90,0.25), 0 2px 8px rgba(0,0,0,0.08);
  animation: a2hsIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

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

.a2hs-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(0,150,120,0.3);
}

.a2hs-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.a2hs-text strong { font-size: 0.86rem; color: #1a4a3a; }
.a2hs-text span { font-size: 0.74rem; color: rgba(40,100,80,0.75); line-height: 1.45; }

.a2hs-btn {
  background: linear-gradient(135deg, #00c896, #0090e0);
  color: white;
  border: none;
  padding: 9px 18px;
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,180,140,0.35);
  flex-shrink: 0;
}

.a2hs-close {
  background: none;
  border: none;
  color: rgba(60,120,100,0.55);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
  line-height: 1;
}

/* ===== Toast ===== */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px); background: rgba(255,255,255,0.9); backdrop-filter: blur(16px); border: 1.5px solid rgba(0,200,160,0.3); color: #00a878; padding: 10px 24px; border-radius: 100px; font-size: 0.88rem; font-weight: 500; opacity: 0; transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); z-index: 300; white-space: nowrap; box-shadow: 0 8px 32px rgba(0,160,120,0.2); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Empty & Error ===== */
.empty-msg { text-align: center; color: rgba(60,120,100,0.4); padding: 48px 16px; font-size: 0.9rem; }
.error-msg { color: #c04040; padding: 16px; }

/* ===== Hidden ===== */
.hidden { display: none !important; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(200,240,230,0.3); }
::-webkit-scrollbar-thumb { background: rgba(0,180,140,0.25); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,200,160,0.4); }

/* ===== Bubble float animations (14 variants) ===== */
@keyframes bf0  { 0%,100%{transform:translate(0,0) scale(1)}   30%{transform:translate(14px,-18px) scale(1.05)} 70%{transform:translate(-10px,12px) scale(0.97)} }
@keyframes bf1  { 0%,100%{transform:translate(0,0) scale(1)}   25%{transform:translate(-16px,10px) scale(1.04)} 65%{transform:translate(12px,-14px) scale(0.96)} }
@keyframes bf2  { 0%,100%{transform:translate(0,0) scale(1)}   40%{transform:translate(10px,16px) scale(1.06)}  75%{transform:translate(-14px,-8px) scale(0.95)} }
@keyframes bf3  { 0%,100%{transform:translate(0,0) scale(1)}   35%{transform:translate(-12px,-14px) scale(1.04)} 60%{transform:translate(16px,10px) scale(0.97)} }
@keyframes bf4  { 0%,100%{transform:translate(0,0) scale(1)}   45%{transform:translate(18px,-10px) scale(1.05)} 80%{transform:translate(-8px,16px) scale(0.96)} }
@keyframes bf5  { 0%,100%{transform:translate(0,0) scale(1)}   20%{transform:translate(-10px,18px) scale(1.03)} 55%{transform:translate(14px,-12px) scale(0.98)} }
@keyframes bf6  { 0%,100%{transform:translate(0,0) scale(1)}   50%{transform:translate(12px,12px) scale(1.06)}  85%{transform:translate(-16px,-6px) scale(0.95)} }
@keyframes bf7  { 0%,100%{transform:translate(0,0) scale(1)}   30%{transform:translate(-14px,-10px) scale(1.04)} 70%{transform:translate(10px,18px) scale(0.97)} }
@keyframes bf8  { 0%,100%{transform:translate(0,0) scale(1)}   40%{transform:translate(16px,8px) scale(1.05)}  75%{transform:translate(-12px,-16px) scale(0.96)} }
@keyframes bf9  { 0%,100%{transform:translate(0,0) scale(1)}   25%{transform:translate(-8px,14px) scale(1.03)}  60%{transform:translate(18px,-10px) scale(0.98)} }
@keyframes bf10 { 0%,100%{transform:translate(0,0) scale(1)}   35%{transform:translate(10px,-16px) scale(1.06)} 65%{transform:translate(-16px,10px) scale(0.95)} }
@keyframes bf11 { 0%,100%{transform:translate(0,0) scale(1)}   55%{transform:translate(-18px,8px) scale(1.04)}  80%{transform:translate(12px,-14px) scale(0.97)} }
@keyframes bf12 { 0%,100%{transform:translate(0,0) scale(1)}   30%{transform:translate(14px,14px) scale(1.05)}  70%{transform:translate(-10px,-12px) scale(0.96)} }
@keyframes bf13 { 0%,100%{transform:translate(0,0) scale(1)}   45%{transform:translate(-12px,-18px) scale(1.03)} 75%{transform:translate(16px,8px) scale(0.98)} }

/* Apply float animations to bubbles */
.subject-bubble:nth-child(1)  { animation: bf0  7.2s ease-in-out infinite; }
.subject-bubble:nth-child(2)  { animation: bf1  8.5s ease-in-out infinite; }
.subject-bubble:nth-child(3)  { animation: bf2  6.8s ease-in-out infinite; }
.subject-bubble:nth-child(4)  { animation: bf3  9.1s ease-in-out infinite; }
.subject-bubble:nth-child(5)  { animation: bf4  7.7s ease-in-out infinite; }
.subject-bubble:nth-child(6)  { animation: bf5  8.3s ease-in-out infinite; }
.subject-bubble:nth-child(7)  { animation: bf6  6.5s ease-in-out infinite; }
.subject-bubble:nth-child(8)  { animation: bf7  9.4s ease-in-out infinite; }
.subject-bubble:nth-child(9)  { animation: bf8  7.0s ease-in-out infinite; }
.subject-bubble:nth-child(10) { animation: bf9  8.8s ease-in-out infinite; }
.subject-bubble:nth-child(11) { animation: bf10 6.3s ease-in-out infinite; }
.subject-bubble:nth-child(12) { animation: bf11 9.6s ease-in-out infinite; }
.subject-bubble:nth-child(13) { animation: bf12 7.4s ease-in-out infinite; }
.subject-bubble:nth-child(14) { animation: bf13 8.1s ease-in-out infinite; }

/* Pause float on hover/drag */
.subject-bubble:hover, .subject-bubble:active { animation-play-state: paused; }

/* ===== Depth scroll entrance animation ===== */
@keyframes depthIn {
  from {
    opacity: 0;
    transform: perspective(700px) translateZ(-120px) translateY(28px) scale(0.82);
  }
  to {
    opacity: 1;
    transform: perspective(700px) translateZ(0px) translateY(0px) scale(1);
  }
}

.depth-in {
  animation: depthIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
/* stagger delays for grid items */
.depth-in:nth-child(2)  { animation-delay: 0.04s; }
.depth-in:nth-child(3)  { animation-delay: 0.08s; }
.depth-in:nth-child(4)  { animation-delay: 0.12s; }
.depth-in:nth-child(5)  { animation-delay: 0.16s; }
.depth-in:nth-child(6)  { animation-delay: 0.20s; }
.depth-in:nth-child(7)  { animation-delay: 0.24s; }
.depth-in:nth-child(8)  { animation-delay: 0.28s; }

/* ===== Mobile subject grid (desktop: hidden) ===== */
.mobile-subject-grid { display: none; }

.mobile-subject-card {
  background: rgba(255,255,255,0.7);
  border: 1.5px solid rgba(100,200,160,0.25);
  border-radius: 16px;
  padding: 14px 6px 10px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  box-shadow: 0 3px 12px rgba(0,160,120,0.08);
  -webkit-tap-highlight-color: transparent;
}

.mobile-subject-card:active { transform: scale(0.93); }
.mobile-subject-card .sub-icon { font-size: 1.8rem; display: block; margin-bottom: 4px; }
.mobile-subject-card .sub-name { font-size: 0.7rem; font-weight: 600; color: #2a5a4a; line-height: 1.3; }

/* ===== Back button (mobile only, hidden on desktop) ===== */
.mobile-back-btn {
  display: none;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.75);
  border: 1.5px solid rgba(100,200,160,0.3);
  border-radius: 100px;
  padding: 8px 18px;
  font-size: 0.85rem;
  color: #3a7a6a;
  cursor: pointer;
  margin-bottom: 14px;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  backdrop-filter: blur(8px);
  transition: all 0.2s;
}
.mobile-back-btn:active { transform: scale(0.96); }

@media (min-width: 1100px) {
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .unit-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

@media (max-width: 1024px) {
  .layout {
    max-width: 100%;
    padding: 14px;
    gap: 14px;
  }

  .sidebar {
    width: 280px;
    top: 68px;
  }

  .bubble-shell {
    width: 280px;
    height: calc(100vh - 92px);
    border-radius: 20px;
  }

  #bubbleCanvas { perspective: none; }
  .bubble-fade-overlay { border-radius: 20px; }
  .unit-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
  /* Layout: sidebar on top, full width */
  body { min-height: 100dvh; }
  .layout { flex-direction: column; padding: 10px; gap: 10px; }
  .sidebar { width: 100%; position: static; }

  /* Bubble shell: tall, full width */
  .bubble-shell {
    width: 100%;
    height: calc(100dvh - 104px);
    min-height: 620px;
    border-radius: 20px;
    max-height: none;
  }

  /* Bubble size on mobile */
  .bubble-icon { font-size: 1.6rem; }
  .bubble-label { font-size: 0.58rem; }

  /* Hide sidebar once subject selected */
  body.subject-selected .sidebar { display: none; }

  /* Welcome: keep visible to show subject grid; hide desktop text */
  .welcome {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    box-shadow: none;
    padding: 12px 0;
    border-radius: 0;
  }
  .welcome-inner { display: none; }
  .mobile-subject-grid {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;
  }

  /* Back button visible on mobile */
  .mobile-back-btn { display: flex; }

  /* Header */
  header { padding: 8px 14px; }
  header h1 { font-size: 1.05rem; }
  .header-inner { gap: 8px; align-items: center; }
  .header-nav { flex: 1 1 100%; gap: 6px; }
  .nav-btn { flex: 1; padding: 8px 10px; font-size: 0.76rem; text-align: center; }
  .auth-area { margin-left: auto; }
  .auth-btn { padding: 7px 10px; font-size: 0.72rem; }

  /* Unit grid */
  .unit-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .unit-card { padding: 16px 10px; }
  .unit-card h3 { font-size: 0.88rem; }

  /* Topic chips */
  .topic-chip { font-size: 0.78rem; padding: 5px 11px; }

  /* Search bar */
  .search-bar {
    flex-direction: column;
    gap: 8px;
    position: sticky;
    top: 91px;
    z-index: 20;
    padding: 8px;
    margin: 0 -2px 14px;
    border-radius: 18px;
    background: rgba(232,244,240,0.86);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  .search-bar input { width: 100%; min-width: unset; }
  .search-bar select, .search-bar button { width: 100%; min-height: 42px; }

  /* Video grid: 1 column full width */
  .video-grid { grid-template-columns: 1fr; gap: 12px; }
  .video-card { border-radius: 16px; }
  .video-title { font-size: 0.9rem; }
  .video-channel { font-size: 0.78rem; }
  .btn-action { padding: 9px 4px; font-size: 0.8rem; }

  /* History/Lists */
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header-actions { width: 100%; }
  .page-header-actions select { flex: 1; }

  /* Modal */
  .modal-box { padding: 20px 16px; border-radius: 20px; }
  .ai-review-modal-box { max-height: 94dvh; }
  .ai-review-inputs { grid-template-columns: 1fr; }
  .ai-review-insights { grid-template-columns: 1fr; }
  .ai-review-actions {
    bottom: -20px;
    margin: 12px -16px -20px;
    padding: 12px 16px 14px;
  }
}

@media (max-width: 480px) {
  .layout { padding: 8px; }
  header { padding: 7px 10px; }
  .bubble-shell {
    height: calc(100dvh - 104px);
    min-height: 620px;
  }

  .mobile-subject-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .mobile-subject-card {
    min-height: 82px;
    padding: 12px 8px;
  }

  .unit-grid { grid-template-columns: 1fr; }
  .unit-card {
    min-height: 74px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .topic-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .topic-chips::-webkit-scrollbar { display: none; }
  .topic-chip { flex: 0 0 auto; }
  .video-actions { gap: 8px; }
  .btn-action { min-height: 40px; font-size: 0.73rem; }
  .page-header-actions { flex-direction: column; align-items: stretch; }
  .page-header-actions select,
  .page-header-actions button { width: 100%; }
  .modal-btns { flex-wrap: wrap; }
  .ai-review-source img { width: 86px; }
  .ai-review-header h3 { font-size: 1.02rem; }
  .ai-question { grid-template-columns: 28px minmax(0, 1fr); padding: 9px; }
  .ai-review-actions button { flex: 1 1 140px; }
}

/* ===== Future Nature concept layer ===== */
:root {
  --bio-bg: #dff8f1;
  --bio-ink: #092c34;
  --bio-cyan: #00d7ff;
  --bio-mint: #35f3ad;
  --bio-lime: #b8ff6f;
  --bio-glass: rgba(236, 255, 249, 0.58);
}

body {
  color: var(--bio-ink);
  background:
    radial-gradient(circle at 16% 18%, rgba(65,255,190,0.12), transparent 26%),
    radial-gradient(circle at 82% 10%, rgba(0,215,255,0.12), transparent 28%),
    linear-gradient(145deg, #d8f4ed 0%, #d7f6ff 48%, #def8df 100%);
}

body::before {
  background:
    linear-gradient(rgba(130,255,235,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(130,255,235,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(234,255,250,0.08), rgba(234,255,255,0.02) 44%, rgba(232,255,238,0.06)),
    radial-gradient(ellipse 95% 62% at 58% 14%, rgba(180,255,244,0.18), transparent 66%),
    url("assets/future-school-hero.png"),
    linear-gradient(160deg, #e7fff8 0%, #dff8ff 48%, #e9ffe7 100%);
  background-size: 34px 34px, 34px 34px, auto, auto, cover, auto;
  background-position: top left, top left, center, center, center top, center;
}

body::after {
  background:
    radial-gradient(circle 320px at 12% 18%, rgba(53,243,173,0.1), transparent 70%),
    radial-gradient(circle 420px at 82% 18%, rgba(0,215,255,0.1), transparent 70%),
    radial-gradient(circle 260px at 70% 82%, rgba(184,255,111,0.08), transparent 70%);
  mix-blend-mode: normal;
}

header {
  background: rgba(234, 255, 248, 0.62);
  border-bottom: 1px solid rgba(0,215,255,0.22);
  box-shadow: 0 2px 28px rgba(0,125,145,0.1);
}

header h1 {
  background: linear-gradient(135deg, #00b889, #00aeea 52%, #73d94a);
  -webkit-background-clip: text;
  background-clip: text;
}

.nav-btn {
  background: rgba(255,255,255,0.52);
  border-color: rgba(0,215,255,0.28);
  color: #11616b;
}

.nav-btn.active {
  background: linear-gradient(135deg, #00d2a0, #00a8f0);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.5), 0 10px 30px rgba(0,184,210,0.28);
}

.bubble-shell {
  background:
    radial-gradient(circle at 50% 42%, rgba(255,255,255,0.78), rgba(213,255,244,0.46) 48%, rgba(0,190,180,0.12) 100%),
    linear-gradient(150deg, rgba(255,255,255,0.82), rgba(226,255,247,0.5));
  border: 1px solid rgba(0,215,255,0.28);
  box-shadow:
    0 18px 54px rgba(0,132,150,0.14),
    inset 0 0 0 1px rgba(255,255,255,0.46),
    inset 0 0 58px rgba(53,243,173,0.1);
}

.bubble-shell::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 24px;
  background:
    linear-gradient(rgba(0,215,255,0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,215,255,0.1) 1px, transparent 1px),
    radial-gradient(circle at 50% 46%, transparent 0 38%, rgba(53,243,173,0.16) 39%, transparent 41%);
  background-size: 28px 28px, 28px 28px, auto;
  opacity: 0.55;
  pointer-events: none;
}

.bubble-shell::after {
  content: "ドラッグで教科を選ぶ";
  bottom: 16px;
  background: rgba(239,255,251,0.74);
  color: rgba(0,105,118,0.72);
  border: 1px solid rgba(0,215,255,0.2);
  letter-spacing: 0;
}

.bubble-fade-overlay {
  background:
    radial-gradient(circle at 50% 50%, transparent 40%, rgba(227,255,248,0.22) 72%, rgba(245,255,252,0.86) 100%),
    linear-gradient(to bottom, rgba(245,255,252,0.62), transparent 18%, transparent 82%, rgba(245,255,252,0.62));
}

.subject-bubble {
  border-color: rgba(0,215,255,0.34);
  background:
    radial-gradient(circle at 32% 24%, rgba(255,255,255,1), rgba(232,255,250,0.95) 42%, rgba(182,255,229,0.78) 100%);
  box-shadow:
    0 0 30px rgba(0,215,255,0.22),
    0 12px 28px rgba(0,120,130,0.18),
    inset 0 1px 0 rgba(255,255,255,0.98);
}

.subject-bubble::before {
  inset: 7px 9px auto;
  height: 17px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.85), transparent);
}

.subject-bubble::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid rgba(0,215,255,0.32);
  box-shadow: 0 0 18px rgba(53,243,173,0.24);
  opacity: var(--node-glow, 0.45);
  pointer-events: none;
}

.subject-bubble:hover {
  border-color: rgba(53,243,173,0.78);
  box-shadow:
    0 0 34px rgba(0,215,255,0.34),
    0 16px 36px rgba(0,120,130,0.2),
    inset 0 1px 0 rgba(255,255,255,0.98);
}

.subject-bubble.active {
  background:
    radial-gradient(circle at 32% 24%, #f8fffd, rgba(53,243,173,0.95) 42%, rgba(0,148,228,0.92) 100%);
  border-color: rgba(184,255,111,0.76);
}

.bubble-icon {
  font-size: 1.65rem;
  filter: drop-shadow(0 0 8px rgba(0,215,255,0.32));
}

.bubble-label {
  color: #0a545d;
  font-size: 0.64rem;
  font-weight: 900;
  text-shadow:
    0 1px 0 rgba(255,255,255,0.92),
    0 0 8px rgba(255,255,255,0.74);
}

.welcome,
.unit-card,
.video-card,
.modal-box {
  background: rgba(244,255,251,0.62);
  border-color: rgba(0,215,255,0.18);
}

.welcome {
  position: relative;
  overflow: visible;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.welcome::before {
  display: none;
}

.welcome-inner {
  position: relative;
  z-index: 1;
}

.welcome-icon {
  filter: drop-shadow(0 0 18px rgba(0,215,255,0.34));
}

.welcome h2 {
  color: #00a987;
  text-shadow: 0 0 18px rgba(53,243,173,0.32), 0 1px 0 rgba(255,255,255,0.8);
}

.welcome p {
  color: rgba(9,44,52,0.68);
  font-weight: 500;
}

@media (max-width: 768px) {
  .bubble-shell::before { inset: 12px; border-radius: 18px; }
  .bubble-shell::after { bottom: 13px; font-size: 0.62rem; }
  #welcomeView.welcome { display: none; }
  body::before {
    background:
      linear-gradient(rgba(130,255,235,0.08) 1px, transparent 1px),
      linear-gradient(90deg, rgba(130,255,235,0.08) 1px, transparent 1px),
      linear-gradient(145deg, rgba(235,255,250,0.1), rgba(235,255,255,0.02) 46%, rgba(235,255,238,0.08)),
      url("assets/future-school-hero.png");
    background-size: 28px 28px, 28px 28px, auto, cover;
    background-position: top left, top left, center, 18% top;
  }
}

/* Floating subject nodes directly over the background */
.bubble-shell {
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}

.bubble-shell::before {
  display: none;
}

.bubble-shell::after {
  display: none;
}

.bubble-fade-overlay {
  display: none;
}

#bubbleCanvas {
  overflow: visible;
}

.subject-bubble.dragging {
  cursor: grabbing;
  filter: saturate(1.18) brightness(1.06);
  box-shadow:
    0 0 42px rgba(0,215,255,0.42),
    0 20px 44px rgba(0,120,130,0.24),
    inset 0 1px 0 rgba(255,255,255,0.98);
}

@media (max-width: 768px) {
  .bubble-shell::before {
    inset: 0;
    border-radius: 18px;
  }
  .bubble-shell::after { display: none; }
}
