*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #eff6ff;
  --ot:            #7c3aed;
  --ot-dark:       #6d28d9;
  --ot-light:      #f5f3ff;
  --success:       #059669;
  --danger:        #dc2626;
  --warning:       #d97706;
  --gray-50:       #f9fafb;
  --gray-100:      #f3f4f6;
  --gray-200:      #e5e7eb;
  --gray-400:      #9ca3af;
  --gray-600:      #4b5563;
  --gray-800:      #1f2937;
  --radius:        16px;
  --radius-sm:     10px;
  --shadow:        0 2px 12px rgba(0,0,0,.08);
  --shadow-md:     0 4px 20px rgba(0,0,0,.12);
}

html { font-size: 16px; }
body {
  font-family: 'Sarabun', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ── App wrapper ── */
.app-wrap {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--gray-50);
  position: relative;
}

/* ── Header ── */
.app-header {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 60%, #3b82f6 100%);
  padding: 44px 20px 0;
  color: #fff;
  transition: background .35s ease;
}
.app-header.mode-ot {
  background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 60%, #8b5cf6 100%);
}
.header-inner { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.logo-mark {
  width: 52px; height: 52px;
  background: rgba(255,255,255,.2);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  backdrop-filter: blur(4px);
  flex-shrink: 0;
}
.app-title { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.app-sub   { font-size: .88rem; opacity: .8; margin-top: 2px; }

/* ── Mode Toggle ── */
.mode-toggle {
  display: flex;
  background: rgba(0,0,0,.2);
  border-radius: 14px 14px 0 0;
  padding: 6px 6px 0;
  gap: 4px;
}
.mode-btn {
  flex: 1;
  border: none;
  background: none;
  color: rgba(255,255,255,.65);
  font-family: 'Sarabun', sans-serif;
  font-size: .92rem;
  font-weight: 600;
  padding: 10px 8px 12px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all .2s;
}
.mode-btn i { font-size: 1rem; }
.mode-btn.active {
  background: var(--gray-50);
  color: var(--primary);
}
.app-header.mode-ot .mode-btn.active { color: var(--ot); }

/* ── Form body ── */
.form-body {
  padding: 14px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

/* ── Hint banner ── */
.form-hint {
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ot-hint { background: var(--ot-light); color: var(--ot); }

/* ── Section card ── */
.section-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
}
.section-label {
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.form-body#formOT .section-label { color: var(--ot); }

/* ── Date display ── */
.date-display {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  padding: 8px 2px;
  margin-bottom: 8px;
}

/* ── Date / Time picker ── */
.date-picker {
  width: 100%;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: 'Sarabun', sans-serif;
  font-size: 1rem;
  color: var(--gray-800);
  outline: none;
  background: #fff;
  transition: border-color .15s;
  cursor: pointer;
}
.date-picker:focus { border-color: var(--primary); }
#formOT .date-picker:focus { border-color: var(--ot); }
.time-hint { font-size: .78rem; color: var(--gray-400); margin-top: 6px; }

.note-input {
  width: 100%;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: 'Sarabun', sans-serif;
  font-size: .95rem;
  color: var(--gray-800);
  outline: none;
  resize: none;
  min-height: 80px;
  transition: border-color .15s;
}
.note-input:focus { border-color: var(--primary); }
#formOT .note-input:focus { border-color: var(--ot); }

/* ── Team list ── */
.team-list {
  display: flex;
  flex-direction: column;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.team-loading {
  padding: 14px;
  color: var(--gray-400);
  font-size: .9rem;
}
.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border: none;
  border-bottom: 1px solid var(--gray-100);
  background: #fff;
  cursor: pointer;
  font-family: 'Sarabun', sans-serif;
  font-size: 1rem;
  color: var(--gray-800);
  text-align: left;
  width: 100%;
  transition: background .1s;
  -webkit-tap-highlight-color: transparent;
}
.team-row:last-child { border-bottom: none; }
.team-row:active { background: var(--gray-100); }
.team-row.selected {
  background: var(--primary-light);
  color: var(--primary);
  border-bottom-color: var(--primary-light);
}
.team-row.selected .team-row-name { font-weight: 700; }
.team-row.selected::after {
  content: '\F26B';
  font-family: 'bootstrap-icons';
  font-size: 1.1rem;
  color: var(--primary);
  margin-left: 8px;
}
#formOT .team-row.selected { background: var(--ot-light); color: var(--ot); }
#formOT .team-row.selected::after { color: var(--ot); }
.team-row-name { font-weight: 500; }
.team-row-time { font-size: .78rem; color: var(--gray-400); }

/* ── Members ── */
.member-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; min-height: 0; }
.member-row {
  display: flex; align-items: center; gap: 8px;
  animation: slideIn .2s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.member-num {
  width: 28px; height: 28px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .76rem; font-weight: 700; color: var(--primary); flex-shrink: 0;
}
#formOT .member-num { background: var(--ot-light); color: var(--ot); }
.member-input {
  flex: 1; border: 2px solid var(--gray-200); border-radius: var(--radius-sm);
  padding: 10px 12px; font-family: 'Sarabun', sans-serif; font-size: .95rem;
  color: var(--gray-800); outline: none; transition: border-color .15s;
}
.member-input:focus { border-color: var(--primary); }
#formOT .member-input:focus { border-color: var(--ot); }
.member-del {
  width: 36px; height: 36px; border: none; background: var(--gray-100);
  border-radius: 50%; cursor: pointer; display: flex; align-items: center;
  justify-content: center; color: var(--gray-400); font-size: 1rem; flex-shrink: 0;
}
.member-del:active { background: #fee2e2; color: var(--danger); }

.add-member-btn {
  width: 100%; border: 2px dashed var(--gray-200); background: none;
  border-radius: var(--radius-sm); padding: 12px; font-family: 'Sarabun', sans-serif;
  font-size: .95rem; color: var(--gray-400); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .15s;
}
.add-member-btn:active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
#formOT .add-member-btn:active { border-color: var(--ot); color: var(--ot); background: var(--ot-light); }
.add-icon {
  width: 24px; height: 24px; background: var(--primary); color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700; line-height: 1;
}
#formOT .add-icon { background: var(--ot); }

/* ── Alert ── */
.alert-box {
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: .9rem; font-weight: 500;
}
.alert-box.danger  { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-box.warning { background: #fffbeb; color: var(--warning); border: 1px solid #fde68a; }

/* ── Submit buttons ── */
.submit-btn {
  width: 100%; border: none; border-radius: var(--radius);
  padding: 16px; font-family: 'Sarabun', sans-serif; font-size: 1.1rem; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  color: #fff; transition: all .15s;
}
.submit-btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-attend {
  background: var(--primary);
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
}
.btn-attend:active { background: var(--primary-dark); transform: scale(.98); }
.btn-ot {
  background: var(--ot);
  box-shadow: 0 4px 14px rgba(124,58,237,.35);
}
.btn-ot:active { background: var(--ot-dark); transform: scale(.98); }

/* ── Success ── */
.success-view {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 70vh; padding: 32px 20px; text-align: center;
}
.success-icon {
  font-size: 5rem; color: var(--success); margin-bottom: 16px;
  animation: popIn .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.success-view h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 8px; }
.success-view p  { color: var(--gray-600); line-height: 1.6; margin-bottom: 16px; }
.success-code {
  background: var(--gray-100); border-radius: var(--radius-sm);
  padding: 10px 20px; font-weight: 700; letter-spacing: .06em;
  color: var(--gray-600); font-size: .88rem;
}

/* ── Spinner ── */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 500px) {
  .app-wrap { box-shadow: var(--shadow-md); }
  body { display: flex; justify-content: center; }
}
