/* RH Motion — tema denim gelap dengan aksen benang jahit.
   Hanya memakai sumber dari situs sendiri (kompatibel dengan CSP style-src 'self'). */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #131a2b;          /* latar */
  --denim: #1b2540;        /* permukaan */
  --denim-2: #243152;      /* permukaan terangkat */
  --seam: #3a4a72;         /* garis */
  --chalk: #eaeff8;        /* teks */
  --chalk-dim: #a6b4d1;    /* teks sekunder */
  --thread: #e9a23b;       /* aksen: benang jahit */
  --thread-hi: #f3b85e;
  --on-thread: #1a1203;
  --rust: #f0776b;         /* galat */
  --sage: #7cc9a0;         /* berhasil */
  --radius: 10px;
  --font-head: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Figtree", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--chalk);
  font: 400 16px/1.55 var(--font-body);
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.7rem, 3.2vw, 2.3rem); font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--thread-hi); text-underline-offset: 3px; }
a:hover { color: var(--chalk); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--chalk-dim); }
.small { font-size: 0.875rem; }

:focus-visible { outline: 2px solid var(--thread-hi); outline-offset: 2px; border-radius: 4px; }

/* ---------- Kerangka ---------- */
.topbar {
  display: flex; align-items: center; gap: 28px;
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--seam);
  background: var(--ink);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--chalk-dim); text-decoration: none; padding: 8px 14px; border-radius: 8px; font-weight: 500;
}
.nav a:hover { color: var(--chalk); background: var(--denim); }
.nav a[aria-current="page"] { color: var(--chalk); background: var(--denim-2); box-shadow: inset 0 -2px 0 var(--thread); }
.who { display: flex; align-items: center; gap: 12px; color: var(--chalk-dim); font-size: 0.9rem; }
.who span { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page { max-width: 1040px; margin: 0 auto; padding: clamp(20px, 4vw, 44px) clamp(16px, 4vw, 40px) 80px; }
.page-head { margin-bottom: 28px; max-width: 62ch; }
.page-head p { margin-top: 8px; color: var(--chalk-dim); }
.footer { max-width: 1040px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 40px; color: var(--chalk-dim); font-size: 0.875rem; }
.link-btn { background: none; border: 0; padding: 0; color: var(--thread-hi); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- Tombol & kolom isian ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--seam); background: var(--denim); color: var(--chalk);
  padding: 10px 18px; border-radius: 8px; font-weight: 600; cursor: pointer; min-height: 42px;
}
.btn:hover { background: var(--denim-2); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--thread); border-color: var(--thread); color: var(--on-thread); }
.btn-primary:hover { background: var(--thread-hi); }
.btn-danger { border-color: var(--rust); color: var(--rust); background: transparent; }
.btn-danger:hover { background: rgba(240, 119, 107, 0.12); }
.btn-small { padding: 6px 12px; min-height: 34px; font-size: 0.9rem; }
.btn-quiet { background: transparent; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 0.95rem; }
.field .hint { color: var(--chalk-dim); font-size: 0.85rem; }
.input {
  width: 100%; background: var(--ink); border: 1px solid var(--seam); border-radius: 8px;
  padding: 11px 12px; min-height: 44px;
}
.input:focus { outline: none; border-color: var(--thread); box-shadow: 0 0 0 3px rgba(233, 162, 59, 0.25); }
.notice {
  border: 1px solid var(--seam); background: var(--denim); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 20px;
}
.notice.is-warn { border-color: var(--thread); }
.notice.is-error { border-color: var(--rust); color: #ffd5d0; }
.notice strong { display: block; margin-bottom: 2px; }

/* ---------- Masuk / daftar ---------- */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(24px, 6vw, 80px); max-width: 1000px; margin: 0 auto; padding: clamp(28px, 8vh, 90px) clamp(16px, 4vw, 40px); align-items: center; }
.auth-intro h1 { margin-bottom: 14px; }
.auth-intro p { color: var(--chalk-dim); max-width: 44ch; }
.auth-intro ul { margin: 22px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; max-width: 44ch; }
.auth-intro li { padding-left: 22px; position: relative; color: var(--chalk); }
.auth-intro li::before { content: ""; position: absolute; left: 0; top: 0.7em; width: 12px; border-top: 2px dashed var(--thread); }
.auth-card { background: var(--denim); border: 1px solid var(--seam); border-radius: 14px; padding: 26px; }
.tabs { display: flex; gap: 4px; margin-bottom: 22px; background: var(--ink); padding: 4px; border-radius: 10px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--chalk-dim); }
.tabs button[aria-selected="true"] { background: var(--denim-2); color: var(--chalk); box-shadow: inset 0 -2px 0 var(--thread); }

