/* =========================================================
   Media Ajar Generator — by Evegrow Digital
   Brand: ungu pastel · Tombol: ungu pastel terang
   ========================================================= */
:root {
  color-scheme: light;
  --bg: #f6f2ff;
  --surface: #ffffff;
  --brand: #b9a2f2;          /* ungu pastel brand */
  --brand-soft: #e9e0ff;
  --btn: #dccfff;            /* tombol: ungu pastel terang */
  --btn-hover: #cfbdff;
  --btn-edge: #c4aff8;
  --btn-ink: #3b2478;
  --ink: #2a1f4d;
  --ink-soft: #5d5381;
  --line: #e1d7fa;
  --danger: #b3261e;
  --radius: 18px;
  --font-head: 'Bricolage Grotesque', 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 85% -80px, #e4d8ff 0%, transparent 70%),
    radial-gradient(700px 380px at -10% 120px, #efe6ff 0%, transparent 70%),
    var(--bg);
  min-height: 100vh;
}
[hidden] { display: none !important; }
code { background: var(--brand-soft); padding: 1px 6px; border-radius: 6px; font-size: .9em; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(246, 242, 255, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  max-width: 920px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--ink);
}
.brand-logo { width: 48px; height: 48px; border-radius: 14px; object-fit: cover; background: var(--brand-soft); flex: none; }
.brand-logo.fallback { display: grid; place-items: center; font: 800 24px var(--font-head); color: var(--btn-ink); background: var(--brand); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--font-head); font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.brand-text small { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

main { max-width: 920px; margin: 0 auto; padding: 28px 20px 56px; }

/* ---------- Hero ---------- */
.hero { margin: 8px 0 28px; max-width: 640px; }
.hero h1 {
  font-family: var(--font-head);
  font-size: clamp(28px, 5.4vw, 44px);
  line-height: 1.08; font-weight: 800; letter-spacing: -.025em;
  margin: 0 0 12px;
}
.hero p { margin: 0; color: var(--ink-soft); font-size: 17px; }

/* ---------- Kartu media ---------- */
.media-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.media-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px; border-radius: var(--radius);
  text-decoration: none; color: inherit;
  border: 1.5px solid var(--line);
  background: var(--surface);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.media-card:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: 0 10px 24px -14px rgba(108, 75, 196, .55); }
.media-card:focus-visible, .btn:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible,
.seg-opt:focus-within, .pill:focus-within { outline: 3px solid #8f73e0; outline-offset: 2px; }
/* Ikon 3D: tile gradien mengkilap, tiap game beda warna */
.media-icon {
  --c1: #d9a3f0; --c2: #a24fcf;
  position: relative; flex: none; width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center; font-size: 26px; color: #fff;
  background: linear-gradient(145deg, var(--c1), var(--c2));
  box-shadow:
    0 10px 18px -7px var(--c2),
    inset 0 2px 2px rgba(255, 255, 255, .55),
    inset 0 -5px 7px rgba(0, 0, 0, .14);
}
.media-icon::before {
  content: ''; position: absolute; inset: 2px 2px 50% 2px; pointer-events: none;
  border-radius: 14px 14px 50% 50% / 14px 14px 22px 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .42), rgba(255, 255, 255, 0));
}
.media-icon svg {
  position: relative; width: 56%; height: 56%;
  fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .22));
}
.media-icon.big { width: 60px; height: 60px; border-radius: 19px; font-size: 30px; }
.c0 { --c1: #d9a3f0; --c2: #a24fcf; }
.c1 { --c1: #f9b48a; --c2: #ec7f4f; }
.c2 { --c1: #8fd8c9; --c2: #3fa795; }
.c3 { --c1: #8ec5ff; --c2: #4a86e8; }
.c4 { --c1: #ffa8c8; --c2: #e8588f; }
.c5 { --c1: #ffd978; --c2: #f0a020; }
.c6 { --c1: #a6e3a1; --c2: #4cae5a; }
.c7 { --c1: #b9a2f2; --c2: #7a58d6; }
.media-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.media-body strong { font-family: var(--font-head); font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.media-body span { font-size: 14px; color: var(--ink-soft); }
.media-body small { margin-top: 4px; font-size: 12.5px; font-weight: 600; color: #6c4bc4; }

.empty { grid-column: 1 / -1; padding: 24px; border: 1.5px dashed var(--brand); border-radius: var(--radius); background: var(--surface); }
.empty h3 { margin: 0 0 6px; font-family: var(--font-head); }
.empty p { margin: 0; color: var(--ink-soft); }

/* ---------- Tombol (semua ungu pastel terang) ---------- */
.btn {
  appearance: none; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; min-height: 44px;
  font: 700 15px var(--font-body); color: var(--btn-ink);
  background: var(--btn); border: 1.5px solid var(--btn-edge); border-radius: 14px;
  box-shadow: 0 3px 0 var(--btn-edge);
  transition: background .12s ease, transform .08s ease, box-shadow .08s ease;
}
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--btn-edge); }
.btn-lg { min-height: 56px; padding: 14px 26px; font-size: 17px; border-radius: 16px; }
.btn-block { width: 100%; }
.btn-soft { background: #ece4ff; }
.btn-quiet { background: #efe8ff; box-shadow: none; padding: 8px 14px; min-height: 40px; font-size: 14px; }
.btn-quiet:active { transform: none; }

/* ---------- Form ---------- */
.back { margin-bottom: 18px; }
.form-head { display: flex; gap: 16px; align-items: center; margin-bottom: 22px; }
.form-head h2 { margin: 0 0 2px; font-family: var(--font-head); font-size: clamp(24px, 4.4vw, 32px); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.form-head p { margin: 0; color: var(--ink-soft); }

.panel {
  margin: 0 0 16px; padding: 20px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius);
  min-inline-size: 0;
}
.panel legend {
  padding: 0 8px; margin-left: -8px;
  font-family: var(--font-head); font-weight: 700; font-size: 17px; letter-spacing: -.01em;
}
.grid2 { display: grid; gap: 14px 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid2 .wide { grid-column: 1 / -1; }
}
.field { margin-bottom: 14px; }
.grid2 .field { margin-bottom: 0; }
.panel > .field:last-child { margin-bottom: 0; }
label, .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.opt { font-weight: 500; color: var(--ink-soft); }

select, input[type="text"], input[type="number"], textarea {
  width: 100%; font: 500 16px var(--font-body); color: var(--ink);
  padding: 11px 13px; min-height: 46px;
  background: #fbf9ff; border: 1.5px solid var(--line); border-radius: 12px;
}
select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1.5l6 6 6-6' fill='none' stroke='%236c4bc4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
select:disabled { opacity: .55; cursor: not-allowed; }
textarea { resize: vertical; line-height: 1.5; }
::placeholder { color: #9b92bd; }

.hint { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); }
.hint:empty { display: none; }
.error { display: none; margin: 6px 0 0; font-size: 13px; font-weight: 600; color: var(--danger); }
.invalid .error { display: block; }
.invalid select, .invalid input[type="text"], .invalid textarea { border-color: var(--danger); background: #fff7f6; }

/* Unggah file */
.upload { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 10px; }
.upload .btn { margin: 0; font-size: 14px; }
.upload-note { font-size: 13px; color: var(--ink-soft); }
.chip-file {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px; padding: 8px 8px 8px 14px;
  background: var(--brand-soft); border-radius: 12px; font-size: 14px; font-weight: 600;
}
.chip-x { cursor: pointer; border: 0; width: 32px; height: 32px; border-radius: 10px; background: #fff; color: var(--btn-ink); font-size: 14px; }
.chip-x:hover { background: #f3ecff; }

/* Segmen & pil */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-opt, .pill { position: relative; margin: 0; cursor: pointer; border-radius: 12px; }
.seg-opt input, .pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span, .pill span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 9px 16px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fbf9ff;
  font-weight: 600; font-size: 14.5px; transition: background .12s, border-color .12s;
}
.seg-opt:hover span, .pill:hover span { border-color: var(--brand); }
.seg-opt input:checked + span { background: var(--btn); border-color: #9d83ea; color: var(--btn-ink); }
.pill input:checked + span { background: var(--btn); border-color: #9d83ea; color: var(--btn-ink); }
.pill input:checked + span::before { content: '✓'; margin-right: 7px; font-weight: 800; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Hasil ---------- */
#result { margin-top: 22px; }
.result { border-color: var(--brand); box-shadow: 0 18px 40px -26px rgba(108, 75, 196, .6); }
.result-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 14px; margin-bottom: 12px; }
.result-head h3 { margin: 0; font-family: var(--font-head); font-size: 22px; font-weight: 800; letter-spacing: -.015em; }
.meta { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
#promptOut { font-size: 14px; line-height: 1.55; min-height: 180px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 12px 0 4px; }
.row .hint { margin: 0; }
.result h4 { margin: 24px 0 10px; font-family: var(--font-head); font-size: 18px; font-weight: 700; }

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 10px; max-width: 70ch; }
.steps li { counter-increment: step; position: relative; padding-left: 42px; min-height: 30px; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center;
  background: var(--btn); color: var(--btn-ink); font: 800 14px var(--font-head);
}
.open-ai { margin-top: 24px; padding-top: 20px; border-top: 1.5px dashed var(--line); }
.open-ai .hint { text-align: center; margin-top: 10px; }

.foot { text-align: center; padding: 18px 20px 30px; font-size: 13px; color: var(--ink-soft); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 50;
  transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 460px); padding: 12px 18px; border-radius: 14px;
  background: #2a1f4d; color: #fff; font-size: 14px; font-weight: 600; text-align: center;
  transition: opacity .2s ease, transform .2s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 480px) {
  main { padding: 20px 14px 44px; }
  .brand { padding: 8px 14px; }
  .panel { padding: 16px; }
  .seg-opt span, .pill span { padding: 9px 13px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
