/*
  Modal 03 — Smart Form Dialog — standalone HTML/CSS/JS.
  No build step, no framework, no external dependency: copy index.html,
  this file, and script.js into any project as-is.
*/

:root {
  --form-fg: oklch(0.17 0 0);
  --form-muted: oklch(0.52 0 0);
  --form-line: oklch(0.91 0 0);
  --form-soft: oklch(0.97 0 0);
  --form-error: oklch(0.52 0.19 27);
  --form-accent: #39ff14;
}

.modal03 {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji";
}

.modal03[hidden] {
  display: none;
}

.modal03 p,
.modal03 h2,
.modal03 fieldset,
.modal03 legend {
  margin: 0;
  padding: 0;
}

.modal03 fieldset {
  min-width: 0;
  border: 0;
}

.modal03 svg {
  display: block;
}

/* The lightest dim of the set — this dialog is routine work, not a warning. */
.modal03__backdrop {
  position: fixed;
  inset: 0;
  background-color: oklch(0.3 0 0 / 0.3);
  animation: modal03-fade-in 180ms ease-out both;
}

.modal03[data-state="closing"] .modal03__backdrop {
  animation: modal03-fade-out 150ms ease-in both;
}

.modal03__positioner {
  position: relative;
  display: flex;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* Rises from below, like a sheet being pulled up to the desk. */
.modal03__panel {
  position: relative;
  width: 100%;
  max-width: 32rem;
  overflow: hidden;
  border: 1px solid var(--form-line);
  border-radius: 1rem;
  background-color: #ffffff;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.32);
  animation: modal03-rise 240ms cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.modal03[data-state="closing"] .modal03__panel {
  animation: modal03-sink 150ms ease-in both;
}

.modal03__head {
  border-bottom: 1px solid var(--form-line);
  padding: 1rem 1.5rem;
}

.modal03__title {
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--form-fg);
}

.modal03__description {
  margin-top: 0.125rem !important;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--form-muted);
}

.modal03__body {
  padding: 1.25rem 1.5rem;
}

.modal03__field + .modal03__field,
.modal03__field + .modal03__pair,
.modal03__pair + .modal03__field {
  margin-top: 1rem;
}

.modal03__pair {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.modal03__label {
  display: block;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  color: var(--form-fg);
}

.modal03__input,
.modal03__select {
  width: 100%;
  height: 2.5rem;
  margin-top: 0.375rem;
  border: 1px solid var(--form-line);
  border-radius: 0.5rem;
  background-color: #ffffff;
  padding: 0 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--form-fg);
  outline: none;
  transition:
    border-color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.modal03__input:focus-visible,
.modal03__select:focus-visible {
  border-color: var(--form-fg);
  box-shadow: 0 0 0 2px oklch(0.17 0 0 / 0.12);
}

.modal03__input[aria-invalid="true"],
.modal03__select[aria-invalid="true"] {
  border-color: var(--form-error);
}

.modal03__input[aria-invalid="true"]:focus-visible,
.modal03__select[aria-invalid="true"]:focus-visible {
  border-color: var(--form-error);
  box-shadow: 0 0 0 2px oklch(0.52 0.19 27 / 0.15);
}

.modal03__hint {
  margin-top: 0.375rem !important;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--form-muted);
}

.modal03__error {
  margin-top: 0.375rem !important;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--form-error);
}

.modal03__error[hidden] {
  display: none;
}

.modal03__choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.375rem;
}

.modal03__choice {
  display: flex;
  min-height: 2.75rem;
  cursor: pointer;
  align-items: center;
  gap: 0.625rem;
  border: 1px solid var(--form-line);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  transition:
    background-color 150ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.modal03__choice:hover {
  background-color: var(--form-soft);
}

.modal03__choice:has(:checked) {
  border-color: var(--form-fg);
  background-color: var(--form-soft);
}

.modal03__choice:has(:focus-visible) {
  outline: 2px solid var(--form-fg);
  outline-offset: 2px;
}

.modal03__radio {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.modal03__dot {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
  border: 2px solid oklch(0.78 0 0);
  border-radius: 9999px;
}

.modal03__choice:has(:checked) .modal03__dot {
  border-color: var(--form-fg);
  background-color: var(--form-fg);
  box-shadow: inset 0 0 0 2px #ffffff;
}

.modal03__choice-text {
  min-width: 0;
}

.modal03__choice-name {
  display: block;
  font-weight: 500;
  color: var(--form-fg);
}

.modal03__choice-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--form-muted);
}

