:root {
  --pink: #ff8fab;
  --pink-dark: #e26d8d;
  --pink-soft: #ffd6e3;
  --cream: #fff8fb;
  --card: #ffffff;
  --ink: #5b4a52;
  --muted: #a08a94;
  --mint: #bfe8cf;
  --yellow: #ffe9a8;
  --blue: #c7e9ff;
  --purple: #dccdf5;
  --teal: #bde8e2;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(226, 109, 141, 0.14);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: 'Quicksand', 'Segoe UI', sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #fff0f5 0%, #fff9f0 40%, #f0f9ff 100%);
  min-height: 100vh;
}
h1, h2, h3, .brand-name, .auth-tab, .tab { font-family: 'Baloo 2', cursive; }
.hidden { display: none !important; }

/* ---------- header ---------- */
#app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--pink-soft);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 32px; }
.brand-name { font-size: 20px; font-weight: 800; color: var(--pink-dark); line-height: 1; }
.brand-sub { font-size: 12px; color: var(--muted); }
.header-right { display: flex; gap: 8px; align-items: center; }
.demo-badge {
  font-size: 11px; font-weight: 700; color: #8a6d1a;
  background: var(--yellow); border-radius: 20px; padding: 4px 10px;
}

/* ---------- buttons & inputs ---------- */
.btn {
  font-family: 'Baloo 2', cursive; font-weight: 700; font-size: 15px;
  border: none; border-radius: 14px; padding: 10px 18px; cursor: pointer;
  background: #f3e4ec; color: var(--ink); transition: transform .1s, box-shadow .2s;
}
.btn:active { transform: scale(0.96); }
.btn.primary { background: linear-gradient(135deg, var(--pink), var(--pink-dark)); color: #fff; box-shadow: var(--shadow); }
.btn.ghost { background: transparent; border: 2px solid var(--pink-soft); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.big { width: 100%; padding: 13px; font-size: 17px; margin-top: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input[type="email"], input[type="password"], input[type="text"], input[type="date"], input[type="number"], select {
  width: 100%; padding: 12px 14px; margin-top: 6px;
  border: 2px solid var(--pink-soft); border-radius: 12px;
  font-family: inherit; font-size: 15px; color: var(--ink); background: #fff;
}
input:focus, select:focus { outline: none; border-color: var(--pink); }
label { display: block; margin: 12px 0; font-weight: 600; font-size: 14px; text-align: left; }
label small { color: var(--muted); font-weight: 500; }
.code-input { font-size: 28px !important; letter-spacing: 10px; text-align: center; font-weight: 700; }

/* ---------- auth ---------- */
#auth-view { display: flex; justify-content: center; padding: 32px 16px; }
.auth-card {
  background: var(--card); border-radius: 26px; box-shadow: var(--shadow);
  padding: 32px 28px; width: 100%; max-width: 420px; text-align: center;
  border: 3px solid var(--pink-soft);
}
.auth-logo { font-size: 56px; }
.auth-card h1 { color: var(--pink-dark); margin: 4px 0; font-size: 34px; }
.tagline { color: var(--muted); margin-top: 0; }
.auth-tabs { display: flex; gap: 8px; margin: 18px 0 6px; }
.auth-tab { flex: 1; padding: 10px; border-radius: 12px; border: 2px solid var(--pink-soft); background: #fff; cursor: pointer; font-size: 16px; color: var(--muted); }
.auth-tab.active { background: var(--pink-soft); color: var(--pink-dark); border-color: var(--pink); }
.hint { color: var(--muted); font-size: 14px; }
.hint.small { font-size: 12.5px; }
.msg { color: var(--pink-dark); font-weight: 600; min-height: 20px; font-size: 14px; }
.ver { text-align: center; font-size: 11px; color: #c9a9b4; margin: 12px 0 0; }
.demo-code { background: var(--yellow); border-radius: 12px; padding: 10px; font-size: 15px; }

/* ---------- layout ---------- */
#app-view { max-width: 860px; margin: 0 auto; padding: 0 14px 40px; }
#tabs {
  display: flex; gap: 6px; margin: 14px 0;
  background: #fff; border-radius: 20px; padding: 8px;
  box-shadow: var(--shadow); border: 2px solid var(--pink-soft);
  position: sticky; top: 66px; z-index: 40;
  overflow-x: auto;
}
.tab {
  flex: 1; min-width: 64px; border: none; background: transparent; cursor: pointer;
  border-radius: 14px; padding: 8px 4px; font-size: 20px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab span { font-size: 11px; font-weight: 700; }
.tab.active { background: linear-gradient(135deg, var(--pink-soft), #ffeef4); color: var(--pink-dark); }
.panel { animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 4px 12px; flex-wrap: wrap; gap: 8px; }
.panel-head h2 { margin: 0; color: var(--pink-dark); font-size: 24px; }
.panel-head h3 { margin: 0; }
.panel-head small { color: var(--muted); font-family: 'Quicksand'; font-size: 14px; }

/* ---------- cards & lists ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); border: 2px solid #fbe7ee; position: relative;
}
.code-chip {
  display: inline-block; background: var(--purple); color: #5b4a72;
  font-weight: 700; font-size: 12px; border-radius: 8px; padding: 3px 10px; margin: 6px 0;
  letter-spacing: 1px;
}
.subjek-card h3 { margin: 2px 0 4px; font-size: 19px; }
.progress { height: 10px; background: #f3e4ec; border-radius: 6px; overflow: hidden; margin: 10px 0 4px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--pink), #ffb3c6); border-radius: 6px; transition: width .3s; }
.progress-label { font-size: 12.5px; color: var(--muted); }
.card-actions { display: flex; gap: 6px; margin-top: 10px; }
.icon-btn { border: none; background: #f8eef2; border-radius: 10px; padding: 7px 10px; cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: var(--pink-soft); }
.icon-btn.danger:hover { background: #ffd9de; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  background: var(--card); border-radius: 16px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow); border: 2px solid #fbe7ee;
}
.row.done { opacity: 0.65; }
.row.done .row-title { text-decoration: line-through; }
.check {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  border: 3px solid var(--pink-soft); background: #fff; cursor: pointer;
  font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.check.on { background: var(--mint); border-color: #7bc496; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; font-size: 16px; }
.row-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.date-chip {
  background: var(--blue); color: #2f5d7d; font-weight: 700; font-size: 12.5px;
  border-radius: 10px; padding: 5px 10px; white-space: nowrap;
}
.date-chip.urgent { background: #ffd9de; color: #b03248; }
.date-chip.today { background: var(--yellow); color: #8a6d1a; }
.date-chip.over { background: #e0a3b0; color: #fff; }
.row-actions { display: flex; gap: 4px; flex-shrink: 0; }

.pills { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; }
.pill {
  border: 2px solid var(--pink-soft); background: #fff; border-radius: 20px;
  padding: 8px 16px; cursor: pointer; font-family: 'Baloo 2'; font-weight: 700;
  font-size: 14px; white-space: nowrap; color: var(--ink);
}
.pill.active { background: var(--pink); border-color: var(--pink); color: #fff; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 40px; }
.empty p { font-size: 15px; }

.widget-box {
  background: linear-gradient(135deg, #e8f7ee, #f0f9ff);
  border: 2px dashed #7bc496; border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; font-size: 14px;
}
.widget-box p { margin: 8px 0 12px; line-height: 1.7; }

/* ---------- template ---------- */
.template-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.template-card {
  border: 3px solid var(--pink-soft); border-radius: var(--radius); overflow: hidden;
  background: #fff; cursor: pointer; padding: 0; font-family: 'Baloo 2'; font-weight: 700; font-size: 16px;
}
.template-card img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.template-card span { display: block; padding: 10px; }
.template-card.selected { border-color: var(--pink-dark); box-shadow: 0 0 0 3px var(--pink-soft); }
.preview-wrap {
  background: #fff; border-radius: var(--radius); padding: 12px;
  box-shadow: var(--shadow); border: 2px solid #fbe7ee; margin-bottom: 14px;
}
#preview-canvas { width: 100%; border-radius: 12px; display: block; }

/* ---------- modal & toast ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; background: rgba(91, 74, 82, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card {
  background: #fff; border-radius: 22px; padding: 24px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2); border: 3px solid var(--pink-soft);
}
.modal-card h3 { margin: 0 0 6px; color: var(--pink-dark); }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 30px;
  font-weight: 600; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  animation: fadein .2s ease; max-width: 90vw; text-align: center;
}

@media (max-width: 560px) {
  .row { flex-wrap: wrap; }
  .row-actions { width: 100%; justify-content: flex-end; }
  #tabs { top: 62px; }
}
