:root {
  --outer-bg: #eaecef;
  --card-bg: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border-soft: #e5e7eb;
  --border-focus: #f59e0b;
  --amber-primary: #f5b700;
  --amber-hover: #eab000;
  --emerald-bg: #ecfdf5;
  --emerald-border: #10b981;
  --emerald-text: #065f46;
  --rose-bg: #fff1f2;
  --rose-border: #f43f5e;
  --rose-text: #9f1239;
  --radius-shell: 28px;
  --radius-hero: 22px;
  --radius-pill: 14px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Prompt', 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-main);
  background-color: var(--outer-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.page-backdrop {
  min-height: 100dvh;
  width: 100%;
  background-color: var(--outer-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 3vw, 38px);
  transition: background-color 0.25s ease;
}

/* Main Floating Split Card */
.shell-card {
  width: 100%;
  max-width: 1040px;
  background: var(--card-bg);
  border-radius: var(--radius-shell);
  padding: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.04);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.06fr);
  gap: 24px;
  align-items: stretch;
}

/* Left Panel: Registration Form */
.form-panel {
  width: auto;
  display: flex;
  flex-direction: column;
  padding: 14px 18px 12px;
  min-width: 0;
}

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #111827;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.28);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-org {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.admin-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: #f9fafb;
  color: #4b5563;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.18s ease;
}

.admin-trigger-btn:hover {
  background: #f3f4f6;
  color: var(--text-main);
  border-color: #d1d5db;
}

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

.event-title {
  margin: 0 0 6px;
  font-size: clamp(1.32rem, 2.2vw, 1.65rem);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.event-subtitle {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.reg-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.dynamic-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dynamic-fields:empty {
  display: none;
}

.field-group {
  width: auto;
  display: flex;
  flex-direction: column;
}

/* Pill Input Box matching reference UI */
.pill-input-box {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-pill);
  background: #ffffff;
  min-height: 54px;
  padding: 6px 14px 6px 0;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}

.pill-input-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.pill-input-box.has-error {
  border-color: var(--rose-border);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.12);
}

.pill-icon {
  width: 46px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  border-right: 1px solid #f1f5f9;
  flex-shrink: 0;
  pointer-events: none;
}

.pill-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-left: 12px;
}

.pill-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.2;
  margin-bottom: 2px;
  pointer-events: none;
}

.req-star {
  color: #ef4444;
}

.pill-control {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--text-main);
  padding: 0;
  line-height: 1.4;
}

.pill-control::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

.pill-textarea-box {
  align-items: flex-start;
  padding-top: 10px;
  padding-bottom: 10px;
}

.pill-textarea {
  resize: vertical;
  min-height: 54px;
}

.pill-time-box {
  cursor: pointer;
}

.pill-time-input {
  cursor: pointer;
  position: relative;
  z-index: 5;
}

.pill-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
  margin-left: 8px;
  transition: background-color 0.2s ease;
}

.pill-input-box.is-filled .pill-status-dot {
  background: #10b981;
}

.field-error {
  margin: 4px 0 0 6px;
  font-size: 0.76rem;
  color: #e11d48;
  min-height: 0;
}

.field-error:empty {
  display: none;
}

/* Attendance Toggle Buttons */
.attendance-label-row {
  margin: 2px 0 6px 2px;
}

.attendance-heading {
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
}

.attendance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.attendance-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-soft);
  background: #ffffff;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: all 0.18s ease;
}

.attendance-btn:hover {
  border-color: #d1d5db;
  background: #f9fafb;
}

.att-icon {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  color: #6b7280;
}

.attendance-btn[data-value="เข้าร่วม"].is-selected {
  background: var(--emerald-bg);
  border-color: var(--emerald-border);
  color: var(--emerald-text);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.attendance-btn[data-value="เข้าร่วม"].is-selected .att-yes-icon {
  background: #10b981;
  color: #ffffff;
}

.attendance-btn[data-value="ไม่เข้าร่วม"].is-selected {
  background: var(--rose-bg);
  border-color: var(--rose-border);
  color: var(--rose-text);
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.15);
}

