:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f4f6f4;
  --card-bg: #ffffff;
  --text: #162019;
  --text-muted: #5a685f;
  --text-light: #87948b;
  --accent: #146444;
  --accent-hover: #0e4d34;
  --accent-soft: #e8f5ee;
  --line: #e2e7e2;
  --line-subtle: #eff2ef;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --otp-green: #10b981;
  --otp-green-dark: #059669;
  --otp-green-text: #064e3b;
  --radius-lg: 20px;
  --radius-md: 15px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(16, 32, 22, 0.04), 0 1px 2px rgba(16, 32, 22, 0.02);
  --shadow-md: 0 6px 20px -4px rgba(16, 32, 22, 0.07);
  --shadow-lg: 0 16px 36px -6px rgba(16, 32, 22, 0.16);
}

/* Segment Color Tokens */
[data-segment="umum"] {
  --seg-accent: #156646;
  --seg-soft: #e8f7f0;
  --seg-border: #7fd4ae;
  --seg-pill-bg: #d1f1e1;
  --seg-dot: #10b981;
  --seg-glow: rgba(16, 185, 129, 0.16);
}

[data-segment="youth"] {
  --seg-accent: #4338ca;
  --seg-soft: #eef0ff;
  --seg-border: #a5b4fc;
  --seg-pill-bg: #e0e7ff;
  --seg-dot: #6366f1;
  --seg-glow: rgba(99, 102, 241, 0.16);
}

[data-segment="kids"] {
  --seg-accent: #b45309;
  --seg-soft: #fef5e7;
  --seg-border: #fcd34d;
  --seg-pill-bg: #fde68a;
  --seg-dot: #f59e0b;
  --seg-glow: rgba(245, 158, 11, 0.16);
}

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

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 50% -10%, rgba(16, 185, 129, 0.06), transparent 55%);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body:has(dialog[open]) {
  overflow: hidden;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible, input:focus-visible {
  outline: 3px solid var(--otp-green);
  outline-offset: 2px;
}

.session:focus-visible {
  outline: 2.5px solid var(--seg-dot);
  outline-offset: 2px;
}

/* App Container */
.app {
  max-width: 460px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(88px, calc(env(safe-area-inset-bottom) + 74px));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  margin-bottom: 18px;
}

.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}

.brand-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 10px;
  border-radius: 99px;
  transition: background-color 0.25s, color 0.25s;
}

.brand-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--otp-green);
  transition: background-color 0.25s;
}

.admin-badge[hidden] {
  display: none !important;
}

.admin-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffffff;
  background: #dc2626;
  padding: 4px 8px;
  border-radius: 99px;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.28);
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.admin-toggle-btn {
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.14s;
}

.admin-toggle-btn:hover {
  color: var(--text);
  border-color: #cbd3cb;
}

.admin-toggle-btn:active {
  transform: scale(0.95);
}

.admin-toggle-label[hidden] {
  display: none !important;
}

.admin-toggle-label {
  font-size: 11px;
  font-weight: 700;
}

.summary-pill {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: #ffffff;
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 99px;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.summary-pill.all-done {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #9be2c2;
}

h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.7px;
  margin: 0 0 4px;
  color: var(--text);
}

.subtitle {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
}

/* Date Bar (Kartu Tanggal Kuning) */
.date-bar {
  background: linear-gradient(180deg, #fefcf3 0%, #fbf6e3 100%);
  border: 1.5px solid #e7d69c;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(135, 109, 33, 0.08);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.date-bar.is-other-day {
  background: linear-gradient(180deg, #fffbeb 0%, #fef0c7 100%);
  border-color: #d97706;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.14);
}

.date-bar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.date-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.date-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #f4e9c4;
  color: #876d21;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.date-caption {
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.9px;
  color: #8c6f1d;
  margin-bottom: 2px;
}

.date-value {
  display: block;
  font-size: 14px;
  font-weight: 750;
  color: #423309;
  letter-spacing: -0.2px;
}

.lock-pill[hidden],
.change-date-btn[hidden],
.date-other-row[hidden] {
  display: none !important;
}

.lock-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f3e8c2;
  border: 1px solid #e2cf93;
  color: #6b5314;
  font-size: 10.5px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 8px;
  flex-shrink: 0;
}

