body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  background: #f5f6f8;
  color: #222;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 24px;
  background: #1d3557;
  color: #fff;
}

.site-header-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.site-title {
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}

.site-title:hover {
  color: #f1faee;
}

.site-nav {
  display: flex;
  gap: 8px;
}

.site-nav a {
  color: #f1faee;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
}

.site-nav a:hover {
  background: rgba(255, 255, 255, 0.15);
}

.site-header .site-user a {
  margin-left: 12px;
}

.site-header a {
  color: #f1faee;
  text-decoration: none;
}

.container {
  max-width: 960px;
  margin: 24px auto;
  padding: 0 16px 48px;
}

.card {
  background: #fff;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 20px;
}

.hint {
  margin-top: 0;
  color: #5b6470;
  font-size: 0.92rem;
}

.document-notice {
  margin: 0 0 12px 0;
  padding: 10px 12px;
  background: #e8f4fc;
  border-left: 4px solid #1d3557;
  color: #333;
  font-size: 0.92rem;
  line-height: 1.5;
}

.document-notice a {
  color: #457b9d;
  font-weight: 600;
  text-decoration: none;
}

.document-notice a:hover {
  text-decoration: underline;
}

.document-notice-fix {
  margin-top: 8px;
}

.notice-card {
  background: #e8f4fc;
  border-left: 4px solid #1d3557;
}

.notice-card .notice-message {
  margin: 0;
  color: #333;
  font-size: 0.95rem;
  line-height: 1.5;
}

.notice-card .notice-message a {
  color: #457b9d;
  font-weight: 600;
  text-decoration: none;
}

.notice-card .notice-message a:hover {
  text-decoration: underline;
}

/* アップロードガイド（開閉可能） */
.upload-guide {
  margin: 12px 0 16px 0;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.92rem;
}

.upload-guide summary {
  cursor: pointer;
  font-weight: 600;
  color: #1d3557;
  list-style: none;
}

.upload-guide summary::-webkit-details-marker {
  display: none;
}

.upload-guide summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 6px;
  font-size: 0.75em;
  transition: transform 0.2s;
}

.upload-guide[open] summary::before {
  transform: rotate(90deg);
}

.upload-guide ul {
  margin: 10px 0 0 20px;
  padding: 0;
  line-height: 1.6;
  color: #4a5568;
}

.upload-guide li {
  margin-bottom: 4px;
}

.upload-guide li:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  margin-bottom: 12px;
}

input,
select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #d0d5dd;
  border-radius: 4px;
}

button,
.btn {
  background: #457b9d;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-primary {
  background: #457b9d;
}

.btn-primary:hover {
  background: #3a6a8a;
}

.flash-list {
  margin-bottom: 16px;
}

.flash {
  padding: 10px 12px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.flash-error {
  background: #ffe5e5;
  color: #8a1c1c;
}

.flash-success {
  background: #e6f7e6;
  color: #1f6f1f;
}

.result-list {
  list-style: none;
  padding: 0;
}

.result-list li {
  margin-bottom: 8px;
}

/* 一覧画面：絞り込みフォーム */
.filter-form .filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

@media (max-width: 600px) {
  .site-header {
    padding: 12px 16px;
  }

  .site-header-left {
    gap: 12px;
  }

  .site-nav {
    flex-wrap: wrap;
    gap: 4px;
  }

  .site-nav a {
    padding: 8px 10px;
  }

  .filter-form .filter-row {
    grid-template-columns: 1fr;
  }
}

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

.btn-secondary {
  background: #6c757d;
  color: #fff;
}

.btn-secondary:hover {
  background: #5a6268;
}

.document-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #eee;
}

.document-list-item > a {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  text-decoration: none;
  color: #1d3557;
}

.document-list-item > a:hover {
  color: #457b9d;
}

.document-list .doc-title {
  font-weight: 600;
}

.document-list .doc-meta {
  font-size: 0.875rem;
  color: #5b6470;
}

.list-delete-form {
  flex-shrink: 0;
}

.btn-danger {
  background: #c1121f;
  color: #fff;
}

.btn-danger:hover {
  background: #a00f1a;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.875rem;
}

.empty-message {
  color: #5b6470;
  margin: 0;
}

.empty-message a {
  color: #457b9d;
}

.child-fixed {
  display: inline-block;
  padding: 8px 10px;
  background: #f0f0f0;
  border: 1px solid #d0d5dd;
  border-radius: 4px;
  color: #5b6470;
}

/* ドキュメント詳細：AI要約（改行を反映して読みやすく） */
.summary-text {
  line-height: 1.7;
}

.edit-summary {
  width: 100%;
  min-height: 120px;
  padding: 8px 12px;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 1rem;
}

.edit-list {
  margin-bottom: 12px;
}

.edit-list-row {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.edit-list-row input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
}

.edit-actions .edit-list-row input:first-child {
  flex: 2;
}

.pdf-frame {
  width: 100%;
  height: 600px;
  border: none;
}

/* 画像ビュー: 全体が表示されるように contain でフィット */
.document-viewer-image-wrapper {
  max-height: 80vh;
  overflow: auto;
  background: #f0f0f0;
}

.document-viewer-image {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  margin: 0 auto;
}

/* 取り込み中のオーバーレイ（進捗表示・他操作ブロック） */
.upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.9);
  color: #222;
}

.upload-overlay[hidden] {
  display: none;
}

.upload-overlay__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e0e0e0;
  border-top-color: #457b9d;
  border-radius: 50%;
  animation: upload-spin 0.9s linear infinite;
}

.upload-overlay__message {
  font-size: 1rem;
  font-weight: 500;
}

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

/* 詳細画面: 対象の子ども選択（ラジオ＋反映ボタン） */
.target-child .target-child-form {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.target-child .target-child-form label {
  display: inline-flex;
  align-items: center;
  margin-bottom: 0;
  margin-right: 4px;
}
.target-child .target-child-form input[type="radio"] {
  display: inline-block;
  width: auto;
  margin: 0 4px 0 0;
}

/* チャット画面 */
.chat-card {
  padding-bottom: 8px;
}

.chat-thread {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.chat-message-user {
  align-self: flex-end;
  text-align: right;
}

.chat-message-assistant {
  align-self: flex-start;
}

.chat-role {
  margin: 0 0 4px;
  font-size: 0.8rem;
  color: #5b6470;
}

.chat-bubble {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.6;
}
.chat-bubble p:first-child { margin-top: 0; }
.chat-bubble p:last-child { margin-bottom: 0; }

.chat-message-user .chat-bubble {
  background: #1d3557;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message-assistant .chat-bubble {
  background: #eef3f8;
  color: #1f2933;
  border-bottom-left-radius: 4px;
}

.chat-citation-label {
  margin: 6px 0 4px;
}

.chat-citation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-citation-item {
  background: #f0f4f8;
  border: 1px solid #d6dbe2;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.82rem;
}

.chat-citation-link {
  display: block;
  margin: -3px -10px;
  padding: 3px 10px;
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
}

.chat-citation-link:hover {
  color: #1d3557;
  text-decoration: underline;
}

.chat-compose-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-compose-input {
  width: 100%;
  min-height: 88px;
  max-height: 40vh;
  padding: 10px 12px;
  box-sizing: border-box;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}

.chat-compose-input[data-chat-sending="1"] {
  opacity: 0.7;
  background: #f0f1f3;
  cursor: not-allowed;
}

.chat-compose-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

@media (max-width: 600px) {
  .chat-message {
    max-width: 100%;
  }

  .chat-compose-actions {
    flex-direction: column;
    align-items: flex-start;
  }
}