:root {
  /* Brand palette — warm playful */
  --ink: #1b1740;        /* deep navy ink */
  --ink-soft: #45406b;
  --muted: #8b87a8;
  --paper: #fffaf2;       /* warm white */
  --paper-2: #fff5e6;
  --card: #ffffff;
  --border: #ece4d6;
  --border-strong: #1b1740;

  --sky: #7CC8FF;
  --sky-deep: #3FA4F2;
  --coral: #FF8A8A;
  --coral-deep: #F26666;
  --mint: #A7E8C4;
  --mint-deep: #5DC892;
  --yellow: #FFD668;
  --yellow-deep: #F6B93B;
  --purple: #B79CFF;
  --purple-deep: #8364E8;
  --pink: #FFB0DB;

  --shadow-sm: 0 2px 0 var(--ink);
  --shadow: 0 4px 0 var(--ink);
  --shadow-lg: 0 6px 0 var(--ink);
  --shadow-soft: 0 10px 30px -10px rgba(27, 23, 64, 0.18);

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-xl: 36px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Quicksand", "Noto Sans Thai", system-ui, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, .display {
  font-family: "Baloo 2", "Quicksand", system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}

button { font-family: inherit; }

/* ============== App shell ============== */
.app {
  min-height: 100vh;
  background:
    radial-gradient(800px 500px at 90% -10%, rgba(124, 200, 255, 0.18), transparent 60%),
    radial-gradient(700px 500px at -10% 30%, rgba(255, 138, 138, 0.14), transparent 60%),
    radial-gradient(900px 600px at 50% 110%, rgba(183, 156, 255, 0.16), transparent 60%),
    var(--paper);
  display: grid;
  grid-template-columns: 260px 1fr 360px;
  gap: 0;
}

@media (max-width: 1280px) {
  .app { grid-template-columns: 240px 1fr; }
  .right-rail { display: none !important; }
}

/* ============== Sidebar ============== */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 2px solid var(--ink);
  background: var(--card);
  z-index: 5;
}
.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 18px;
}
.sidebar .logo .mark {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: var(--coral);
  border: 2px solid var(--ink);
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.sidebar .logo h1 {
  font-size: 24px;
  line-height: 1;
}
.sidebar .logo small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  font-family: "Quicksand", sans-serif;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  cursor: pointer;
  border: 2px solid transparent;
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 15px;
  transition: transform 0.12s ease, background 0.12s ease;
  user-select: none;
}
.nav-item:hover { background: var(--paper-2); }
.nav-item .ico {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--paper-2);
  flex-shrink: 0;
}
.nav-item.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.nav-item.active .ico { background: rgba(255,255,255,0.15); color: white; }
.nav-item .badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--coral);
  color: white;
  border: 1.5px solid var(--ink);
}

.profile-card {
  margin-top: auto;
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--yellow) 0%, var(--coral) 100%);
  box-shadow: var(--shadow-sm);
  display: flex; gap: 10px; align-items: center;
}
.profile-card .avi {
  width: 44px; height: 44px; border-radius: 50%;
  background: white; border: 2px solid var(--ink);
  display: grid; place-items: center;
  font-size: 22px;
}
.profile-card b { font-family: "Baloo 2"; font-size: 16px; }
.profile-card .lv { font-size: 12px; font-weight: 700; color: var(--ink-soft); }

/* ============== Main column ============== */
.main {
  padding: 28px 36px 80px;
  min-width: 0;
}

.topbar {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 22px;
}
.search {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  background: white;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 12px 20px;
  box-shadow: var(--shadow-sm);
}
.search input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 15px; font-family: inherit; font-weight: 500;
  color: var(--ink);
}
.search input::placeholder { color: var(--muted); }
.icon-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
  cursor: pointer;
  position: relative;
}
.icon-btn .dot {
  position: absolute; top: 6px; right: 8px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--coral); border: 2px solid white;
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 0 var(--ink); }

