.d001-modal-open {
  overflow: hidden;
}

.d001-standard-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  opacity: 0;
  transition:
    opacity 200ms ease,
    background 200ms ease,
    backdrop-filter 200ms ease;
}

.d001-standard-modal-backdrop.is-open {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 1;
}

.d001-standard-modal-backdrop.is-closing {
  pointer-events: none;
  opacity: 0;
}

.d001-standard-modal {
  width: min(560px, 100%);
  max-height: 80vh;
  display: grid;
  grid-template-rows: auto minmax(0, auto) auto;
  overflow: hidden;
  color: var(--text, #1a1a1a);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(247, 250, 255, 0.88)),
    var(--glass-strong, rgba(255, 255, 255, 0.88));
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: scale(0.96) translateY(8px);
  transition:
    opacity 200ms ease,
    transform 200ms ease;
}

.is-open > .d001-standard-modal {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.is-closing > .d001-standard-modal {
  opacity: 0;
  transform: scale(0.96) translateY(8px);
}

body.dark .d001-standard-modal {
  background:
    linear-gradient(145deg, rgba(38, 48, 68, 0.96), rgba(21, 29, 43, 0.92)),
    var(--glass-strong, rgba(34, 44, 64, 0.9));
  border-color: rgba(255, 255, 255, 0.12);
}

.d001-modal-header {
  position: relative;
  padding: 24px 24px 16px;
}

.d001-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 4px;
  color: #8e8e93;
  background: transparent;
  border: 0;
  border-radius: 8px;
  transition:
    color 160ms ease,
    background 160ms ease,
    transform 100ms ease;
}

.d001-modal-close:hover {
  color: #3a3a3c;
  background: rgba(142, 142, 147, 0.12);
}

.d001-modal-close:active {
  transform: scale(0.92);
}

.d001-modal-close:focus-visible,
.d001-modal-button:focus-visible {
  outline: 3px solid rgba(0, 122, 255, 0.28);
  outline-offset: 2px;
}

.d001-modal-close svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.d001-modal-header-content {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding-inline: 28px;
  text-align: center;
}

.d001-modal-label {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.d001-modal-label.tone-neutral {
  color: #636366;
  background: rgba(142, 142, 147, 0.12);
}

.d001-modal-label.tone-primary {
  color: #007aff;
  background: rgba(0, 122, 255, 0.12);
}

.d001-modal-label.tone-warning {
  color: #c66f00;
  background: rgba(255, 149, 0, 0.14);
}

.d001-modal-label.tone-danger {
  color: #d63029;
  background: rgba(255, 59, 48, 0.13);
}

.d001-modal-title,
.d001-modal-subtitle,
.d001-modal-description {
  margin: 0;
  overflow-wrap: anywhere;
}

.d001-modal-title {
  color: var(--text, #1a1a1a);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

.d001-modal-subtitle {
  color: #666;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}

.d001-modal-description {
  color: var(--muted, #666);
  font-size: 14px;
  line-height: 1.5;
}

body.dark .d001-modal-subtitle {
  color: #c4c9d4;
}

.d001-modal-body {
  position: relative;
  min-width: 0;
  padding: 16px 24px 24px;
  overflow: auto;
  overscroll-behavior: contain;
}

.d001-modal-body-content {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.d001-modal-body label {
  display: grid;
  gap: 8px;
  color: var(--text, #1a1a1a);
  font-size: 14px;
  font-weight: 600;
}

.d001-modal-body input,
.d001-modal-body select,
.d001-modal-body textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 9px 12px;
  color: var(--text, #1a1a1a);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line, rgba(83, 95, 122, 0.18));
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.d001-modal-body textarea {
  min-height: 120px;
  resize: vertical;
}

body.dark .d001-modal-body input,
body.dark .d001-modal-body select,
body.dark .d001-modal-body textarea {
  background: rgba(255, 255, 255, 0.08);
}

.d001-modal-loading {
  position: absolute;
  inset: 12px;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--muted, #666);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.d001-standard-modal.is-loading .d001-modal-loading {
  display: grid;
}

body.dark .d001-modal-loading {
  background: rgba(20, 28, 42, 0.76);
}

.d001-modal-spinner,
.d001-button-spinner {
  border: 2px solid rgba(142, 142, 147, 0.22);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: d001-modal-spin 700ms linear infinite;
}

.d001-modal-spinner {
  width: 28px;
  height: 28px;
}

.d001-modal-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  color: #d63029;
  background: rgba(255, 59, 48, 0.09);
  border: 1px solid rgba(255, 59, 48, 0.2);
  border-radius: 8px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.d001-modal-footer {
  padding: 0 24px 24px;
}

.d001-modal-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  min-width: 0;
}

.d001-modal-button {
  min-width: 120px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  font-size: 14px;
  font-weight: 700;
  transition:
    color 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    opacity 160ms ease,
    transform 100ms ease;
}

.d001-modal-button:active {
  transform: scale(0.97);
}

.d001-modal-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.d001-button-primary {
  color: #fff;
  background: #007aff;
}

.d001-button-primary:hover:not(:disabled) {
  background: #006ee6;
}

.d001-button-secondary {
  color: #2c2c2e;
  background: #e9e9eb;
}

.d001-button-secondary:hover:not(:disabled) {
  background: #dedee1;
}

body.dark .d001-button-secondary {
  color: #f5f5f7;
  background: rgba(255, 255, 255, 0.12);
}

.d001-button-danger {
  color: #fff;
  background: #ff3b30;
}

.d001-button-danger:hover:not(:disabled) {
  background: #d63029;
}

.d001-button-danger:active:not(:disabled) {
  background: #c0392b;
}

.d001-button-danger:disabled {
  background: #ffaaaa;
}

.d001-button-spinner {
  display: none;
  width: 16px;
  height: 16px;
}

.d001-modal-button.is-loading .d001-button-spinner {
  display: inline-block;
}

@keyframes d001-modal-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 720px) {
  .d001-standard-modal-backdrop {
    padding:
      max(12px, env(safe-area-inset-top))
      2.5%
      max(12px, env(safe-area-inset-bottom));
  }

  .d001-standard-modal {
    width: 95%;
    max-height: 90vh;
  }

  .d001-modal-header {
    padding: 22px 18px 14px;
  }

  .d001-modal-body {
    padding: 14px 18px 22px;
    font-size: 16px;
  }

  .d001-modal-body input,
  .d001-modal-body select {
    min-height: 46px;
  }

  .d001-modal-footer {
    padding: 0 18px 18px;
  }

  .d001-modal-actions {
    flex-direction: column;
    gap: 10px;
  }

  .d001-modal-button {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .d001-button-primary,
  .d001-button-danger {
    order: -1;
  }
}

@media (min-width: 721px) and (max-width: 900px) {
  .d001-standard-modal {
    width: 90%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .d001-standard-modal-backdrop,
  .d001-standard-modal,
  .d001-modal-button,
  .d001-modal-close {
    animation: none;
    transition: none;
  }
}
