* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: 40px 16px;
  min-height: 100vh;
  background: linear-gradient(135deg, #eafaf1 0%, #e6f3ff 100%);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: #222;
}

.container {
  max-width: 680px;
  margin: 0 auto;
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(16, 150, 120, 0.15);
}

header {
  text-align: center;
  padding: 36px 24px 28px;
  background: linear-gradient(135deg, #1fa38a 0%, #2a8fd8 100%);
  color: #fff;
}

h1 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: 0.5px;
}

.subtitle {
  margin: 0 0 16px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
}

.main-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: none;
  padding: 8px 20px;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: none;
  box-shadow: none;
}

.content {
  padding: 28px 32px 32px;
}

h2 {
  font-size: 18px;
  margin: 0 0 14px;
}

h3 {
  font-size: 15px;
  margin: 28px 0 12px;
}

h4 {
  font-size: 13px;
  margin: 0;
  color: #555;
}

input[type="text"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e0e6e3;
  border-radius: 10px;
  font-size: 14px;
  background: #f7fbf9;
  font-family: inherit;
  color: #222;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #1fa38a;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(31, 163, 138, 0.15);
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

button {
  padding: 10px 22px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #1fa38a, #2a8fd8);
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(31, 163, 138, 0.25);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(31, 163, 138, 0.35);
}

button:disabled {
  background: #bcd8d1;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* フォーム */

#subject-form {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

#subject-form input {
  flex: 1;
}

.material-upload-section form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: #f7fbf9;
  border-radius: 14px;
  border: 1px solid #eaf2ee;
}

.pdf-label {
  font-size: 13px;
  color: #555;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pdf-status {
  font-size: 12px;
  color: #888;
  margin: 0;
}

.pdf-status.error {
  color: #e0526a;
}

.material-upload-section button {
  align-self: flex-start;
}

/* 科目一覧 */

.subject-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 14px;
  background: #f9faff;
  border: 1px solid #eef0fb;
  margin-bottom: 10px;
  transition: box-shadow 0.15s, transform 0.15s;
}

.subject-card-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.subject-card:hover {
  box-shadow: 0 6px 20px rgba(31, 163, 138, 0.12);
}

.subject-name {
  font-weight: 700;
  font-size: 14.5px;
  color: #1c2e2a;
}

.subject-count {
  font-size: 12px;
  color: #888;
}

.delete-subject-btn,
.delete-material-btn {
  margin-left: 12px;
  padding: 6px 14px;
  font-size: 12px;
  background: #fff;
  color: #e0526a;
  border: 1px solid #f5d9de;
  box-shadow: none;
}

.delete-subject-btn:hover,
.delete-material-btn:hover {
  background: #fdf1f2;
  transform: none;
  box-shadow: none;
}

/* 科目詳細 */

.back-btn {
  background: none;
  color: #2a8fd8;
  box-shadow: none;
  padding: 6px 0;
  margin-bottom: 12px;
  font-weight: 600;
}

.back-btn:hover {
  transform: none;
  box-shadow: none;
  text-decoration: underline;
}

/* 資料一覧 */

.material-row {
  border-radius: 14px;
  background: #f9faff;
  border: 1px solid #eef0fb;
  margin-bottom: 10px;
  overflow: hidden;
}

.material-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
}

.material-header-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  flex-wrap: wrap;
}

.material-title {
  font-weight: 700;
  font-size: 14px;
  color: #1c2e2a;
}

.material-date {
  font-size: 12px;
  color: #999;
}

.summary-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e3f6ef;
  color: #1fa38a;
}

.type-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fdeee3;
  color: #d97b3f;
}

.material-detail {
  padding: 0 16px 16px;
  border-top: 1px solid #eef0fb;
}

.toggle-content-btn {
  margin-top: 14px;
  padding: 6px 14px;
  font-size: 12px;
  background: #fff;
  color: #2a8fd8;
  border: 1px solid #d7e8f5;
  box-shadow: none;
}

.toggle-content-btn:hover {
  background: #eef6fc;
  transform: none;
  box-shadow: none;
}

.material-content {
  margin-top: 10px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #eef0fb;
  font-size: 13px;
  line-height: 1.7;
  color: #444;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.summary-block {
  margin-top: 14px;
}

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

.summary-header button {
  padding: 6px 14px;
  font-size: 12px;
}