.attendance-btn[data-value="ไม่เข้าร่วม"].is-selected .att-no-icon {
  background: #f43f5e;
  color: #ffffff;
}

/* Primary Amber Submit Button */
.submit-cta-btn {
  margin-top: 6px;
  width: 100%;
  min-height: 50px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, #fbbf24 0%, var(--amber-primary) 100%);
  color: #111827;
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 20px rgba(245, 183, 0, 0.28);
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.submit-cta-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #f5b700 0%, var(--amber-hover) 100%);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(245, 183, 0, 0.35);
}

.submit-cta-btn:active:not(:disabled) {
  transform: translateY(0);
}

.submit-cta-btn:disabled {
  background: #e5e7eb;
  color: #6b7280;
  box-shadow: none;
  cursor: not-allowed;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(17, 24, 39, 0.25);
  border-top-color: #111827;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Success Banner */
.success-banner {
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: 20px;
  padding: 28px 20px;
  text-align: center;
  margin: 12px 0;
}

.success-check {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: #10b981;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.28);
}

.success-banner h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  color: #065f46;
}

.success-banner p {
  margin: 0 0 18px;
  font-size: 0.9rem;
  color: #047857;
  line-height: 1.5;
}

.secondary-pill-btn {
  padding: 11px 22px;
  border-radius: var(--radius-pill);
  border: 1.5px solid #10b981;
  background: #ffffff;
  color: #065f46;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.secondary-pill-btn:hover {
  background: #ecfdf5;
}

.card-footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.card-footer p {
  margin: 0;
}

.footer-org {
  font-size: 0.72rem;
  color: #9ca3af;
}

/* Right Panel: Visual Showcase */
.hero-panel {
  display: flex;
  min-width: 0;
}

.hero-visual {
  width: 100%;
  min-height: 560px;
  border-radius: var(--radius-hero);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: #c6ab83;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.hero-top-row {
  padding: 18px;
  display: flex;
  justify-content: flex-end;
  z-index: 2;
}

.hero-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.28);
}

.hero-scrim {
  padding: 48px 26px 24px;
  background: linear-gradient(
    to top,
    rgba(15, 23, 42, 0.82) 0%,
    rgba(15, 23, 42, 0.44) 55%,
    rgba(15, 23, 42, 0) 100%
  );
  color: #ffffff;
  z-index: 2;
}

.hero-quote {
  margin: 0 0 18px;
  font-size: clamp(1.06rem, 1.7vw, 1.32rem);
  font-weight: 600;
  line-height: 1.5;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.hero-meta-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.hero-org-tag {
  margin: 0 0 2px;
  font-size: 0.88rem;
  font-weight: 600;
}

.hero-subtext {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.85);
}

.hero-stars {
  font-size: 0.9rem;
  letter-spacing: 2px;
  color: #fde68a;
  flex-shrink: 0;
}

