/* ============================================
   Studylink Journal — Styles
   ============================================ */

:root {
  --bg: #b8dcf2;
  --surface: #ffffff;
  --text: #2c2c2c;
  --text-muted: #777;
  --border: #e5e1d6;
  --primary: #6b9b76;
  --primary-hover: #588462;
  --secondary: #5b8def;
  --secondary-hover: #4a78d4;
  --accent: #e8a87c;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --radius-small: 6px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

/* ============================================
   Modal
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 960px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-hover);
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-size: 1.1rem;
  margin: 0;
}
.modal-body {
  padding: 16px 20px;
  overflow: auto;
}

/* 誤操作防止の「入力して確認」ダイアログ */
.modal-content--dialog { max-width: 440px; }
.confirm-warning ul { margin: 8px 0 0; padding-left: 20px; }
.confirm-warning li { margin: 2px 0; }
.confirm-typed-label { margin: 14px 0 6px; }
.confirm-typed-input { width: 100%; }
.confirm-typed-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.confirm-typed-go:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================
   Activity Log
   ============================================ */
.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.activity-table th,
.activity-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.activity-table th {
  background: #f7f3e8;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  position: sticky;
  top: 0;
}
.activity-table tr:hover td {
  background: #faf8f0;
}
.nowrap { white-space: nowrap; }

.activity-action {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.activity-action-login { background: #e7f1ff; color: #2c5db3; }
.activity-action-entry_created { background: #eaf6ec; color: #2e7036; }
.activity-action-entry_deleted { background: #fae3e3; color: #a53030; }
.activity-action-comment_created { background: #f3edd9; color: #7a5c10; }
.activity-action-comment_deleted { background: #fae3e3; color: #a53030; }
.activity-action-read_marked { background: #ede4f4; color: #5b3f80; }
.activity-action-read_cleared { background: #eee; color: #555; }

/* ============================================
   Students Management Table
   ============================================ */
.students-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.students-table th,
.students-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.students-table th {
  background: #f7f3e8;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.student-name-input {
  width: 100%;
  min-width: 120px;
}

.btn-danger {
  color: #a53030 !important;
}
.btn-danger:hover {
  background: #fae3e3 !important;
}

.info-box {
  background: #fff8e1;
  border-left: 3px solid #e8a87c;
  padding: 12px 14px;
  border-radius: var(--radius-small);
  font-size: 0.9rem;
}
.info-box code {
  background: rgba(0,0,0,0.06);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}
.info-box a {
  color: #2c5db3;
  text-decoration: underline;
  font-weight: 600;
}
.info-box a:hover { color: #1e4a99; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
               "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3 { margin: 0 0 0.5em; }

p { margin: 0 0 0.5em; }

.muted { color: var(--text-muted); }
.small { font-size: 0.85em; }

/* ============================================
   Layout
   ============================================ */
.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 600;
}

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

.app-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.card-title {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--text);
}

.section-title {
  font-size: 1.1rem;
  margin: 24px 0 16px;
  padding-left: 4px;
}

.entries-section {
  margin-top: 8px;
}

/* ============================================
   Login Card
   ============================================ */
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 32px;
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.brand {
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.3;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.login-note {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================
   Forms
   ============================================ */
.input, .textarea, .select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  font-family: inherit;
  font-size: 0.95rem;
  background: #fdfcf8;
  color: var(--text);
  margin-bottom: 12px;
}

.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

.textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='%23777' d='M4 6l4 4 4-4z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 32px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 140px;
}

.field-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.field .select {
  margin-bottom: 0;
}

.row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.controls-row > * { margin-bottom: 0; }

.news-accordion {
  background: #fffbe6;
  border: 1px solid #f2d97a;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.85rem;
  overflow: hidden;
}

.news-accordion > summary {
  cursor: pointer;
  padding: 8px 14px;
  font-weight: 600;
  color: #8a6d1f;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.news-accordion > summary::-webkit-details-marker { display: none; }
.news-accordion > summary::marker { content: ''; }

.news-accordion > summary::after {
  content: '▼';
  font-size: 0.7rem;
  margin-left: auto;
  transition: transform 0.2s;
}

.news-accordion[open] > summary::after {
  transform: rotate(180deg);
}

/* アコーディオンと同じ見た目の外部リンク行（リトリバなど） */
a.news-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-weight: 600;
  color: #8a6d1f;
  text-decoration: none;
}
a.news-link::after {
  content: '↗';
  font-size: 0.8rem;
  margin-left: auto;
}
a.news-link:hover { background: #fff3c4; }

/* スタディリンクの外部アプリへのショートカット */
.external-app-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

a.external-app-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid #f2d97a;
  border-radius: var(--radius);
  background: #fffbe6;
  color: #8a6d1f;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}

a.external-app-link:hover {
  background: #fff3c4;
  transform: translateY(-1px);
}

a.external-app-link span {
  font-size: 0.8rem;
}


/* 生徒・先生共通：2列のショートカットと「その他」の展開領域 */
.dashboard-shortcuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.dashboard-shortcut {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 56px;
  padding: 12px 14px;
  border: 1px solid #e7ca69;
  border-radius: var(--radius);
  background: #fffbe6;
  color: #725819;
  box-shadow: var(--shadow);
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.dashboard-shortcut:hover,
.dashboard-shortcut[aria-expanded="true"] {
  background: #fff0b8;
  border-color: #b99632;
}

.dashboard-shortcut:focus-visible {
  outline: 3px solid #725819;
  outline-offset: 3px;
}

.dashboard-shortcut-icon { font-size: 1.25rem; }
.dashboard-shortcut-label { min-width: 0; overflow-wrap: anywhere; }
.dashboard-shortcut-indicator { margin-left: auto; flex-shrink: 0; }
.dashboard-shortcut[aria-expanded="true"] .dashboard-more-chevron { transform: rotate(180deg); }
.dashboard-more-panel { grid-column: 1 / -1; min-width: 0; }
.dashboard-more-panel .news-accordion { margin-bottom: 8px; }
.dashboard-more-panel .news-accordion:last-child { margin-bottom: 0; }

@media (max-width: 600px) {
  .dashboard-shortcuts { gap: 8px; }
  .dashboard-shortcut { gap: 5px; padding: 10px; font-size: 0.85rem; }
  .dashboard-shortcut-icon { font-size: 1.1rem; }
}

.news-body {
  padding: 4px 14px 12px;
  color: #5a4a18;
  line-height: 1.6;
  border-top: 1px dashed #f2d97a;
}

.news-body ul {
  margin: 6px 0;
  padding-left: 1.2em;
}

.news-body li {
  margin: 4px 0;
}

.news-body .news-date {
  font-weight: 700;
  color: #8a6d1f;
  margin-top: 8px;
  display: block;
}

.news-body .news-date:first-child { margin-top: 0; }

/* ============================================
   ホームルームの資料（materials バケット）
   ============================================ */
.material-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  margin: 8px 0;
  overflow: hidden;
}

.material-item > summary {
  cursor: pointer;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}

.material-item[open] > summary {
  border-bottom: 1px dashed var(--border);
}

.material-body {
  padding: 8px 12px 12px;
  color: var(--text);
}

.material-text {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  line-height: 1.8;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.material-images-acc > summary {
  cursor: pointer;
  color: var(--secondary);
  font-weight: 600;
  user-select: none;
  padding: 4px 0;
}

.material-images img {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  border-radius: var(--radius-small);
  border: 1px solid var(--border);
  margin: 8px auto;
}

.filter-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filter-bar .field { min-width: 180px; }
.filter-bar .input { margin-bottom: 0; }

.filter-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.filter-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.study-jump-card {
  padding: 12px 16px;
}

.study-jump-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#study-live-card,
#study-selector-card,
#study-stats-section-t,
#study-log-section-t,
#study-timeline-card {
  scroll-margin-top: 88px;
}

.status-text {
  font-size: 0.85rem;
  color: var(--primary);
}

.char-counter {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.char-counter.is-limit {
  color: #b33a3a;
  font-weight: 700;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-small);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
  background: var(--secondary);
  color: white;
}
.btn-secondary:hover:not(:disabled) { background: var(--secondary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: #f0ede4; }

.btn-block { width: 100%; padding: 12px; }
.btn-small { padding: 6px 12px; font-size: 0.85rem; }

/* ============================================
   Entry Card
   ============================================ */
.entry-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.entry-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.entry-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.entry-seq {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  background: #eaf2ec;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 8px;
  letter-spacing: 0.02em;
}

.entry-author {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2d5b8a;
  background: #e6f0fa;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  margin-right: 6px;
}

.entry-author-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #c9d8e8;
  color: #2d5b8a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  overflow: hidden;
}

.entry-author-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: #eaf2ec;
  vertical-align: middle;
  margin-right: 8px;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-title {
  display: inline-flex;
  align-items: center;
}

.settings-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.avatar-edit-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #eaf2ec;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-edit-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.print-entry-seq {
  font-weight: 700;
  color: #4a7752;
}

.entry-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 8px 0;
}

.entry-body {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0;
  line-height: 1.7;
}

.entry-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.read-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #f8b878, #e8a87c);
  border: 2px solid #d18b50;
  border-radius: 999px;
  padding: 4px 14px 4px 4px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 6px rgba(209, 139, 80, 0.35);
  text-shadow: 0 1px 2px rgba(120, 70, 20, 0.35);
}

.like-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #ff8aae, #ff6b9a);
  border: 2px solid #e84a7d;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 6px rgba(232, 74, 125, 0.35);
  text-shadow: 0 1px 2px rgba(120, 30, 50, 0.35);
}

.bookmark-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff3c4;
  border: 2px solid #d8a822;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #7a5810;
  box-shadow: 0 2px 6px rgba(216, 168, 34, 0.22);
}

.btn-bookmark-on {
  background: #f5c542;
  color: #4d3500;
  border-color: #d8a822;
}
.btn-bookmark-on:hover:not(:disabled) {
  background: #e2b633;
}

.btn-like-on {
  background: #ff6b9a;
  color: #fff;
  border-color: #e84a7d;
}
.btn-like-on:hover:not(:disabled) {
  background: #e84a7d;
}

.comment-like-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.comment-like-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.comment-like-btn:hover {
  background: #fbe6ee;
  border-color: #ff6b9a;
  color: #e84a7d;
}
.comment-like-btn.is-liked {
  background: #ffd6e3;
  border-color: #e84a7d;
  color: #c43770;
}

.comment-like-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #c43770;
  padding: 2px 8px;
}

.comment-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 2px;
}

.comment-action-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.comment-action-btn:hover {
  background: #f0ede4;
  border-color: var(--border);
}

.comment-edit-textarea {
  width: 100%;
  margin-bottom: 6px;
  resize: vertical;
}

.comment-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* ============================================
   掲示板
   ============================================ */
/* ============================================
   学習機能
   ============================================ */
.study-summary {
  display: flex;
  gap: 24px;
  justify-content: space-around;
  text-align: center;
  padding: 16px 20px;
}

.study-summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.study-summary-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.study-summary-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.study-summary-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 累計の学習登録・達成回数バナー */
.study-total-banner {
  padding: 12px 16px;
  text-align: center;
  font-size: 0.95rem;
  background: linear-gradient(135deg, #fff8e6, #fff3f0);
  border: 1px solid #f0dfb8;
}

.study-total-banner strong {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 2px;
}

.badge-required {
  display: inline-block;
  background: #e84a4a;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}

.subject-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.subject-radio {
  --subject-color: #888;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 2px solid var(--subject-color);
  border-radius: 999px;
  cursor: pointer;
  background: var(--surface);
  color: var(--subject-color);
  transition: all 0.15s;
  user-select: none;
  font-size: 0.92rem;
  font-weight: 600;
}

.subject-radio input { display: none; }
.subject-radio:hover {
  background: color-mix(in srgb, var(--subject-color) 12%, white);
}
.subject-radio:has(input:checked) {
  background: var(--subject-color);
  color: #fff;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--subject-color) 50%, transparent);
}

/* 教科ごとの色（グラフと統一） */
.subject-radio[data-subject="数学"]    { --subject-color: #4285F4; }
.subject-radio[data-subject="英語"]    { --subject-color: #EA4335; }
.subject-radio[data-subject="国語"]    { --subject-color: #d99c00; }
.subject-radio[data-subject="理科"]    { --subject-color: #34A853; }
.subject-radio[data-subject="社会"]    { --subject-color: #FF6D00; }
.subject-radio[data-subject="情報"]    { --subject-color: #00ACC1; }
.subject-radio[data-subject="その他"]  { --subject-color: #757575; }

.study-timer-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.study-timer-input-row .input {
  max-width: 100px;
  margin-bottom: 0;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
}

.study-timer-card { text-align: center; }
.study-timer-task {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 16px;
}

.study-timer-display {
  font-size: 5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  margin: 16px 0;
  letter-spacing: -2px;
}

/* タイマー終了時の光（画面が真っ白に近くなるくらい強く光る） */
.flash-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 250, 220, 1) 25%,
    rgba(255, 230, 150, 0.98) 55%,
    rgba(255, 200, 80, 0.92) 85%,
    rgba(255, 170, 40, 0.85) 100%);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  box-shadow: inset 0 0 200px 80px rgba(255, 220, 100, 0.9);
}

@keyframes screen-glow {
  0%   { opacity: 0; }
  6%   { opacity: 1; }
  18%  { opacity: 1; }
  28%  { opacity: 0.35; }
  38%  { opacity: 1; }
  50%  { opacity: 1; }
  60%  { opacity: 0.3; }
  72%  { opacity: 1; }
  84%  { opacity: 0.9; }
  100% { opacity: 0; }
}

.flash-overlay.is-flashing {
  animation: screen-glow 2.6s ease-in-out;
}

.achievement-group {
  display: flex;
  gap: 12px;
}
.achievement-radio {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-small);
  cursor: pointer;
  background: var(--surface);
  font-weight: 600;
  transition: all 0.15s;
}
.achievement-radio input { display: none; }
.achievement-radio:hover { border-color: var(--primary); }
.achievement-radio:has(input:checked) {
  background: #e2efe5;
  border-color: var(--primary);
  color: var(--primary);
}

.focus-group {
  display: flex;
  gap: 4px;
}
.focus-star {
  font-size: 2.2rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #d8d4c6;
  padding: 4px 6px;
  transition: all 0.15s;
  text-shadow: none;
}
.focus-star.is-selected {
  color: #ffd60a;
  text-shadow: 0 0 8px rgba(255, 200, 0, 0.55), 0 2px 4px rgba(180, 130, 0, 0.35);
  transform: scale(1.08);
}

.study-session-item {
  background: var(--surface);
  border-radius: var(--radius-small);
  padding: 10px 14px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}

/* 上段: 生徒名・教科・内容・写真 */
.study-session-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 下段: 通し番号・結果・時刻・いいね（いいねは右端に寄せる） */
.study-session-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.study-session-meta .study-session-like-btn,
.study-session-meta .study-session-like-badge {
  margin-left: auto;
}

.study-session-subject-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.study-session-task {
  flex: 1;
  color: var(--text);
  min-width: 100px;
}

.study-session-result {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* 各記録の通し番号（◯回目の学習登録・◯回目の達成） */
.study-session-ordinal {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: #8a7434;
  background: #fff8e6;
  border: 1px solid #f0dfb8;
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}

.study-session-ordinal-ach {
  color: #b3541e;
}

/* その時点までの累計学習時間（⏱ 累計◯時間） */
.study-session-ordinal-cum {
  color: #2f6b4f;
  background: #eef8f0;
  border-color: #cde8d4;
}

.study-session-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.study-session-thumbs {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}

.study-session-image-link {
  display: inline-flex;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  flex: 0 0 auto;
}

.study-session-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform 0.1s;
}
.study-session-thumb:hover { transform: scale(1.05); }

.study-session-add-photo-btn {
  appearance: none;
  border: 1px dashed var(--border);
  background: transparent;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--muted);
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.study-session-add-photo-btn:hover {
  background: #f0f4ff;
  border-color: #6b8cff;
  color: #3a59d6;
}

.study-session-like-btn,
.study-session-like-badge {
  appearance: none;
  border: 1px solid #ead8ad;
  background: #fff8e6;
  color: #75531b;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
}

.study-session-like-btn {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.study-session-like-btn:hover {
  background: #ffedbd;
  border-color: #e2bd62;
  transform: translateY(-1px);
}

.study-session-like-btn.is-liked,
.study-session-like-badge {
  background: #ffe8a3;
  border-color: #d6aa3e;
}

/* 振り返り未入力セッション復元バナー */
.pending-reflection-card {
  border: 2px solid #f5c842;
  background: #fffbe6;
}
.pending-reflection-text {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: #8a6d00;
}
.pending-reflection-icon { font-size: 1.4rem; }
.pending-reflection-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pending-reflection-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #fff;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.pending-reflection-time {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.9rem;
  min-width: 56px;
}
.pending-reflection-task {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pending-reflection-delete { color: #b94343; }
.pending-reflection-delete:hover { background: #ffe8e8; color: #911e1e; }

/* 学習ライブボード（先生ダッシュボード） */
.live-board-card {
  border: 2px solid #ffc4c4;
  background: #fff8f8;
}
.live-board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.live-board-indicator {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}
.live-board-indicator.is-connected {
  color: #d94343;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.live-board-body { display: flex; flex-direction: column; gap: 6px; }
.live-board-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
}
.live-board-row.is-active {
  background: #fff5f5;
  border-color: #ffb3b3;
  box-shadow: 0 0 0 2px rgba(255, 100, 100, 0.15);
}
.live-board-row.is-done { background: #f3fbf4; border-color: #c4e9c8; }
.live-board-row.is-failed { background: #fff3e8; border-color: #ffd6a8; }
.live-board-row.is-pending { background: #fff8e0; border-color: #f3d76b; }
.live-board-time {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 42px;
}
.live-board-name {
  font-weight: 600;
  min-width: 90px;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-board-task {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #222;
}
.live-board-thumbs { display: inline-flex; gap: 4px; flex-shrink: 0; }
.live-board-thumb {
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
}
.live-board-status {
  font-size: 0.82rem;
  font-weight: 600;
  flex-shrink: 0;
}
.live-board-status.is-active { color: #d94343; }
.live-board-status.is-done { color: #2c8c3a; }
.live-board-status.is-failed { color: #c8731a; }
.live-board-status.is-pending { color: #a07a0a; }
.live-board-stars { color: #f5c30c; flex-shrink: 0; font-size: 0.82rem; }

/* モバイル: 行をスタック */
@media (max-width: 600px) {
  .live-board-row {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .live-board-task { flex-basis: 100%; }
}

/* 振り返りグラフ */
.study-stats-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.study-period-tabs {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.6);
  padding: 4px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  gap: 4px;
  height: 38px;
  box-sizing: border-box;
}

.period-tab {
  background: transparent;
  border: none;
  padding: 0 18px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-small);
  font-size: 0.92rem;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.period-tab:hover { color: var(--text); }
.period-tab.is-active {
  background: var(--primary);
  color: #fff;
}

#study-date-picker-wrap,
#study-year-picker-wrap,
#study-date-picker-wrap-t,
#study-year-picker-wrap-t { display: none; }

#study-date-picker-wrap.is-shown,
#study-year-picker-wrap.is-shown,
#study-date-picker-wrap-t.is-shown,
#study-year-picker-wrap-t.is-shown { display: inline-flex; }

#study-date-picker-wrap input,
#study-year-picker-wrap select,
#study-date-picker-wrap-t input,
#study-year-picker-wrap-t select {
  margin-bottom: 0;
  min-height: 38px;
  height: 38px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.study-chart-wrap {
  position: relative;
  padding: 16px;
}

.study-chart-wrap canvas { width: 100% !important; max-height: 360px; }

.study-summary-table {
  margin-top: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.study-summary-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.study-summary-table th,
.study-summary-table td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.study-summary-table th:first-child,
.study-summary-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  width: 110px;
}
.study-summary-table tr:last-child td { border-bottom: none; }

.study-monthly-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
}

.study-monthly-detail .month-block {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.study-monthly-detail .month-block h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.study-monthly-detail table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.study-monthly-detail th,
.study-monthly-detail td {
  padding: 4px 6px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.study-monthly-detail th:first-child,
.study-monthly-detail td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  background: #f7f5ed;
}
.study-monthly-detail th { font-weight: 700; color: #fff; }
.study-monthly-detail .month-score {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  margin-left: 8px;
}

/* セッションログ（週次・月次の下に出る詳細リスト） */
.study-session-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 学習履歴のグループ見出し（チャンク描画のためフラット構造） */
.study-session-log .log-group-header {
  font-size: 0.9rem;
  font-weight: 700;
  color: #2c5777;
  margin: 18px 0 8px;
  padding: 6px 12px;
  background: var(--surface);
  border-radius: var(--radius-small);
  box-shadow: var(--shadow);
}

.study-session-log .log-group-header .log-group-summary {
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: 8px;
}

/* 学習スコアの説明クリック可能ラベル */
.study-score-help {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.study-score-help::after {
  content: ' ⓘ';
  font-size: 0.75em;
  color: var(--primary);
}
.study-score-help:hover {
  color: var(--primary);
}

.study-score-formula {
  background: #f7f5ed;
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: var(--radius-small);
  margin: 12px 0;
  font-family: -apple-system, "Hiragino Sans", monospace;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text);
}

/* ============================================
   タブナビゲーション
   ============================================ */
.tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-small);
  transition: all 0.2s;
}

.tab-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.5); }

.tab-btn.is-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(107, 155, 118, 0.3);
}

.tab-content { display: block; }
.tab-content[hidden] { display: none; }

.bulletin-card {
  background: linear-gradient(135deg, #ffd84d, #fff0a3);
  border: 2px solid #e89c0a;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(232, 156, 10, 0.25);
}

.bulletin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}

.bulletin-title {
  font-size: 1rem;
  margin: 0;
  color: #6b4108;
}

.bulletin-body {
  font-size: 0.95rem;
  color: #3a2808;
  font-weight: 500;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.6em;
}
.bulletin-body a {
  color: #1e4a99;
  text-decoration: underline;
  word-break: break-all;
}
.bulletin-body a:hover { color: #15336b; }

.bulletin-body.is-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* ジャーナル投稿のその場編集 */
.entry-edit-title { margin-bottom: 8px; }
.entry-edited { white-space: nowrap; }

.bulletin-updated {
  margin: 8px 0 0;
  color: #6b4108;
  text-align: right;
}

.bulletin-edit { margin-top: 12px; }

.bulletin-edit-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  justify-content: flex-end;
}

.bulletin-edit-status {
  margin: 6px 0 0;
  text-align: right;
}

/* ============================================
   通知バッジ & ドロップダウン
   ============================================ */
.btn-notification {
  position: relative;
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #e84a7d;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.notification-dropdown {
  position: fixed;
  top: 64px;
  right: 16px;
  width: min(360px, calc(100vw - 32px));
  max-height: 70vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.notification-header {
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #f9f7f1;
}

.notification-list {
  overflow-y: auto;
  flex: 1;
}

.notification-item {
  padding: 10px 16px;
  border-bottom: 1px solid #f0ede4;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.notification-item:last-child { border-bottom: 0; }

.notification-item .notif-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.notification-item .notif-text {
  flex: 1;
}

.notification-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.notification-item.is-clickable {
  cursor: pointer;
  transition: background 0.15s;
}
.notification-item.is-clickable:hover {
  background: #f5f1e8;
}

.notification-item.is-unread {
  background: #fff8e0;
  border-left: 3px solid #f0a830;
}
.notification-item.is-unread:hover {
  background: #fdefc4;
}

.notif-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 4px;
}

@keyframes entry-highlight-fade {
  0% { box-shadow: 0 0 0 4px #ffd97a; background: #fff8e0; }
  100% { box-shadow: 0 0 0 4px transparent; background: var(--surface); }
}

.entry-highlight {
  animation: entry-highlight-fade 2s ease-out;
}

/* ============================================
   許可メアド管理
   ============================================ */
.allowed-email-add {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin: 8px 0;
}

.allowed-email-add .input { margin-bottom: 0; flex: 1; }

.allowed-emails-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.allowed-emails-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f0ede4;
}

.allowed-emails-table td:last-child { text-align: right; }

.allowed-emails-table tr:last-child td { border-bottom: none; }

.allowed-email-status {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}
.allowed-email-status.is-active {
  background: #e2efe5;
  color: #4a7752;
}
.allowed-email-status.is-pending {
  background: #fff3d6;
  color: #8a6d1f;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}
.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.read-avatar {
  display: inline-flex;
  align-items: center;
}
.read-avatar img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

/* ============================================
   Comments
   ============================================ */
.entry-comments {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.comment {
  background: #f9f6ee;
  border-radius: var(--radius-small);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.comment-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.comment-avatar img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.comment-avatar-student {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--secondary);
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  text-transform: uppercase;
}

.comment-from-student {
  background: #eef2fb;
  border-left: 3px solid var(--secondary);
}
.comment-from-teacher {
  background: #fff4c4;
  border-left: 4px solid #e89c0a;
}

.comment-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.comment-images .entry-image-link {
  aspect-ratio: 1 / 1;
}

.comment-image-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.comment-image-picker > label {
  align-self: flex-start;
}
.comment-image-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}
.comment-image-previews .image-preview {
  aspect-ratio: 1 / 1;
}

.comment-author {
  font-weight: 600;
  color: var(--text);
}

.comment-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-compose {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.comment-compose .textarea {
  margin-bottom: 8px;
  transition: min-height 0.2s ease;
}

/* 編集中（フォーカス中 or 入力済み）だけ返信欄を大きくする */
.comment-compose .textarea:focus,
.comment-compose .textarea:not(:placeholder-shown) {
  min-height: 240px;
}

/* ============================================
   Empty State
   ============================================ */
.empty {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
}

/* ============================================
   Image picker / previews
   ============================================ */
.image-picker {
  margin-top: 10px;
}

.btn-file {
  display: inline-block;
  cursor: pointer;
}

.image-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.image-preview {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-small);
  overflow: hidden;
  background: #f1ede3;
  border: 1px solid var(--border);
}

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

.image-preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.image-preview-remove:hover {
  background: rgba(0, 0, 0, 0.85);
}

/* ============================================
   Entry images (表示)
   ============================================ */
.entry-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.entry-image-link {
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-small);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f1ede3;
}

.entry-image-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

.entry-image-link:hover img {
  transform: scale(1.03);
}

/* ============================================
   Image Lightbox
   ============================================ */
#image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
}

#image-lightbox[hidden] {
  display: none;
}

.lightbox-img {
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  object-fit: contain;
  border-radius: var(--radius-small);
  transition: transform 0.2s;
}

/* 90度・270度回転時は縦横の制約を入れ替えて画面に収める */
.lightbox-img.is-rotated-side {
  max-width: calc(100vh - 24px);
  max-height: calc(100vw - 24px);
}

.lightbox-img.is-zoomed {
  cursor: grab;
}

.lightbox-img.is-zoomed:active {
  cursor: grabbing;
}

.lightbox-img.no-anim {
  transition: none;
}

.lightbox-close,
.lightbox-rotate,
.lightbox-zoom-in,
.lightbox-zoom-out,
.lightbox-prev,
.lightbox-next {
  position: fixed;
  z-index: 1001;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close:hover,
.lightbox-rotate:hover,
.lightbox-zoom-in:hover,
.lightbox-zoom-out:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-close {
  top: 14px;
  right: 14px;
}

.lightbox-rotate {
  top: 14px;
  right: 70px;
  font-size: 24px;
}

.lightbox-zoom-in {
  top: 14px;
  right: 126px;
}

.lightbox-zoom-out {
  top: 14px;
  right: 182px;
}

.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  font-size: 30px;
  padding-bottom: 4px;
}

.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }

.lightbox-prev[hidden],
.lightbox-next[hidden] {
  display: none;
}

.lightbox-counter {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 12px;
  border-radius: 999px;
}

body.lightbox-open {
  overflow: hidden;
}

@media print {
  #image-lightbox {
    display: none !important;
  }
}

/* ============================================
   Print Area (hidden on screen)
   ============================================ */
#print-area {
  display: none;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  body > * { display: none !important; }
  #print-area { display: block !important; }

  /* 学習レポート用 */
  .study-print-chart { margin: 8px 0 16px; text-align: center; }
  .study-print-chart img { max-width: 100%; max-height: 380px; }
  .study-print-section { margin-top: 16px; page-break-inside: avoid; }
  .study-print-section h2 {
    font-size: 12pt;
    border-bottom: 1px solid #999;
    padding-bottom: 4px;
    margin: 12px 0 8px;
  }
  .study-print-section table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9.5pt;
  }
  .study-print-section table th,
  .study-print-section table td {
    border: 1px solid #ccc;
    padding: 4px 8px;
    text-align: center;
  }
  .study-print-section table th:first-child,
  .study-print-section table td:first-child {
    text-align: left;
    background: #f7f5ed;
    font-weight: 600;
  }
  .study-print-section .month-block { margin-bottom: 14px; page-break-inside: avoid; }
  .study-print-section .month-block h3 {
    font-size: 10.5pt;
    margin: 8px 0 4px;
  }
  .study-print-footer {
    margin-top: 24px;
    padding-top: 8px;
    border-top: 1px solid #ccc;
    text-align: center;
  }

  /* ノート画像アルバム */
  .study-print-album { display: flex; flex-direction: column; gap: 16px; }
  .study-print-album-item {
    page-break-inside: avoid;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
  }
  .study-print-album-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 9pt;
    margin-bottom: 6px;
  }
  .study-print-album-meta .album-task {
    flex: 1;
    font-weight: 600;
  }
  .study-print-album-meta .album-date {
    color: #666;
    font-size: 8.5pt;
  }
  .study-print-album-photos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .study-print-album-photos img {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    border: 1px solid #ddd;
  }

  body {
    background: white;
    color: black;
    font-size: 11pt;
  }

  #print-area {
    padding: 0;
    margin: 0;
  }

  .print-header {
    border-bottom: 2px solid #333;
    padding-bottom: 12px;
    margin-bottom: 24px;
  }

  .print-header h1 {
    font-size: 18pt;
    margin: 0 0 4px;
  }

  .print-header p {
    margin: 0;
    color: #555;
    font-size: 12pt;
  }

  .print-entry {
    margin-bottom: 14px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
  }

  .print-entry-date {
    font-size: 9pt;
    color: #555;
    margin-bottom: 4px;
  }

  .print-entry-title {
    font-size: 13pt;
    font-weight: 600;
    margin: 4px 0 8px;
  }

  .print-entry-body {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
    margin: 4px 0;
  }

  .print-entry-images {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-top: 8px;
  }

  .print-entry-images img {
    width: 100%;
    height: auto;
    max-height: 220px;
    object-fit: contain;
    border: 1px solid #ddd;
    border-radius: 4px;
    page-break-inside: avoid;
  }

  .print-comments {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f5f5f5;
    border-radius: 4px;
  }

  .print-comments-label {
    font-size: 9pt;
    color: #555;
    margin-bottom: 6px;
    font-weight: 600;
  }

  .print-comment {
    margin: 6px 0;
    padding: 6px 8px;
    border-radius: 4px;
    page-break-inside: avoid;
  }

  .print-comment-teacher {
    background: #eef5ee;
    border-left: 3px solid #6b9b76;
  }

  .print-comment-student {
    background: #eef2fb;
    border-left: 3px solid #5b8def;
  }

  .print-comment-meta {
    font-size: 8.5pt;
    color: #555;
    margin-bottom: 3px;
    display: flex;
    gap: 8px;
    align-items: baseline;
  }

  .print-comment-author {
    font-weight: 700;
    color: #333;
  }

  .print-comment-body {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
  }

  .print-comment-images {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-top: 4px;
  }

  .print-comment-images img {
    width: 100%;
    height: auto;
    max-height: 140px;
    object-fit: contain;
    border: 1px solid #ddd;
    border-radius: 4px;
    page-break-inside: avoid;
  }

  @page {
    margin: 18mm 14mm;
  }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 600px) {
  .app-main { padding: 16px; }
  .card { padding: 16px; }
  .entry-card { padding: 16px; }
  .header-inner {
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .header-title {
    font-size: 1rem;
    white-space: normal;
    word-break: break-word;
  }
  .header-actions { flex-wrap: wrap; }
  .row { flex-direction: column; align-items: stretch; }
  .field { width: 100%; }

  /* タブナビ: 文字小さく、隙間詰める */
  .tab-btn { padding: 8px 10px; font-size: 0.9rem; }

  /* 学習: 各種コントロール */
  .study-stats-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .study-period-tabs { width: 100%; justify-content: stretch; }
  .study-period-tabs .period-tab { flex: 1; }
  #study-date-picker-wrap,
  #study-year-picker-wrap,
  #study-date-picker-wrap-t,
  #study-year-picker-wrap-t { width: 100%; }
  #study-date-picker-wrap.is-shown,
  #study-year-picker-wrap.is-shown,
  #study-date-picker-wrap-t.is-shown,
  #study-year-picker-wrap-t.is-shown { display: flex; }

  /* 学習サマリー: 余白詰める */
  .study-summary { padding: 12px; }
  .study-summary-value { font-size: 1.5rem; }

  /* 教科ラジオボタン: 文字小さく */
  .subject-radio { padding: 6px 12px; font-size: 0.85rem; }

  /* タイマー表示: スマホでも大きく */
  .study-timer-display { font-size: 4rem; }

  /* グラフ: 期間別に縦幅を確保（スマホ） */
  /* Chart.js (maintainAspectRatio:false) は親要素の高さを使うので、
     wrap 側に height を指定して canvas にも反映する */
  .study-chart-wrap { position: relative; }
  .study-chart-wrap.period-day   { height: 360px; }
  .study-chart-wrap.period-week  { height: 500px; }
  .study-chart-wrap.period-month { height: 600px; }
  .study-chart-wrap canvas { max-height: none !important; height: 100% !important; }
}

/* ============================================
   保護者モード（先生ビューを読取専用で再利用）
   ============================================ */
/* 通知ベルは保護者にも表示する（YouTube新着・掲示板の通知用） */
body.parent-mode #btn-manage-students,
body.parent-mode #btn-activity-log,
body.parent-mode #btn-edit-bulletin,
body.parent-mode #teacher-study-jump-card,
body.parent-mode .live-board-card,
body.parent-mode .tab-nav[data-tab-group="teacher"] {
  display: none !important;
}

/* ============================================
   学習登録コメント
   ============================================ */
/* セッション本体とコメント欄をひとつの白いカードにまとめる */
.study-session-block {
  background: var(--surface);
  border-radius: var(--radius-small);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
}
.study-session-block .study-session-item {
  background: none;
  box-shadow: none;
  border-radius: 0;
  margin-bottom: 0;
}
.study-comments-acc {
  margin: 0;
  padding: 8px 14px 12px;
  border-top: 1px solid #e3edf4;
  background: #f6fafd;
}
.study-comments-summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #2c5777;
  user-select: none;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s;
}
.study-comments-summary:hover {
  background: #e7f1f9;
}
.study-comments-count {
  background: #f08c00;
  color: #fff;
  border-radius: 10px;
  padding: 1px 9px;
  font-size: 0.8rem;
  font-weight: 700;
}
.study-comments-acc[open] .study-comments-summary {
  margin-bottom: 8px;
}
.study-comments-thread {
  margin-top: 4px;
}
.study-comments-thread .comment {
  font-size: 0.95rem;
  padding: 12px 14px;
}
.study-comments-thread .comment-body {
  line-height: 1.7;
}
.study-comment-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 6px;
}
.study-comment-input-row .study-comment-textarea {
  flex: 1;
  min-height: 40px;
  transition: min-height 0.2s ease;
}

/* 編集中（フォーカス中 or 入力済み）だけコメント欄を大きくする */
.study-comment-input-row .study-comment-textarea:focus,
.study-comment-input-row .study-comment-textarea:not(:placeholder-shown) {
  min-height: 240px;
}
.study-comment-edit {
  margin: 4px 0;
}
.study-comment-edit .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* 学習タイムラインの生徒名バッジ */
.study-session-author {
  font-weight: 600;
  font-size: 0.85rem;
  color: #2c5777;
  background: #eaf2f8;
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* 学習ライブ → タイムラインへのジャンプボタン */
.live-board-jump {
  border: 1px solid #cfe0ec;
  background: #fff;
  border-radius: 8px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, transform 0.1s;
}
.live-board-jump:hover {
  background: #e7f1f9;
  transform: scale(1.05);
}

/* ============================================
   YouTubeチャンネル新着カード（保護者ページ）
   ============================================ */
.yt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 640px) {
  .yt-grid { grid-template-columns: 1fr; }
}
.yt-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: var(--text);
}
.yt-thumb-wrap {
  position: relative;
  display: block;
  border-radius: var(--radius-small);
  overflow: hidden;
  background: #000;
}
.yt-thumb {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 0.2s;
}
.yt-item:hover .yt-thumb { transform: scale(1.04); }
.yt-new-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: #e53935;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 6px;
  padding: 2px 8px;
}
.yt-new-badge--inline {
  position: static;
  display: inline-block;
  vertical-align: baseline;
  margin-right: 2px;
}
.yt-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.yt-archive { margin-top: 14px; }
.yt-archive > summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: #2c5777;
  user-select: none;
}
.yt-archive-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid #eef3f7;
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
}
.yt-archive-row:hover { background: #f4f9fc; }
.yt-archive-row .yt-date { white-space: nowrap; }

/* ============================================
   面談マインドマップ・スタディリンクマニュアル
   ============================================ */
.mindmap-link {
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}
.mindmap-link:hover { text-decoration: underline; }
.link-buttons-card {
  padding: 14px 20px;
}
.link-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.link-buttons .btn {
  flex: 1;
  min-width: 180px;
  text-align: center;
  text-decoration: none;
}
.student-links-editor {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #eef3f7;
}
.student-links-editor .field-label .mindmap-link { margin-left: 6px; font-size: 0.85rem; }

/* ============================================
   転送量対策: 未取得画像の「タップで表示」タイル
   ============================================ */
.lazy-image-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 100%;
  background: #f1ede3;
  color: #8a7f6a;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  border-radius: inherit;
}
.lazy-image-tile small {
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}
/* 学習記録・ライブボードの40pxサムネ枠では文字を出さない */
.lazy-image-tile.study-session-thumb,
.lazy-image-tile.live-board-thumb {
  width: 40px;
  height: 40px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  object-fit: unset;
}
.lazy-image-tile.study-session-thumb small,
.lazy-image-tile.live-board-thumb small { display: none; }
.entry-image-link.is-lazy:hover .lazy-image-tile { background: #e9e3d4; }
.entry-image-link.is-loading .lazy-image-tile,
.study-session-image-link.is-loading .lazy-image-tile { opacity: 0.5; }
.entry-image-link.is-loading .lazy-image-tile::after,
.study-session-image-link.is-loading .lazy-image-tile::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid #8a7f6a;
  border-top-color: transparent;
  border-radius: 50%;
  animation: lazy-img-spin 0.8s linear infinite;
}
@keyframes lazy-img-spin { to { transform: rotate(360deg); } }

/* キーワード検索のハイライト */
mark.search-hit {
  background: #ffe08a;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}
#student-search-input, #teacher-search-input { min-width: 130px; }

/* 今週の目標：常時展開し、今日・累計の実績も同じカードにまとめる */
.weekly-goal-card { border: 1px solid #b4cbb7; }
.weekly-goal-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.weekly-goal-title-row { display: flex; align-items: center; gap: 12px; flex: 1 1 280px; min-width: 0; }
.weekly-goal-heading .card-title { margin: 0; white-space: nowrap; }
.weekly-goal-heading p { margin: 0; white-space: nowrap; }
.weekly-goal-metrics, .weekly-goal-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.weekly-goal-metric { padding: 16px; border-radius: 10px; background: #f0f6f0; min-width: 0; }
.weekly-goal-metric h3 { margin: 0; font-size: 0.85rem; font-weight: 600; color: #405d46; }
.weekly-goal-metric-line { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; margin-bottom: 12px; }
.weekly-goal-metric p { margin: 0; }
.weekly-goal-metric strong { font-size: 1rem; color: #466c4f; }
.weekly-goal-metric p > span { font-size: 0.8rem; }
.weekly-goal-metric progress { display: block; width: 100%; height: 10px; margin-bottom: 8px; appearance: none; border: 0; border-radius: 6px; background: #d9e6da; accent-color: var(--primary); }
.weekly-goal-metric progress::-webkit-progress-bar { background: #d9e6da; border-radius: 6px; }
.weekly-goal-metric progress::-webkit-progress-value { background: var(--primary); border-radius: 6px; }
.weekly-goal-metric progress::-moz-progress-bar { background: var(--primary); border-radius: 6px; }
.weekly-goal-note { margin: 12px 0; padding: 12px 14px; background: #fffbe6; border-radius: 8px; overflow-wrap: anywhere; white-space: pre-wrap; }
.weekly-goal-fields { margin-bottom: 14px; }
.weekly-goal-fields .field { min-width: 0; }
.weekly-goal-fields .input, .weekly-goal-fields .select { margin-bottom: 0; }
.weekly-goal-today { display: flex; flex-wrap: wrap; gap: 8px 24px; border-top: 1px solid var(--border); padding-top: 12px; font-size: 0.85rem; }
.weekly-goal-today strong { color: #466c4f; font-size: 1.1rem; }
.weekly-goal-card .study-total-banner { margin: 12px 0 0; padding: 12px; font-size: 0.8rem; text-align: left; }
.weekly-goal-card .study-total-banner strong { font-size: 1rem; }
.weekly-goal-caption { margin: 14px 0 10px; }
#weekly-goal-status:empty { display: none; }
@media (max-width: 600px) {
  .weekly-goal-metrics, .weekly-goal-fields { gap: 8px; }
  .weekly-goal-metric { padding: 10px; }
  .weekly-goal-metrics { grid-template-columns: 1fr; }
  .weekly-goal-metric-line { gap: 6px; }
  .weekly-goal-metric strong { font-size: 0.9rem; }
  .weekly-goal-heading .btn { flex-shrink: 0; margin-left: auto; }
  .weekly-goal-title-row { gap: 8px; }
  .weekly-goal-heading .card-title { font-size: 0.95rem; }
  #weekly-goal-period { font-size: 0.75rem; }
}

#weekly-goal-form { margin-top: 16px; }

#weekly-goal-form .field-label { color: #333; font-weight: 700; }

/* 先生用：今週の目標一覧 */
.teacher-goals-heading, .teacher-goals-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.teacher-goals-heading .card-title { margin: 0; }
.teacher-goals-heading { margin: 0; cursor: pointer; list-style: none; }
.teacher-goals-heading::-webkit-details-marker { display: none; }
.teacher-goals-heading::marker { content: ''; }
.teacher-goals-heading::after { content: '▼'; margin-left: auto; font-size: 0.75rem; color: #405d46; }
.teacher-goals-accordion[open] > .teacher-goals-heading { margin-bottom: 16px; }
.teacher-goals-accordion[open] > .teacher-goals-heading::after { transform: rotate(180deg); }
.teacher-goals-heading:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 4px; }
.teacher-goals-toolbar { margin-bottom: 12px; }
.teacher-goals-toolbar > strong { margin-right: auto; color: #405d46; }
.teacher-goals-filters { display: flex; gap: 4px; }
.teacher-goals-filters [aria-pressed="true"] { background: #e3efe5; border-color: #6b9b76; color: #36543d; font-weight: 700; }
.teacher-goals-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; table-layout: fixed; }
.teacher-goals-table th, .teacher-goals-table td { padding: 12px 8px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.teacher-goals-table thead th { background: #f0f6f0; color: #405d46; }
.teacher-goals-table th:first-child { width: 20%; }
.teacher-goals-table th:nth-child(2) { width: 27%; }
.teacher-goals-table th:nth-child(3) { width: 23%; }
.teacher-goals-table td:last-child { white-space: pre-wrap; }
.teacher-goal-name { border: 0; padding: 4px 0; background: transparent; color: #3568a8; text-decoration: underline; text-underline-offset: 3px; font: inherit; font-weight: 700; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.teacher-goal-achieved { color: #d0021b; font-weight: 800; }
.teacher-goal-achieved-badge { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: #ffe3e3; color: #d0021b; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.teacher-goal-unset { display: inline-block; padding: 2px 8px; border-radius: 4px; background: #fff2cc; color: #715516; font-weight: 600; }
#teacher-weekly-goals-status:empty { display: none; }
body.parent-mode #teacher-weekly-goals-card { display: none !important; }
@media (max-width: 600px) {
  .teacher-goals-table, .teacher-goals-table tbody { display: block; }
  .teacher-goals-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .teacher-goals-table tbody tr { display: block; border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-top: 10px; }
  .teacher-goals-table tbody th { display: block; width: auto; padding: 0 0 6px; border: 0; }
  .teacher-goals-table td { display: grid; grid-template-columns: 7em minmax(0, 1fr); gap: 8px; padding: 6px 0; border: 0; }
  .teacher-goals-table td::before { content: attr(data-label); color: #555; font-size: 0.8rem; }
}

/* 今日の学習ライブは最初は閉じ、見出しから開閉する。 */
#study-live-card > summary { cursor: pointer; list-style: none; margin-bottom: 0; flex-wrap: wrap; }
#study-live-card > summary .card-title { margin: 0; }
#study-live-card > summary::-webkit-details-marker { display: none; }
#study-live-card > summary::marker { content: ''; }
#study-live-card > summary::after { content: '▼'; font-size: 0.75rem; margin-left: auto; }
#study-live-card[open] > summary { margin-bottom: 12px; }
#study-live-card[open] > summary::after { transform: rotate(180deg); }
#study-live-card > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 4px; }
.refresh-status { max-width: 800px; padding: 0 24px 8px; margin: 0 auto; color: #405d46; }
.refresh-status:empty { display: none; }
.refresh-status.is-error { color: #a12c25; }

/* 保存済みの数値は閲覧のみ。ひとことの履歴は必要なときに展開。 */
.weekly-goal-fields input[readonly] { background: #f0f2f0; color: #405d46; cursor: default; }
.goal-note-history { margin: 12px 0; font-size: 0.85rem; overflow-wrap: anywhere; }
.goal-note-history summary { cursor: pointer; color: #405d46; font-weight: 600; }
.goal-note-history ol { padding-left: 24px; }
.goal-note-history li { margin: 12px 0; }
.goal-note-history time { color: #666; }

.study-comment-buttons { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.study-ai-status { margin: 6px 0 0; line-height: 1.6; }
.study-comment-input-row .study-comment-textarea { min-width: 0; }
@media (max-width: 480px) {
  .study-comment-input-row { flex-wrap: wrap; }
  .study-comment-input-row .study-comment-textarea { flex-basis: 100%; }
  .study-comment-buttons { flex-direction: row; margin-left: auto; }
}

/* これまでの週の目標（閲覧のみ） */
.weekly-goal-past { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; font-size: 0.85rem; overflow-wrap: anywhere; }
.weekly-goal-past summary { cursor: pointer; color: #405d46; font-weight: 600; }
.weekly-goal-past ol { list-style: none; margin: 8px 0 0; padding: 0; }
.weekly-goal-past li { display: grid; gap: 4px; padding: 10px 12px; margin-top: 8px; border-radius: 8px; background: #f7faf7; }
.weekly-goal-past-period { color: #405d46; font-weight: 700; }
.weekly-goal-past-miss { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: #eceeec; color: #555; font-size: 0.75rem; white-space: nowrap; }
.weekly-goal-past-note { color: #555; white-space: pre-wrap; }

/* 週の目標達成のクラッカー演出 */
.goal-celebration { position: fixed; inset: 0; z-index: 10000; overflow: hidden; display: grid; place-items: center; padding: 16px; background: rgba(20, 30, 22, 0.55); cursor: pointer; animation: goal-fade-in 0.3s ease-out; transition: opacity 0.5s; }
.goal-celebration.is-leaving { opacity: 0; }
.goal-celebration-rays { position: absolute; top: 40%; left: 50%; width: 160vmax; height: 160vmax; margin: -80vmax 0 0 -80vmax; background: repeating-conic-gradient(rgba(255, 221, 102, 0.28) 0 10deg, transparent 10deg 20deg); mask-image: radial-gradient(circle, #000 0, transparent 45%); -webkit-mask-image: radial-gradient(circle, #000 0, transparent 45%); animation: goal-rays 12s linear infinite; pointer-events: none; }
.goal-celebration-card { position: relative; z-index: 1; width: min(360px, 100%); padding: 24px 20px 16px; border-radius: 20px; background: linear-gradient(180deg, #fffdf2, #fff); border: 3px solid #ffd166; box-shadow: 0 12px 40px rgba(0,0,0,0.3); text-align: center; animation: goal-card-pop 0.6s cubic-bezier(.2,1.6,.4,1), goal-card-glow 0.7s ease-in-out 1.4s infinite alternate; }
.goal-celebration-trophy { font-size: 4rem; line-height: 1; animation: goal-trophy 1.2s ease-in-out 0.3s infinite alternate; }
.goal-celebration-title { margin: 12px 0 8px; color: #d0021b; font-size: 1.5rem; font-weight: 900; line-height: 1.4; animation: goal-title-blink 0.7s ease-in-out 1.4s infinite alternate; }
.goal-celebration-title span { display: inline-block; opacity: 0; animation: goal-char 0.5s cubic-bezier(.2,1.8,.4,1) forwards; }
.goal-celebration-sub { margin: 0; color: #405d46; font-size: 0.95rem; opacity: 0; animation: goal-fade-in 0.5s ease-out 1.6s forwards; }
.goal-celebration-sub strong { color: #d0021b; font-size: 1.3rem; }
.goal-celebration-close { margin: 12px 0 0; color: #999; font-size: 0.75rem; }
.goal-confetti { position: absolute; width: 8px; height: 12px; border-radius: 2px; pointer-events: none; z-index: 2; }
.goal-confetti:nth-child(3n) { width: 6px; height: 6px; border-radius: 50%; }
/* 点滅は1秒に1回程度のゆっくりした明滅にとどめ、画面全体は光らせない（光過敏への配慮）。 */
@keyframes goal-title-blink { from { color: #d0021b; text-shadow: 0 0 0 transparent; } to { color: #ff8c00; text-shadow: 0 0 12px #ffd166, 0 0 24px #ffd166; } }
@keyframes goal-card-glow { from { border-color: #ffd166; box-shadow: 0 12px 40px rgba(0,0,0,0.3); } to { border-color: #ff6b6b; box-shadow: 0 12px 40px rgba(0,0,0,0.3), 0 0 30px 8px rgba(255, 209, 102, 0.8); } }
@keyframes goal-twinkle { 0%, 100% { opacity: 0; transform: scale(0.4) rotate(0deg); } 50% { opacity: 1; transform: scale(1.2) rotate(20deg); } }
.goal-celebration-sparkle { position: absolute; font-size: 1.6rem; pointer-events: none; opacity: 0; animation: goal-twinkle 1.2s ease-in-out infinite; }
@keyframes goal-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes goal-rays { to { transform: rotate(360deg); } }
@keyframes goal-card-pop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes goal-trophy { from { transform: translateY(0) rotate(-8deg) scale(1); } to { transform: translateY(-8px) rotate(8deg) scale(1.1); } }
@keyframes goal-char { 0% { opacity: 0; transform: translateY(20px) scale(0.3); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .goal-celebration, .goal-celebration-card, .goal-celebration-rays, .goal-celebration-trophy, .goal-celebration-title span, .goal-celebration-sub { animation: none; opacity: 1; }
  .goal-celebration-sparkle { display: none; }
}

/* 先生の目標一覧：表示する週の切り替え */
.teacher-goals-week-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 12px; }
.teacher-goals-week-nav > span { min-width: 5em; text-align: center; font-weight: 700; color: #405d46; }
.teacher-goals-week-nav .btn:disabled { opacity: 0.4; cursor: default; }