.summary-text {
  padding: 12px 14px;
  background: linear-gradient(135deg, #eafaf4, #eef7ff);
  border-left: 3px solid #1fa38a;
  border-radius: 4px 12px 12px 4px;
  font-size: 13px;
  line-height: 1.8;
  color: #333;
}

.summary-text.empty {
  background: none;
  border-left-color: #ccc;
  color: #999;
}

.summary-text.error {
  background: none;
  border-left-color: #e0526a;
  color: #e0526a;
}

/* 検索画面 */

#keyword-search-form {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}

#keyword-search-form input {
  flex: 1;
  min-width: 160px;
}

#keyword-search-form select {
  width: auto;
}

.ask-section form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: #f7fbf9;
  border-radius: 14px;
  border: 1px solid #eaf2ee;
  margin-top: 12px;
}

.ask-section button[type="submit"],
.ask-section select {
  align-self: flex-start;
}

.section-hint {
  font-size: 12px;
  color: #888;
  margin: -6px 0 4px;
}

.search-result-row {
  padding: 14px 16px;
  border-radius: 14px;
  background: #f9faff;
  border: 1px solid #eef0fb;
  margin-bottom: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.search-result-row:hover {
  box-shadow: 0 6px 20px rgba(31, 163, 138, 0.12);
}

.search-result-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.search-result-subject {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eaf2fb;
  color: #2a8fd8;
}

.search-result-snippet {
  font-size: 12.5px;
  color: #666;
  line-height: 1.6;
}

.used-materials {
  margin-top: 14px;
}

.used-materials-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.used-material-btn {
  padding: 6px 14px;
  font-size: 12px;
  background: #fff;
  color: #1fa38a;
  border: 1px solid #d5ece6;
  box-shadow: none;
}

.used-material-btn:hover {
  background: #eafaf4;
  transform: none;
  box-shadow: none;
}

/* クイズ画面 */

.field-label {
  display: block;
  font-size: 12px;
  color: #555;
  margin-bottom: 6px;
  font-weight: 600;
}

.quiz-subject-select-section {
  margin-bottom: 8px;
}

.quiz-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0 16px;
}

.quiz-controls select {
  flex: 1;
  min-width: 160px;
}

.secondary-btn {
  background: #fff;
  color: #2a8fd8;
  border: 1px solid #d7e8f5;
  box-shadow: none;
}

.secondary-btn:hover {
  background: #eef6fc;
  transform: none;
  box-shadow: none;
}

.flashcard {
  padding: 16px;
  border-radius: 14px;
  background: #f9faff;
  border: 1px solid #eef0fb;
  border-left: 3px solid transparent;
  margin-bottom: 10px;
}

.flashcard.result-ok {
  border-left-color: #1fa38a;
}

.flashcard.result-ng {
  border-left-color: #e0526a;
}

.flashcard-question {
  font-size: 14px;
  font-weight: 700;
  color: #1c2e2a;
  line-height: 1.6;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.reveal-answer-btn {
  padding: 6px 14px;
  font-size: 12px;
  background: #fff;
  color: #1fa38a;
  border: 1px solid #d5ece6;
  box-shadow: none;
}

.reveal-answer-btn:hover {
  background: #eafaf4;
  transform: none;
  box-shadow: none;
}

.flashcard-answer {
  margin-top: 10px;
}

.flashcard-answer-text {
  padding: 12px 14px;
  background: linear-gradient(135deg, #eafaf4, #eef7ff);
  border-left: 3px solid #1fa38a;
  border-radius: 4px 12px 12px 4px;
  font-size: 13px;
  line-height: 1.8;
  color: #333;
}

.flashcard-explanation {
  margin-top: 10px;
  padding: 12px 14px;
  background: #fdf8f1;
  border-left: 3px solid #d97b3f;
  border-radius: 4px 12px 12px 4px;
}

.flashcard-explanation h4 {
  color: #b3652a;
  margin-bottom: 6px;
}

.flashcard-explanation-text {
  font-size: 13px;
  line-height: 1.8;
  color: #333;
}

.flashcard-result-controls {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.result-btn {
  padding: 6px 14px;
  font-size: 12px;
  box-shadow: none;
}

.result-ok-btn {
  background: #fff;
  color: #1fa38a;
  border: 1px solid #d5ece6;
}

.result-ok-btn:hover {
  background: #eafaf4;
  transform: none;
  box-shadow: none;
}

.result-ng-btn {
  background: #fff;
  color: #e0526a;
  border: 1px solid #f5d9de;
}

.result-ng-btn:hover {
  background: #fdf1f2;
  transform: none;
  box-shadow: none;
}

/* 共通ステータス */

.empty,
.loading {
  font-size: 13px;
  color: #999;
  padding: 12px 0;
}

.error {
  font-size: 13px;
  color: #e0526a;
  padding: 12px 0;
}
