/* ===== Reset & base ===== */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", Meiryo, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #1f2430;
  background: #f7f7fa;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: #2a5fd9;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3 {
  line-height: 1.3;
  margin: 0 0 12px;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 20px;
}

p {
  margin: 0 0 12px;
}

.muted {
  color: #6b7280;
}

/* ===== Header ===== */
.site-header {
  background: #16192b;
  color: #ffffff;
}

.site-header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.brand {
  color: #ffffff;
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
}

.main-nav {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.main-nav a {
  color: #d7d9e6;
  font-size: 15px;
  text-decoration: none;
}

.main-nav a.active,
.main-nav a:hover {
  color: #ffffff;
}

/* ===== Layout ===== */
.site-main {
  flex: 1;
  width: 100%;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px;
}

.container.narrow {
  max-width: 560px;
}

.section-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 32px 0;
}

/* ===== Footer ===== */
.site-footer {
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
}

.site-footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px;
  color: #9ca3af;
  font-size: 14px;
}

/* ===== Cards ===== */
.card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.center-card {
  text-align: center;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.course-card {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.course-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
  text-decoration: none;
}

.bonus-teaser {
  text-align: center;
}

/* ===== Forms ===== */
form label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: #374151;
}

form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="file"],
form textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #1f2430;
}

form textarea {
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 14px;
}

form input:focus,
form textarea:focus {
  outline: 2px solid #2a5fd9;
  outline-offset: 1px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-label input {
  width: auto;
}

.stacked-form {
  display: block;
}

.inline-form {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.inline-form label {
  margin-bottom: 0;
  flex: 1;
  min-width: 200px;
}

.inline-mini-form {
  display: inline-block;
  margin: 0 2px;
}

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

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  background: #eef1f6;
  color: #1f2430;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
}

.btn:hover {
  background: #e2e6ee;
  text-decoration: none;
}

.btn-primary {
  background: #2a5fd9;
  border-color: #2a5fd9;
  color: #ffffff;
}

.btn-primary:hover {
  background: #234ec0;
}

.btn-done {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

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

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

.btn-small {
  padding: 6px 10px;
  font-size: 13px;
}

.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Alerts ===== */
.alert {
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 15px;
}

.alert-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

/* ===== Progress bar ===== */
.progress-bar {
  background: #e5e7eb;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin: 10px 0 6px;
}

.progress-bar-fill {
  background: #2a5fd9;
  height: 100%;
}

.progress-label {
  font-size: 14px;
  color: #6b7280;
}

/* ===== Lesson list ===== */
.lesson-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.lesson-list li + li {
  border-top: 1px solid #e5e7eb;
}

.lesson-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
}

.lesson-list a:hover {
  background: #f9fafb;
}

.lesson-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid #d1d5db;
  font-size: 13px;
  color: #16a34a;
  flex-shrink: 0;
}

.lesson-check.done {
  background: #f0fdf4;
  border-color: #16a34a;
}

/* ===== Lesson detail / video ===== */
.video-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

.video-embed iframe,
.video-embed video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-embed-native video {
  object-fit: contain;
  background: #000;
}

.lesson-body {
  font-size: 16px;
  line-height: 1.8;
  margin-bottom: 24px;
}

.lesson-body img {
  max-width: 100%;
}

.complete-form {
  margin-bottom: 20px;
}

.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.video-preview {
  margin-bottom: 16px;
}

.video-preview .video-embed {
  max-width: 480px;
}

/* ===== Video upload (R2) ===== */
.video-upload {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: #f9fafb;
}

.video-upload label {
  margin-bottom: 6px;
}

.upload-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.upload-progress .progress-bar {
  flex: 1;
  margin: 0;
}

/* ===== File meta ===== */
.file-meta {
  font-size: 14px;
  color: #6b7280;
}

/* ===== Tables (dense data) ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  font-size: 14px;
  margin-bottom: 24px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eef0f3;
  vertical-align: middle;
}

.data-table th {
  background: #f9fafb;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

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

.data-table .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.recipient-list {
  font-size: 15px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px 24px;
  background: #f9fafb;
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  background: #eef1f6;
  color: #374151;
}

.badge-active,
.badge-sent {
  background: #f0fdf4;
  color: #15803d;
}

.badge-invited,
.badge-draft,
.badge-dev {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge-disabled,
.badge-failed {
  background: #fef2f2;
  color: #b91c1c;
}

.badge-sending {
  background: #fffbeb;
  color: #b45309;
}

/* ===== Admin ===== */
.admin-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.admin-nav a {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 15px;
  color: #374151;
  text-decoration: none;
}

.admin-nav a.active {
  background: #16192b;
  color: #ffffff;
}

.admin-nav a:hover {
  text-decoration: none;
  background: #eef1f6;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  text-align: center;
  margin-bottom: 0;
}

.stat-value {
  display: block;
  font-size: 32px;
  font-weight: 700;
  color: #16192b;
}

.stat-label {
  display: block;
  font-size: 14px;
  color: #6b7280;
  margin-top: 4px;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .site-header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .main-nav {
    gap: 12px;
  }

  h1 {
    font-size: 24px;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }
}