.change-date-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ffffff;
  border: 1.5px solid #d9c279;
  color: #6b5314;
  font-size: 11px;
  font-weight: 750;
  padding: 6px 10px;
  border-radius: 9px;
  min-height: 34px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(135, 109, 33, 0.1);
  transition: background-color 0.15s, border-color 0.15s, transform 0.12s;
}

.change-date-btn:hover {
  background: #fffdf5;
  border-color: #b48a1e;
}

.change-date-btn:active {
  transform: scale(0.96);
}

.change-date-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.date-other-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 9px;
  border-top: 1px dashed #e2be6c;
  flex-wrap: wrap;
}

.other-day-badge {
  font-size: 10.5px;
  font-weight: 800;
  color: #9a3412;
  background: #ffedd5;
  border: 1px solid #fdba74;
  padding: 3px 9px;
  border-radius: 99px;
}

.return-today-btn {
  border: 0;
  background: #b91c1c;
  color: #ffffff;
  font-size: 11px;
  font-weight: 750;
  padding: 6px 11px;
  border-radius: 8px;
  min-height: 32px;
  box-shadow: 0 2px 6px rgba(185, 28, 28, 0.22);
  transition: background-color 0.15s, transform 0.12s;
}

.return-today-btn:hover {
  background: #991b1b;
}

.return-today-btn:active {
  transform: scale(0.96);
}

.return-today-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Notice */
.notice {
  margin: 10px 0 20px;
  padding: 8px 12px;
  background: rgba(254, 249, 235, 0.85);
  border: 1px solid #efe2b8;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.notice-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
  background: #927119;
  color: white;
  padding: 2px 6px;
  border-radius: 5px;
  flex-shrink: 0;
}

.notice-text {
  font-size: 11.5px;
  line-height: 1.35;
  color: #6b561c;
  margin: 0;
  flex: 1;
}

.reset-link {
  border: 1px solid #dfd0a0;
  background: rgba(255, 255, 255, 0.65);
  color: #7c6216;
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background-color 0.15s, color 0.15s;
}

.reset-link:hover, .reset-link:active {
  background: #ffffff;
  color: #5c460c;
}

/* Session Groups */
.sessions-container {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.session-group {
  animation: fadeSlideUp 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.session-group:nth-child(2) {
  animation-delay: 50ms;
}

.session-group:nth-child(3) {
  animation-delay: 100ms;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 2px;
}

.section-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.segment-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background-color: var(--seg-dot);
  box-shadow: 0 0 0 3px var(--seg-soft);
}

.section-heading h2 {
  font-size: 15.5px;
  font-weight: 750;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.2px;
}

.section-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--seg-accent);
  background: var(--seg-soft);
  padding: 2px 8px;
  border-radius: 99px;
}

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

/* Session Card */
.session {
  background: var(--card-bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 4px 10px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  color: inherit;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.2s, box-shadow 0.2s, background 0.2s;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.session::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  transition: background-color 0.2s;
}

.session:not(.disabled):active {
  transform: scale(0.94);
}

.session:not(.disabled):hover {
  border-color: var(--seg-border);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.session .time {
  font-size: clamp(32px, 9.5vw, 41px);
  font-weight: 250;
  letter-spacing: -2px;
  line-height: 0.95;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin: auto 0;
}

.session .status-pill {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-light);
  background: var(--line-subtle);
  padding: 4px 8px;
  border-radius: 7px;
  max-width: 94%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 8px;
  position: relative;
  z-index: 1;
}

/* Filled Card Nuance (Per Segment) */
.session.filled {
  background: linear-gradient(165deg, #ffffff 10%, var(--seg-soft) 100%);
  border-color: var(--seg-border);
  box-shadow: 0 4px 14px -3px var(--seg-glow);
}

.session.filled::before {
  content: "";
  position: absolute;
  inset: -25%;
  background: linear-gradient(
    45deg,
    transparent 22%,
    rgba(255, 255, 255, 0.88) 50%,
    transparent 78%
  );
  transform: translate(-115%, 115%);
  pointer-events: none;
  z-index: 2;
}

.session.filled.highlight-sweep::before {
  animation: cardHighlightSweep 1.5s cubic-bezier(0.22, 1, 0.36, 1) var(--sweep-delay, 0ms) forwards;
}

.session.filled::after {
  background: var(--seg-dot);
}

.session.filled .time {
  color: var(--seg-accent);
  font-weight: 300;
}

.session.filled .status-pill {
  background: var(--seg-pill-bg);
  color: var(--seg-accent);
  font-weight: 750;
  padding: 4px 9px;
}

/* Disabled Card (Youth 08.00) */
.session.disabled {
  background: rgba(235, 239, 235, 0.52);
  border: 1.5px solid #e4e8e4;
  box-shadow: none;
  cursor: not-allowed;
}

.session.disabled .time {
  color: #b7c1ba;
  font-weight: 250;
  opacity: 0.8;
}

.session.disabled .status-pill {
  background: transparent;
  color: #9ba69f;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* Footer */
.app-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-light);
  text-align: center;
}

.app-footer p {
  margin: 0;
}

.app-footer code {
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Dialog / Entry Modal */
dialog#entry {
  border: 0;
  border-radius: 24px;
  padding: 0;
  width: min(460px, calc(100% - 24px));
  max-height: 94dvh;
  color: inherit;
  background: #f8faf8;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform-origin: center center;
}

dialog#entry.is-entering {
  animation: dialogZoomFromCard 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

dialog#entry.is-closing {
  animation: dialogZoomToCard 0.48s cubic-bezier(0.32, 0.72, 0, 1) forwards;
  pointer-events: none;
}