/* ============== Cards ============== */
.card {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 22px;
  position: relative;
}
.card.flat { box-shadow: var(--shadow-sm); }
.card.tint-sky { background: linear-gradient(160deg, #DCF0FF 0%, #B3DFFF 100%); }
.card.tint-coral { background: linear-gradient(160deg, #FFE0E0 0%, #FFC2C2 100%); }
.card.tint-mint { background: linear-gradient(160deg, #DAF6E6 0%, #B8EBD0 100%); }
.card.tint-yellow { background: linear-gradient(160deg, #FFEEC2 0%, #FFE08A 100%); }
.card.tint-purple { background: linear-gradient(160deg, #E5DAFF 0%, #CBB6FF 100%); }
.card.tint-dark { background: var(--ink); color: white; }
.card.tint-dark h1, .card.tint-dark h2, .card.tint-dark h3 { color: white; }

/* ============== Buttons ============== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: "Baloo 2"; font-weight: 700; font-size: 15px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: white;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 0 var(--ink); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--coral); color: white; }
.btn.sky { background: var(--sky); color: var(--ink); }
.btn.mint { background: var(--mint); color: var(--ink); }
.btn.yellow { background: var(--yellow); color: var(--ink); }
.btn.purple { background: var(--purple); color: var(--ink); }
.btn.dark { background: var(--ink); color: white; }
.btn.line { background: #06C755; color: white; }
.btn.lg { padding: 16px 28px; font-size: 17px; }
.btn.sm { padding: 7px 14px; font-size: 13px; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--paper-2); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }

/* ============== Pills / Badges ============== */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--ink);
  background: white;
  color: var(--ink);
}
.pill.sky { background: var(--sky); }
.pill.mint { background: var(--mint); }
.pill.coral { background: var(--coral); color: white; }
.pill.yellow { background: var(--yellow); }
.pill.purple { background: var(--purple); }
.pill.ghost { border-color: var(--border); background: transparent; }

.sticker {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: white;
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-sm);
  transform: rotate(-2deg);
}

/* ============== Layout helpers ============== */
.row { display: flex; gap: 14px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 14px; }
.grid { display: grid; gap: 18px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }

/* ============== Right rail ============== */
.right-rail {
  border-left: 2px solid var(--ink);
  background: var(--card);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ============== Mascot ============== */
.mascot-wrap {
  position: relative;
  display: inline-block;
}
.mascot {
  animation: float 4s ease-in-out infinite;
  transform-origin: center;
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}
@keyframes wobble {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes shine {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* ============== Floating shapes ============== */
.floaty {
  position: absolute;
  pointer-events: none;
  opacity: 0.9;
  animation: float 6s ease-in-out infinite;
}

/* ============== Calendar / Booking ============== */
.day-pill {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 6px;
  border-radius: var(--r-md);
  background: white;
  border: 2px solid var(--ink);
  cursor: pointer;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease;
}
.day-pill:hover { transform: translateY(-2px); }
.day-pill .d { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.day-pill .n { font-family: "Baloo 2"; font-size: 22px; font-weight: 800; }
.day-pill.active { background: var(--ink); color: white; }
.day-pill.active .d, .day-pill.active .n { color: white; }
.day-pill.disabled { opacity: 0.35; cursor: not-allowed; }

.time-slot {
  padding: 14px 10px;
  border-radius: var(--r-md);
  border: 2px solid var(--ink);
  background: white;
  font-family: "Baloo 2";
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease;
  position: relative;
}
.time-slot:hover { transform: translateY(-2px); }
.time-slot.booked { background: var(--paper-2); color: var(--muted); cursor: not-allowed; text-decoration: line-through; }
.time-slot.selected { background: var(--coral); color: white; }

/* ============== Progress bar ============== */
.bar {
  height: 14px;
  background: var(--paper-2);
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--coral), var(--yellow));
  border-right: 2px solid var(--ink);
  border-radius: 0 999px 999px 0;
}

/* ============== LINE chat ============== */
.line-strip {
  background: #06C755;
  color: white;
  border-radius: var(--r-md);
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  border: 2px solid var(--ink);
  font-weight: 700;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  background: white;
  border: 2px solid var(--ink);
  font-size: 14px;
  line-height: 1.4;
  box-shadow: var(--shadow-sm);
}
.bubble.me {
  background: var(--coral);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.bubble.them {
  background: white;
  border-bottom-left-radius: 4px;
}
.bubble.line {
  background: #DCF8C6;
}

/* ============== Tutor card ============== */
.tutor-card {
  position: relative;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 18px;
  cursor: pointer;
  transition: transform 0.15s ease;
  overflow: hidden;
}
.tutor-card:hover { transform: translateY(-3px); }
.tutor-card .avatar {
  width: 72px; height: 72px;
  border-radius: 22px;
  border: 2px solid var(--ink);
  display: grid; place-items: center;
  font-size: 38px;
  flex-shrink: 0;
  background: var(--yellow);
}

/* ============== Stat tile ============== */
.stat {
  padding: 14px;
  border-radius: var(--r-md);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-sm);
  background: white;
}
.stat .v {
  font-family: "Baloo 2";
  font-weight: 800;
  font-size: 28px;
  line-height: 1;
}
.stat .l {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 700;
  margin-top: 4px;
}

/* ============== Misc utilities ============== */
.divider {
  height: 2px;
  background: var(--border);
  border-radius: 1px;
}
.kbd {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--paper-2);
  border: 1px solid var(--border);
}

.confetti {
  position: absolute;
  width: 8px; height: 14px;
  border-radius: 3px;
  animation: confettiFall 3s linear infinite;
}
@keyframes confettiFall {
  0% { transform: translateY(-100px) rotate(0); opacity: 1; }
  100% { transform: translateY(600px) rotate(720deg); opacity: 0; }
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Tweaks panel positioning override for our app */
.tutoro-tweaks { z-index: 99; }

/* ============== Mobile layout ============== */
.m-app {
  min-height: 100vh;
  background:
    radial-gradient(500px 320px at 90% -10%, rgba(124, 200, 255, 0.18), transparent 60%),
    radial-gradient(400px 320px at -10% 30%, rgba(255, 138, 138, 0.14), transparent 60%),
    var(--paper);
  position: relative;
  padding-bottom: env(safe-area-inset-bottom);
}

.m-screen {
  min-height: 100vh;
  position: relative;
}

.m-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(255, 250, 242, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.m-logo-mark {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--coral);
  border: 2px solid var(--ink);
  box-shadow: 0 2px 0 var(--ink);
  display: grid; place-items: center;
  flex-shrink: 0;
}

.m-back-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: white;
  box-shadow: 0 2px 0 var(--ink);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 700; font-family: inherit;
  flex-shrink: 0;
  color: var(--ink);
}

.m-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 8px calc(20px + env(safe-area-inset-bottom)) 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 2px solid var(--ink);
  display: flex;
  justify-content: space-around;
  z-index: 20;
}

.m-nav-btn {
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--muted);
  font-family: inherit;
}

.m-nav-btn.active { color: var(--coral-deep); }

.m-nav-ico {
  width: 36px; height: 36px;
  border-radius: 12px;
  display: grid; place-items: center;
  position: relative;
}

.m-nav-btn.active .m-nav-ico { background: var(--paper-2); }

.m-nav-badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  background: var(--coral);
  color: white;
  font-size: 9px; font-weight: 800;
  display: grid; place-items: center;
  padding: 0 4px;
  border: 1.5px solid white;
}

.m-nav-label {
  font-size: 10px;
  font-weight: 800;
}

.m-section-title {
  font-family: "Baloo 2";
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
}

.m-section-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.m-link-btn {
  border: 0;
  background: transparent;
  color: var(--coral-deep);
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.m-pill-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.m-pill-scroll::-webkit-scrollbar { display: none; }

.m-form-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.m-sticky-cta {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 250, 242, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 2px solid var(--ink);
  z-index: 15;
}

.m-chat-input {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 2px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 15;
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

@media (max-width: 768px) {
  .floaty { opacity: 0.5; transform: scale(0.7); }
  h1 { line-height: 1.1; }
  body { overflow-x: hidden; }
}
