#modal {
  box-sizing: border-box;
  width: min(28rem, calc(100% - 2rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--ink, #45383b);
  background: #fffcf9;
  border: 1px solid var(--border, #eadbd8);
  border-radius: 1.45rem;
  box-shadow: 0 24px 95px #4d33383d, 0 3px 18px #4d333819;
  font-family: "DM Sans", sans-serif;
  scrollbar-width: thin;
}

body:has(#modal[open]) { overflow: hidden; }
#modal[open] { animation: dlg-appear .18s ease-out; }
#modal::backdrop { background: rgb(59 42 47 / 44%); backdrop-filter: blur(4px); }
#modal *, #modal *::before, #modal *::after { box-sizing: border-box; }
#modal [hidden] { display: none !important; }
#modal[data-view="editor"], #modal[data-view="detail"] { width: min(32rem, calc(100% - 2rem)); }
#modal .dlg-panel { padding: 2rem; }
#modal h2 {
  color: var(--ink, #45383b);
  margin: 0;
  font: 850 clamp(1.65rem, 5vw, 2.05rem)/1.16 "Nunito", sans-serif;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}
#modal h2:focus { outline: none; }
#modal .dlg-header { margin: 0 0 1.5rem; }
#modal .dlg-header h2 { padding-right: .4rem; }
#modal .dlg-emblem {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  color: #9f5263;
  border: 1px solid #efd0d7;
  border-radius: 1rem;
  background: #fce8eb;
}
#modal .dlg-emblem svg { width: 1.45rem; height: 1.45rem; }
#modal .dlg-header p, #modal .dlg-description {
  margin: .65rem 0 0;
  color: var(--muted, #756266);
  font-size: .97rem;
  line-height: 1.55;
}
#modal .dlg-description { margin: -.55rem 0 1.5rem; overflow-wrap: anywhere; }
#modal .dlg-icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  flex: 0 0 auto;
  padding: 0;
  color: var(--ink, #45383b);
  background: #fffcfa;
  border: 1px solid var(--border, #eadbd8);
  border-radius: 50%;
  cursor: pointer;
}
#modal .dlg-icon-button svg, #modal .button svg { width: 1.15rem; height: 1.15rem; flex: none; }
#modal .dlg-icon-button:hover:not(:disabled) { color: #944d5d; background: #faedf0; }
#modal .dlg-icon-button:disabled { opacity: .4; cursor: default; }
#modal .dlg-close { position: absolute; top: .85rem; right: .85rem; z-index: 1; }
#modal :is(button, input):focus-visible, #modal .dlg-upload:focus-within {
  outline: 3px solid #a16475;
  outline-offset: 2px;
}
#modal .dlg-form { display: grid; gap: .45rem; }
#modal .dlg-form > label { font-size: .92rem; font-weight: 650; }
#modal .dlg-form > label:not(:first-child) { margin-top: .45rem; }
#modal .dlg-form input:not([type="file"]) {
  width: 100%;
  min-width: 0;
  min-height: 2.85rem;
  padding: .64rem .82rem;
  color: var(--ink, #45383b);
  font: inherit;
  font-size: 1rem;
  background: #fff;
  border: 1px solid #ddcecd;
  border-radius: .72rem;
}
#modal .dlg-form input::placeholder { color: #897b7d; opacity: 1; }
#modal .dlg-form input[type="date"] { display: block; }
#modal .dlg-password { position: relative; }
#modal .dlg-password input { padding-right: 3rem !important; }
#modal .dlg-password button {
  position: absolute;
  right: .26rem;
  top: 50%;
  height: 2.35rem;
  width: 2.35rem;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
}
#modal .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 2.75rem;
  padding: .65rem 1rem;
  line-height: 1.25;
  text-align: center;
}
#modal .button:disabled { opacity: .65; cursor: wait; }
#modal .dlg-wide { width: 100%; margin-top: .8rem; }
#modal .dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; }
#modal .dlg-editor .dlg-actions { margin-top: .7rem; }
#modal .dlg-error {
  margin: .4rem 0;
  padding: .63rem .78rem;
  color: #913c4c;
  background: #fcebed;
  border-radius: .55rem;
  font-size: .9rem;
  line-height: 1.4;
}
#modal .dlg-upload {
  position: relative;
  display: flex;
  align-items: center;
  gap: .8rem;
  min-height: 5rem;
  padding: .6rem .9rem .6rem .6rem;
  border: 1px dashed #cea5ae;
  border-radius: .9rem;
  background: #fff3f4;
}
#modal .dlg-upload:hover { background: #fbe9ec; }
#modal .dlg-upload > input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
#modal .dlg-photo-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 3.8rem;
  height: 3.8rem;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: .6rem;
  background: #f4dfe3;
  color: #a96675;
}
#modal .dlg-photo-frame svg { width: 1.5rem; height: 1.5rem; }
#modal .dlg-photo-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#modal .dlg-upload strong { display: block; font-size: .95rem; }
#modal .dlg-upload small { display: block; margin-top: .22rem; color: var(--muted, #756266); font-size: .77rem; }
#modal .dlg-upload > svg { width: 1.22rem; height: 1.22rem; margin-left: auto; flex: none; color: #a96675; }
#modal .dlg-detail-photo {
  position: relative;
  display: grid;
  place-items: center;
  background: #f4eae6;
  overflow: hidden;
}
#modal .dlg-detail-photo img { display: block; width: 100%; height: clamp(11rem, 35dvh, 21rem); object-fit: contain; }
#modal .dlg-favorite { position: absolute; top: .85rem; left: .85rem; }
#modal .dlg-favorite.is-favorite { color: #a94e63; }
#modal .dlg-favorite.is-favorite svg { fill: #de899d; }
#modal .dlg-detail { padding-top: 1.35rem; }
#modal .dlg-kicker {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: 0 0 .4rem;
  color: #8c5a68;
  font-size: .83rem;
  font-weight: 650;
}
#modal .dlg-kicker svg, #modal .dlg-meta svg { width: 1rem; height: 1rem; flex: none; }
#modal .dlg-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 1rem;
  padding: 0;
  margin: 1.3rem 0 0;
}
#modal .dlg-meta dt {
  display: flex;
  align-items: center;
  gap: .35rem;
  color: var(--muted, #756266);
  font-size: .82rem;
}
#modal .dlg-meta dd { margin: .36rem 0 0; overflow-wrap: anywhere; font-size: .98rem; font-weight: 550; }
#modal .dlg-edit-actions { justify-content: flex-start; align-items: center; margin-top: 1.35rem; }
#modal .dlg-delete { margin-left: auto; color: #9c5664; border: 0; background: transparent; }
#modal .dlg-danger { background: #944857; border: 1px solid #944857; color: #fff; }
#modal .dlg-danger:hover { background: #7e3947; }
#modal .dlg-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #eadbd8);
  color: var(--muted, #756266);
  font-size: .87rem;
}
#modal .dlg-pagination .dlg-icon-button { width: 2.4rem; height: 2.4rem; }
@keyframes dlg-appear { from { opacity: 0; transform: translateY(.3rem); } to { opacity: 1; transform: none; } }
@media (max-width: 480px) {
  #modal .dlg-panel { padding: 1.4rem; }
  #modal .dlg-header { margin-bottom: 1.15rem; }
  #modal .dlg-emblem { margin-bottom: .75rem; }
  #modal .dlg-actions .button { flex: 1 1 auto; }
  #modal .dlg-edit-actions .button { flex: 0 1 auto; }
}
@media (max-width: 340px) {
  #modal .dlg-meta { grid-template-columns: 1fr; }
  #modal .dlg-upload > svg { display: none; }
}
@media (prefers-reduced-motion: reduce) { #modal[open] { animation: none; } }
