:root {
  --ink: #17345a;
  --muted: #6a7fa3;
  --line: #dde7f5;
  --teal: #1bb5b8;
  --lav: #8a5cd0;
  --pink: #e5487f;
  --bg: #eef4fc;
  --display: "Lilita One", "Fredoka", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink);
  background: radial-gradient(1200px 500px at 10% -10%, #dff5f3, transparent), radial-gradient(1000px 500px at 100% 0, #ece3ff, transparent), var(--bg);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); font-size: .9rem; margin: 6px 0 12px; }

.btn {
  border: 0; border-radius: 999px; padding: 10px 20px; font-weight: 600; font-size: 1rem; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { color: #fff; background: linear-gradient(90deg, #1bb5b8, #4f8ff0); box-shadow: 0 6px 16px rgba(40, 130, 210, .3); }
.btn.primary:disabled { background: #b9c8dc; box-shadow: none; cursor: default; transform: none; }
.btn.ghost { background: #fff; color: #4b6390; box-shadow: inset 0 0 0 2px var(--line); }
.btn.big { width: 100%; justify-content: center; padding: 13px; font-size: 1.1rem; }
.btn.add { background: #fff; color: #0f8b8e; box-shadow: inset 0 0 0 2px #bfe9e6; }
.btn.add:hover { background: #e9faf8; }

/* Classrooms (owner) */
.class-name { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 1rem; color: var(--lav); margin-left: 6px; }
.class-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.class-list li { border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; display: grid; gap: 2px; }
.class-list .cn { font-weight: 600; }
.class-list .cs { font-size: .8rem; color: var(--muted); word-break: break-all; }
.class-list .ca { display: flex; gap: 4px; margin-top: 6px; }
.class-list .ca a, .class-list .ca button { width: 32px; height: 32px; border-radius: 9px; border: 0; background: #f1f5fb; display: grid; place-items: center; text-decoration: none; font-size: .9rem; }
.class-list .ca a:hover, .class-list .ca button:hover { background: #e2ecf9; }
.class-list .empty { border-style: dashed; color: var(--muted); font-size: .9rem; display: block; }
.class-form { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.class-form .btn { justify-content: center; }
.class-form .error { font-size: .85rem; margin: 0 !important; }
.share { margin-top: 12px; padding: 12px; border-radius: 14px; background: #eefbf6; border: 2px solid #bfeedd; font-size: .88rem; line-height: 1.5; }
.share pre { white-space: pre-wrap; word-break: break-all; margin: 6px 0 8px; font: inherit; font-size: .82rem; background: #fff; border-radius: 10px; padding: 8px; }
.share .btn { padding: 6px 14px; font-size: .9rem; }

/* Lock */
.lock { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(180deg, #1c2a62, #4f63b4 60%, #b9a8ea); }
.lock-card { width: min(400px, 100%); background: #fff; border-radius: 28px; padding: 30px 28px 22px; text-align: center; box-shadow: 0 30px 70px rgba(0, 0, 0, .35); }
.lock-pip { width: 110px; margin-top: -80px; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .25)); }
.lock-card h1 { font-family: var(--display); font-weight: 400; font-size: 2.2rem; }
.lock-card p { color: var(--muted); margin: 6px 0 16px; }
.lock-card input[type="password"] { width: 100%; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); font-size: 1.05rem; }
.lock-card input:focus { outline: none; border-color: var(--teal); }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; justify-content: center; margin: 12px 0 16px; color: var(--muted); font-size: .9rem; }
.check input { width: auto; margin: 0; }
.error { color: var(--pink); font-weight: 600; min-height: 1.3em; margin: 10px 0 0 !important; }
.back { color: var(--muted); font-size: .9rem; }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px clamp(14px, 3vw, 32px); background: rgba(255, 255, 255, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 46px; }
.brand h1 { font-family: var(--display); font-weight: 400; font-size: 1.6rem; line-height: 1; }
.status { font-size: .85rem; color: var(--muted); font-weight: 500; }
.status.dirty { color: #c07000; }
.status.ok { color: #138a5a; }
.bar-actions { display: flex; gap: 10px; }

.notice { margin: 16px clamp(14px, 3vw, 32px) 0; padding: 12px 16px; border-radius: 14px; background: #fff7df; border: 2px solid #ffe3a3; color: #7a5600; font-size: .95rem; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; padding: 20px clamp(14px, 3vw, 32px) 80px; max-width: 1280px; margin: 0 auto; }
.panel { background: #fff; border-radius: 20px; padding: 18px; box-shadow: 0 6px 20px rgba(30, 60, 120, .07); border: 1px solid var(--line); }
.heading-panel { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: .85rem; color: #4b6390; }
input, select, textarea { border: 2px solid var(--line); border-radius: 12px; padding: 9px 11px; background: #fff; font-size: 1rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(27, 181, 184, .12); }
textarea { resize: vertical; line-height: 1.35; }

.list-head { margin: 26px 4px 12px; }
.list-head h2 { font-family: var(--display); font-weight: 400; font-size: 1.7rem; }
.list-head p { margin: 4px 0 0; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.card {
  background: #fff; border-radius: 20px; padding: 14px 16px 16px; border: 2px solid var(--line); box-shadow: 0 4px 14px rgba(30, 60, 120, .06);
  display: grid; gap: 10px; transition: border-color .2s, box-shadow .2s, transform .2s, opacity .2s;
  border-left: 8px solid var(--accent, var(--teal));
}
.card:focus-within { border-color: #b7e6e4; border-left-color: var(--accent, var(--teal)); box-shadow: 0 8px 24px rgba(30, 90, 140, .12); }
.card.final { background: linear-gradient(90deg, #fffaf0, #fff); }
.card.dragging { opacity: .45; }
.card { position: relative; }
.card.drop-before::before, .card.drop-after::after {
  content: ""; position: absolute; left: 10px; right: 10px; height: 6px; border-radius: 6px; background: var(--teal); box-shadow: 0 0 12px rgba(27, 181, 184, .6);
}
.card.drop-before::before { top: -10px; }
.card.drop-after::after { bottom: -10px; }
body.dragging { user-select: none; cursor: grabbing; }
.card.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { background: #e6fbf8; transform: scale(1.01); } }
.card.leaving { transform: translateX(40px); opacity: 0; }
.card-top { display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) 200px auto; gap: 10px; align-items: center; }
.handle { border: 0; background: none; font-size: 1.4rem; color: #a9b8d0; cursor: grab; padding: 4px 2px; line-height: 1; touch-action: none; }
.handle:active { cursor: grabbing; }
.daybadge { width: 58px; text-align: center; border-radius: 14px; padding: 4px 0 2px; background: var(--accent-bg, #e2f8f6); color: var(--accent, #0f8b8e); line-height: 1; }
.daybadge small { display: block; font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.daybadge b { font-family: var(--display); font-weight: 400; font-size: 1.6rem; }
.emoji { width: 52px; height: 52px; border-radius: 14px; border: 2px dashed var(--line); background: #f7faff; font-size: 1.7rem; line-height: 1; }
.emoji:hover { border-color: var(--teal); background: #eefbfa; }
.f-title { font-weight: 600; font-size: 1.1rem; }
.tools { display: flex; gap: 4px; }
.icon { width: 36px; height: 36px; border-radius: 10px; border: 0; background: #f1f5fb; color: #4b6390; font-size: 1rem; }
.icon:hover { background: #e2ecf9; }
.icon:disabled { opacity: .35; cursor: default; }
.icon.del:hover { background: #ffe3ec; }
.icon.preview { color: #0f8b8e; }
.joke-row { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }
.final-tag { font-size: .75rem; font-weight: 700; color: #b26b00; background: #fff1cc; border-radius: 99px; padding: 2px 10px; justify-self: start; }

.add-row { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin-top: 16px; }

.side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 86px; align-self: start; max-height: calc(100vh - 100px); overflow: auto; }
.side h3 { font-size: 1.1rem; }
.ideas { display: flex; flex-wrap: wrap; gap: 8px; }
.idea { border: 2px solid var(--line); background: #fbfdff; border-radius: 999px; padding: 6px 12px; font-size: .9rem; font-weight: 500; text-align: left; }
.idea:hover { border-color: var(--teal); background: #eefbfa; }
.tips ul { margin: 10px 0 0; padding-left: 18px; font-size: .9rem; line-height: 1.45; color: #3c5583; }
.tips li { margin-bottom: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: #17345a; color: #fff; border-radius: 16px;
  padding: 12px 16px; display: flex; gap: 14px; align-items: center; box-shadow: 0 12px 30px rgba(0, 0, 0, .3); font-weight: 500;
  animation: up .3s ease;
}
.toast button { border: 0; background: #ffcf46; color: #17345a; font-weight: 700; border-radius: 999px; padding: 6px 14px; }
@keyframes up { from { transform: translate(-50%, 20px); opacity: 0; } }

.emoji-pop {
  position: absolute; z-index: 40; width: 300px; padding: 10px; background: #fff; border-radius: 16px; border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(20, 40, 90, .2); display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
}
.emoji-pop button { border: 0; background: none; font-size: 1.45rem; padding: 4px 0; border-radius: 8px; }
.emoji-pop button:hover { background: #eef5ff; }
.emoji-pop input { grid-column: 1 / -1; margin-top: 6px; font-size: .9rem; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .card-top { grid-template-columns: auto auto auto minmax(0, 1fr); }
  .f-style { grid-column: 2 / 5; }
  .tools { grid-column: 1 / -1; justify-content: flex-end; }
}
@media (max-width: 600px) {
  .heading-panel, .joke-row { grid-template-columns: 1fr; }
  .handle { display: none; }
  .card-top { grid-template-columns: auto auto minmax(0, 1fr); }
  .f-style { grid-column: 1 / -1; }
}