dialog#entry::backdrop {
  background: rgba(14, 24, 18, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

dialog#entry.is-entering::backdrop {
  animation: backdropFadeIn 0.45s ease-out both;
}

dialog#entry.is-closing::backdrop {
  animation: backdropFadeOut 0.44s ease-out forwards;
}

dialog#entry.is-entering .session-hero {
  animation: contentSlideUp 0.48s cubic-bezier(0.16, 1, 0.3, 1) 70ms both;
}

dialog#entry.is-entering .input-card {
  animation: contentSlideUp 0.48s cubic-bezier(0.16, 1, 0.3, 1) 140ms both;
}

dialog#entry.is-entering .entry-bottom {
  animation: contentFadeIn 0.44s ease-out 200ms both;
}

dialog#entry.is-entering .slot:nth-child(1) {
  animation: slotStaggerIn 0.42s cubic-bezier(0.16, 1, 0.3, 1) 180ms both;
}

dialog#entry.is-entering .slot:nth-child(2) {
  animation: slotStaggerIn 0.42s cubic-bezier(0.16, 1, 0.3, 1) 245ms both;
}

dialog#entry.is-entering .slot:nth-child(3) {
  animation: slotStaggerIn 0.42s cubic-bezier(0.16, 1, 0.3, 1) 310ms both;
}

#entry-form {
  display: flex;
  flex-direction: column;
  min-height: 510px;
  height: 100%;
}

.entry-top {
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line-subtle);
  background: #ffffff;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  padding: 8px 6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  transition: background-color 0.15s;
}

.text-button:hover, .text-button:active {
  background: var(--line-subtle);
}

.dialog-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.4px;
  color: var(--text-light);
}

.entry-content {
  padding: 20px 18px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Session Hero Card inside Dialog */
.session-hero {
  background: #ffffff;
  border: 1.5px solid var(--seg-border, var(--line));
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 4px 14px -3px var(--seg-glow, rgba(0, 0, 0, 0.04));
  position: relative;
  overflow: hidden;
}

.session-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
  background: var(--seg-dot, var(--accent));
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.hero-segment-pill {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--seg-accent, var(--accent));
  background: var(--seg-soft, var(--accent-soft));
  padding: 3px 9px;
  border-radius: 6px;
}

.hero-date {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  margin: 0;
}

.hero-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--text);
  margin: 0 0 4px;
}

.hero-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* Input Card & High-Craft OTP Field */
.input-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 16px 18px;
  box-shadow: var(--shadow-sm);
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.field-label {
  font-size: 13px;
  font-weight: 750;
  color: var(--text);
}

.clear-button {
  background: var(--line-subtle);
  border: 0;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 650;
  padding: 4px 10px;
  border-radius: 99px;
  transition: background-color 0.15s, color 0.15s;
}

.clear-button:hover, .clear-button:active {
  background: var(--danger-soft);
  color: var(--danger);
}

.number-field {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 6px 0 10px;
}

