:root {
  --vf-green: #2E7D32;
  --vf-green-dark: #1B5E20;
  --vf-orange: #F57C00;
  --vf-orange-dark: #E65100;
  --bg: #F5F7F5;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #c62828;
  --success: #2E7D32;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--vf-green); text-decoration: none; }
a:hover { color: var(--vf-green-dark); text-decoration: underline; }

.nav {
  background: var(--vf-green);
  color: #fff;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,.08);
}
.nav .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; }
.nav .brand img { height: 32px; }
.nav .brand a { color: #fff; }
.nav .actions a { color: #fff; margin-left: 16px; }
.nav .actions a:hover { text-decoration: underline; }
.nav .actions a.lobby-link {
  background: var(--vf-orange);
  color: #000;
  padding: 7px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  margin-left: 0;
  margin-right: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.nav .actions a.lobby-link:hover {
  background: var(--vf-orange);
  color: #000;
  text-decoration: none;
  filter: brightness(1.08);
}

.container { max-width: 1200px; margin: 24px auto; padding: 0 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

h1, h2, h3 { color: var(--vf-green-dark); margin-top: 0; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

.btn {
  display: inline-block;
  background: var(--vf-green);
  color: #fff;
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.btn:hover { background: var(--vf-green-dark); color: #fff; text-decoration: none; }
.btn.btn-orange { background: var(--vf-orange); }
.btn.btn-orange:hover { background: var(--vf-orange-dark); }
.btn.btn-ghost { background: transparent; color: var(--vf-green); border: 1px solid var(--vf-green); }
.btn.btn-ghost:hover { background: var(--vf-green); color: #fff; }
.btn.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { background: #aaa; cursor: not-allowed; }

label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=tel], input[type=date], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--vf-green);
  box-shadow: 0 0 0 3px rgba(46,125,50,.15);
}
.form-row { margin-bottom: 16px; }
.help { font-size: 13px; color: var(--muted); margin-top: 4px; }

.error {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f5c6c6;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #fafafa; font-weight: 600; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: #fafafa; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.stat .label { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
.stat .value { font-size: 28px; font-weight: 700; color: var(--vf-green-dark); margin-top: 4px; }

.login-wrap { max-width: 420px; margin: 80px auto; padding: 0 20px; }
.login-wrap .card { padding: 28px; }
.login-wrap .brand-row { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.login-wrap .brand-row img { height: 40px; }
.login-wrap h1 { font-size: 22px; margin: 0; }

.muted { color: var(--muted); }
.row-flex { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.toolbar .toolbar-actions { display: flex; gap: 10px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.badge.active { background: #e8f5e9; color: var(--vf-green-dark); }
.badge.inactive { background: #f5f5f5; color: var(--muted); }

.qr-block { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.qr-block .qr-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: #fafafa; padding: 10px 14px; border-radius: 6px; border: 1px solid var(--border);
  font-size: 14px; word-break: break-all;
}

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 0; }

/* ---------------- question editor ---------------- */
.q-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 12px;
  background: #fafafa;
}
.q-card .q-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}

/* ---------------- public sign page ---------------- */
.public-page { max-width: 100%; }

.public-header {
  position: relative;
  min-height: 280px;
  background-size: cover;
  background-position: center;
  color: #fff;
}
.public-header-overlay {
  background: linear-gradient(180deg, rgba(27,94,32,.2) 0%, rgba(27,94,32,.78) 100%);
  min-height: 280px;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 16px 24px 28px;
}
.public-header-bar {
  display: flex; justify-content: space-between; align-items: center;
}
.public-logo { height: 56px; background: #fff; border-radius: 50%; padding: 4px; }
.lang-toggle {
  background: rgba(255,255,255,.95);
  border-radius: 999px;
  padding: 4px;
  display: inline-flex;
}
.lang-toggle a {
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  color: var(--vf-green-dark);
}
.lang-toggle a.active { background: var(--vf-green); color: #fff; }

.public-titles { text-align: center; }
.public-titles h1 {
  color: #fff;
  font-size: 28px;
  margin: 0 0 6px;
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.public-titles h2 {
  color: rgba(255,255,255,.9);
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 10px;
  text-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.public-target, .public-count {
  color: rgba(255,255,255,.95);
  font-size: 14px;
  margin: 4px 0;
  text-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.public-count { font-weight: 700; font-size: 16px; }

.public-main {
  max-width: 760px;
  margin: -20px auto 0;
  padding: 0 16px 40px;
  position: relative;
}

.intro-card .intro-body {
  white-space: normal;
  font-size: 15.5px;
}

.sign-card { margin-top: 16px; }

.closed-banner { background: #fffde7; border-color: #fbc02d; }

.choice-row { display: flex; gap: 16px; flex-wrap: wrap; }
.choice-row label, .choice-stack label {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: normal; font-size: 15px; margin-bottom: 0;
}
.choice-stack {
  display: flex; flex-direction: column; gap: 8px;
}

.sig-wrap {
  border: 2px dashed var(--vf-green);
  border-radius: 8px;
  background: #fff;
  padding: 6px;
  position: relative;
}
#sig-pad {
  display: block;
  width: 100%;
  height: 200px;
  touch-action: none;
  cursor: crosshair;
  background: #fff;
}
.sig-actions {
  display: flex; justify-content: flex-end;
  padding: 6px 0 0;
}

.consent { background: #f1f8e9; border: 1px solid #c8e6c9; padding: 12px 14px; border-radius: 6px; }
.consent label {
  font-weight: normal;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 14px; line-height: 1.5;
}
.consent input[type=checkbox] { margin-top: 4px; }

/* ---------------- video series ---------------- */
.public-main--wide { max-width: 980px; }

.public-header--compact { min-height: 200px; }
.public-header-overlay--compact { min-height: 200px; padding-bottom: 20px; }
.public-logo--sm { height: 44px; }
.series-back {
  color: #fff;
  background: rgba(0,0,0,.28);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
}
.series-back:hover { color: #fff; background: rgba(0,0,0,.45); text-decoration: none; }

.intro-body--en { margin-top: 14px; color: var(--muted); }

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 18px;
}
.ep-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow .15s ease, transform .15s ease;
}
a.ep-card:hover {
  text-decoration: none; color: var(--text);
  box-shadow: 0 6px 18px rgba(27,94,32,.18);
  transform: translateY(-2px);
}
.ep-card--soon { opacity: .75; }
.ep-thumb {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--vf-green) 0%, var(--vf-green-dark) 100%);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.ep-thumb--soon { background: linear-gradient(135deg, #9e9e9e 0%, #616161 100%); }
.ep-thumb-week {
  color: rgba(255,255,255,.92); font-size: 22px; font-weight: 800;
  text-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.ep-play {
  position: absolute;
  width: 58px; height: 58px;
  background: var(--vf-orange);
  color: #000;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 3px 10px rgba(0,0,0,.3);
}
.ep-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.ep-body h3 { margin: 0; font-size: 16px; }
.ep-title-en { margin: 0; color: var(--muted); font-size: 13px; }
.ep-week-badge {
  display: inline-block; background: var(--vf-green); color: #fff;
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em;
}
.ep-week-badge--soon { background: #9e9e9e; }
.ep-week-badge--hero { margin-bottom: 8px; background: var(--vf-orange); color: #000; }
.ep-soon-label { color: var(--muted); font-size: 13px; font-weight: 600; }

.video-card { padding: 0; overflow: hidden; }
.video-wrap { background: #000; }
.video-wrap video { display: block; width: 100%; max-height: 70vh; }
.video-placeholder {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--vf-green) 0%, var(--vf-green-dark) 100%);
  background-size: cover; background-position: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: #fff; text-align: center; padding: 20px;
}
.video-placeholder p { margin: 0; text-shadow: 0 1px 4px rgba(0,0,0,.4); }
.video-placeholder--locked { position: relative; }
.locked-overlay {
  position: absolute; inset: 0;
  background: rgba(20,40,22,.72);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; text-align: center;
}
.locked-overlay p { color: #fff; margin: 0; font-size: 15px; line-height: 1.6; }
.locked-icon { font-size: 36px; }
.ep-description { padding: 16px 20px; }
.ep-description p { margin: 0 0 8px; }

.ep-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}
@media (max-width: 760px) { .ep-columns { grid-template-columns: 1fr; } }

.comments-card h3, .cloud-card h3 { margin-bottom: 12px; }
.comment-input-row { display: flex; gap: 8px; }
.comment-input-row input { flex: 1; }
.comments-list { margin-top: 14px; max-height: 420px; overflow-y: auto; }
.comment {
  border-bottom: 1px solid var(--border);
  padding: 10px 2px;
}
.comment:last-child { border-bottom: none; }
.comment-who { font-weight: 700; font-size: 13px; color: var(--vf-green-dark); }
.comment-at { font-size: 11px; color: var(--muted); margin-left: 8px; }
.comment p { margin: 4px 0 0; font-size: 14px; }

.cloud-wrap { width: 100%; }
.cloud-wrap canvas { width: 100%; display: block; }

.join-card { margin-top: 18px; }

.questions-card { margin-top: 18px; }
.question-block { margin-bottom: 16px; }
.question-block:last-child { margin-bottom: 0; }
.question-block label { margin-bottom: 8px; }
.answer-done { color: var(--vf-green-dark); font-weight: 600; margin-top: 4px; }

.heatmap {
  display: grid;
  grid-template-columns: 36px repeat(24, 1fr);
  gap: 2px;
  font-size: 10px;
}
.heatmap .hcell { aspect-ratio: 1; background: #eef2f0; border-radius: 2px; }
.heatmap .label-y { color: var(--muted); padding-right: 4px; text-align: right; align-self: center; }
.heatmap .label-x { color: var(--muted); text-align: center; font-size: 9px; }
.otp-input {
  width: 100%;
  font-size: 28px;
  letter-spacing: 12px;
  text-align: center;
  font-weight: 700;
  padding: 12px;
}

.ep-strip {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  margin-top: 22px;
}
.ep-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; padding: 7px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--vf-green);
  color: var(--vf-green-dark);
  font-weight: 700; font-size: 13px;
}
a.ep-chip:hover { background: var(--vf-green); color: #fff; text-decoration: none; }
.ep-chip--current { background: var(--vf-green); color: #fff; }
.ep-chip--soon { border-color: var(--border); color: var(--muted); }
