/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP",
               "Yu Gothic UI", "Meiryo", sans-serif;
  background: #f5f7fb;
  color: #1f2937;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-weight: 400;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: #6b7280; font-weight: 400; }

/* ========== Layout ========== */
.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; width: 100%; }
main.container { flex: 1; padding-top: 24px; padding-bottom: 48px; }

header {
  background: #1e293b;
  color: white;
  padding: 10px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  display: inline-flex;
  align-items: center;
  color: white;
}
.logo:hover { text-decoration: none; opacity: 0.9; }
.logo-img {
  max-height: 42px;
  width: auto;
  display: block;
}
.logo-text {
  margin-left: 10px;
  font-size: 1.1rem;
  font-weight: 400;
  color: white;
}
header nav a {
  color: #cbd5e1;
  margin-left: 16px;
  font-weight: 400;
  font-size: 0.95rem;
}
header nav a:hover { color: white; }

footer {
  background: #1e293b;
  color: #94a3b8;
  padding: 14px 0;
  text-align: center;
}

/* ========== Hero / Index ========== */
.hero { text-align: center; padding: 40px 0 20px; }
.hero h1 { font-size: 2.2rem; margin-bottom: 8px; font-weight: 600; }
.hero .lead { color: #64748b; margin-bottom: 24px; line-height: 1.7; }
.hero-img {
  max-width: 360px;
  width: 40%;
  height: auto;
  margin: 16px auto 32px;
  display: block;
  border-radius: 12px;
}

/* ========== Cards ========== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.card-grid.single {
  grid-template-columns: minmax(220px, 340px);
  justify-content: center;
}
.card-grid.single-wide {
  grid-template-columns: minmax(280px, 420px);
  justify-content: center;
}
/* 学生ページ左上タイトル */
.student-page-title {
  font-size: 1.3rem;
  font-weight: 500;
  color: #2563eb;
}
.student-page-title small {
  color: #6b7280;
  font-weight: 400;
  font-size: 0.85rem;
}
/* 縦配列メニュー */
.menu-vertical {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 480px;
}
.menu-vertical .card {
  padding: 14px 20px;
}
/* メニューカード(学生ホーム用) */
.menu-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  text-decoration: none;
  color: #1f2937;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.menu-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-color: #93c5fd;
  text-decoration: none;
}
.menu-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
  width: 44px;
  text-align: center;
}
.menu-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.menu-title {
  font-size: 1.05rem;
  font-weight: 500;
  color: #1f2937;
}
.menu-desc {
  font-size: 0.88rem;
  color: #6b7280;
}
/* 試験情報 */
.exam-info {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 0.93rem;
  color: #374151;
}
.exam-info p { margin: 4px 0; }
.card {
  background: white;
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid #e5e7eb;
  transition: transform 0.15s, box-shadow 0.15s;
  color: #1f2937;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  text-decoration: none;
}
.card h2 { margin: 0 0 8px; font-size: 1.2rem; font-weight: 500; }
.card-with-icon {
  display: flex;
  align-items: center;
  gap: 16px;
}
.card-icon { width: 25%; flex-shrink: 0; }
.card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.card-icon-sm { width: 32px; height: 32px; object-fit: contain; }
.card p { margin: 0; color: #6b7280; font-size: 0.92rem; }

/* ========== Panel ========== */
.panel {
  background: white;
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid #e5e7eb;
}
.panel.narrow { max-width: 520px; margin: 0 auto; }
.panel.center { text-align: center; }
.panel h1 { margin-top: 0; font-size: 1.5rem; font-weight: 500; }
.panel h2 { font-size: 1.15rem; margin-top: 0; font-weight: 500; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.panel-head h1 { margin: 0; }
.panel-head h1 small { color: #6b7280; font-weight: 400; font-size: 0.95rem; }
.actions-group { display: flex; gap: 8px; flex-wrap: wrap; }
.mt-lg { margin-top: 32px; }
.sub { color: #6b7280; font-size: 0.92rem; margin-top: -8px; }

/* ========== Upload Panel (広め・柔らかい) ========== */
.upload-panel {
  max-width: 620px;
  margin: 0 auto;
  padding: 36px 40px;
  border-radius: 18px;
  background: #fefefe;
}
.upload-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.form-group {
  margin-bottom: 22px;
}
.form-label {
  display: block;
  font-size: 0.95rem;
  color: #374151;
  margin-bottom: 8px;
  font-weight: 400;
}
.form-control {
  width: 100%;
  padding: 12px 16px;
  font-size: 1.05rem;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  background: #fafbfc;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.form-control:focus {
  outline: none;
  border-color: #60a5fa;
  background: white;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.15);
}
.btn-upload {
  margin-top: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  border-radius: 10px;
}

/* ========== Password Input (大きめ・柔らかい) ========== */
.pw-input-lg {
  margin-top: 0;
}
.pw-input-lg input[type="password"],
.pw-input-lg input[type="text"] {
  padding: 12px 16px;
  font-size: 1.05rem;
  border: 1.5px solid #d1d5db;
  border-radius: 10px 0 0 10px;
  background: #fafbfc;
  border-right: none;
  margin-top: 0;
}
.pw-input-lg input:focus {
  border-color: #60a5fa;
  background: white;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.15);
}
.pw-toggle-lg {
  padding: 0 16px;
  font-size: 0.9rem;
  border: 1.5px solid #d1d5db;
  border-left: none;
  background: #f3f4f6;
  border-radius: 0 10px 10px 0;
  cursor: pointer;
  color: #374151;
  font-family: inherit;
  min-width: 56px;
  white-space: nowrap;
}
.pw-toggle-lg:hover { background: #e5e7eb; }

/* ========== Dropzone (大きめ・枠明確) ========== */
.dropzone-lg {
  margin: 8px 0 24px;
  border: 3px dashed #93c5fd;
  border-radius: 16px;
  background: linear-gradient(135deg, #f0f7ff 0%, #f8fafc 100%);
  text-align: center;
  padding: 40px 24px;
  transition: all 0.2s;
  cursor: pointer;
}
.dropzone-lg.dragover {
  border-color: #2563eb;
  background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
  transform: scale(1.01);
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.12);
}
.dropzone-lg.file-selected {
  border-color: #34d399;
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
}
.dz-icon-lg { font-size: 3rem; margin-bottom: 12px; }
.dz-main-text {
  font-size: 1.05rem;
  color: #374151;
  margin: 8px 0;
  font-weight: 400;
}
.dz-sub-text {
  font-size: 0.9rem;
  color: #9ca3af;
  margin: 6px 0 12px;
}
.dz-filename {
  font-weight: 500;
  color: #059669 !important;
  margin-top: 14px !important;
  font-size: 0.95rem;
}

/* ========== Form (基本) ========== */
form { display: block; }
.vstack { display: flex; flex-direction: column; gap: 12px; }
label {
  display: block;
  margin-bottom: 14px;
  font-weight: 400;
  color: #374151;
}
input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%;
  padding: 10px 12px;
  margin-top: 6px;
  font-size: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
input[disabled] { background: #f3f4f6; color: #6b7280; }
textarea { resize: vertical; }
label small {
  display: block;
  margin-top: 4px;
  color: #6b7280;
  font-weight: 400;
  font-size: 0.85rem;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.required {
  color: #dc2626;
  font-size: 0.85rem;
  font-weight: 400;
  margin-left: 8px;
}

/* パスワード表示トグル(標準サイズ) */
.pw-input {
  position: relative;
  display: flex;
  align-items: stretch;
  margin-top: 6px;
}
.pw-input input[type="password"],
.pw-input input[type="text"] {
  margin-top: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}
.pw-toggle {
  padding: 0 12px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  white-space: nowrap;
  min-width: 50px;
}
.pw-toggle:hover { background: #f3f4f6; }

/* ========== Buttons ========== */
.btn {
  display: inline-block;
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: white;
  color: #374151;
  cursor: pointer;
  font-family: inherit;
  font-weight: 400;
  transition: all 0.15s;
  text-decoration: none;
  text-align: center;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn.primary { background: #2563eb; color: white; border-color: #2563eb; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { background: #dc2626; color: white; border-color: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 5px 12px; font-size: 0.85rem; }
.btn-link {
  background: none;
  border: none;
  color: #2563eb;
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-weight: 400;
}
.btn-link.danger { color: #dc2626; }
.btn-link:hover { text-decoration: underline; }

/* ========== Table (基本) ========== */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.93rem;
  table-layout: auto;
}
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}
.table th {
  background: #f9fafb;
  font-weight: 500;
  color: #374151;
  font-size: 0.88rem;
  white-space: nowrap;
}
.table tr:hover { background: #fafbfc; }
.table .actions a, .table .actions form { margin-right: 10px; }
.table td.wrap {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 140px;
}
.table .col-title { min-width: 180px; }
.table .col-filename { min-width: 220px; }
.table td.nowrap { white-space: nowrap; }
.mono { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.85rem; }
.small { font-size: 0.85rem; }
.muted { color: #9ca3af; }
.url-cell code {
  font-size: 0.78rem;
  word-break: break-all;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ========== ファイル一覧テーブル(広め) ========== */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.files-table-wide th,
.files-table-wide td {
  padding: 13px 16px;
}
.files-table-wide .td-title {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 160px;
  font-weight: 500;
}
.files-table-wide .td-user { white-space: nowrap; }
.files-table-wide .td-email {
  font-size: 0.85rem;
  word-break: break-all;
}
.files-table-wide .td-date {
  white-space: nowrap;
  font-size: 0.85rem;
  color: #6b7280;
}
.files-table-wide .td-filename {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  white-space: normal;
  word-break: break-all;
  overflow-wrap: anywhere;
  min-width: 180px;
}
.files-table-wide .th-ops,
.files-table-wide .td-ops {
  text-align: center;
  white-space: nowrap;
}

/* 操作アイコン(大きめ) */
.op-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
  text-decoration: none;
  padding: 0;
  vertical-align: middle;
}
.op-btn:hover { background: #f1f5f9; text-decoration: none; }
.op-download { color: #2563eb; }
.op-download:hover { background: #dbeafe; }
.op-edit { color: #d97706; }
.op-edit:hover { background: #fef3c7; }
.op-delete { color: #dc2626; }
.op-delete:hover { background: #fee2e2; }

/* ========== 展開パネル(編集・削除) ========== */
.action-panel-row.hidden { display: none; }
.action-panel-row td { padding: 0 !important; }
.action-panel {
  padding: 16px 20px;
  border-radius: 0 0 10px 10px;
  margin: 0;
}
.edit-panel {
  background: #f0f7ff;
  border-top: 2px solid #60a5fa;
}
.del-panel {
  background: #fef2f2;
  border-top: 2px solid #f87171;
}
.ap-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
}
.ap-field {
  flex: 1 1 200px;
  min-width: 0;
}
.ap-field label {
  display: block;
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 4px;
  font-weight: 400;
}
.ap-field input[type="text"],
.ap-field input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  background: white;
  margin-top: 0;
}
.ap-field input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}
.ap-field.ap-field-pw {
  flex: 0 1 240px;
}
.ap-field .pw-input-lg { margin-top: 0; }
.ap-field .pw-input-lg input {
  padding: 10px 14px;
  font-size: 0.95rem;
  border-radius: 8px 0 0 8px;
}
.ap-field .pw-toggle-lg {
  border-radius: 0 8px 8px 0;
  padding: 0 14px;
}
.ap-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}
.ap-actions .btn {
  padding: 8px 18px;
  font-size: 0.9rem;
  border-radius: 8px;
}

/* ========== File List カード式(未使用だが残す) ========== */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}
.file-card {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.file-card:hover { background: #f5f7fb; }
.file-main { flex: 1 1 280px; min-width: 0; }
.file-title {
  font-size: 1.05rem;
  color: #1f2937;
  font-weight: 500;
  word-break: break-word;
  overflow-wrap: anywhere;
  margin-bottom: 6px;
  line-height: 1.4;
}
.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 0.85rem;
  color: #6b7280;
}
.file-meta .meta-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  word-break: break-all;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.file-meta .meta-label {
  color: #9ca3af;
  font-size: 0.75rem;
  margin-right: 2px;
}
.file-meta .file-name {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem;
}
.file-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  min-width: 180px;
}
.delete-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ========== File Edit Forms ========== */
.edit-form-admin, .edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.edit-label {
  font-size: 0.8rem;
  color: #6b7280;
  min-width: 60px;
  margin-bottom: 0;
  font-weight: 400;
}
.edit-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.9rem;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-family: inherit;
  margin-top: 0;
}
.edit-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}
.edit-input.mono {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
}
.edit-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

/* ========== Badge ========== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.78rem;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-weight: 400;
}
.badge.ok { background: #d1fae5; color: #065f46; }
.badge.warn { background: #fef3c7; color: #92400e; }

/* ========== Dropzone (旧・小さめ版、未使用だが残す) ========== */
.dropzone {
  margin-top: 20px;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  background: #f9fafb;
  text-align: center;
  padding: 32px 16px;
  transition: all 0.15s;
  cursor: pointer;
}
.dropzone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
  transform: scale(1.01);
}
.dz-icon { font-size: 2.5rem; margin-bottom: 8px; }
.dropzone p { margin: 6px 0; color: #6b7280; }

/* ========== Flash ========== */
.flashes { margin-bottom: 20px; }
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.93rem;
  border: 1px solid;
}
.flash-success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.flash-error { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.flash-info { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }

/* ========== Utility ========== */
.empty { color: #9ca3af; text-align: center; padding: 32px 0; }
.hidden { display: none; }

/* 提出時の注意・処理中 */
.submit-notice {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  color: #92400e;
  margin-bottom: 12px;
  line-height: 1.6;
}
.processing-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 14px 18px;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  font-size: 0.95rem;
  color: #1e40af;
}
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 3px solid #93c5fd;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* TA管理 */
.ta-add-form {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 18px 22px;
  margin-bottom: 24px;
}
.ta-add-form h2 { margin-top: 0; font-size: 1.1rem; }
.inline-ta-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.inline-ta-form .ap-fields { flex: 1; }
.ta-help {
  margin-top: 24px;
  padding: 12px 16px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
}

/* 並び替え番号入力 */
.sort-input {
  width: 50px;
  text-align: center;
  padding: 4px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 640px) {
  .panel { padding: 20px; }
  .upload-panel { padding: 24px 20px; }
  .table { font-size: 0.85rem; }
  .table th, .table td { padding: 8px 6px; }
  .files-table-wide th, .files-table-wide td { padding: 10px 8px; }
  .url-cell code { font-size: 0.7rem; }
  .file-card { flex-direction: column; }
  .file-actions { min-width: 0; width: 100%; }
  .logo-img { max-height: 32px; }
  .hero-img { max-width: 280px; }
  .actions-group { flex-direction: column; align-items: stretch; }
  .actions-group .btn { text-align: center; }
  .ap-fields { flex-direction: column; }
  .op-btn { width: 32px; height: 32px; font-size: 1rem; }
}