/* Toast */
.toast-box {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 12px 20px;
  border-radius: 999px;
  background: #111827;
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast-box.toast-error {
  background: #be123c;
}

.toast-box.toast-success {
  background: #047857;
}

/* Admin Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 90dvh;
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 28px 64px rgba(15, 23, 42, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.modal-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #f3f4f6;
  color: #374151;
  font-size: 1rem;
  cursor: pointer;
}

.modal-close-btn:hover {
  background: #e5e7eb;
}

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal-body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.admin-hint {
  margin: 0 0 14px;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.admin-login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.admin-input {
  width: 100%;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1.5px solid var(--border-soft);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
}

.admin-input:focus {
  border-color: var(--border-focus);
}

.admin-textarea {
  resize: vertical;
}

.warning-alert {
  padding: 10px 14px;
  border-radius: 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 0.82rem;
  margin-bottom: 14px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-tab {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: #f9fafb;
  color: #4b5563;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.admin-tab.active {
  background: #111827;
  color: #ffffff;
  border-color: #111827;
}

.admin-field {
  margin-bottom: 14px;
}

.admin-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.admin-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  cursor: pointer;
}

.admin-divider {
  border: none;
  border-top: 1px solid #f1f5f9;
  margin: 16px 0;
}

.bg-mode-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bg-mode-btn {
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: #ffffff;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

.bg-mode-btn.active {
  border-color: var(--border-focus);
  background: #fffbeb;
  color: #92400e;
  font-weight: 600;
}

.preset-swatches {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.swatch-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1.5px solid var(--border-soft);
  background: #ffffff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  text-align: left;
}

.swatch-card.active {
  border-color: var(--border-focus);
  background: #fffbeb;
}

.swatch-dot {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
}

.upload-dropzone {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px;
  border: 2px dashed #d1d5db;
  border-radius: 14px;
  background: #f9fafb;
  cursor: pointer;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 500;
}

.upload-dropzone small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.upload-preview {
  margin-top: 10px;
  border-radius: 12px;
  overflow: hidden;
  max-height: 150px;
  border: 1px solid var(--border-soft);
}

.upload-preview img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-picker-wrap input[type="color"] {
  width: 44px;
  height: 36px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 2px;
  background: #ffffff;
  cursor: pointer;
}

.fixed-fields-note {
  padding: 10px 14px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 0.82rem;
  color: #334155;
  margin-bottom: 14px;
}

.fields-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.admin-fields-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-builder-item {
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 12px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-builder-top {
  display: grid;
  grid-template-columns: 1.3fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.field-builder-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.field-builder-controls {
  display: flex;
  gap: 6px;
}

.icon-mini-btn {
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: #ffffff;
  cursor: pointer;
  font-size: 0.78rem;
}

.icon-mini-btn.danger {
  color: #e11d48;
  border-color: #fecdd3;
}

.sheet-url-row {
  display: flex;
  gap: 8px;
}

.admin-help-text {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.sheet-test-status {
  margin: 8px 0 0;
  font-size: 0.82rem;
  font-weight: 600;
}

.sheet-test-status.ok {
  color: #047857;
}

.sheet-test-status.err {
  color: #be123c;
}

.sheet-actions-box {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.sheet-action-link {
  display: inline-flex;
  align-items: center;
  padding: 9px 14px;
  border-radius: 10px;
  background: #eff6ff;
  color: #1d4ed8;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid #bfdbfe;
}

.sheet-action-link.excel-link {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.password-change-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.secondary-small-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.secondary-small-btn:hover {
  background: #f3f4f6;
}

.ghost-small-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

.ghost-small-btn:hover {
  background: #f3f4f6;
  color: var(--text-main);
}

.modal-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-save-btn {
  width: auto;
  min-width: 190px;
  margin-top: 0;
}

/* Mobile & Portrait iPad (< 860px): Keep same floating card look, stack neatly */
@media (max-width: 859px) {
  .page-backdrop {
    padding: 12px;
    align-items: flex-start;
  }

  .shell-card {
    grid-template-columns: 1fr;
    border-radius: 24px;
    padding: 12px;
    gap: 14px;
  }

  .hero-panel {
    order: -1;
  }

  .hero-visual {
    min-height: 200px;
    height: auto;
    border-radius: 18px;
  }

  .hero-top-row {
    padding: 12px 12px 6px;
  }

  .hero-scrim {
    padding: 16px 16px 14px;
  }

  .hero-quote {
    font-size: 0.92rem;
    line-height: 1.42;
    margin-bottom: 10px;
  }

  .hero-org-tag {
    font-size: 0.8rem;
  }

  .hero-subtext {
    font-size: 0.72rem;
  }

  .form-panel {
    padding: 4px 6px 8px;
  }

  .brand-bar {
    margin-bottom: 14px;
  }

  .admin-trigger-label {
    display: none;
  }

  .admin-field-row,
  .field-builder-top,
  .password-change-grid {
    grid-template-columns: 1fr;
  }

  .sheet-url-row,
  .modal-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-save-btn {
    width: 100%;
  }
}