.modal03__footer {
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  gap: 0.75rem;
  border-top: 1px solid var(--form-line);
  background-color: oklch(0.97 0 0 / 0.6);
  padding: 1rem 1.5rem;
}

.modal03__status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--form-muted);
}

.modal03__status-dot {
  width: 0.375rem;
  height: 0.375rem;
  flex-shrink: 0;
  border-radius: 9999px;
  background-color: oklch(0.8 0 0);
}

/* Turns on only when every required field is filled. */
.modal03[data-ready] .modal03__status-dot {
  background-color: var(--form-accent);
  box-shadow: 0 0 0 3px oklch(0.85 0.22 130 / 0.35);
}

.modal03__buttons {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
}

.modal03__cancel,
.modal03__submit {
  display: flex;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  padding: 0 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.25rem;
  cursor: pointer;
  outline: none;
  transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.modal03__cancel {
  border: 1px solid var(--form-line);
  background-color: #ffffff;
  font-weight: 500;
  color: var(--form-fg);
}

.modal03__cancel:hover {
  background-color: var(--form-soft);
}

.modal03__submit {
  border: 0;
  background-color: var(--form-fg);
  font-weight: 600;
  color: #ffffff;
}

.modal03__submit:hover {
  background-color: oklch(0.3 0 0);
}

.modal03__submit[aria-disabled="true"] {
  cursor: progress;
  background-color: var(--form-soft);
  color: var(--form-muted);
}

.modal03__cancel:focus-visible,
.modal03__submit:focus-visible {
  outline: 2px solid var(--form-fg);
  outline-offset: 2px;
}

@keyframes modal03-fade-in {
  from {
    opacity: 0;
  }
}

@keyframes modal03-fade-out {
  to {
    opacity: 0;
  }
}

@keyframes modal03-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes modal03-sink {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (min-width: 40rem) {
  .modal03__pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .modal03__footer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .modal03__buttons {
    flex-direction: row;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal03__panel {
    animation-name: modal03-fade-in;
    animation-duration: 120ms;
  }
  .modal03[data-state="closing"] .modal03__panel {
    animation-name: modal03-fade-out;
  }
}

/*
  Page layout — the canvas this resource is presented on. Adjust or drop it
  when placing the resource inside your own layout.
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  line-height: 1.5;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(to bottom, #fafafa, #f4f4f5);
}
p {
  margin: 0;
}
.modal03-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem;
}
.modal03-layout__app {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 60rem;
  height: 44rem;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 1rem;
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 18px 44px -20px rgba(0, 0, 0, 0.18);
  transform: translateZ(0);
}
.modal03-layout__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid oklch(0.97 0 0);
  padding: 0.875rem 1.5rem;
}
.modal03-layout__title {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
  color: oklch(0.205 0 0);
}
.modal03-layout__sub {
  font-size: 0.75rem;
  line-height: 1rem;
  color: oklch(0.556 0 0);
}
.modal03-layout__new {
  display: flex;
  height: 2.25rem;
  align-items: center;
  gap: 0.375rem;
  border: 0;
  border-radius: 0.5rem;
  background: oklch(0.205 0 0);
  padding: 0 0.875rem;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
  color: #ffffff;
  cursor: pointer;
  outline: none;
  transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.modal03-layout__new svg {
  display: block;
  width: 1rem;
  height: 1rem;
}
.modal03-layout__new:hover {
  background: oklch(0.371 0 0);
}
.modal03-layout__new:focus-visible {
  outline: 2px solid oklch(0.205 0 0);
  outline-offset: 2px;
}
.modal03-layout__list {
  margin: 0;
  padding: 0 1.5rem;
  list-style: none;
}
.modal03-layout__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 0;
}
.modal03-layout__item + .modal03-layout__item {
  border-top: 1px solid oklch(0.97 0 0);
}
.modal03-layout__item-text {
  min-width: 0;
}
.modal03-layout__name,
.modal03-layout__client {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal03-layout__name {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  color: oklch(0.205 0 0);
}
.modal03-layout__client {
  font-size: 0.75rem;
  line-height: 1rem;
  color: oklch(0.556 0 0);
}
.modal03-layout__when {
  flex-shrink: 0;
  font-size: 0.75rem;
  line-height: 1rem;
  color: oklch(0.708 0 0);
}
.modal03-layout__badge {
  flex-shrink: 0;
  border-radius: 9999px;
  background: oklch(0.97 0 0);
  padding: 0.125rem 0.5rem;
  font-size: 11px;
  line-height: 1rem;
  font-weight: 500;
  color: oklch(0.439 0 0);
}
@media (min-width: 40rem) {
  .modal03-layout__app {
    height: 31rem;
  }
}