.number-field input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 36px;
  cursor: text;
  z-index: 2;
  -webkit-appearance: none;
}

#slots {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 4px;
}

/* 3-Digit Locked Slot Style */
.slot {
  width: 72px;
  height: 88px;
  background: #fcfdfc;
  border: 2px solid #dce3dc;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  position: relative;
  overflow: hidden;
  user-select: none;
  box-shadow: 0 2px 6px rgba(16, 32, 22, 0.03);
  transition:
    border-color 0.2s ease,
    background-color 0.25s ease,
    box-shadow 0.22s ease,
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Glass Shimmer Sweep Overlay */
.slot::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 20%,
    rgba(16, 185, 129, 0.34) 50%,
    transparent 80%
  );
  transform: translateX(-140%);
  pointer-events: none;
}

/* Filled Slot Base State */
.slot.has-value {
  border-color: #6ee7b7;
  background: linear-gradient(180deg, #ffffff 0%, #effcf5 100%);
  color: var(--otp-green-text);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.1);
}

/* Active Focused Slot State */
.number-field:focus-within .slot.active {
  border-color: var(--otp-green);
  background: #ffffff;
  box-shadow:
    0 0 0 4px rgba(16, 185, 129, 0.18),
    0 8px 20px -4px rgba(16, 185, 129, 0.2);
  transform: translateY(-2px);
}

