/* susun atur dan kerangka UI — menggantikan bahagian layout dalam style.css */

.masthead {
  position: fixed;
  z-index: var(--z-chrome);
  top: max(30px, env(safe-area-inset-top));
  left: 40px;
  right: 40px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  pointer-events: none;
}

.title {
  color: var(--ink);
  text-shadow: 0 1px 14px #f2ecdccc;
  max-width: 34ch;
}

.eyebrow {
  display: inline-block;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 2.4px;
  color: var(--accent-ink);
  text-transform: uppercase;
}

.title h1 {
  font-size: 52px;
  font-weight: 600;
  margin: 14px 0 10px;
  letter-spacing: -.024em;
  /* jangan seragamkan: bergantung pada font paparan */
  font-variation-settings: 'SOFT' 20, 'WONK' 1;
}

.title p {
  font-size: 12.5px;
  letter-spacing: .12px;
  margin: 0;
  color: var(--ink-2);
  opacity: .85;
}

.top-actions {
  display: flex;
  gap: var(--s-2);
  pointer-events: auto;
  flex-shrink: 0;
}

.top-actions button {
  font-size: 12px;
  padding: 10px 15px;
  min-height: 44px;
  background: var(--surface-overlay);
  color: var(--ink);
  border: 1px solid #00000000;
  box-shadow: var(--sh-2);
  transition: background var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}

.top-actions button:hover {
  background: var(--surface);
  box-shadow: var(--sh-3);
}

.top-actions #pause[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface);
}

/* toolbar: tidak lagi simetri — kumpulan kanan lebih menonjol */
.toolbar {
  position: fixed;
  z-index: var(--z-chrome);
  bottom: max(26px, env(safe-area-inset-bottom));
  left: 40px;
  right: 40px;
  display: flex;
  align-items: flex-end;
  gap: var(--s-3);
  pointer-events: none;
}

.toolbar > * {
  pointer-events: auto;
}

.gesture {
  margin: 0 auto 4px 0;
  padding: 10px 13px;
  font-size: 11.5px;
  line-height: 1.55;
  background: var(--surface-overlay);
  color: var(--ink-2);
  border-radius: var(--r-2);
  box-shadow: var(--sh-1);
  max-width: 30ch;
}

.gesture span {
  display: block;
  font-size: 10px;
  opacity: .72;
  margin-top: 2px;
}

.views {
  display: flex;
  gap: 1px;
  padding: 4px;
  background: var(--surface);
  border-radius: var(--r-3);
  box-shadow: var(--sh-3);
}

.views button {
  font-size: 12px;
  padding: 10px 19px;
  background: none;
  border-radius: var(--r-2);
  color: var(--ink-2);
}

.views button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--sh-1);
}

#settings-toggle {
  min-height: 52px;
  font-size: 12px;
  padding: 12px 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--sh-2);
  border-radius: var(--r-3);
}

#settings-toggle[aria-expanded="true"] {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

/* panel — overlap sengaja, bukan terapung rata */
#settings {
  position: fixed;
  z-index: var(--z-panel);
  right: 40px;
  bottom: 104px;
  width: 318px;
  max-height: calc(100dvh - 140px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s-5) 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  box-shadow: var(--sh-4);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: 26px;
  margin: 0;
  font-weight: 550;
}

.panel-head button {
  padding: 8px 10px;
  min-height: 40px;
  font-size: 11px;
  color: var(--muted);
  background: none;
  border-radius: var(--r-2);
}

.panel-head button:hover {
  color: var(--ink);
  background: var(--surface-2);
}

label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-2);
  font-size: 12px;
  font-weight: 550;
  margin: var(--s-4) 0 var(--s-2);
  color: var(--ink-2);
}

label:first-of-type {
  margin-top: 0;
}

output {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 400;
}

select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface-2);
  color: var(--ink);
  box-shadow: var(--sh-1);
}

input[type="range"] {
  width: 100%;
  min-height: 44px;
  margin: 0;
  accent-color: var(--accent);
}

#reset {
  width: 100%;
  margin-top: var(--s-5);
  border: 1px solid var(--line);
  font-size: 12px;
  background: var(--surface-2);
  border-radius: var(--r-2);
}

#reset:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
}

.note {
  border-top: 1px solid var(--line);
  padding-top: var(--s-3);
  margin: var(--s-4) 0 0;
}

/* #scene mesti kekal penuh skrin dan boleh sentuh */
#scene {
  position: fixed;
  inset: 0;
  z-index: var(--z-scene);
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline-offset: -5px;
}

@media (max-width: 760px) {
  .masthead {
    left: 20px;
    right: 20px;
    top: max(22px, env(safe-area-inset-top));
  }
  .title h1 { font-size: 40px; }
  .title p { font-size: 11px; }
  .eyebrow { font-size: 8px; letter-spacing: 1.6px; }
  .top-actions { flex-direction: column; align-items: flex-end; gap: var(--s-1); }
  .top-actions button { font-size: 11px; padding: 8px 11px; }
  .toolbar {
    left: 16px;
    right: 16px;
    bottom: max(18px, env(safe-area-inset-bottom));
    gap: var(--s-2);
  }
  .gesture { display: none; }
  .views { flex: 1; min-width: 0; justify-content: space-between; }
  .views button { flex: 1; min-width: 0; padding: 9px 8px; font-size: 11px; }
  #settings-toggle { font-size: 11px; padding: 10px 13px; min-height: 50px; }
  #settings {
    right: 16px;
    left: 16px;
    bottom: 82px;
    width: auto;
    max-height: calc(100dvh - 118px);
    padding: var(--s-4) 18px;
  }
}

@media (max-width: 360px) {
  .masthead { left: 16px; right: 16px; }
  .title h1 { font-size: 34px; }
  .title p { font-size: 10px; }
  .eyebrow { font-size: 7px; letter-spacing: 1px; }
  .views button { padding: 9px 6px; font-size: 10px; }
  #settings-toggle { padding: 10px; font-size: 10px; }
  .toolbar { left: 12px; right: 12px; }
}
