*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body:has(dialog[open]) {
  overflow: hidden;
}

h1,
h2,
h3,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.018em;
  font-variation-settings: "opsz" 96;
}

h3 {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

img,
svg {
  display: block;
}

img {
  max-width: 100%;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-sun {
  display: none;
}

[data-theme="dark"] .theme-sun {
  display: block;
}

[data-theme="dark"] .theme-moon {
  display: none;
}

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.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;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 2000;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform var(--speed-fast) var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
}

.wordmark {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  color: var(--ink);
  text-decoration: none;
  line-height: 1;
}

.wordmark__text {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 48;
}

.wordmark__sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition:
    background-color var(--speed-fast) var(--ease),
    border-color var(--speed-fast) var(--ease),
    color var(--speed-fast) var(--ease),
    transform var(--speed-fast) var(--ease);
}

.button:active {
  transform: translateY(1px);
}

.button:disabled {
  opacity: 0.5;
}

.button .icon {
  width: 18px;
  height: 18px;
}

.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.button--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.button--quiet {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
}

.button--quiet:hover:not(:disabled) {
  background: var(--paper-deep);
}

.button--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-accent);
}

.button--danger:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.button--wide {
  width: 100%;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  transition:
    background-color var(--speed-fast) var(--ease),
    border-color var(--speed-fast) var(--ease);
}

.icon-button:hover {
  background: var(--paper-deep);
  border-color: var(--line-strong);
}

.link-button {
  min-height: 44px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.24em;
}

.link-button:hover {
  color: var(--ink);
}

.field {
  display: grid;
  gap: 6px;
  align-content: start;
}

.field__label {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.field__optional {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.4;
  transition:
    background-color var(--speed-fast) var(--ease),
    border-color var(--speed-fast) var(--ease);
}

.field textarea {
  min-height: 78px;
  resize: vertical;
}

.field select {
  padding-right: 34px;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--ink);
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted);
  opacity: 0.82;
}

.field input[type="date"] {
  color-scheme: light;
}

[data-theme="dark"] .field input[type="date"] {
  color-scheme: dark;
}

.field__hint {
  justify-self: end;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.field__error,
.form-error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.form-error {
  padding: 9px 11px;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
}

/* Dialog dasar */
dialog {
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 0;
}

dialog::backdrop {
  background: rgba(18, 16, 12, 0.58);
}

.dialog {
  width: min(460px, calc(100vw - 32px));
  max-width: 460px;
  max-height: calc(100dvh - 40px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  animation: dialog-in var(--speed) var(--ease);
}

.dialog--confirm {
  width: min(420px, calc(100vw - 32px));
}

.dialog__body {
  padding: clamp(22px, 4vw, 30px);
}

.dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dialog__head .icon-button {
  margin-top: -8px;
  margin-right: -8px;
}

.dialog h2 {
  font-size: clamp(27px, 5vw, 34px);
}

.dialog__sub,
.dialog__text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.dialog__sub {
  margin-top: 7px;
}

.dialog__text {
  margin-bottom: 16px;
}

.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.dialog form .form-error {
  margin-top: 12px;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Toast */
.toasts {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, calc(16px + env(safe-area-inset-bottom)));
  z-index: 3000;
  display: grid;
  gap: 9px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 44px;
  align-items: start;
  gap: 10px;
  padding: 13px 8px 13px 15px;
  background: #24211b;
  border: 1px solid rgba(246, 241, 231, 0.18);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
  color: #f6f1e7;
  pointer-events: auto;
  animation: toast-in var(--speed) var(--ease);
}

.toast .icon {
  margin-top: 2px;
  color: #e29a72;
}

.toast--error .icon {
  color: #f0a394;
}

.toast--success .icon {
  color: #a7cfb4;
}

.toast__message {
  align-self: center;
  font-size: 13.5px;
  line-height: 1.45;
}

.toast__close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-top: -8px;
  padding: 0;
  color: #cfc6b6;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
}

.toast__close:hover {
  color: #f6f1e7;
  background: rgba(246, 241, 231, 0.08);
}

.toast__close .icon {
  width: 16px;
  height: 16px;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity var(--speed-fast) var(--ease),
    transform var(--speed-fast) var(--ease);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.admin-badge .icon {
  width: 15px;
  height: 15px;
}

.simple-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
}

.simple-page__main {
  width: min(560px, 100%);
  padding-block: 40px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.simple-page__mark {
  margin-bottom: 28px;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
}

.simple-page h1 {
  margin-bottom: 14px;
  font-size: clamp(36px, 8vw, 58px);
}

.simple-page p:not(.simple-page__mark) {
  max-width: 46ch;
  margin-bottom: 26px;
  color: var(--muted);
}

.simple-page .button {
  width: fit-content;
}

.login-noscript {
  max-width: 420px;
  margin: 20px auto 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