/* High-level Pop + Green Pulse Animation on Digit Entry */
.slot.pop {
  animation: greenSlotPulse 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.slot.pop::before {
  animation: slotShimmer 0.48s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.slot .digit {
  display: inline-block;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.slot.pop .digit {
  animation: digitSpringIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Animated Blinking Caret */
.caret {
  width: 2.5px;
  height: 36px;
  background: linear-gradient(180deg, #10b981, #059669);
  border-radius: 3px;
  display: inline-block;
  animation: caretBlink 1s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.45);
}

.caret.trailing {
  margin-left: 3px;
  height: 32px;
}

.placeholder-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #d2dad2;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Hints & Error */
.field-meta {
  margin-top: 14px;
  text-align: center;
}

.hint-text {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

#input-error {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--danger);
  min-height: 20px;
  margin: 8px 0 0;
  line-height: 1.4;
}

/* Bottom Primary Button */
.entry-bottom {
  padding: 14px 18px max(20px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.primary-btn {
  width: 100%;
  border: 0;
  background: linear-gradient(180deg, #16744e 0%, #115c3e 100%);
  color: #ffffff;
  min-height: 52px;
  border-radius: var(--radius-md);
  font-weight: 750;
  font-size: 15.5px;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.14s, box-shadow 0.18s, filter 0.18s;
  box-shadow: 0 6px 18px -2px rgba(17, 92, 62, 0.32);
}

.primary-btn:hover {
  filter: brightness(1.06);
}

.primary-btn:active {
  transform: scale(0.98);
}

.demo-label {
  font-size: 10.5px;
  color: var(--text-light);
  text-align: center;
  margin: 10px 0 0;
}

/* Toast */
#toast[hidden] {
  display: none !important;
}

#toast {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 11px 18px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #145338;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 28px -4px rgba(16, 83, 56, 0.18), 0 2px 8px rgba(0, 0, 0, 0.05);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid #a7f3d0;
  animation: toastIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

body.is-admin #toast {
  color: #991b1b;
  border-color: #fecaca;
  box-shadow: 0 10px 28px -4px rgba(185, 28, 28, 0.16), 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Keyframes */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dialogZoomFromCard {
  0% {
    opacity: 0;
    transform: translate(var(--origin-x, 0px), var(--origin-y, 24px)) scale(var(--origin-sx, 0.9), var(--origin-sy, 0.9));
    border-radius: 42px;
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1, 1);
    border-radius: var(--dialog-radius, 24px);
  }
}

@keyframes dialogZoomToCard {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1, 1);
    border-radius: var(--dialog-radius, 24px);
  }
  65% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
    transform: translate(var(--origin-x, 0px), var(--origin-y, 24px)) scale(var(--origin-sx, 0.25), var(--origin-sy, 0.16));
    border-radius: 48px;
  }
}

.session.just-landed {
  animation: cardLandBounce 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardLandBounce {
  0% {
    transform: scale(0.95);
  }
  55% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes backdropFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes backdropFadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes cardHighlightSweep {
  0% {
    transform: translate(-115%, 115%);
  }
  100% {
    transform: translate(115%, -115%);
  }
}

@keyframes contentSlideUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes contentFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slotStaggerIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.88);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes caretBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes digitSpringIn {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.65);
    filter: blur(4px);
  }
  58% {
    opacity: 1;
    transform: translateY(-3px) scale(1.08);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes greenSlotPulse {
  0% {
    border-color: var(--otp-green);
    background-color: #d1fae5;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45), inset 0 0 14px rgba(16, 185, 129, 0.22);
    transform: scale(1.04);
  }
  55% {
    border-color: var(--otp-green);
    background-color: #ecfdf5;
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0), inset 0 0 4px rgba(16, 185, 129, 0.08);
    transform: scale(1);
  }
  100% {
    border-color: #6ee7b7;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.1);
  }
}

@keyframes slotShimmer {
  0% {
    transform: translateX(-140%);
  }
  100% {
    transform: translateX(140%);
  }
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.shake {
  animation: shakeEffect 0.34s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.shake .slot {
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}

@keyframes shakeEffect {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Mobile Fullscreen Dialog */
@media (max-width: 600px) {
  dialog#entry {
    --dialog-radius: 0px;
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  #entry-form {
    min-height: 100%;
    min-height: 100dvh;
  }

  .entry-top {
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .entry-bottom {
    position: sticky;
    bottom: 0;
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.04);
  }
}

/* Narrow Devices (320px) */
@media (max-width: 360px) {
  .app {
    padding: 16px 10px 24px;
  }

  .cards {
    gap: 6px;
  }

  .session {
    padding: 12px 4px 10px;
    min-height: 100px;
  }

  .session .time {
    font-size: 29px;
    letter-spacing: -1.4px;
  }

  .slot {
    width: 62px;
    height: 76px;
    font-size: 34px;
    border-radius: 15px;
  }

  #slots {
    gap: 9px;
  }

  .caret {
    height: 30px;
  }
}

/* ======================================================
   ADMIN LOCK & MODE ADMIN (RED THEME)
   ====================================================== */

/* Locked status pill icon on filled card */
.session .status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.lock-inline-icon {
  flex-shrink: 0;
  opacity: 0.78;
}

.session.locked-nudge {
  animation: shakeEffect 0.34s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Clear badge inside filled card in Admin Mode */
.clear-chip {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #b91c1c;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  padding: 2px 7px;
  border-radius: 99px;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Admin Mode Theme Overrides */
body.is-admin {
  --bg: #fdf2f2;
  --accent: #b91c1c;
  --accent-hover: #991b1b;
  --accent-soft: #fee2e2;
  --line: #efd2d2;
  --line-subtle: #fbe8e8;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 50% -10%, rgba(220, 38, 38, 0.13), transparent 55%);
}

body.is-admin .brand-dot {
  background: #ef4444;
}

body.is-admin .summary-pill {
  border-color: #f3c2c2;
  color: #991b1b;
}

body.is-admin .summary-pill.all-done {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

body.is-admin .admin-toggle-btn {
  background: #dc2626;
  border-color: #b91c1c;
  color: #ffffff;
  padding: 0 10px;
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.25);
}

body.is-admin .admin-toggle-btn:hover {
  background: #b91c1c;
  color: #ffffff;
}

body.is-admin .notice {
  background: rgba(254, 226, 226, 0.72);
  border-color: #f5bcbc;
}

body.is-admin .notice-badge {
  background: #b91c1c;
}

body.is-admin .notice-text {
  color: #7f1d1d;
}

body.is-admin .primary-btn {
  background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 6px 18px -2px rgba(185, 28, 28, 0.34);
}

body.is-admin .session.filled {
  border-color: #fca5a5;
}

body.is-admin .session.filled::after {
  background: #dc2626;
}

/* PIN Dialog */
dialog#pin-dialog {
  border: 0;
  border-radius: 24px;
  padding: 0;
  width: min(460px, calc(100% - 24px));
  max-height: 94dvh;
  color: inherit;
  background: #f8faf8;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

dialog#pin-dialog[open] {
  animation: contentSlideUp 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

dialog#pin-dialog::backdrop {
  background: rgba(14, 24, 18, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#pin-form {
  display: flex;
  flex-direction: column;
  max-height: 94dvh;
  height: 100%;
}

.pin-hero {
  background: #ffffff;
  border: 1.5px solid #f3d0d0;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
  box-shadow: 0 4px 14px -3px rgba(185, 28, 28, 0.08);
}

.pin-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #fee2e2;
  color: #b91c1c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.pin-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
  margin: 0 0 6px;
  color: var(--text);
}

.pin-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
}

.pin-input-card {
  padding: 20px 12px 18px;
}

.pin-slots {
  display: flex;
  gap: 7px;
  justify-content: center;
  width: 100%;
  padding: 4px 0;
  position: relative;
}

.pin-focus-glider {
  position: absolute;
  top: 4px;
  left: 0;
  width: 48px;
  height: 74px;
  border-radius: 15px;
  border: 2.5px solid #1f2937;
  box-shadow:
    0 0 0 3.5px rgba(31, 41, 55, 0.1),
    0 8px 18px -4px rgba(31, 41, 55, 0.14);
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition:
    transform 0.34s cubic-bezier(0.34, 1.45, 0.64, 1),
    width 0.2s ease,
    height 0.2s ease,
    opacity 0.2s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

.number-field:focus-within .pin-focus-glider.visible {
  opacity: 1;
}

.pin-slot {
  flex: 1 1 0;
  min-width: 0;
  max-width: 58px;
  height: 74px;
  background: #fcfdfc;
  border: 2px solid #dce3dc;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  position: relative;
  overflow: hidden;
  user-select: none;
  box-shadow: 0 2px 6px rgba(16, 32, 22, 0.03);
  transition:
    border-color 0.25s ease,
    background-color 0.3s ease,
    box-shadow 0.25s ease,
    transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pin-slot::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 18%,
    rgba(16, 185, 129, 0.42) 50%,
    transparent 82%
  );
  transform: translateX(-140%);
  pointer-events: none;
}

.pin-slot.has-value {
  border-color: #b7c2ba;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 3px 10px rgba(16, 32, 22, 0.06);
}

.number-field:focus-within .pin-slot.active {
  background: #ffffff;
  transform: translateY(-2px);
}

.pin-slot .caret {
  height: 28px;
  background: #1f2937;
  box-shadow: none;
}

.pin-slot .digit {
  display: inline-block;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.pin-slot.pop .digit {
  animation: digitSpringIn 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Verifying subtle pulse */
.pin-slots.is-verifying .pin-slot {
  animation: pinVerifyPulse 0.7s ease-in-out infinite alternate;
  animation-delay: calc(var(--slot-i, 0) * 60ms);
}

@keyframes pinVerifyPulse {
  from {
    transform: scale(1);
    border-color: #b7c2ba;
  }
  to {
    transform: scale(0.96);
    border-color: #9ca3af;
  }
}

/* Success Green Wave across all 6 boxes */
.pin-slots.is-success .pin-focus-glider {
  opacity: 0 !important;
}

.pin-slots.is-success .pin-slot {
  border-color: var(--otp-green);
  background: linear-gradient(180deg, #ffffff 0%, #d1fae5 100%);
  color: var(--otp-green-text);
  box-shadow: 0 0 0 3.5px rgba(16, 185, 129, 0.22), 0 8px 18px -4px rgba(16, 185, 129, 0.28);
  animation: greenSlotWave 0.65s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--slot-i, 0) * 65ms) both;
}

.pin-slots.is-success .pin-slot::before {
  animation: slotShimmer 0.65s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--slot-i, 0) * 65ms) forwards;
}

@keyframes greenSlotWave {
  0% {
    transform: scale(1);
    border-color: #b7c2ba;
  }
  45% {
    transform: translateY(-4px) scale(1.06);
    border-color: #10b981;
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.18), 0 10px 22px -4px rgba(16, 185, 129, 0.32);
  }
  100% {
    transform: translateY(0) scale(1);
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16);
  }
}