/* ---------- Halaman buat video ---------- */
.patches { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }
.patch-wrap h2 { margin-bottom: 4px; }
.patch-wrap > p { margin-bottom: 12px; color: var(--chalk-dim); font-size: 0.9rem; }
.patch {
  position: relative; display: grid; place-items: center; text-align: center; width: 100%;
  aspect-ratio: 4 / 3; color: var(--chalk-dim);
  background: var(--denim); border: 0; border-radius: 12px;
  outline: 2px dashed var(--thread); outline-offset: -9px;   /* garis jahitan */
}
.patch-pick {
  position: absolute; inset: 0; display: grid; place-items: center; width: 100%; padding: 18px;
  background: none; border: 0; border-radius: 12px; color: inherit; cursor: pointer; text-align: center;
}
.patch-pick:focus-visible { outline: 2px solid var(--thread-hi); outline-offset: -4px; }
.patch:hover, .patch.is-over { background: var(--denim-2); color: var(--chalk); }
.patch.is-filled { padding: 0; outline-offset: -6px; background: #0e1424; overflow: hidden; }
.patch strong { display: block; color: var(--chalk); font-family: var(--font-head); font-size: 1.05rem; margin-bottom: 4px; }
.patch img, .patch video { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 12px; }
.patch-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; font-size: 0.875rem; color: var(--chalk-dim); min-height: 34px; }
.patch-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-list { display: grid; gap: 10px; margin-bottom: 24px; }
.app-option {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  background: var(--denim); border: 1px solid var(--seam); border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
}
.app-option:has(input:checked) { border-color: var(--thread); background: var(--denim-2); }
.app-option input { accent-color: var(--thread); width: 18px; height: 18px; }
.app-option .cost { font-family: var(--font-head); font-weight: 650; white-space: nowrap; }
.app-option .cost small { font-family: var(--font-body); font-weight: 400; color: var(--chalk-dim); }

.submit-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  border-top: 1px dashed var(--seam); padding-top: 22px;
}
.submit-bar p { color: var(--chalk-dim); max-width: 52ch; }

.sewing { margin-top: 16px; }
.sewing .label { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 8px; }

/* ---------- Benang jahit (progres) ---------- */
.thread-bar { height: 10px; background-image: repeating-linear-gradient(90deg, var(--seam) 0 8px, transparent 8px 14px); border-radius: 2px; position: relative; overflow: hidden; }
.thread-bar > i { position: absolute; inset: 0 auto 0 0; width: 0; background-image: repeating-linear-gradient(90deg, var(--thread) 0 8px, transparent 8px 14px); transition: width 0.6s ease; }
.thread-bar.is-live > i { animation: march 1s linear infinite; }
@keyframes march { to { background-position: 14px 0; } }

/* ---------- Riwayat ---------- */
.tasks { display: grid; gap: 14px; }
.task { background: var(--denim); border: 1px solid var(--seam); border-radius: 12px; padding: 18px; }
.task-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.task-head h3 { margin-bottom: 2px; }
.task-meta { color: var(--chalk-dim); font-size: 0.875rem; }
.task-body { margin-top: 14px; }
.task-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.task video { width: 100%; max-width: 420px; max-height: 70vh; background: #0e1424; border-radius: 10px; display: block; }
.task .err { color: #ffd5d0; font-size: 0.95rem; }
.empty { border: 2px dashed var(--seam); border-radius: 14px; padding: 40px 24px; text-align: center; color: var(--chalk-dim); }
.empty h2 { color: var(--chalk); margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

/* ---------- Status ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; border: 1px solid var(--seam); white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip[data-tone="live"] { color: var(--thread-hi); border-color: var(--thread); }
.chip[data-tone="ok"] { color: var(--sage); border-color: rgba(124, 201, 160, 0.5); }
.chip[data-tone="bad"] { color: var(--rust); border-color: rgba(240, 119, 107, 0.5); }
.chip[data-tone="off"] { color: var(--chalk-dim); }

/* ---------- API key ---------- */
.keys { display: grid; gap: 10px; margin-bottom: 30px; }
.key-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; background: var(--denim); border: 1px solid var(--seam); border-radius: var(--radius); padding: 14px 16px; }
.key-row .name { font-weight: 600; }
.key-row code { font: 500 0.9rem ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--chalk-dim); }
.key-row .why { grid-column: 1 / -1; color: var(--chalk-dim); font-size: 0.875rem; }
.key-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.key-form { background: var(--denim); border: 1px solid var(--seam); border-radius: 12px; padding: 22px; max-width: 560px; }
.key-form details { margin: 4px 0 16px; }
.key-form summary { cursor: pointer; color: var(--chalk-dim); }

/* ---------- Dialog & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 12, 22, 0.72); display: grid; place-items: center; padding: 16px; z-index: 50; }
.dialog { background: var(--denim); border: 1px solid var(--seam); border-radius: 14px; padding: 24px; width: min(520px, 100%); max-height: 88vh; overflow: auto; }
.dialog h2 { margin-bottom: 10px; }
.dialog .body { color: var(--chalk-dim); display: grid; gap: 10px; margin-bottom: 20px; }
.dialog .body strong { color: var(--chalk); }
.dialog .actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--denim-2); border: 1px solid var(--seam); border-left: 3px solid var(--thread); border-radius: 8px; padding: 12px 14px; }
.toast.is-error { border-left-color: var(--rust); }
.toast.is-ok { border-left-color: var(--sage); }

.loading { display: grid; place-items: center; min-height: 60vh; color: var(--chalk-dim); }

@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .patches { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px 16px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .key-row { grid-template-columns: 1fr; }
  .key-actions { justify-content: flex-start; }
  .app-option { grid-template-columns: auto 1fr; }
  .app-option .cost { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