/* Error Red State across all 6 boxes */
.pin-slots.is-error .pin-focus-glider {
  opacity: 0 !important;
}

.pin-slots.is-error .pin-slot,
.shake .pin-slot {
  border-color: #ef4444 !important;
  background: linear-gradient(180deg, #ffffff 0%, #fef2f2 100%) !important;
  color: #dc2626 !important;
  box-shadow: 0 0 0 3.5px rgba(239, 68, 68, 0.2), 0 6px 14px rgba(239, 68, 68, 0.14) !important;
}

.error-text {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--danger);
  min-height: 20px;
  margin: 8px 0 0;
  line-height: 1.4;
}

.primary-btn.admin-btn {
  background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 6px 18px -2px rgba(185, 28, 28, 0.32);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

/* Confirm Clear Dialog */
dialog#confirm-dialog {
  border: 0;
  border-radius: 22px;
  padding: 0;
  width: min(360px, calc(100% - 32px));
  max-height: 90dvh;
  background: #ffffff;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

dialog#confirm-dialog[open] {
  animation: contentSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

dialog#confirm-dialog::backdrop {
  background: rgba(14, 24, 18, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.confirm-box {
  padding: 24px 20px 20px;
  text-align: center;
  max-height: 90dvh;
  overflow-y: auto;
}

.confirm-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #fee2e2;
  color: #dc2626;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.confirm-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 8px;
  color: var(--text);
}

.confirm-message {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 6px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.secondary-btn {
  min-height: 46px;
  border: 1.5px solid #dce2dc;
  background: #ffffff;
  color: var(--text);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  transition: background-color 0.15s;
}

.secondary-btn:hover {
  background: #f4f6f4;
}

.danger-btn {
  min-height: 46px;
  border: 0;
  background: #dc2626;
  color: #ffffff;
  border-radius: var(--radius-sm);
  font-weight: 750;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
  transition: background-color 0.15s, transform 0.12s;
}

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

.danger-btn:active {
  transform: scale(0.97);
}

.danger-btn:disabled, .secondary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Date Picker Dialog (Mode Admin) */
dialog#date-dialog {
  border: 0;
  border-radius: 24px;
  padding: 0;
  width: min(460px, calc(100% - 24px));
  max-height: 94dvh;
  color: inherit;
  background: #f8faf8;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

dialog#date-dialog[open] {
  animation: contentSlideUp 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

dialog#date-dialog::backdrop {
  background: rgba(14, 24, 18, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#date-form {
  display: flex;
  flex-direction: column;
  max-height: 94dvh;
  height: 100%;
}

.date-dialog-hero {
  background: linear-gradient(180deg, #fefcf3 0%, #fbf6e3 100%);
  border: 1.5px solid #e7d69c;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.date-input-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.date-picker-input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  background: #fcfdfc;
  border: 2px solid #dce3dc;
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.date-picker-input:focus {
  border-color: #b91c1c;
  box-shadow: 0 0 0 3.5px rgba(185, 28, 28, 0.14);
  background: #ffffff;
}

/* Mobile Fullscreen for PIN & Date Dialogs */
@media (max-width: 600px) {
  dialog#pin-dialog,
  dialog#date-dialog {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  #pin-form,
  #date-form {
    min-height: 100dvh;
    max-height: 100dvh;
  }
}

@media (max-width: 360px) {
  .pin-slots {
    gap: 5px;
  }

  .pin-slot {
    height: 62px;
    font-size: 22px;
    border-radius: 12px;
  }
}

/* Short Landscape Fix (e.g. 756x413) so Submit button is never clipped */
@media (max-height: 520px) {
  dialog#entry, dialog#pin-dialog, dialog#date-dialog {
    max-height: 98dvh;
  }

  #entry-form, #pin-form, #date-form {
    min-height: 0;
    max-height: 98dvh;
  }

  .entry-top {
    padding: 8px 16px;
  }

  .entry-content {
    padding: 10px 16px;
  }

  .session-hero, .pin-hero, .date-dialog-hero {
    padding: 10px 14px;
    margin-bottom: 10px;
  }

  .pin-icon-wrap {
    display: none;
  }

  .hero-title, .pin-title {
    font-size: 18px;
  }

  .input-card {
    padding: 12px 14px;
  }

  .field-header {
    margin-bottom: 8px;
  }

  .slot {
    height: 62px;
    font-size: 30px;
  }

  .pin-slot {
    height: 48px;
    font-size: 20px;
  }

  .field-meta {
    margin-top: 8px;
  }

  .entry-bottom {
    padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  }

  .primary-btn {
    min-height: 44px;
  }

  .demo-label {
    margin-top: 6px;
  }
}

/* Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
